async def add_handlers(dispatcher: Dispatcher): ## Plugins de personalidades ## Carregados primeiro para sobrescrever todos outros (comportamento aiogram) await plugin_personalidades.add_handlers(dispatcher) ## Plugins especiais if dispatcher.bot.info.get('personalidade') in [ 'default', 'metarec', 'pave', 'cryptoforex' ]: await plugin_donate.add_handlers(dispatcher) await plugin_archive.add_handlers(dispatcher) await plugin_ytdl.add_handlers(dispatcher) ## Plugins mais que especiais if dispatcher.bot.info.get('personalidade') in ['default', 'metarec']: try: await plugin_tropixel.add_handlers(dispatcher) except KeyError: logging.warning(u"plugin tropixel não configurado") if dispatcher.bot.info.get('personalidade') in ['cryptoforex']: try: await plugin_cryptoforex.add_handlers(dispatcher) except KeyError: logging.warning(u"plugin cryptoforex não configurado") ## Plugins gerais await plugin_hashes.add_handlers(dispatcher) await plugin_matematica.add_handlers(dispatcher) await plugin_qr.add_handlers(dispatcher) await plugin_feedback.add_handlers(dispatcher) await plugin_admin.add_handlers(dispatcher) try: await plugin_welcome.add_handlers(dispatcher) except KeyError: logging.warning(u"plugin welcome não configurado") await plugin_default.add_handlers(dispatcher) ## Todas updates que não forem tratadas por handlers anteriores dispatcher.register_message_handler( any_message_callback, content_types=types.message.ContentType.ANY, ) dispatcher.register_edited_message_handler(any_edited_message_callback) dispatcher.register_channel_post_handler(any_channel_post_callback) dispatcher.register_edited_channel_post_handler( any_edited_channel_post_callback, ) dispatcher.register_errors_handler(any_error_callback)
def setup(dp: Dispatcher): dp.register_errors_handler(message_not_modified, exception=exceptions.MessageNotModified) dp.register_errors_handler(message_to_delete_not_found, exception=exceptions.MessageToDeleteNotFound) dp.register_errors_handler(blocked_by_user, exception=exceptions.BotBlocked)
def setup(dp: Dispatcher): dp.register_errors_handler(errors_handler) dp.register_message_handler(anime_info, commands="anime") dp.register_message_handler(broadcast_info, commands="broadcast", user_id=admins) dp.register_message_handler(broadcast, state="message", content_types=types.ContentTypes.ANY) dp.register_message_handler(character_info, commands="char") dp.register_message_handler(show_help, commands="help") dp.register_inline_handler(inline_query) dp.register_message_handler(manga_info, commands="manga") dp.register_message_handler(change_news_status, commands="news") dp.register_callback_query_handler(yes_status, news_callback.filter(title="yes")) dp.register_callback_query_handler(no_status, news_callback.filter(title="no")) dp.register_message_handler(start, commands="start") dp.register_callback_query_handler( change_anime_news_status, main_news_callback.filter(title="anime_news"))
def add_handlers(dispatcher: Dispatcher): dispatcher.register_message_handler( start_callback, commands=['start', 'help'], ) dispatcher.register_message_handler( lista_callback, commands=['lista', 'ajuda'], ) dispatcher.register_message_handler(cats, regexp='(^cat[s]?$|puss)') ## Todas updates que não forem tratadas por handlers anteriores dispatcher.register_message_handler( any_message_callback, content_types=types.message.ContentType.ANY, ) dispatcher.register_edited_message_handler(any_edited_message_callback) dispatcher.register_channel_post_handler(any_channel_post_callback) dispatcher.register_edited_channel_post_handler( any_edited_channel_post_callback) dispatcher.register_edited_channel_post_handler( any_edited_channel_post_callback) dispatcher.register_errors_handler(any_error_callback)
def setup_handlers(dp: Dispatcher): dp.register_errors_handler(process_errors_handler) logger.info('Error handlers are successfully configured')
def setup(dp: Dispatcher): dp.register_errors_handler(errors.bot_kicked, exception=BotKicked) dp.register_errors_handler(errors.message_not_modified, exception=MessageNotModified) dp.register_errors_handler(errors.generic_error)
def setup(dp: Dispatcher): dp.register_errors_handler(errors_handler) dp.register_message_handler(start_command, commands="start")
client.flood_sleep_threshold = 5 client.start() # MIDDLEWARE middle = userbot.UserBot(client=client) middle.add_func(app.username_reply) # HANDLERS dp.register_message_handler(admin.stats, commands=["stats"], user_id=CONFIG["ADMINS"]) dp.register_message_handler(service.start, commands=["start"]) dp.register_message_handler(service.lang, commands=["lang"]) dp.register_message_handler(service.help, commands=["help"]) dp.register_message_handler(service.credits, commands=["credits"]) dp.register_message_handler(app.reply_id, commands=["id"]) dp.register_message_handler( middle.username_reply, lambda m: any([x.type == "mention" for x in m.entities]) ) dp.register_message_handler(app.reply_with_age) dp.register_callback_query_handler(callback.button_lang) dp.register_inline_handler(callback.query_with_age) dp.register_errors_handler(excepts.on_err, exception=TelegramAPIError) # DISPATCH if __name__ == "__main__": executor.start_polling(dp, skip_updates=True)
def setup(dispatcher: Dispatcher) -> NoReturn: dispatcher.register_errors_handler(errors_handler)
def setup(dp: Dispatcher): dp.register_errors_handler(bot_blocked_error, exception=BotBlocked) dp.register_errors_handler(errors)