From 70a683c06e314ebba18308c675dbd864e02fda55 Mon Sep 17 00:00:00 2001 From: SmartManoj Date: Mon, 15 Jul 2019 17:03:19 +0530 Subject: [PATCH] Update assistant.py --- telethon_examples/assistant.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/telethon_examples/assistant.py b/telethon_examples/assistant.py index 720f6071..20548d86 100644 --- a/telethon_examples/assistant.py +++ b/telethon_examples/assistant.py @@ -271,17 +271,18 @@ async def handler(event): @bot.on(events.NewMessage(pattern='(?i)[/#](list|help)', forwards=False)) async def handler(event): - if event.chat_id: - text = 'Available commands:\n' - for callback, handler in bot.list_event_handlers(): - if isinstance(handler, events.NewMessage) and callback.__doc__: - text += f'\n{callback.__doc__.strip()}' - text += '\n\nYou can suggest new commands [here](https://docs.google.com/'\ - 'spreadsheets/d/12yWwixUu_vB426_toLBAiajXxYKvR2J1DD6yZtQz9l4/edit).' - text.replace('#','/') - text += '\nCommand prefixes supports both hastag and forward slash' - message = await event.respond(text, link_preview=False) - + text = 'Available commands:\n' + for callback, handler in bot.list_event_handlers(): + if isinstance(handler, events.NewMessage) and callback.__doc__: + text += f'\n{callback.__doc__.strip()}' + text += '\n\nYou can suggest new commands [here](https://docs.google.com/'\ + 'spreadsheets/d/12yWwixUu_vB426_toLBAiajXxYKvR2J1DD6yZtQz9l4/edit).' + text.replace('#','/') + text += '\nCommand prefixes supports both hastag and forward slash' + message = await event.respond(text, link_preview=False) + if event.chat_id < 0 : + await asyncio.sleep(1 * text.count(' ')) # Sleep ~1 second per word + await message.delete() if aiohttp: @bot.on(events.NewMessage(pattern='(?i)[/#][hp]aste(bin)?', forwards=False))