@@ -65,7 +65,7 @@ async def logs_handler(event: events.NewMessage.Event):
6565 return
6666
6767 if not args :
68- await event .edit (await event .client .get_string ("help_logs_usage" ))
68+ await event .edit (await event .client .get_string ("help_logs_usage" ), parse_mode = "markdown" )
6969 return
7070
7171 command : str = args [0 ].lower ()
@@ -83,6 +83,8 @@ async def logs_handler(event: events.NewMessage.Event):
8383 await conv .send_message (await event .client .get_string ("logs_purge_cancelled" ))
8484 except asyncio .TimeoutError :
8585 await event .respond (await event .client .get_string ("delete_timeout" ))
86+ finally :
87+ await event .delete ()
8688 return
8789
8890 # --- Log Fetching Logic ---
@@ -91,8 +93,7 @@ async def logs_handler(event: events.NewMessage.Event):
9193 level : Optional [str ] = None
9294 source : Optional [str ] = None
9395
94- # Parse arguments
95- if args [0 ].lower () in ["head" , "tail" ]:
96+ if args and args [0 ].lower () in ["head" , "tail" ]:
9697 mode = args .pop (0 ).lower ()
9798
9899 if args and args [0 ].isdigit ():
@@ -113,7 +114,6 @@ async def logs_handler(event: events.NewMessage.Event):
113114 await event .edit (await event .client .get_string ("logs_not_found" ))
114115 return
115116
116- # Prepare file and caption
117117 log_content : str = "\n " .join (
118118 f"[{ log .timestamp .strftime ('%Y-%m-%d %H:%M:%S' )} ] [{ log .level } ] [{ log .module_name or 'System' } ] { log .message } "
119119 for log in logs_list
@@ -137,7 +137,7 @@ async def logs_handler(event: events.NewMessage.Event):
137137 file = log_file ,
138138 caption = caption ,
139139 attributes = [DocumentAttributeFilename (filename )],
140- parse_mode = "HTML "
140+ parse_mode = "markdown "
141141 )
142142
143143# --- Account Management Handlers ---
@@ -165,7 +165,7 @@ async def list_accounts_handler(event: events.NewMessage.Event):
165165 account_id = acc .account_id , status_text = status_text , last_used = last_used
166166 )
167167 )
168- await event .edit ("\n " .join (response_lines ), parse_mode = "html " )
168+ await event .edit ("\n " .join (response_lines ), parse_mode = "markdown " )
169169
170170async def add_account_handler (event : events .NewMessage .Event ):
171171 account_name : str = event .pattern_match .group (1 )
@@ -298,47 +298,43 @@ async def set_lang_handler(event: events.NewMessage.Event):
298298 await event .edit (await event .client .get_string ("lang_update_fail" ))
299299
300300async def help_commands_handler (event : events .NewMessage .Event ):
301- # Part 1: Management
302301 help_management = "\n " .join ([
303- f"<code> .listaccs</code> - { await event .client .get_string ('help_listaccs' )} " ,
304- f"<code> .addacc <name></code> - { await event .client .get_string ('help_addacc' )} " ,
305- f"<code> .delacc <name></code> - { await event .client .get_string ('help_delacc' )} " ,
306- f"<code> .toggleacc <name></code> - { await event .client .get_string ('help_toggleacc' )} " ,
307- f"<code> .setlang < code|url></code> - { await event .client .get_string ('help_setlang' )} "
302+ f"` { ' .listaccs' } ` - { await event .client .get_string ('help_listaccs' )} " ,
303+ f"` { ' .addacc <name>' } ` - { await event .client .get_string ('help_addacc' )} " ,
304+ f"` { ' .delacc <name>' } ` - { await event .client .get_string ('help_delacc' )} " ,
305+ f"` { ' .toggleacc <name>' } ` - { await event .client .get_string ('help_toggleacc' )} " ,
306+ f"` { ' .setlang < code|url>' } ` - { await event .client .get_string ('help_setlang' )} "
308307 ])
309308
310- # Part 2: Module Management
311309 help_modules = "\n " .join ([
312- f"<code> .addmod</code> - { await event .client .get_string ('help_addmod' )} " ,
313- f"<code> .delmod <name></code> - { await event .client .get_string ('help_delmod' )} " ,
314- f"<code> .trustmod <name></code> - { await event .client .get_string ('help_trustmod' )} " ,
315- f"<code> .configmod < ...></code> - { await event .client .get_string ('help_configmod' )} "
310+ f"` { ' .addmod' } ` - { await event .client .get_string ('help_addmod' )} " ,
311+ f"` { ' .delmod <name>' } ` - { await event .client .get_string ('help_delmod' )} " ,
312+ f"` { ' .trustmod <name>' } ` - { await event .client .get_string ('help_trustmod' )} " ,
313+ f"` { ' .configmod < ...>' } ` - { await event .client .get_string ('help_configmod' )} "
316314 ])
317315
318- # Part 3: Utilities
319316 help_utils = "\n " .join ([
320- f"<code> .ping</code> - { await event .client .get_string ('help_ping' )} " ,
321- f"<code> .restart</code> - { await event .client .get_string ('help_restart' )} " ,
322- f"<code> .logs</code> - { await event .client .get_string ('help_logs' )} " ,
323- f"<code> .logs purge</code> - { await event .client .get_string ('help_logs_purge' )} " ,
324- f"<code> .updatemodules</code> - { await event .client .get_string ('help_updatemodules' )} " ,
325- f"<code> .about</code> - { await event .client .get_string ('help_about' )} "
317+ f"` { ' .ping' } ` - { await event .client .get_string ('help_ping' )} " ,
318+ f"` { ' .restart' } ` - { await event .client .get_string ('help_restart' )} " ,
319+ f"` { ' .logs' } ` - { await event .client .get_string ('help_logs' )} " ,
320+ f"` { ' .logs purge' } ` - { await event .client .get_string ('help_logs_purge' )} " ,
321+ f"` { ' .updatemodules' } ` - { await event .client .get_string ('help_updatemodules' )} " ,
322+ f"` { ' .about' } ` - { await event .client .get_string ('help_about' )} "
326323 ])
327324
328- # Combine all parts
329325 final_text = (
330326 f"{ await event .client .get_string ('help_header_management' )} \n { help_management } \n \n "
331327 f"{ await event .client .get_string ('help_header_modules' )} \n { help_modules } \n \n "
332328 f"{ await event .client .get_string ('help_header_utils' )} \n { help_utils } "
333329 )
334330
335- await event .edit (final_text , parse_mode = "HTML " )
331+ await event .edit (final_text , parse_mode = "markdown " )
336332
337333async def about_command_handler (event : events .NewMessage .Event ):
338- await event .edit (await event .client .get_string ("about_text" ), parse_mode = "HTML " )
334+ await event .edit (await event .client .get_string ("about_text" ), parse_mode = "markdown " )
339335
340336async def restart_handler (event : events .NewMessage .Event ):
341- await event .edit (await event .client .get_string ("restarting_now" ))
337+ await event .edit (await event .client .get_string ("restarting_now" ), parse_mode = "markdown" )
342338 await asyncio .sleep (1 )
343339 sys .exit (0 )
344340
@@ -362,4 +358,4 @@ async def ping_handler(event: events.NewMessage.Event):
362358 server_api = f"{ api_latency :.2f} " ,
363359 total = f"{ total_latency :.2f} "
364360 )
365- await event .edit (response_text , parse_mode = "HTML " )
361+ await event .edit (response_text , parse_mode = "markdown " )
0 commit comments