diff options
author | Mikhail Kirillov <w96k@runbox.com> | 2024-10-09 03:40:27 +0400 |
---|---|---|
committer | Mikhail Kirillov <w96k@runbox.com> | 2024-10-09 03:40:27 +0400 |
commit | 0d48ea28aeb8a6290d2aeab202efa9c8d6e30fe3 (patch) | |
tree | 8b83495d3eb235194b9d736bf0713ff362e27f2b /main.py | |
parent | cc34991f2098692a2cb2a9e913bd6667d38fdab5 (diff) |
Add /set command; Add error_handler;
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -35,19 +35,32 @@ async def unknown(update: Update, context: ContextTypes.DEFAULT_TYPE): text=INVALID_COMMAND ) +async def error_handler(update: object, context: ContextTypes.DEFAULT_TYPE) -> None: + logging.error("Exception:", exc_info=context.error) + + await context.bot.send_message( + chat_id=update.effective_chat.id, + text=context.error.message + ) if __name__ == "__main__": app = ApplicationBuilder().token( os.environ.get("TELEGRAM_TOKEN") ).persistence(Persistence).build() + # Meta commands app.add_handler(CommandHandler("about", commands.about)) + + # Movie commands + app.add_handler(CommandHandler("set", commands.set_users)) app.add_handler(CommandHandler("add", commands.add_users)) app.add_handler(CommandHandler("list", commands.list_users)) app.add_handler(CommandHandler("remove", commands.remove_users)) app.add_handler(CommandHandler("chooser", commands.chooser_user)) - app.add_handler(MessageHandler(filters.COMMAND, unknown)) + app.add_error_handler(error_handler) + app.run_polling() + |