summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rw-r--r--main.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/main.py b/main.py
index 7ca8b59..10c05a7 100644
--- a/main.py
+++ b/main.py
@@ -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()
+