def main(): test_handler = CommandHandler("test", test) start_handler = CommandHandler("start", start, pass_args=True) help_handler = CommandHandler("help", get_help) help_callback_handler = CallbackQueryHandler(help_button, pattern=r"help_") start_callback_handler = CallbackQueryHandler(send_start, pattern=r"bot_start") dispatcher.add_handler(start_callback_handler) #cntrl_panel = CommandHandler("controlpanel", control_panel) #cntrl_panel_callback_handler = CallbackQueryHandler(control_panel, pattern=r"cntrl_panel") #dispatcher.add_handler(cntrl_panel_callback_handler) #dispatcher.add_handler(cntrl_panel) #settings_handler = CommandHandler("settings", get_settings) #settings_callback_handler = CallbackQueryHandler(settings_button, pattern=r"stngs_") migrate_handler = MessageHandler(Filters.status_update.migrate, migrate_chats) 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) # add antiflood processor Dispatcher.process_update = process_update LOGGER.info("Using long polling.") updater.start_polling(poll_interval=0, timeout=15, read_latency=4, clean=True) LOGGER.info("Successfully loaded") if len(argv) not in (1, 3, 4): tbot.disconnect() else: tbot.run_until_disconnected() updater.idle()
return f"• {sql.num_chats()} chats have rules set." def __import_data__(chat_id, data): # set chat rules rules = data.get("info", {}).get("rules", "") sql.set_rules(chat_id, rules) def __migrate__(old_chat_id, new_chat_id): sql.migrate_chat(old_chat_id, new_chat_id) def __chat_settings__(chat_id, user_id): return f"This chat has had it's rules set: `{bool(sql.get_rules(chat_id))}`" __mod_name__ = "Rules" GET_RULES_HANDLER = CommandHandler("rules", get_rules, filters=Filters.group) SET_RULES_HANDLER = CommandHandler("setrules", set_rules, filters=Filters.group) RESET_RULES_HANDLER = CommandHandler("clearrules", clear_rules, filters=Filters.group) dispatcher.add_handler(GET_RULES_HANDLER) dispatcher.add_handler(SET_RULES_HANDLER) dispatcher.add_handler(RESET_RULES_HANDLER)
def __migrate__(old_chat_id, new_chat_id): sql.migrate_chat(old_chat_id, new_chat_id) BROADCAST_HANDLER = CommandHandler("broadcast", broadcast, filters=Filters.user(OWNER_ID)) USER_HANDLER = MessageHandler(Filters.all & Filters.group, log_user) CHATLIST_HANDLER = CommandHandler("chatlist", chats, filters=Filters.user(OWNER_ID)) GETLINK_HANDLER = CommandHandler("getlink", getlink, pass_args=True, filters=Filters.user(OWNER_ID)) LEAVECHAT_HANDLER = CommandHandler("leavechat", leavechat, pass_args=True, filters=Filters.user(OWNER_ID)) SLIST_HANDLER = CommandHandler("slist", slist) WLIST_HANDLER = CommandHandler("wlist", wlist) dispatcher.add_handler(GETLINK_HANDLER) dispatcher.add_handler(LEAVECHAT_HANDLER) dispatcher.add_handler(SLIST_HANDLER) dispatcher.add_handler(WLIST_HANDLER) dispatcher.add_handler(USER_HANDLER, USERS_GROUP) dispatcher.add_handler(BROADCAST_HANDLER) dispatcher.add_handler(CHATLIST_HANDLER)
else: update.message.reply_text("Maybe.") def table(bot: Bot, update: Update): r = randint(1, 100) if r <= 45: update.message.reply_text("(╯°□°)╯彡 ┻━┻") elif r <= 90: update.message.reply_text("Send money bsdk to buy new table to flip") else: update.message.reply_text( "Go do some work instead of flippin tables you helpless fagit.") ABUSE_HANDLER = CommandHandler("abuse", abuse) ROLL_HANDLER = CommandHandler("roll", roll) TOSS_HANDLER = CommandHandler("toss", toss) #BLUETEXT_HANDLER = CommandHandler("bluetext", bluetext) RLG_HANDLER = CommandHandler("rlg", rlg) DECIDE_HANDLER = CommandHandler("decide", decide) TABLE_HANDLER = CommandHandler("table", table) dispatcher.add_handler(ABUSE_HANDLER) dispatcher.add_handler(ROLL_HANDLER) dispatcher.add_handler(TOSS_HANDLER) #dispatcher.add_handler(BLUETEXT_HANDLER) dispatcher.add_handler(RLG_HANDLER) dispatcher.add_handler(DECIDE_HANDLER) dispatcher.add_handler(TABLE_HANDLER)
TEMPBAN_HANDLER = CommandHandler(["tban", "tempban"], temp_ban, pass_args=True, filters=Filters.group) KICK_HANDLER = CommandHandler("kick", kick, pass_args=True, filters=Filters.group) UNBAN_HANDLER = CommandHandler("unban", unban, pass_args=True, filters=Filters.group) KICKME_HANDLER = CommandHandler("kickme", kickme, filters=Filters.group) SBAN_HANDLER = CommandHandler("sban", sban, pass_args=True, filters=Filters.group) BANME_HANDLER = CommandHandler("banme", banme, filters=Filters.group) ROAR_HANDLER = CommandHandler("selfunban", selfunban, pass_args=True, filters=Filters.user(OWNER_ID)) dispatcher.add_handler(BAN_HANDLER) dispatcher.add_handler(TEMPBAN_HANDLER) dispatcher.add_handler(KICK_HANDLER) dispatcher.add_handler(UNBAN_HANDLER) dispatcher.add_handler(KICKME_HANDLER) dispatcher.add_handler(BANME_HANDLER) dispatcher.add_handler(SBAN_HANDLER) dispatcher.add_handler(ROAR_HANDLER)
ADD_WARN_HANDLER = CommandHandler("addwarn", add_warn_filter, filters=Filters.group) RM_WARN_HANDLER = CommandHandler(["nowarn", "stopwarn"], remove_warn_filter, filters=Filters.group) LIST_WARN_HANDLER = CommandHandler(["warnlist", "warnfilters"], list_warn_filters, filters=Filters.group) WARN_FILTER_HANDLER = MessageHandler(CustomFilters.has_text & Filters.group, reply_filter) WARN_LIMIT_HANDLER = CommandHandler("warnlimit", set_warn_limit, pass_args=True, filters=Filters.group) WARN_STRENGTH_HANDLER = CommandHandler("strongwarn", set_warn_strength, pass_args=True, filters=Filters.group) dispatcher.add_handler(WARN_HANDLER) dispatcher.add_handler(CALLBACK_QUERY_HANDLER) dispatcher.add_handler(RESET_WARN_HANDLER) dispatcher.add_handler(MYWARNS_HANDLER) dispatcher.add_handler(ADD_WARN_HANDLER) dispatcher.add_handler(RM_WARN_HANDLER) dispatcher.add_handler(LIST_WARN_HANDLER) dispatcher.add_handler(WARN_LIMIT_HANDLER) dispatcher.add_handler(WARN_STRENGTH_HANDLER) dispatcher.add_handler(WARN_FILTER_HANDLER, WARN_HANDLER_GROUP)
else: message.reply_text(tld(chat.id, "No log channel has been set yet!")) def __stats__(): return "{} log channels set.".format(sql.num_logchannels()) def __migrate__(old_chat_id, new_chat_id): sql.migrate_chat(old_chat_id, new_chat_id) def __chat_settings__(bot, update, chat, chatP, user): log_channel = sql.get_chat_log_channel(chat.id) if log_channel: log_channel_info = dispatcher.bot.get_chat(log_channel) return "This group has all it's logs sent to: {} (`{}`)".format( escape_markdown(log_channel_info.title), log_channel) return "No log channel is set for this group!" LOG_HANDLER = CommandHandler("logchannel", logging) SET_LOG_HANDLER = CommandHandler("setlog", setlog) UNSET_LOG_HANDLER = CommandHandler("unsetlog", unsetlog) dispatcher.add_handler(LOG_HANDLER) dispatcher.add_handler(SET_LOG_HANDLER) dispatcher.add_handler(UNSET_LOG_HANDLER) else: # run anyway if module not loaded def loggable(func): return func
@user_admin def me_too(bot: Bot, update: Update): message = update.effective_message if random.randint(0, 100) > 60: reply = random.choice( ["Me too thanks", "Haha yes, me too", "Same lol", "Me irl"]) message.reply_text(reply) COPYPASTA_HANDLER = CommandHandler("copypasta", copypasta) #COPYPASTA_ALIAS_HANDLER = CommandHandler("😂", copypasta) CLAPMOJI_HANDLER = CommandHandler("clapmoji", clapmoji) #CLAPMOJI_ALIAS_HANDLER = CommandHandler("👏", clapmoji) ANGRYMOJI_HANDLER = CommandHandler("angrymoji", angrymoji) #ANGRYMOJI_ALIAS_HANDLER = CommandHandler("😡", angrymoji) CRYMOJI_HANDLER = CommandHandler("crymoji", crymoji) #CRYMOJI_ALIAS_HANDLER = CommandHandler("😭", crymoji) #BMOJI_HANDLER = CommandHandler("🅱️", bmoji) BMOJI_ALIAS_HANDLER = CommandHandler("bmoji", bmoji) dispatcher.add_handler(COPYPASTA_HANDLER) #dispatcher.add_handler(COPYPASTA_ALIAS_HANDLER) dispatcher.add_handler(CLAPMOJI_HANDLER) #dispatcher.add_handler(CLAPMOJI_ALIAS_HANDLER) dispatcher.add_handler(ANGRYMOJI_HANDLER) #dispatcher.add_handler(ANGRYMOJI_ALIAS_HANDLER) dispatcher.add_handler(CRYMOJI_HANDLER) #dispatcher.add_handler(CRYMOJI_ALIAS_HANDLER) #dispatcher.add_handler(BMOJI_HANDLER) dispatcher.add_handler(BMOJI_ALIAS_HANDLER)
from telegram import Message, Update, Bot, User from telegram import MessageEntity from telegram.ext import Filters, MessageHandler, run_async, CommandHandler from alexa import dispatcher, LOGGER from alexa.modules.disable import DisableAbleCommandHandler from alexa.modules.helper_funcs.chat_status import user_admin from googletrans import LANGUAGES, Translator @run_async def do_translate(bot: Bot, update: Update, args: List[str]): short_name = "Created By @MidukkiBot 😬" msg = update.effective_message # type: Optional[Message] lan = " ".join(args) to_translate_text = msg.reply_to_message.text translator = Translator() try: translated = translator.translate(to_translate_text, dest=lan) src_lang = translated.src translated_text = translated.text msg.reply_text("Translated from {} to {}.\n {}".format(src_lang, lan, translated_text)) except : msg.reply_text("Error") dispatcher.add_handler(CommandHandler("tr", do_translate, pass_args=True))
FACTOR_HANDLER = CommandHandler("factor", factor) DERIVE_HANDLER = CommandHandler("derive", derive) INTEGRATE_HANDLER = CommandHandler("integrate", integrate) ZEROES_HANDLER = CommandHandler("zeroes", zeroes) TANGENT_HANDLER = CommandHandler("tangent", tangent) AREA_HANDLER = CommandHandler("area", area) COS_HANDLER = CommandHandler("cos", cos) SIN_HANDLER = CommandHandler("sin", sin) TAN_HANDLER = CommandHandler("tan", tan) ARCCOS_HANDLER = CommandHandler("arccos", arccos) ARCSIN_HANDLER = CommandHandler("arcsin", arcsin) ARCTAN_HANDLER = CommandHandler("arctan", arctan) ABS_HANDLER = CommandHandler("abs", abs) LOG_HANDLER = CommandHandler("log", log) dispatcher.add_handler(SIMPLIFY_HANDLER) dispatcher.add_handler(FACTOR_HANDLER) dispatcher.add_handler(DERIVE_HANDLER) dispatcher.add_handler(INTEGRATE_HANDLER) dispatcher.add_handler(ZEROES_HANDLER) dispatcher.add_handler(TANGENT_HANDLER) dispatcher.add_handler(AREA_HANDLER) dispatcher.add_handler(COS_HANDLER) dispatcher.add_handler(SIN_HANDLER) dispatcher.add_handler(TAN_HANDLER) dispatcher.add_handler(ARCCOS_HANDLER) dispatcher.add_handler(ARCSIN_HANDLER) dispatcher.add_handler(ARCTAN_HANDLER) dispatcher.add_handler(ABS_HANDLER) dispatcher.add_handler(LOG_HANDLER)
if suggestions: sugg_str = suggestions[0].get( 'Text') # should look at this list more curr_string += msg.text[prev_end:start] + sugg_str prev_end = end curr_string += msg.text[prev_end:] print(curr_string) update.effective_message.reply_text(curr_string) __help__ = """ - /afk <reason>: mark yourself as AFK(Away From Keyboard) - brb <reason>: same as the afk command - /spell: while replying to a message, will reply with a grammar corrected version(ENGLISH ONLY) - /forbesify: Correct your punctuations better use the advanged spell module - /tr (language code) as reply to a long message. - /define <text>: Type the word or expression you want to search\nFor example /define Gay - /banme: ban yourself from a chat - /kickme: kicks yourself from a chat - /markdownhelp: quick summary of how markdown works in telegram - can only be called in private chats - /smsbomb {country code without +} {phone no}: Take revenge upon your enemy by sending bulk messages """ __mod_name__ = "Helpers 🤗" TRANSLATE_HANDLER = CommandHandler('spell', translate) dispatcher.add_handler(TRANSLATE_HANDLER)
def __stats__(): return "{} notes, across {} chats.".format(sql.num_notes(), sql.num_chats()) def __migrate__(old_chat_id, new_chat_id): sql.migrate_chat(old_chat_id, new_chat_id) def __chat_settings__(bot, update, chat, chatP, user): chat_id = chat.id notes = sql.get_all_chat_notes(chat_id) return "There are `{}` notes in this chat.".format(len(notes)) GET_HANDLER = CommandHandler("get", cmd_get, pass_args=True) HASH_GET_HANDLER = RegexHandler(r"^#[^\s]+", hash_get) SAVE_HANDLER = CommandHandler("save", save) DELETE_HANDLER = CommandHandler("clear", clear, pass_args=True) LIST_HANDLER = CommandHandler(["notes", "saved"], list_notes) dispatcher.add_handler(GET_HANDLER) dispatcher.add_handler(SAVE_HANDLER) dispatcher.add_handler(LIST_HANDLER) dispatcher.add_handler(DELETE_HANDLER) dispatcher.add_handler(HASH_GET_HANDLER)
NEW_MEM_HANDLER = MessageHandler(Filters.status_update.new_chat_members, new_member) LEFT_MEM_HANDLER = MessageHandler(Filters.status_update.left_chat_member, left_member) WELC_PREF_HANDLER = CommandHandler("welcome", welcome, pass_args=True, filters=Filters.group) GOODBYE_PREF_HANDLER = CommandHandler("goodbye", goodbye, pass_args=True, filters=Filters.group) SET_WELCOME = CommandHandler("setwelcome", set_welcome, filters=Filters.group) SET_GOODBYE = CommandHandler("setgoodbye", set_goodbye, filters=Filters.group) RESET_WELCOME = CommandHandler("resetwelcome", reset_welcome, filters=Filters.group) RESET_GOODBYE = CommandHandler("resetgoodbye", reset_goodbye, filters=Filters.group) CLEAN_WELCOME = CommandHandler("cleanwelcome", clean_welcome, pass_args=True, filters=Filters.group) WELCOME_HELP = CommandHandler("welcomehelp", welcome_help) SECURITY_HANDLER = CommandHandler("welcomesecurity", security, pass_args=True, filters=Filters.group) CLEAN_SERVICE_HANDLER = CommandHandler("cleanservice", cleanservice, pass_args=True, filters=Filters.group) help_callback_handler = CallbackQueryHandler(check_bot_button, pattern=r"check_bot_") 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(WELCOME_HELP) dispatcher.add_handler(RESET_WELCOME) dispatcher.add_handler(RESET_GOODBYE) dispatcher.add_handler(CLEAN_WELCOME) dispatcher.add_handler(SECURITY_HANDLER) dispatcher.add_handler(CLEAN_SERVICE_HANDLER) dispatcher.add_handler(help_callback_handler)
LOGGER.exception( "ERROR muting user %s in chat %s (%s) due to %s", user_id, chat.title, chat.id, excp.message, ) message.reply_text("Well damn, I can't mute that user.") return "" __mod_name__ = "Muting" MUTE_HANDLER = CommandHandler("mute", mute, pass_args=True, filters=Filters.group) UNMUTE_HANDLER = CommandHandler("unmute", unmute, pass_args=True, filters=Filters.group) TEMPMUTE_HANDLER = CommandHandler(["tmute", "tempmute"], temp_mute, pass_args=True, filters=Filters.group) dispatcher.add_handler(MUTE_HANDLER) dispatcher.add_handler(UNMUTE_HANDLER) dispatcher.add_handler(TEMPMUTE_HANDLER)
["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] __help__ = """ - /cash : currency converter example syntax: /cash 1 USD INR """ __mod_name__ = "Currency 💰"
@user_can_delete @loggable def del_message(bot: Bot, update: Update) -> str: chat = update.effective_chat # type: Optional[Chat] if update.effective_message.reply_to_message: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] if can_delete(chat, bot.id): update.effective_message.reply_to_message.delete() update.effective_message.delete() return "<b>{}:</b>" \ "\n#DEL" \ "\n<b>Admin:</b> {}" \ "\nMessage deleted.".format(html.escape(chat.title), mention_html(user.id, user.first_name)) else: update.effective_message.reply_text( tld(chat.id, "Whadya want to delete?")) return "" DELETE_HANDLER = CommandHandler("del", del_message, filters=Filters.group) PURGE_HANDLER = CommandHandler("purge", purge, filters=Filters.group, pass_args=True) dispatcher.add_handler(DELETE_HANDLER) dispatcher.add_handler(PURGE_HANDLER)
user_id = message.reply_to_message.from_user.id fst_name = message.reply_to_message.from_user.first_name check_afk(bot, update, user_id, fst_name) def check_afk(bot, update, user_id, fst_name): chat = update.effective_chat # type: Optional[Chat] if sql.is_afk(user_id): user = sql.check_afk_status(user_id) elapsed_time = time.time() - start_time final = time.strftime("%Hh: %Mm: %Ss", time.gmtime(elapsed_time)) if not user.reason: res = tld(chat.id, f"{fst_name} is AFK !\n\nLast seen {final} ago") else: res = tld( chat.id, f"{fst_name} is AFK !\n\nReason: {user.reason}\n\nLast seen {final} ago" ) update.effective_message.reply_text(res) AFK_HANDLER = DisableAbleCommandHandler("afk", afk) AFK_REGEX_HANDLER = DisableAbleRegexHandler("(?i)brb", afk, friendly="afk") NO_AFK_HANDLER = MessageHandler(Filters.all & Filters.group, no_longer_afk) AFK_REPLY_HANDLER = MessageHandler(Filters.all & Filters.group, reply_afk) dispatcher.add_handler(AFK_HANDLER, AFK_GROUP) dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP) dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP) dispatcher.add_handler(AFK_REPLY_HANDLER, AFK_REPLY_GROUP)
timeout=360, reply_to_message_id=msg.message_id, parse_mode=ParseMode.MARKDOWN) os.remove("Alexa{}.backup".format(chat_id)) # Cleaning file # Temporary data def put_chat(chat_id, value, chat_data): # print(chat_data) if value == False: status = False else: status = True chat_data[chat_id] = {'backups': {"status": status, "value": value}} def get_chat(chat_id, chat_data): # print(chat_data) try: value = chat_data[chat_id]['backups'] return value except KeyError: return {"status": False, "value": False} IMPORT_HANDLER = CommandHandler("import", import_data) EXPORT_HANDLER = CommandHandler("export", export_data, pass_chat_data=True) dispatcher.add_handler(IMPORT_HANDLER) dispatcher.add_handler(EXPORT_HANDLER)
sql.disconnected_chat = query.message.edit_text( "Disconnected from chat!") else: bot.answer_callback_query(query.id, "You're not connected!", show_alert=True) elif clear_match: sql.clear_history_conn(query.from_user.id) query.message.edit_text("History connected has been cleared!") elif connect_close: query.message.edit_text("Closed.\nTo open again, type /connect") else: connect_chat(bot, update, []) 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)
base_string += "- <code>{}</code>\n".format(domain) message.reply_text(base_string, parse_mode=ParseMode.HTML) URL_BLACKLIST_HANDLER = CommandHandler("blacklist", add_blacklist_url, filters=Filters.group, pass_args=True) ADD_URL_BLACKLIST_HANDLER = CommandHandler("addurl", add_blacklist_url, filters=Filters.group) RM_BLACKLIST_URL_HANDLER = CommandHandler("delurl", rm_blacklist_url, filters=Filters.group) GET_BLACKLISTED_URLS = CommandHandler("geturl", get_blacklisted_urls, filters=Filters.group) URL_DELETE_HANDLER = MessageHandler(Filters.entity("url"), del_blacklist_url, edited_updates=True) dispatcher.add_handler(URL_BLACKLIST_HANDLER) dispatcher.add_handler(ADD_URL_BLACKLIST_HANDLER) dispatcher.add_handler(RM_BLACKLIST_URL_HANDLER) dispatcher.add_handler(GET_BLACKLISTED_URLS) dispatcher.add_handler(URL_DELETE_HANDLER)
| CustomFilters.support_filter) UNGMUTE_HANDLER = CommandHandler("ungmute", ungmute, pass_args=True, filters=CustomFilters.sudo_filter | CustomFilters.support_filter) GMUTE_LIST = CommandHandler("gmutelist", gmutelist, filters=Filters.user(OWNER_ID)) GKICK_HANDLER = CommandHandler("gkick", gkick, pass_args=True, filters=CustomFilters.sudo_filter | CustomFilters.support_filter) # dispatcher.add_handler(ANTISPAM_STATUS) dispatcher.add_handler(GBAN_HANDLER) dispatcher.add_handler(UNGBAN_HANDLER) dispatcher.add_handler(GBAN_LIST) dispatcher.add_handler(GMUTE_HANDLER) dispatcher.add_handler(UNGMUTE_HANDLER) dispatcher.add_handler(GMUTE_LIST) dispatcher.add_handler(GKICK_HANDLER) if STRICT_ANTISPAM: # enforce GBANS if this is set dispatcher.add_handler(GBAN_ENFORCER, GBAN_ENFORCE_GROUP)
msg.reply_text("Please enter a query!") return else: caption = query term = query.replace(" ", "%20") json_rep = r.get( f"https://wall.alphacoders.com/api2.0/get.php?auth={WALL_API}&method=search&term={term}" ).json() if not json_rep.get("success"): msg.reply_text(f"An error occurred! Report this to @AlexaSupport") else: wallpapers = json_rep.get("wallpapers") if not wallpapers: msg.reply_text("No results found! Refine your search.") return else: index = randint(0, len(wallpapers) - 1) # Choose random index wallpaper = wallpapers[index] wallpaper = wallpaper.get("url_image") wallpaper = wallpaper.replace("\\", "") bot.send_document(chat_id, document=wallpaper, filename='wallpaper', caption=caption, reply_to_message_id=msg_id, timeout=60) WALLPAPER_HANDLER = CommandHandler("wall", wall, pass_args=True) dispatcher.add_handler(WALLPAPER_HANDLER)
return results def scam(imgspage, lim): """Parse/Scrape the HTML code for the info we want.""" single = opener.open(imgspage).read() decoded = single.decode('utf-8') if int(lim) > 10: lim = 10 imglinks = [] counter = 0 pattern = r'^,\[\"(.*[.png|.jpg|.jpeg])\",[0-9]+,[0-9]+\]$' oboi = re.findall(pattern, decoded, re.I | re.M) for imglink in oboi: counter += 1 imglinks.append(imglink) if counter >= int(lim): break return imglinks REVERSE_HANDLER = CommandHandler("reverse", reverse, pass_args=True) dispatcher.add_handler(REVERSE_HANDLER)
num_chats = sql.get_user_num_chats(user_id) return """I've seen them in <code>{}</code> chats in total.""".format( num_chats) def __stats__(): return "× {} users, across {} chats".format(sql.num_users(), sql.num_chats()) def __migrate__(old_chat_id, new_chat_id): sql.migrate_chat(old_chat_id, new_chat_id) __mod_name__ = "Users" BROADCAST_HANDLER = CommandHandler("broadcast", broadcast, filters=Filters.user(OWNER_ID)) USER_HANDLER = MessageHandler(Filters.all & Filters.group, log_user) CHATLIST_HANDLER = CommandHandler("chatlist", chats, filters=Filters.user(OWNER_ID)) CHAT_CHECKER_HANDLER = MessageHandler(Filters.all & Filters.group, chat_checker) dispatcher.add_handler(USER_HANDLER, USERS_GROUP) dispatcher.add_handler(BROADCAST_HANDLER) dispatcher.add_handler(CHATLIST_HANDLER) dispatcher.add_handler(CHAT_CHECKER_HANDLER, CHAT_GROUP)
- /sticklet <text>: Turn a text into a sticker, you'll get a random colour from a rainbow(out of 7 colours) - /fortune: gets a random fortune quote - /quotly: An alternative to @QuotlyBot, type /quotly in reply to a message """ __mod_name__ = "Memes 💢" COPYPASTA_HANDLER = CommandHandler("copypasta", copypasta) CLAPMOJI_HANDLER = CommandHandler("clapmoji", clapmoji) BMOJI_HANDLER = CommandHandler("bmoji", bmoji) OWO_HANDLER = CommandHandler("owo", owo) STRETCH_HANDLER = CommandHandler("stretch", stretch) VAPOR_HANDLER = CommandHandler("vapor", vapor, pass_args=True) ZALGO_HANDLER = CommandHandler("zalgofy", zalgotext) FORBES_HANDLER = CommandHandler("forbes", forbesify) DEEPFRY_HANDLER = CommandHandler("deepfry", deepfryer) SHOUT_HANDLER = CommandHandler("shout", shout, pass_args=True) #FORBES_HANDLER = CommandHandler("forbesify", forbesify) dispatcher.add_handler(COPYPASTA_HANDLER) dispatcher.add_handler(CLAPMOJI_HANDLER) dispatcher.add_handler(BMOJI_HANDLER) dispatcher.add_handler(SHOUT_HANDLER) dispatcher.add_handler(OWO_HANDLER) #dispatcher.add_handler(FORBES_HANDLER) dispatcher.add_handler(STRETCH_HANDLER) dispatcher.add_handler(VAPOR_HANDLER) dispatcher.add_handler(ZALGO_HANDLER) dispatcher.add_handler(FORBES_HANDLER) dispatcher.add_handler(DEEPFRY_HANDLER)
@run_async def list_chatbot(bot: Bot, update: Update): chats = sql.get_all_chats() text = "<b>AI-Enabled Chats</b>\n" for chat in chats: try: x = bot.get_chat(int(*chat)) name = x.title if x.title else x.first_name text += f"• <code>{name}</code>\n" except BadRequest: sql.rem_chat(*chat) except Unauthorized: sql.rem_chat(*chat) except RetryAfter as e: sleep(e.retry_after) update.effective_message.reply_text(text, parse_mode="HTML") ADD_CHAT_HANDLER = CommandHandler("autochat", add_chat) REMOVE_CHAT_HANDLER = CommandHandler("stopchat", remove_chat) CHATBOT_HANDLER = MessageHandler(Filters.text & (~Filters.regex( r"^#[^\s]+") & ~Filters.regex(r"^!") & ~Filters.regex(r"^s\/")), chatbot) # CHATBOTLIST_HANDLER = CommandHandler("listai", list_chatbot, 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(CHATBOTLIST_HANDLER)
def imresize(kangsticker): im = Image.open(kangsticker) maxsize = (512, 512) if (im.width and im.height) < 512: size1 = im.width size2 = im.height if im.width > im.height: scale = 512/size1 size1new = 512 size2new = size2 * scale else: scale = 512/size2 size1new = size1 * scale size2new = 512 size1new = math.floor(size1new) size2new = math.floor(size2new) sizenew = (size1new, size2new) im = im.resize(sizenew) else: im.thumbnail(maxsize) return im STICKERID_HANDLER = CommandHandler("stickerid", stickerid) GETSTICKER_HANDLER = CommandHandler("getsticker", getsticker) KANG_HANDLER = CommandHandler("kang", kang, pass_args=True) dispatcher.add_handler(STICKERID_HANDLER) dispatcher.add_handler(GETSTICKER_HANDLER) dispatcher.add_handler(KANG_HANDLER)
"You should try playing snake and ladders, with real snakes and no ladders.", "Dance naked on a couple of HT wires.", "Active Volcano is the best swimming pool for you.", "You should try hot bath in a volcano.", "Try to spend one day in a coffin and it will be yours forever.", "Hit Uranium with a slow moving neutron in your presence. It will be a worthwhile experience.", "You can be the first person to step on sun. Have a try.", "People like you are the reason we have middle fingers.", "When your mom dropped you off at the school, she got a ticket for littering.", "You’re so ugly that when you cry, the tears roll down the back of your head…just to avoid your face.", "If you’re talking behind my back then you’re in a perfect position to kiss my a**!.", "Stupidity is not a crime so you are free to go.", ) @run_async @user_admin def insult(update, context): # Bot typing before send messages bot.sendChatAction(update.effective_chat.id, "typing") message = update.effective_message if message.reply_to_message: message.reply_to_message.reply_text(random.choice(SFW_STRINGS)) else: message.reply_text(random.choice(SFW_STRINGS)) INSULT_HANDLER = CommandHandler("insult", insult) dispatcher.add_handler(INSULT_HANDLER)
@run_async @user_admin def rhappy(update: Update, context: CallbackContext): message = update.effective_message rhappy = random.choice(reactionhappy) if message.reply_to_message: message.reply_to_message.reply_text(rhappy) else: message.reply_text(rhappy) @run_async @user_admin def rangry(update: Update, context: CallbackContext): message = update.effective_message rangry = random.choice(reactionangry) if message.reply_to_message: message.reply_to_message.reply_text(rangry) else: message.reply_text(rangry) REACT_HANDLER = CommandHandler("react", react) RHAPPY_HANDLER = CommandHandler("happy", rhappy) RANGRY_HANDLER = CommandHandler("amgery", rangry) dispatcher.add_handler(REACT_HANDLER) dispatcher.add_handler(RHAPPY_HANDLER) dispatcher.add_handler(RANGRY_HANDLER)
chat_name3 = dispatcher.bot.getChat(history.chat_id3).title except: chat_name3 = "" if chat_name1: btn1 = "/connect {} - {}".format(history.chat_id1, chat_name1) else: btn1 = "/connect - Connect to the chat" if chat_name2: btn2 = "/connect {} - {}".format(history.chat_id2, chat_name2) else: btn2 = "" if chat_name3: btn3 = "/connect {} - {}".format(history.chat_id3, chat_name3) else: btn3 = "" #TODO: Remove except garbage update.effective_message.reply_text("Keyboard Updated", reply_markup=ReplyKeyboardMarkup([[ KeyboardButton("/help - Bot Help"), KeyboardButton("/notes - Notes") ], [KeyboardButton(btn1) ], [KeyboardButton(btn2) ], [KeyboardButton(btn3)]])) KEYBOARD_HANDLER = CommandHandler(["keyboard"], keyboard) dispatcher.add_handler(KEYBOARD_HANDLER)