From cea76b0323bed0ff130e0a7ee62c36321902878f Mon Sep 17 00:00:00 2001 From: aahnik <66209958+aahnik@users.noreply.github.com> Date: Sun, 15 Nov 2020 20:53:32 +0530 Subject: [PATCH] add unknown handler --- bot/run_python_bot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot/run_python_bot.py b/bot/run_python_bot.py index 35f8936..7bf6194 100644 --- a/bot/run_python_bot.py +++ b/bot/run_python_bot.py @@ -145,6 +145,10 @@ def inline_eval(update, context): # https://rushter.com/blog/python-strings-and-memory:~:text=4%20bytes%20per%20char%20(UCS%2D4%20encoding) context.bot.answer_inline_query(update.inline_query.id, results) + def unknown(update, context): + update.message.reply_text( + text='Sorry, 😥 I did not understand that command. Press `/` to see the list of availaible commands.', quote=True) + def error_callback(update, context): try: raise context.error @@ -160,6 +164,7 @@ def error_callback(update, context): Filters.text & (~Filters.command), reply_execute) _handlers['eval_handler'] = CommandHandler('e', reply_eval) _handlers['inline_eval_handler'] = InlineQueryHandler(inline_eval) + _handlers['unknown_handler'] = MessageHandler(Filters.command, unknown) for name, _handler in _handlers.items(): print(f'Adding {name}')