Changeset 0d48ea2 in python-cinema-club-bot for main.py


Ignore:
Timestamp:
Oct 9, 2024, 3:40:27 AM (5 weeks ago)
Author:
Mikhail Kirillov <w96k@…>
Branches:
master
Children:
6623428
Parents:
cc34991
Message:

Add /set command; Add error_handler;

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main.py

    rcc34991 r0d48ea2  
    3636    )
    3737
     38async def error_handler(update: object, context: ContextTypes.DEFAULT_TYPE) -> None:
     39    logging.error("Exception:", exc_info=context.error)
     40
     41    await context.bot.send_message(
     42        chat_id=update.effective_chat.id,
     43        text=context.error.message
     44    )
    3845
    3946if __name__ == "__main__":
     
    4249    ).persistence(Persistence).build()
    4350
     51    # Meta commands
    4452    app.add_handler(CommandHandler("about", commands.about))
     53
     54    # Movie commands
     55    app.add_handler(CommandHandler("set", commands.set_users))
    4556    app.add_handler(CommandHandler("add", commands.add_users))
    4657    app.add_handler(CommandHandler("list", commands.list_users))
     
    4859    app.add_handler(CommandHandler("chooser", commands.chooser_user))
    4960
     61    app.add_handler(MessageHandler(filters.COMMAND, unknown))
     62    app.add_error_handler(error_handler)
    5063
    51     app.add_handler(MessageHandler(filters.COMMAND, unknown))
    5264
    5365    app.run_polling()
     66
Note: See TracChangeset for help on using the changeset viewer.