""" SET_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("cleanblue", set_blue_text_must_click) ADD_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("ignoreblue", add_bluetext_ignore) REMOVE_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("unignoreblue", remove_bluetext_ignore) ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER = CommandHandler( "gignoreblue", add_bluetext_ignore_global) REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER = CommandHandler( "ungignoreblue", remove_bluetext_ignore_global) LIST_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("listblue", bluetext_ignore_list) CLEAN_BLUE_TEXT_HANDLER = MessageHandler(Filters.command & Filters.group, clean_blue_text_must_click) dispatcher.add_handler(SET_CLEAN_BLUE_TEXT_HANDLER) dispatcher.add_handler(ADD_CLEAN_BLUE_TEXT_HANDLER) dispatcher.add_handler(REMOVE_CLEAN_BLUE_TEXT_HANDLER) dispatcher.add_handler(ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER) dispatcher.add_handler(REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER) dispatcher.add_handler(LIST_CLEAN_BLUE_TEXT_HANDLER) dispatcher.add_handler(CLEAN_BLUE_TEXT_HANDLER, BLUE_TEXT_CLEAN_GROUP) __mod_name__ = "Bluetext Cleaning" __handlers__ = [ SET_CLEAN_BLUE_TEXT_HANDLER, ADD_CLEAN_BLUE_TEXT_HANDLER, REMOVE_CLEAN_BLUE_TEXT_HANDLER, ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER, REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER, LIST_CLEAN_BLUE_TEXT_HANDLER, (CLEAN_BLUE_TEXT_HANDLER, BLUE_TEXT_CLEAN_GROUP) ]
if query_type == "db_leave_chat": if query.from_user.id in admin_list: bot.editMessageText("Leaving chats ...", chat_id, message.message_id) chat_count = get_muted_chats(update, context, True) bot.sendMessage(chat_id, f"Left {chat_count} chats.") else: query.answer("You are not allowed to use this.") elif query_type == "db_cleanup": if query.from_user.id in admin_list: bot.editMessageText("Cleaning up DB ...", chat_id, message.message_id) invalid_chat_count = get_invalid_chats(update, context, True) invalid_gban_count = get_invalid_gban(update, context, True) reply = "Cleaned up {} chats and {} gbanned users from db.".format( invalid_chat_count, invalid_gban_count) bot.sendMessage(chat_id, reply) else: query.answer( "You are not allowed to use this. Also Check @Cyber_legendss") DB_CLEANUP_HANDLER = CommandHandler("dbcleanup", dbcleanup) BUTTON_HANDLER = CallbackQueryHandler(callback_button, pattern='db_.*') dispatcher.add_handler(DB_CLEANUP_HANDLER) dispatcher.add_handler(BUTTON_HANDLER) __mod_name__ = "DB Cleanup" __handlers__ = [DB_CLEANUP_HANDLER, BUTTON_HANDLER]
filters=Filters.group) WELCOMEMUTE_HANDLER = CommandHandler("welcomemute", welcomemute, filters=Filters.group) CLEAN_SERVICE_HANDLER = CommandHandler("cleanservice", cleanservice, filters=Filters.group) CLEAN_WELCOME = CommandHandler("cleanwelcome", clean_welcome, filters=Filters.group) WELCOME_HELP = CommandHandler("welcomehelp", welcome_help) WELCOME_MUTE_HELP = CommandHandler("welcomemutehelp", welcome_mute_help) BUTTON_VERIFY_HANDLER = CallbackQueryHandler(user_button, pattern=r"user_join_") dispatcher.add_handler(NEW_MEM_HANDLER) dispatcher.add_handler(LEFT_MEM_HANDLER) dispatcher.add_handler(WELC_PREF_HANDLER) dispatcher.add_handler(GOODBYE_PREF_HANDLER) dispatcher.add_handler(SET_WELCOME) dispatcher.add_handler(SET_GOODBYE) dispatcher.add_handler(RESET_WELCOME) dispatcher.add_handler(RESET_GOODBYE) dispatcher.add_handler(CLEAN_WELCOME) dispatcher.add_handler(WELCOME_HELP) dispatcher.add_handler(WELCOMEMUTE_HANDLER) dispatcher.add_handler(CLEAN_SERVICE_HANDLER) dispatcher.add_handler(BUTTON_VERIFY_HANDLER) dispatcher.add_handler(WELCOME_MUTE_HELP) __mod_name__ = "Greetings"
except DisambiguationError as e: update.message.reply_text( "Disambiguated pages found! Adjust your query accordingly.\n<i>{}</i>" .format(e), parse_mode=ParseMode.HTML) except PageError as e: update.message.reply_text("<code>{}</code>".format(e), parse_mode=ParseMode.HTML) if res: result = f"<b>{search}</b>\n\n" result += f"<i>{res}</i>\n" result += f"""<a href="https://en.wikipedia.org/wiki/{search.replace(" ", "%20")}">Read more...</a>""" if len(result) > 4000: with open("result.txt", 'w') as f: f.write(f"{result}\n\nUwU OwO OmO UmU") with open("result.txt", 'rb') as f: context.bot.send_document( document=f, filename=f.name, reply_to_message_id=update.message.message_id, chat_id=update.effective_chat.id, parse_mode=ParseMode.HTML) else: update.message.reply_text(result, parse_mode=ParseMode.HTML, disable_web_page_preview=True) WIKI_HANDLER = DisableAbleCommandHandler("wiki", wiki) dispatcher.add_handler(WIKI_HANDLER)
__mod_name__ = "Connection" __help__ = """ Sometimes, you just want to add some notes and filters to a group chat, but you don't want everyone to see; This is where connections come in... This allows you to connect to a chat's database, and add things to it without the commands appearing in chat! For obvious reasons, you need to be an admin to add things; but any member in the group can view your data. • /connect: Connects to chat (Can be done in a group by /connect or /connect <chat id> in PM) • /connection: List connected chats • /disconnect: Disconnect from a chat • /helpconnect: List available commands that can be used remotely *Admin only:* • /allowconnect <yes/no>: allow a user to connect to a chat """ CONNECT_CHAT_HANDLER = CommandHandler("connect", connect_chat, pass_args=True) CONNECTION_CHAT_HANDLER = CommandHandler("connection", connection_chat) DISCONNECT_CHAT_HANDLER = CommandHandler("disconnect", disconnect_chat) ALLOW_CONNECTIONS_HANDLER = CommandHandler("allowconnect", allow_connections, pass_args=True) HELP_CONNECT_CHAT_HANDLER = CommandHandler("helpconnect", help_connect_chat) CONNECT_BTN_HANDLER = CallbackQueryHandler(connect_button, pattern=r"connect") dispatcher.add_handler(CONNECT_CHAT_HANDLER) dispatcher.add_handler(CONNECTION_CHAT_HANDLER) dispatcher.add_handler(DISCONNECT_CHAT_HANDLER) dispatcher.add_handler(ALLOW_CONNECTIONS_HANDLER) dispatcher.add_handler(HELP_CONNECT_CHAT_HANDLER) dispatcher.add_handler(CONNECT_BTN_HANDLER)
*Note*: Filters also support markdown formatters like: {first}, {last} etc.. and buttons. Check `/markdownhelp` to know more! """ __mod_name__ = "Filters" FILTER_HANDLER = CommandHandler("filter", filters) STOP_HANDLER = CommandHandler("stop", stop_filter) RMALLFILTER_HANDLER = CommandHandler( "removeallfilters", rmall_filters, filters=Filters.group) RMALLFILTER_CALLBACK = CallbackQueryHandler( rmall_callback, pattern=r"filters_.*") LIST_HANDLER = DisableAbleCommandHandler( "filters", list_handlers, admin_ok=True) CUST_FILTER_HANDLER = MessageHandler( CustomFilters.has_text & ~Filters.update.edited_message, reply_filter) dispatcher.add_handler(FILTER_HANDLER) dispatcher.add_handler(STOP_HANDLER) dispatcher.add_handler(LIST_HANDLER) dispatcher.add_handler(CUST_FILTER_HANDLER, HANDLER_GROUP) dispatcher.add_handler(RMALLFILTER_HANDLER) dispatcher.add_handler(RMALLFILTER_CALLBACK) __handlers__ = [ FILTER_HANDLER, STOP_HANDLER, LIST_HANDLER, (CUST_FILTER_HANDLER, HANDLER_GROUP, RMALLFILTER_HANDLER) ]
for i in reversed(range(5)): sent_msg.edit_text(sent_msg_text + str(i + 1)) sleep(1) sent_msg.edit_text("Restarted.") os.system('restart.bat') os.execv('start.bat', sys.argv) @run_async @dev_plus def restart(update: Update, context: CallbackContext): update.effective_message.reply_text( "Starting a new instance and shutting down this one") os.system('restart.bat') os.execv('start.bat', sys.argv) LEAVE_HANDLER = CommandHandler("leave", leave) GITPULL_HANDLER = CommandHandler("gitpull", gitpull) RESTART_HANDLER = CommandHandler("reboot", restart) dispatcher.add_handler(LEAVE_HANDLER) dispatcher.add_handler(GITPULL_HANDLER) dispatcher.add_handler(RESTART_HANDLER) __mod_name__ = "Dev" __handlers__ = [LEAVE_HANDLER, GITPULL_HANDLER, RESTART_HANDLER]
f"&from_currency={orig_cur}" f"&to_currency={new_cur}" f"&apikey={CASH_API_KEY}") response = requests.get(request_url).json() try: current_rate = float(response['Realtime Currency Exchange Rate'] ['5. Exchange Rate']) except KeyError: update.effective_message.reply_text("Currency Not Supported.") return new_cur_amount = round(orig_cur_amount * current_rate, 5) update.effective_message.reply_text( f"{orig_cur_amount} {orig_cur} = {new_cur_amount} {new_cur}") elif len(args) == 1: update.effective_message.reply_text(__help__, parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( f"*Invalid Args!!:* Required 3 But Passed {len(args) -1}", parse_mode=ParseMode.MARKDOWN) CONVERTER_HANDLER = CommandHandler('cash', convert) dispatcher.add_handler(CONVERTER_HANDLER) __command_list__ = ["cash"] __handlers__ = [CONVERTER_HANDLER]
def main(): if SUPPORT_CHAT is not None and isinstance(SUPPORT_CHAT, str): try: dispatcher.bot.sendMessage(f"@{SUPPORT_CHAT}", "I am now online!") 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("Using long polling.") 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()
*Commands:* *Admins only:* • `/addchat`*:* Enables Chatbot mode in the chat. • `/rmchat`*:* Disables Chatbot mode in the chat. Reports bugs at @{SUPPORT_CHAT} *Powered by CoffeeHouse* (https://coffeehouse.intellivoid.net/) from @Intellivoid """ ADD_CHAT_HANDLER = CommandHandler("addchat", add_chat) REMOVE_CHAT_HANDLER = CommandHandler("rmchat", remove_chat) CHATBOT_HANDLER = MessageHandler( Filters.text & (~Filters.regex(r"^#[^\s]+") & ~Filters.regex(r"^!") & ~Filters.regex(r"^\/")), chatbot) LIST_CB_CHATS_HANDLER = CommandHandler("listaichats", list_chatbot_chats, filters=CustomFilters.dev_filter) # Filters for ignoring #note messages, !commands and sed. dispatcher.add_handler(ADD_CHAT_HANDLER) dispatcher.add_handler(REMOVE_CHAT_HANDLER) dispatcher.add_handler(CHATBOT_HANDLER) dispatcher.add_handler(LIST_CB_CHATS_HANDLER) __mod_name__ = "Chatbot" __command_list__ = ["addchat", "rmchat", "listaichats"] __handlers__ = [ ADD_CHAT_HANDLER, REMOVE_CHAT_HANDLER, CHATBOT_HANDLER, LIST_CB_CHATS_HANDLER ]