@@ -89,6 +89,8 @@ def __init__(self, ton, local, *args, **kwargs):
8989 def send_message (self , text : str ):
9090 if self .token is None :
9191 raise Exception ("send_message error: token is not initialized" )
92+ if self .chat_id is None :
93+ raise Exception ("send_message error: chat_id is not initialized" )
9294 request_url = f"https://api.telegram.org/bot{ self .token } /sendMessage"
9395 data = {'chat_id' : self .chat_id , 'text' : text , 'parse_mode' : 'HTML' }
9496 response = requests .post (request_url , data = data , timeout = 3 )
@@ -183,6 +185,9 @@ def print_alerts(self, args):
183185 table .append ([alert_name , alert ['enabled' ], alert ['sent' ]])
184186 print_table (table )
185187
188+ def test_alert (self , args ):
189+ self .send_message ('Test alert' )
190+
186191 def check_db_usage (self ):
187192 usage = self .ton .GetDbUsage ()
188193 if usage > 95 :
@@ -266,3 +271,4 @@ def add_console_commands(self, console):
266271 console .AddItem ("enable_alert" , self .enable_alert , self .local .translate ("enable_alert_cmd" ))
267272 console .AddItem ("disable_alert" , self .disable_alert , self .local .translate ("disable_alert_cmd" ))
268273 console .AddItem ("list_alerts" , self .print_alerts , self .local .translate ("list_alerts_cmd" ))
274+ console .AddItem ("test_alert" , self .test_alert , self .local .translate ("test_alert_cmd" ))
0 commit comments