) 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) WELCOMEMUTE_HANDLER = CommandHandler( "welcomemute", welcomemute, pass_args=True, filters=Filters.group ) CLEAN_WELCOME = CommandHandler( "cleanwelcome", clean_welcome, pass_args=True, 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(BUTTON_VERIFY_HANDLER) dispatcher.add_handler(WELCOME_MUTE_HELP) __mod_name__ = "Greetings" __command_list__ = [
Locks can be used to restrict a group's users. eg: Locking urls will auto-delete all messages with urls which haven't been whitelisted, locking stickers will delete all \ stickers, etc. Locking bots will stop non-admins from adding bots to the chat. """ LOCKTYPES_HANDLER = DisableAbleCommandHandler("locktypes", locktypes) LOCK_HANDLER = CommandHandler("lock", lock, pass_args=True) UNLOCK_HANDLER = CommandHandler("unlock", unlock, pass_args=True) LOCKED_HANDLER = CommandHandler("locks", list_locks) LOCKABLE_HANDLER = MessageHandler(Filters.all & Filters.group, del_lockables) RESTRICTION_HANDLER = MessageHandler(Filters.all & Filters.group, rest_handler) dispatcher.add_handler(LOCK_HANDLER) dispatcher.add_handler(UNLOCK_HANDLER) dispatcher.add_handler(LOCKTYPES_HANDLER) dispatcher.add_handler(LOCKED_HANDLER) dispatcher.add_handler(LOCKABLE_HANDLER, PERM_GROUP) dispatcher.add_handler(RESTRICTION_HANDLER, REST_GROUP) __mod_name__ = "Locks" __handlers__ = [ LOCKTYPES_HANDLER, LOCK_HANDLER, UNLOCK_HANDLER, LOCKED_HANDLER, (LOCKABLE_HANDLER, PERM_GROUP), (RESTRICTION_HANDLER, REST_GROUP), ]
Note: You can appeal gbans or ask gbans at @JarvisSupportOT Jarvis also integrates @Spamwatch API into gbans to remove Spammers as much as possible from your chatroom! *What is SpamWatch?* SpamWatch maintains a large constantly updated ban-list of spambots, trolls, bitcoin spammers and unsavoury characters[.](https://telegra.ph/file/ac12a2c6b831dd005015b.jpg) Jarvis will constantly help banning spammers off from your group automatically So, you don't have to worry about spammers storming your group. """ GBAN_HANDLER = CommandHandler("gban", gban, pass_args=True) UNGBAN_HANDLER = CommandHandler("ungban", ungban, pass_args=True) GBAN_LIST = CommandHandler("gbanlist", gbanlist) GBAN_STATUS = CommandHandler("gbanstat", gbanstat, pass_args=True, filters=Filters.group) GBAN_ENFORCER = MessageHandler(Filters.all & Filters.group, enforce_gban) dispatcher.add_handler(GBAN_HANDLER) dispatcher.add_handler(UNGBAN_HANDLER) dispatcher.add_handler(GBAN_LIST) dispatcher.add_handler(GBAN_STATUS) __mod_name__ = "Global Bans" __handlers__ = [GBAN_HANDLER, UNGBAN_HANDLER, GBAN_LIST, GBAN_STATUS] if STRICT_GBAN: # enforce GBANS if this is set dispatcher.add_handler(GBAN_ENFORCER, GBAN_ENFORCE_GROUP) __handlers__.append((GBAN_ENFORCER, GBAN_ENFORCE_GROUP))
reply_text(random.choice(fun_strings.TABLE)) RUNS_HANDLER = DisableAbleCommandHandler("runs", runs) SLAP_HANDLER = DisableAbleCommandHandler("slap", slap, pass_args=True) ROLL_HANDLER = DisableAbleCommandHandler("roll", roll) TOSS_HANDLER = DisableAbleCommandHandler("toss", toss) SHRUG_HANDLER = DisableAbleCommandHandler("shrug", shrug) BLUETEXT_HANDLER = DisableAbleCommandHandler("bluetext", bluetext) RLG_HANDLER = DisableAbleCommandHandler("rlg", rlg) DECIDE_HANDLER = DisableAbleCommandHandler("decide", decide) TABLE_HANDLER = DisableAbleCommandHandler("table", table) #ABUSE_HANDLER = DisableAbleCommandHandler("abuse", abuse) dispatcher.add_handler(RUNS_HANDLER) dispatcher.add_handler(SLAP_HANDLER) dispatcher.add_handler(ROLL_HANDLER) dispatcher.add_handler(TOSS_HANDLER) dispatcher.add_handler(SHRUG_HANDLER) dispatcher.add_handler(BLUETEXT_HANDLER) dispatcher.add_handler(RLG_HANDLER) dispatcher.add_handler(DECIDE_HANDLER) dispatcher.add_handler(TABLE_HANDLER) #dispatcher.add_handler(ABUSE_HANDLER) __command_list__ = [ "runs", "slap", "roll", "toss",
__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)
"(「• ω •)「", "( ˘ ɜ˘) ♬♪♫", "( o˘◡˘o) ┌iii┐", "♨o(>_<)o♨", "( ・・)つ―{}@{}@{}-", "(*´з`)口゚。゚口(・∀・ )", "( *^^)o∀*∀o(^^* )", "-●●●-c(・・ )", "(ノ≧∀≦)ノ ‥…━━━★", "╰( ͡° ͜ʖ ͡° )つ──☆*:・゚", "(∩ᄑ_ᄑ)⊃━☆゚*・。*・:≡( ε:)", ] @run_async def react(bot: Bot, update: Update): message = update.effective_message react = random.choice(reactions) if message.reply_to_message: message.reply_to_message.reply_text(react) else: message.reply_text(react) REACT_HANDLER = DisableAbleCommandHandler("react", react) dispatcher.add_handler(REACT_HANDLER) __command_list__ = ["react"] __handlers__ = [REACT_HANDLER]
return f"\n<b>About user:</b>\n{me}\n<b>What others say:</b>\n{bio}\n" elif bio: return f"\n<b>What others say:</b>\n{bio}\n" elif me: return f"\n<b>About user:</b>\n{me}\n" else: return "\n" __help__ = """ - /setbio <text>: while replying, will save another user's bio - /bio: will get your or another user's bio. This cannot be set by yourself. - /setme <text>: will set your info - /me: will get your or another user's info """ SET_BIO_HANDLER = DisableAbleCommandHandler("setbio", set_about_bio) GET_BIO_HANDLER = DisableAbleCommandHandler("bio", about_bio, pass_args=True) SET_ABOUT_HANDLER = DisableAbleCommandHandler("setme", set_about_me) GET_ABOUT_HANDLER = DisableAbleCommandHandler("me", about_me, pass_args=True) dispatcher.add_handler(SET_BIO_HANDLER) dispatcher.add_handler(GET_BIO_HANDLER) dispatcher.add_handler(SET_ABOUT_HANDLER) dispatcher.add_handler(GET_ABOUT_HANDLER) __mod_name__ = "Bios" __command_list__ = ["setbio", "bio", "setme", "me"] __handlers__ = [SET_BIO_HANDLER, GET_BIO_HANDLER, SET_ABOUT_HANDLER, GET_ABOUT_HANDLER]
• *Note:* • Value must be filled for tban and tmute!! It can be: `5m` = 5 minutes `6h` = 6 hours `3d` = 3 days `1w` = 1 week """ __mod_name__ = "Anti-Flood" FLOOD_BAN_HANDLER = MessageHandler( Filters.all & ~Filters.status_update & Filters.group, check_flood) SET_FLOOD_HANDLER = CommandHandler("setflood", set_flood, filters=Filters.group) SET_FLOOD_MODE_HANDLER = CommandHandler( "setfloodmode", set_flood_mode, pass_args=True) #, filters=Filters.group) FLOOD_QUERY_HANDLER = CallbackQueryHandler(flood_button, pattern=r"unmute_flooder") FLOOD_HANDLER = CommandHandler("flood", flood, filters=Filters.group) dispatcher.add_handler(FLOOD_BAN_HANDLER, FLOOD_GROUP) dispatcher.add_handler(FLOOD_QUERY_HANDLER) dispatcher.add_handler(SET_FLOOD_HANDLER) dispatcher.add_handler(SET_FLOOD_MODE_HANDLER) dispatcher.add_handler(FLOOD_HANDLER) __handlers__ = [(FLOOD_BAN_HANDLER, FLOOD_GROUP), SET_FLOOD_HANDLER, FLOOD_HANDLER, SET_FLOOD_MODE_HANDLER]
import requests from telegram import Update, Bot, ParseMode from telegram.ext import run_async from jarvis import dispatcher from jarvis.modules.disable import DisableAbleCommandHandler @run_async def ud(bot: Bot, update: Update): message = update.effective_message text = message.text[len("/ud "):] results = requests.get( f"http://api.urbandictionary.com/v0/define?term={text}").json() try: reply_text = f'*{text}*\n\n{results["list"][0]["definition"]}\n\n_{results["list"][0]["example"]}_' except: reply_text = "No results found." message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN) UD_HANDLER = DisableAbleCommandHandler(["ud", "urban"], ud) dispatcher.add_handler(UD_HANDLER) __command_list__ = ["ud", "urban"] __handlers__ = [UD_HANDLER]
is_blacklisted = sql.is_user_blacklisted(user_id) text = "Blacklisted: <b>{}</b>" if user_id in [777000, 1087968824]: return "" if user_id == dispatcher.bot.id: return "" if int(user_id) in DRAGONS + TIGERS + WOLVES: return "" if is_blacklisted: text = text.format("Yes") reason = sql.get_reason(user_id) if reason: text += f"\nReason: <code>{reason}</code>" else: text = text.format("No") return text BL_HANDLER = CommandHandler("ignore", bl_user) UNBL_HANDLER = CommandHandler("notice", unbl_user) BLUSERS_HANDLER = CommandHandler("ignoredlist", bl_users) dispatcher.add_handler(BL_HANDLER) dispatcher.add_handler(UNBL_HANDLER) dispatcher.add_handler(BLUSERS_HANDLER) __mod_name__ = "Blacklisting Users" __handlers__ = [BL_HANDLER, UNBL_HANDLER, BLUSERS_HANDLER]
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 = DisableAbleCommandHandler("reverse", reverse, pass_args=True, admin_ok=True) dispatcher.add_handler(REVERSE_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]
query = " ".join(args) song = "" if not query: msg.reply_text("You haven't specified which song to look for!") return else: song = Song.find_song(query) if song: if song.lyrics: reply = song.format() else: reply = "Couldn't find any lyrics for that song!" else: reply = "Song not found!" if len(reply) > 4090: with open("lyrics.txt", "w") as f: f.write(f"{reply}\n\n\nOwO UwU OmO") with open("lyrics.txt", "rb") as f: msg.reply_document( document=f, caption= "Message length exceeded max limit! Sending as a text file.", ) else: msg.reply_text(reply) LYRICS_HANDLER = DisableAbleCommandHandler("lyrics", lyrics, pass_args=True) dispatcher.add_handler(LYRICS_HANDLER)
f"- {event.from_id} ({event.chat_id}) : {event.text} | {datetime.datetime.now()}" ) support_chat = os.getenv('SUPPORT_CHAT') @run_async @dev_plus def logs(update: Update, context: CallbackContext): chat_username = update.effective_chat.username if not chat_username: return if chat_username != support_chat: return user = update.effective_user with open('log.txt', 'rb') as f: context.bot.send_document(document=f, filename=f.name, chat_id=user.id) LOG_HANDLER = CommandHandler('logs', logs) dispatcher.add_handler(LOG_HANDLER) DEBUG_HANDLER = CommandHandler("debug", debug) dispatcher.add_handler(DEBUG_HANDLER) __mod_name__ = "Debug" __command_list__ = ["debug"] __handlers__ = [DEBUG_HANDLER]
__help__ = """ *Admin only:* - /logchannel: get log channel info - /setlog: set the log channel. - /unsetlog: unset the log channel. Setting the log channel is done by: - adding the bot to the desired channel (as an admin!) - sending /setlog in the channel - forwarding the /setlog to the group """ __mod_name__ = "Log Channels" 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 def gloggable(func): return func
try: query = message.text.strip().split(" ", 1)[1] except: message.reply_text("Provide a country name/abbreviation/timezone to find.") return send_message = message.reply_text( f"Finding timezone info for <b>{query}</b>", parse_mode=ParseMode.HTML ) query_timezone = query.lower() if len(query_timezone) == 2: result = generate_time(query_timezone, ["countryCode"]) else: result = generate_time(query_timezone, ["zoneName", "countryName"]) if not result: send_message.edit_text( f"Timezone info not available for <b>{query}</b>", parse_mode=ParseMode.HTML ) return send_message.edit_text(result, parse_mode=ParseMode.HTML) TIME_HANDLER = DisableAbleCommandHandler("time", gettime) dispatcher.add_handler(TIME_HANDLER) __command_list__ = ["time"] __handlers__ = [TIME_HANDLER]
pass_args=True) REMOVE_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("unignorecleanbluetext", remove_bluetext_ignore, pass_args=True) ADD_CLEAN_BLUE_TEXT_GLOBAL_HANDLER = CommandHandler( "ignoreglobalcleanbluetext", add_bluetext_ignore_global, pass_args=True) REMOVE_CLEAN_BLUE_TEXT_GLOBAL_HANDLER = CommandHandler( "unignoreglobalcleanbluetext", remove_bluetext_ignore_global, pass_args=True) LIST_CLEAN_BLUE_TEXT_HANDLER = CommandHandler("listcleanbluetext", 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__ = "Cleaner" __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,
ID_HANDLER = DisableAbleCommandHandler("id", get_id, pass_args=True) GIFID_HANDLER = DisableAbleCommandHandler("gifid", gifid) INFO_HANDLER = DisableAbleCommandHandler("info", info, pass_args=True) ECHO_HANDLER = DisableAbleCommandHandler("echo", echo, filters=Filters.group) MD_HELP_HANDLER = CommandHandler("markdownhelp", markdown_help, filters=Filters.private) STATS_HANDLER = CommandHandler("stats", stats) PING_HANDLER = DisableAbleCommandHandler("ping", ping) RAM_HANDLER = CommandHandler( "ram", ram, ) dispatcher.add_handler(ID_HANDLER) dispatcher.add_handler(GIFID_HANDLER) dispatcher.add_handler(INFO_HANDLER) dispatcher.add_handler(ECHO_HANDLER) dispatcher.add_handler(MD_HELP_HANDLER) dispatcher.add_handler(STATS_HANDLER) dispatcher.add_handler(PING_HANDLER) dispatcher.add_handler(RAM_HANDLER) __mod_name__ = "Misc" __command_list__ = ["id", "info", "echo", "ping"] __handlers__ = [ ID_HANDLER, GIFID_HANDLER, INFO_HANDLER, ECHO_HANDLER,
) elif e.message == "Internal Server Error: created sticker set not found (500)": msg.reply_text( "Sticker pack successfully created! Get it [here](t.me/addstickers/%s)" % packname, parse_mode=ParseMode.MARKDOWN, ) return if success: msg.reply_text( "Sticker pack successfully created! Get it [here](t.me/addstickers/%s)" % packname, parse_mode=ParseMode.MARKDOWN, ) else: msg.reply_text("Failed to create sticker pack.") STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid) GETSTICKER_HANDLER = DisableAbleCommandHandler("getsticker", getsticker) STEAL_HANDLER = DisableAbleCommandHandler( "steal", steal, pass_args=True, admin_ok=False ) STICKERS_HANDLER = DisableAbleCommandHandler("stickers", cb_sticker) dispatcher.add_handler(STICKERID_HANDLER) dispatcher.add_handler(GETSTICKER_HANDLER) dispatcher.add_handler(STEAL_HANDLER) dispatcher.add_handler(STICKERS_HANDLER)
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))}`" __help__ = """ - /rules: get the rules for this chat. *Admin only:* - /setrules <your rules here>: set the rules for this chat. - /clearrules: clear the rules for this chat. """ __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)
if int(userc_id) == int(user_id): return res = "{} is afk.\nReason: <code>{}</code>".format( html.escape(fst_name), html.escape(user.reason)) update.effective_message.reply_text(res, parse_mode="html") __help__ = """ • `/afk <reason>`*:* mark yourself as AFK(away from keyboard). • `brb <reason>`*:* same as the afk command - but not a command. When marked as AFK, any mentions will be replied to with a message to say you're not available! """ AFK_HANDLER = DisableAbleCommandHandler("afk", afk) AFK_REGEX_HANDLER = DisableAbleMessageHandler(Filters.regex(r"^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) __mod_name__ = "AFK" __command_list__ = ["afk"] __handlers__ = [(AFK_HANDLER, AFK_GROUP), (AFK_REGEX_HANDLER, AFK_GROUP), (NO_AFK_HANDLER, AFK_GROUP), (AFK_REPLY_HANDLER, AFK_REPLY_GROUP)]
cmd = update.message.text.split(" ", maxsplit=1) if len(cmd) == 1: sendMessage("No command provided!", bot, update) return LOGGER.info(cmd) output = shell(cmd[1]) if output[1].decode(): LOGGER.error(f"Shell: {output[1].decode()}") if len(output[0].decode()) > 4000: with open("shell.txt", "w") as f: f.write(f"Output\n-----------\n{output[0].decode()}\n") if output[1]: f.write(f"STDError\n-----------\n{output[1].decode()}\n") with open("shell.txt", "rb") as f: bot.send_document( document=f, filename=f.name, reply_to_message_id=update.message.message_id, chat_id=update.message.chat_id, ) else: if output[1].decode(): sendMessage(f"<code>{output[1].decode()}</code>", bot, update) return else: sendMessage(f"<code>{output[0].decode()}</code>", bot, update) shell_handler = CommandHandler(("sh", "shell"), shellExecute) dispatcher.add_handler(shell_handler)
"凵", "リ", "山", "乂", "丫", "乙", ] @run_async def weebify(bot: Bot, update: Update, args: List[str]): string = " ".join(args).lower() for normiecharacter in string: if normiecharacter in normiefont: weebycharacter = weebyfont[normiefont.index(normiecharacter)] string = string.replace(normiecharacter, weebycharacter) message = update.effective_message if message.reply_to_message: message.reply_to_message.reply_text(string) else: message.reply_text(string) WEEBIFY_HANDLER = DisableAbleCommandHandler("weebify", weebify, pass_args=True) dispatcher.add_handler(WEEBIFY_HANDLER) __command_list__ = ["weebify"] __handlers__ = [WEEBIFY_HANDLER]
• `/punchme`*:* punchs the user who issued the command *Admins only:* • `/ban <userhandle>`*:* bans a user. (via handle, or reply) • `/tban <userhandle> x(m/h/d)`*:* bans a user for `x` time. (via handle, or reply). `m` = `minutes`, `h` = `hours`, `d` = `days`. • `/unban <userhandle>`*:* unbans a user. (via handle, or reply) • `/punch <userhandle>`*:* Punches a user out of the group, (via handle, or reply) """ BAN_HANDLER = CommandHandler("ban", ban) TEMPBAN_HANDLER = CommandHandler(["tban"], temp_ban) PUNCH_HANDLER = CommandHandler("punch", punch) UNBAN_HANDLER = CommandHandler("unban", unban) ROAR_HANDLER = CommandHandler("roar", selfunban) PUNCHME_HANDLER = DisableAbleCommandHandler("punchme", punchme, filters=Filters.group) dispatcher.add_handler(BAN_HANDLER) dispatcher.add_handler(TEMPBAN_HANDLER) dispatcher.add_handler(PUNCH_HANDLER) dispatcher.add_handler(UNBAN_HANDLER) dispatcher.add_handler(ROAR_HANDLER) dispatcher.add_handler(PUNCHME_HANDLER) __mod_name__ = "Bans" __handlers__ = [ BAN_HANDLER, TEMPBAN_HANDLER, PUNCH_HANDLER, UNBAN_HANDLER, ROAR_HANDLER, PUNCHME_HANDLER ]
) stdout, stderr = process.communicate() reply = "" stderr = stderr.decode() stdout = stdout.decode() if stdout: reply += f"*Stdout*\n`{stdout}`\n" LOGGER.info(f"Shell - {cmd} - {stdout}") if stderr: reply += f"*Stderr*\n`{stderr}`\n" LOGGER.error(f"Shell - {cmd} - {stderr}") if len(reply) > 3000: with open("shell_output.txt", "w") as file: file.write(reply) with open("shell_output.txt", "rb") as doc: context.bot.send_document( document=doc, filename=doc.name, reply_to_message_id=message.message_id, chat_id=message.chat_id, ) else: message.reply_text(reply, parse_mode=ParseMode.MARKDOWN) SHELL_HANDLER = CommandHandler(["sh"], shell) dispatcher.add_handler(SHELL_HANDLER) __mod_name__ = "Shell" __command_list__ = ["sh"] __handlers__ = [SHELL_HANDLER]
• `/settitle`*:* sets a custom title for an admin that the bot promoted """ ADMINLIST_HANDLER = DisableAbleCommandHandler(["adminlist", "admins"], adminlist) PIN_HANDLER = CommandHandler("pin", pin, filters=Filters.group) UNPIN_HANDLER = CommandHandler("unpin", unpin, filters=Filters.group) INVITE_HANDLER = DisableAbleCommandHandler("invitelink", invite) PROMOTE_HANDLER = DisableAbleCommandHandler("promote", promote) DEMOTE_HANDLER = DisableAbleCommandHandler("demote", demote) SET_TITLE_HANDLER = CommandHandler("settitle", set_title) dispatcher.add_handler(ADMINLIST_HANDLER) dispatcher.add_handler(PIN_HANDLER) dispatcher.add_handler(UNPIN_HANDLER) dispatcher.add_handler(INVITE_HANDLER) dispatcher.add_handler(PROMOTE_HANDLER) dispatcher.add_handler(DEMOTE_HANDLER) dispatcher.add_handler(SET_TITLE_HANDLER) __mod_name__ = "Admin" __command_list__ = ["adminlist", "admins", "invitelink", "promote", "demote"] __handlers__ = [ ADMINLIST_HANDLER, PIN_HANDLER, UNPIN_HANDLER, INVITE_HANDLER, PROMOTE_HANDLER, DEMOTE_HANDLER, SET_TITLE_HANDLER ]
- /unblacklist <triggers>: Remove triggers from the blacklist. Same newline logic applies here, so you can remove \ multiple triggers at once. - /rmblacklist <triggers>: Same as above. """ BLACKLIST_HANDLER = DisableAbleCommandHandler("blacklist", blacklist, pass_args=True, admin_ok=True) ADD_BLACKLIST_HANDLER = CommandHandler("addblacklist", add_blacklist) UNBLACKLIST_HANDLER = CommandHandler(["unblacklist", "rmblacklist"], unblacklist) BLACKLIST_DEL_HANDLER = MessageHandler( (Filters.text | Filters.command | Filters.sticker | Filters.photo) & Filters.group, del_blacklist, edited_updates=True, ) dispatcher.add_handler(BLACKLIST_HANDLER) dispatcher.add_handler(ADD_BLACKLIST_HANDLER) dispatcher.add_handler(UNBLACKLIST_HANDLER) dispatcher.add_handler(BLACKLIST_DEL_HANDLER, group=BLACKLIST_GROUP) __mod_name__ = "Word Blacklists" __handlers__ = [ BLACKLIST_HANDLER, ADD_BLACKLIST_HANDLER, UNBLACKLIST_HANDLER, (BLACKLIST_DEL_HANDLER, BLACKLIST_GROUP), ]
def __chat_settings__(chat_id, user_id): return build_curr_disabled(chat_id) DISABLE_HANDLER = CommandHandler("disable", disable, pass_args=True) DISABLE_MODULE_HANDLER = CommandHandler("disablemodule", disable_module, pass_args=True) ENABLE_HANDLER = CommandHandler("enable", enable, pass_args=True) ENABLE_MODULE_HANDLER = CommandHandler("enablemodule", enable_module, pass_args=True) COMMANDS_HANDLER = CommandHandler(["cmds", "disabled"], commands) TOGGLE_HANDLER = CommandHandler("listcmds", list_cmds) dispatcher.add_handler(DISABLE_HANDLER) dispatcher.add_handler(DISABLE_MODULE_HANDLER) dispatcher.add_handler(ENABLE_HANDLER) dispatcher.add_handler(ENABLE_MODULE_HANDLER) dispatcher.add_handler(COMMANDS_HANDLER) dispatcher.add_handler(TOGGLE_HANDLER) __help__ = """ - /cmds: check the current status of disabled commands *Admin only:* - /enable <cmd name>: enable that command - /disable <cmd name>: disable that command - /enablemodule <module name>: enable all commands in that module - /disablemodule <module name>: disable all commands in that module - /listcmds: list all possible toggleable commands
__help__ = """ - /filters: list all active filters in this chat. *Admin only:* - /filter <keyword> <reply message>: add a filter to this chat. The bot will now reply that message whenever 'keyword'\ is mentioned. If you reply to a sticker with a keyword, the bot will reply with that sticker. NOTE: all filter \ keywords are in lowercase. If you want your keyword to be a sentence, use quotes. eg: /filter "hey there" How you \ doin? - /stop <filter keyword>: stop that filter. """ FILTER_HANDLER = CommandHandler("filter", filters) STOP_HANDLER = CommandHandler("stop", stop_filter) LIST_HANDLER = DisableAbleCommandHandler("filters", list_handlers, admin_ok=True) CUST_FILTER_HANDLER = MessageHandler(CustomFilters.has_text, 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) __mod_name__ = "Filters" __handlers__ = [ FILTER_HANDLER, STOP_HANDLER, LIST_HANDLER, (CUST_FILTER_HANDLER, HANDLER_GROUP), ]
) return # TODO: some of that link logic # NOTE: consider default permissions stuff? msg.reply_text("Backup fully imported. Welcome back! :D") @run_async @user_admin def export_data(bot: Bot, update: Update): msg = update.effective_message msg.reply_text("Doesn't work yet.") __help__ = """ *Admin only:* - /import: reply to a group butler backup file to import as much as possible, making the transfer super simple! Note \ that files/photos can't be imported due to telegram restrictions. - /export: !!! This isn't a command yet, but should be coming soon! """ IMPORT_HANDLER = CommandHandler("import", import_data) EXPORT_HANDLER = CommandHandler("export", export_data) dispatcher.add_handler(IMPORT_HANDLER) dispatcher.add_handler(EXPORT_HANDLER) __mod_name__ = "Backups" __handlers__ = [IMPORT_HANDLER, EXPORT_HANDLER]