Skip to content
This repository has been archived by the owner on Jan 8, 2022. It is now read-only.

Commit

Permalink
add unknown handler
Browse files Browse the repository at this point in the history
  • Loading branch information
aahnik committed Nov 15, 2020
1 parent d458a88 commit cea76b0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bot/run_python_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}')
Expand Down

0 comments on commit cea76b0

Please sign in to comment.