def main(): test_handler = CommandHandler("test", test, run_async=True) start_handler = DisableAbleCommandHandler("start", start, run_async=True) help_handler = DisableAbleCommandHandler("help", get_help, run_async=True) help_callback_handler = CallbackQueryHandler(help_button, pattern=r"help_.*", run_async=True) settings_handler = DisableAbleCommandHandler("settings", get_settings) settings_callback_handler = CallbackQueryHandler(settings_button, pattern=r"stngs_", run_async=True) data_callback_handler = CallbackQueryHandler(cutiepii_callback_data, pattern=r"cutiepii_", run_async=True) donate_handler = DisableAbleCommandHandler("donate", donate, run_async=True) migrate_handler = MessageHandler(Filters.status_update.migrate, migrate_chats, run_async=True) # dispatcher.add_handler(test_handler) dispatcher.add_handler(start_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(data_callback_handler) dispatcher.add_handler(settings_handler) dispatcher.add_handler(help_callback_handler) dispatcher.add_handler(settings_callback_handler) dispatcher.add_handler(migrate_handler) dispatcher.add_handler(donate_handler) dispatcher.add_error_handler(error_callback) if WEBHOOK: LOGGER.info("Using webhooks.") updater.start_webhook(listen="127.0.0.1", port=PORT, url_path=TOKEN) if CERT_PATH: updater.bot.set_webhook(url=URL + TOKEN, certificate=open(CERT_PATH, "rb")) else: updater.bot.set_webhook(url=URL + TOKEN) else: LOGGER.info( "Cutiepii started, Using long polling. | BOT: [@Cutiepii_Robot]") updater.start_polling(timeout=15, read_latency=4, drop_pending_updates=True, allowed_updates=Update.ALL_TYPES) if len(argv) not in (1, 3, 4): telethn.disconnect() else: telethn.run_until_disconnected() updater.idle()
def main(): if SUPPORT_CHAT is not None and isinstance(SUPPORT_CHAT, str): try: dispatcher.bot.sendMessage(f"@{SUPPORT_CHAT}", "Cutie Is Now Available in Bedroom") except Unauthorized: LOGGER.warning( "Bot isnt able to send message to support_chat, go and check!") except BadRequest as e: LOGGER.warning(e.message) test_handler = CommandHandler("test", test) start_handler = CommandHandler("start", start) help_handler = CommandHandler("help", get_help) help_callback_handler = CallbackQueryHandler(help_button, pattern=r"help_.*") settings_handler = CommandHandler("settings", get_settings) settings_callback_handler = CallbackQueryHandler(settings_button, pattern=r"stngs_") donate_handler = CommandHandler("donate", donate) migrate_handler = MessageHandler(Filters.status_update.migrate, migrate_chats) # dispatcher.add_handler(test_handler) dispatcher.add_handler(start_handler) dispatcher.add_handler(help_handler) dispatcher.add_handler(settings_handler) dispatcher.add_handler(help_callback_handler) dispatcher.add_handler(settings_callback_handler) dispatcher.add_handler(migrate_handler) dispatcher.add_handler(donate_handler) dispatcher.add_error_handler(error_callback) if WEBHOOK: LOGGER.info("Using webhooks.") updater.start_webhook(listen="0.0.0.0", port=PORT, url_path=TOKEN) if CERT_PATH: updater.bot.set_webhook(url=URL + TOKEN, certificate=open(CERT_PATH, 'rb')) else: updater.bot.set_webhook(url=URL + TOKEN) else: LOGGER.info("Ahh Baby. I am Feeling So Good.") updater.start_polling(timeout=15, read_latency=4, clean=True) if len(argv) not in (1, 3, 4): telethn.disconnect() else: telethn.run_until_disconnected() updater.idle()
f"#{context.error.identifier}\n<b>An unknown error occured:</b>\n<code>{e}</code>", reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("HasteBin", url=url)]], ), parse_mode="html", ) def list_errors(update: Update, context: CallbackContext): if update.effective_user.id not in DEV_USERS: return e = dict(sorted(errors.items(), key=lambda item: item[1], reverse=True)) msg = "<b>Errors List:</b>\n" for x, value in e.items(): msg += f'• <code>{x}:</code> <b>{value}</b> #{x.identifier}\n' msg += f"{len(errors)} have occurred since startup." if len(msg) > 4096: with open("errors_msg.txt", "w+") as f: f.write(msg) context.bot.send_document( update.effective_chat.id, open("errors_msg.txt", "rb"), caption="Too many errors have occured..", parse_mode="html", ) return update.effective_message.reply_text(msg, parse_mode="html") dispatcher.add_error_handler(error_callback) dispatcher.add_handler(CommandHandler("errors", list_errors))