示例#1
0
def add_all_handlers(dispatcher):
    dispatcher.add_handler(MessageHandler((Filters.text | Filters.command),
                                          log_message),
                           group=1)
    with db_session:
        for command in select(c for c in Command):
            handler = DeletableCommandHandler(command.name,
                                              globals()[command.name])
            command_handlers[command.name] = handler
            if command.enabled:
                dispatcher.add_handler(handler)
    dispatcher.add_handler(CallbackQueryHandler(button))
示例#2
0
def add_all_handlers(dispatcher):
    descriptions = []
    dispatcher.add_handler(MessageHandler(
        (Filters.text | Filters.command), log_message), group=1)
    with db_session:
        for command in select(c for c in Command):
            handler = DeletableCommandHandler(
                command.name, globals()[command.name])
            command_handlers[command.name] = handler
            if command.enabled:
                dispatcher.add_handler(handler)
                if command.description:
                    descriptions.append((command.name, command.description))
    dispatcher.add_handler(CallbackQueryHandler(button))
    print(descriptions)
    dispatcher.bot.set_my_commands(descriptions)