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) DEL_JOINED = CommandHandler("rmjoin", del_joined, pass_args=True, filters=Filters.group) WELCOME_HELP = CommandHandler("welcomehelp", welcome_help) 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(DEL_JOINED) dispatcher.add_handler(WELCOME_HELP)
changes = json.loads(res.text).get('LightGingerTheTextResult') curr_string = "" prev_end = 0 for change in changes: start = change.get('From') end = change.get('To') + 1 suggestions = change.get('Suggestions') 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__ = """ - /t: while replying to a message, will reply with a grammar corrected version """ __mod_name__ = "Translator" TRANSLATE_HANDLER = CommandHandler('t', translate) dispatcher.add_handler(TRANSLATE_HANDLER)
while song[1].endswith(" "): song[1] = song[1][:-1] while song[0].endswith(" "): song[0] = song[0][:-1] try: lyrics = "\n".join( PyLyrics.getLyrics(song[0], song[1]).split("\n")[:20]) except ValueError as e: return update.effective_message.reply_text("Song %s not found :(" % song[1], failed=True) else: lyricstext = LYRICSINFO % (song[0].replace( " ", "_"), song[1].replace(" ", "_")) return update.effective_message.reply_text(lyrics + lyricstext, parse_mode="MARKDOWN") else: return update.effective_message.reply_text( "Invalid syntax- try Artist - Title!", failed=True) __help__ = """ - /lyrics <keyword> Find your favourite songs' lyrics """ __mod_name__ = "Lyrics" LYRICS_HANDLER = DisableAbleCommandHandler("lyrics", lyrics, pass_args=True) dispatcher.add_handler(LYRICS_HANDLER)
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) TEMP_NOMEDIA_HANDLER = CommandHandler(["trestrict", "temprestrict"], temp_nomedia, pass_args=True, filters=Filters.group) NOMEDIA_HANDLER = CommandHandler(["restrict", "nomedia"], nomedia, pass_args=True, filters=Filters.group) MEDIA_HANDLER = CommandHandler("unrestrict", media, pass_args=True, filters=Filters.group) dispatcher.add_handler(MUTE_HANDLER) dispatcher.add_handler(UNMUTE_HANDLER) dispatcher.add_handler(TEMPMUTE_HANDLER) dispatcher.add_handler(TEMP_NOMEDIA_HANDLER) dispatcher.add_handler(NOMEDIA_HANDLER) dispatcher.add_handler(MEDIA_HANDLER)
from telegram import ChatAction import html import urllib.request import re import json from typing import Optional, List import time import urllib from urllib.request import urlopen, urlretrieve from urllib.parse import quote_plus, urlencode import requests from telegram import Message, Chat, Update, Bot, MessageEntity from telegram import ParseMode from telegram.ext import CommandHandler, run_async, Filters from IHbot import dispatcher from IHbot.__main__ import STATS, USER_INFO from IHbot.modules.disable import DisableAbleCommandHandler def dicks(bot: Bot, update: Update): nsfw = requests.get('http://api.odicks.ru/noise/1').json()[0]["preview"] final = "http://media.odicks.ru/{}".format(nsfw) update.message.reply_photo(final) DICKS_HANDLER = DisableAbleCommandHandler("dicks", dicks) dispatcher.add_handler(DICKS_HANDLER)
num_chats) def __stats__(): return "{} users, across {} chats".format(sql.num_users(), sql.num_chats()) def __gdpr__(user_id): sql.del_user(user_id) def __migrate__(old_chat_id, new_chat_id): sql.migrate_chat(old_chat_id, new_chat_id) __help__ = "" # no help string __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=CustomFilters.sudo_filter) dispatcher.add_handler(USER_HANDLER, USERS_GROUP) dispatcher.add_handler(BROADCAST_HANDLER) dispatcher.add_handler(CHATLIST_HANDLER)
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("Whadya want to delete?") return "" __help__ = """ *Admin only:* - /del: deletes the message you replied to - /purge: deletes all messages between this and the replied to message. - /purge <integer X>: deletes the replied message, and X messages following it. """ __mod_name__ = "Purges" 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)
"(─‿‿─)", "ƪ(˘⌣˘)Ʃ", "(;一_一)", "(¬_¬)", "( ⚆ _ ⚆ )", "(ʘᗩʘ\')", "☜(⌒▽⌒)☞", "。◕‿◕。", "¯(°_O)/¯", "(ʘ‿ʘ)", "ლ,ᔑ•ﺪ͟͠•ᔐ.ლ", "(´・Ω・)", "ಠ~ಠ", "(° ͡ ͜ ͡ʖ ͡ °)", "┬─┬ノ( º _ ºノ)", "(´・Ω・)っ由", "ಠ_ಥ", "Ƹ̵̡Ӝ̵̨Ʒ", "(>ლ)", "ಠ‿↼", "ʘ‿ʘ", "(ღ˘⌣˘ღ)", "ಠOಠ", "ರ_ರ", "(▰˘◡˘▰)", "◔̯◔", "◔ ⌣ ◔", "(✿´‿`)", "¬_¬", "ب_ب", "。゜(`Д´)゜。", "(Ó Ì_Í)=ÓÒ=(Ì_Í Ò)", "°Д°", "( ゚ヮ゚)", "┬─┬ ︵ /(.□. )", "٩◔̯◔۶", "≧☉_☉≦", "☼.☼", "^̮^", "(>人<)", "〆(・∀・@)", "(~_^)", "^̮^", "^̮^", ">_>", "(^̮^)", "(/) (°,,°) (/)", "^̮^", "^̮^", "=U", "(・.◤)" ] @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) __help__ = """ - Reply to a text with /react and the bot will send some reactions """ __mod_name__ = "Reactions" REACT_HANDLER = DisableAbleCommandHandler("react", react) dispatcher.add_handler(REACT_HANDLER)
- /notes or /saved: list all saved notes in this chat If you would like to retrieve the contents of a note without any formatting, use `/get <notename> noformat`. This can \ be useful when updating a current note. *Admin only:* - /save <notename> <notedata>: saves notedata as a note with name notename A button can be added to a note by using standard markdown link syntax - the link should just be prepended with a \ `buttonurl:` section, as such: `[somelink](buttonurl:example.com)`. Check /markdownhelp for more info. - /save <notename>: save the replied message as a note with name notename - /clear <notename>: clear note with this name """ __mod_name__ = "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 = DisableAbleCommandHandler(["notes", "saved"], list_notes, admin_ok=True) 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)
from telegram import Message, Update, Bot, User from telegram.ext import Filters, MessageHandler, run_async from requests import get from IHbot.modules.disable import DisableAbleCommandHandler from IHbot import dispatcher base_url = 'https://translate.yandex.net/api/v1.5/tr.json/translate' api_key = 'trnsl.1.1.20180603T023816Z.763b39e3388b46d6.aa9abf45baceb438c96bb1593ce58199cc66c4f1' @run_async def translate(bot: Bot, update: Update): message = update.effective_message text = message.reply_to_message.text translation = get(f'{base_url}?key={api_key}&text={text}&lang=en').json() reply_text = f"Language: {translation['lang']}\nText: {translation['text'][0]}" message.reply_to_message.reply_text(reply_text) translate_handler = DisableAbleCommandHandler("tl", translate) dispatcher.add_handler(translate_handler)
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!" __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
from IHbot import dispatcher, LOGGER from IHbot.modules.disable import DisableAbleCommandHandler from py_translator import 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 exc: msg.reply_text(str(exc)) __help__ = """- /tr (language code) as reply to a long message. """ __mod_name__ = "Translator" dispatcher.add_handler( DisableAbleCommandHandler("tr", do_translate, pass_args=True))
from telegram import Update, Bot from telegram.ext import run_async from IHbot.modules.disable import DisableAbleCommandHandler from IHbot import dispatcher from requests import get @run_async def ud(bot: Bot, update: Update): message = update.effective_message text = message.text[len('/ud '):] results = get( f'http://api.urbandictionary.com/v0/define?term={text}').json() reply_text = f'Word: {text}\nDefinition: {results["list"][0]["definition"]}' message.reply_text(reply_text) __help__ = """ - /ud:{word} Type the word or expression you want to search use. like /ud telegram Word: Telegram Definition: A once-popular system of telecommunications, in which the sender would contact the telegram service and speak their [message] over the [phone]. The person taking the message would then send it, via a teletype machine, to a telegram office near the receiver's [address]. The message would then be hand-delivered to the addressee. From 1851 until it discontinued the service in 2006, Western Union was the best-known telegram service in the world. """ __mod_name__ = "Urban dictionary" ud_handle = DisableAbleCommandHandler("ud", ud) dispatcher.add_handler(ud_handle)
NEW_FED_HANDLER = CommandHandler("newfed", new_fed, pass_args=True) DEL_FED_HANDLER = CommandHandler("delfed", del_fed, pass_args=True) JOIN_FED_HANDLER = CommandHandler("joinfed", join_fed, pass_args=True) LEAVE_FED_HANDLER = CommandHandler("leavefed", leave_fed, pass_args=True) PROMOTE_FED_HANDLER = CommandHandler("fpromote", user_join_fed, pass_args=True) DEMOTE_FED_HANDLER = CommandHandler("fdemote", user_demote_fed, pass_args=True) INFO_FED_HANDLER = CommandHandler("fedinfo", fed_info, pass_args=True) BAN_FED_HANDLER = CommandHandler("fban", fed_ban, pass_args=True) UN_BAN_FED_HANDLER = CommandHandler("unfban", unfban, pass_args=True) FED_BROADCAST_HANDLER = CommandHandler("fbroadcast", broadcast, pass_args=True) FED_SET_RULES_HANDLER = CommandHandler("setfrules", set_frules, pass_args=True) FED_GET_RULES_HANDLER = CommandHandler("frules", get_frules, pass_args=True) FED_CHAT_HANDLER = CommandHandler("chatfed", fed_chat, pass_args=True) FED_ADMIN_HANDLER = CommandHandler("fedadmins", fed_admin, pass_args=True) dispatcher.add_handler(NEW_FED_HANDLER) dispatcher.add_handler(DEL_FED_HANDLER) dispatcher.add_handler(JOIN_FED_HANDLER) dispatcher.add_handler(LEAVE_FED_HANDLER) dispatcher.add_handler(PROMOTE_FED_HANDLER) dispatcher.add_handler(DEMOTE_FED_HANDLER) dispatcher.add_handler(INFO_FED_HANDLER) dispatcher.add_handler(BAN_FED_HANDLER) dispatcher.add_handler(UN_BAN_FED_HANDLER) #dispatcher.add_handler(FED_BROADCAST_HANDLER) dispatcher.add_handler(FED_SET_RULES_HANDLER) dispatcher.add_handler(FED_GET_RULES_HANDLER) dispatcher.add_handler(FED_CHAT_HANDLER) dispatcher.add_handler(FED_ADMIN_HANDLER)
"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 def insult(bot: Bot, update: Update): bot.sendChatAction(update.effective_chat.id, "typing") # Bot typing before send messages 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)) __help__ = """ - Reply to a text with /insult for insults. """ __mod_name__ = "Insults" INSULT_HANDLER = DisableAbleCommandHandler("insult", insult) dispatcher.add_handler(INSULT_HANDLER)
elif me: return "<b>About user:</b>\n{me}""".format(me=me, bio=bio) else: return "" def __gdpr__(user_id): sql.clear_user_info(user_id) sql.clear_user_bio(user_id) __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 """ __mod_name__ = "Bios and Abouts" 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)
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)
def __chat_settings__(chat_id, user_id): limit = sql.get_flood_limit(chat_id) if limit == 0: return "*Not* currently enforcing flood control." else: return "Antiflood is set to `{}` messages.".format(limit) __help__ = """ - /flood: Get the current flood control setting *Admin only:* - /setflood <int/'no'/'off'>: enables or disables flood control """ __mod_name__ = "AntiFlood" FLOOD_BAN_HANDLER = MessageHandler( Filters.all & ~Filters.status_update & Filters.group, check_flood) SET_FLOOD_HANDLER = CommandHandler("setflood", set_flood, pass_args=True, filters=Filters.group) FLOOD_HANDLER = CommandHandler("flood", flood, filters=Filters.group) dispatcher.add_handler(FLOOD_BAN_HANDLER, FLOOD_GROUP) dispatcher.add_handler(SET_FLOOD_HANDLER) dispatcher.add_handler(FLOOD_HANDLER)
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_") 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) # add antiflood processor Dispatcher.process_update = process_update 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) updater.idle()
if int(user_id) == OWNER_ID: message.reply_text( "Wow! Someone's so noob that he want to gkick my owner! *Grabs Potato Chips*" ) return chats = get_all_chats() message.reply_text("Globally kicking user @{}".format(user_chat.username)) for chat in chats: try: bot.unban_chat_member(chat.chat_id, user_id) # Unban_member = kick (and not ban) except BadRequest as excp: if excp.message in GKICK_ERRORS: pass else: message.reply_text( "User cannot be Globally kicked because: {}".format( excp.message)) return except TelegramError: pass GKICK_HANDLER = CommandHandler("gkick", gkick, pass_args=True, filters=CustomFilters.sudo_filter | CustomFilters.support_filter) dispatcher.add_handler(GKICK_HANDLER)
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 __help__ = """ - /stickerid: Gives the ID of the sticker you've replied to. - /getsticker: Uploads the .png of the sticker you've replied to. - /kang: Reply to a sticker to add it to your pack or makes a new one if it doesn't exist. """ __mod_name__ = "Stickers" STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid) GETSTICKER_HANDLER = DisableAbleCommandHandler("getsticker", getsticker) KANG_HANDLER = DisableAbleCommandHandler("kang", kang, pass_args=True, admin_ok=True) dispatcher.add_handler(STICKERID_HANDLER) dispatcher.add_handler(GETSTICKER_HANDLER) dispatcher.add_handler(KANG_HANDLER)
return # empty string errors -_- if len(text) >= telegram.MAX_MESSAGE_LENGTH: update.effective_message.reply_text( "The result of the sed command was too long for \ telegram!") elif text: update.effective_message.reply_to_message.reply_text(text) __help__ = """ - s/<text1>/<text2>(/<flag>): Reply to a message with this to perform a sed operation on that message, replacing all \ occurrences of 'text1' with 'text2'. Flags are optional, and currently include 'i' for ignore case, 'g' for global, \ or nothing. Delimiters include `/`, `_`, `|`, and `:`. Text grouping is supported. The resulting message cannot be \ larger than {}. *Reminder:* Sed uses some special characters to make matching easier, such as these: `+*.?\\` If you want to use these characters, make sure you escape them! eg: \\?. """.format(telegram.MAX_MESSAGE_LENGTH) __mod_name__ = "Sed/Regex" SED_HANDLER = DisableAbleRegexHandler(r's([{}]).*?\1.*'.format( "".join(DELIMITERS)), sed, friendly="sed") dispatcher.add_handler(SED_HANDLER)
query.message.reply_text( text, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("English 🇺🇸", callback_data="set_lang_en") ]] + [[ InlineKeyboardButton("Russian 🇷🇺", callback_data="set_lang_ru"), InlineKeyboardButton("Ukrainian 🇺🇦", callback_data="set_lang_ua") ]] + [[ InlineKeyboardButton("Spanish 🇪🇸", callback_data="set_lang_es"), InlineKeyboardButton("Turkish 🇹🇷", callback_data="set_lang_tr") ]] + [[ InlineKeyboardButton("Indonesian 🇮🇩", callback_data="set_lang_id"), InlineKeyboardButton("Italian 🇮🇹", callback_data="set_lang_it") ]] + [[InlineKeyboardButton("⬅️ Back", callback_data="bot_start")]])) print(lang_match) query.message.delete() bot.answer_callback_query(query.id) LOCALE_HANDLER = CommandHandler(["set_locale", "locale", "lang", "setlang"], locale, pass_args=True) locale_handler = CallbackQueryHandler(locale_button, pattern="chng_lang") set_locale_handler = CallbackQueryHandler(locale_button, pattern=r"set_lang_") dispatcher.add_handler(LOCALE_HANDLER) dispatcher.add_handler(locale_handler) dispatcher.add_handler(set_locale_handler)
valid, reason = sql.check_afk_status(user_id) if valid: if not reason: res = "{} is AFK!".format(fst_name) else: res = "{} is AFK! says its because of:\n{}".format(fst_name, reason) message.reply_text(res) def __gdpr__(user_id): sql.rm_afk(user_id) __help__ = """ - /afk <reason>: mark yourself as AFK. - 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! """ __mod_name__ = "AFK" 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)
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 = DisableAbleCommandHandler("kickme", kickme, filters=Filters.group) BANME_HANDLER = DisableAbleCommandHandler("banme", banme, filters=Filters.group) SBAN_HANDLER = CommandHandler("sban", sban, pass_args=True, filters=Filters.group) 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)
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. """ __mod_name__ = "Locks" LOCKTYPES_HANDLER = DisableAbleCommandHandler("locktypes", locktypes) LOCK_HANDLER = CommandHandler("lock", lock, pass_args=True, filters=Filters.group) UNLOCK_HANDLER = CommandHandler("unlock", unlock, pass_args=True, filters=Filters.group) LOCKED_HANDLER = CommandHandler("locks", list_locks, filters=Filters.group) dispatcher.add_handler(LOCK_HANDLER) dispatcher.add_handler(UNLOCK_HANDLER) dispatcher.add_handler(LOCKTYPES_HANDLER) dispatcher.add_handler(LOCKED_HANDLER) dispatcher.add_handler( MessageHandler(Filters.all & Filters.group, del_lockables), PERM_GROUP) dispatcher.add_handler( MessageHandler(Filters.all & Filters.group, rest_handler), REST_GROUP)
__mod_name__ = "Word Blacklists" __help__ = """ Blacklists are used to stop certain triggers from being said in a group. Any time the trigger is mentioned, \ the message will immediately be deleted. A good combo is sometimes to pair this up with warn filters! *NOTE:* blacklists do not affect group admins. - /blacklist: View the current blacklisted words. *Admin only:* - /addblacklist <triggers>: Add a trigger to the blacklist. Each line is considered one trigger, so using different \ lines will allow you to add multiple triggers. - /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, filters=Filters.group, pass_args=True, admin_ok=True) ADD_BLACKLIST_HANDLER = CommandHandler("addblacklist", add_blacklist, filters=Filters.group) UNBLACKLIST_HANDLER = CommandHandler(["unblacklist", "rmblacklist"], unblacklist, filters=Filters.group) 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)
__help__ = """ *Admin only:* - /gmutestat <on/off/yes/no>: Will disable the effect of global mutes on your group, or return your current settings. Gmutes, also known as global mutes, are used by the bot owners to mute spammers across all groups. This helps protect \ you and your groups by removing spam flooders as quickly as possible. They can be disabled for you group by calling \ /gmutestat """ __mod_name__ = "Global Mutes" GMUTE_HANDLER = CommandHandler("gmute", gmute, pass_args=True, filters=CustomFilters.sudo_filter | CustomFilters.support_filter) UNGMUTE_HANDLER = CommandHandler("ungmute", ungmute, pass_args=True, filters=CustomFilters.sudo_filter | CustomFilters.support_filter) GMUTE_LIST = CommandHandler("gmutelist", gmutelist, filters=CustomFilters.sudo_filter | CustomFilters.support_filter) GMUTE_STATUS = CommandHandler("gmutestat", gmutestat, pass_args=True, filters=Filters.group) GMUTE_ENFORCER = MessageHandler(Filters.all & Filters.group, enforce_gmute) dispatcher.add_handler(GMUTE_HANDLER) dispatcher.add_handler(UNGMUTE_HANDLER) dispatcher.add_handler(GMUTE_LIST) dispatcher.add_handler(GMUTE_STATUS) if STRICT_GMUTE: dispatcher.add_handler(GMUTE_ENFORCER, GMUTE_ENFORCE_GROUP)
INFO_HANDLER = DisableAbleCommandHandler("info", info, pass_args=True) PING_HANDLER = DisableAbleCommandHandler("ping", ping) ECHO_HANDLER = CommandHandler("echo", echo, filters=CustomFilters.sudo_filter) MD_HELP_HANDLER = CommandHandler("markdownhelp", markdown_help, filters=Filters.private) STATS_HANDLER = CommandHandler("stats", stats, filters=CustomFilters.sudo_filter) GDPR_HANDLER = CommandHandler("gdpr", gdpr, filters=Filters.private) GPS_HANDLER = DisableAbleCommandHandler("gps", gps, pass_args=True) SHRUG_HANDLER = DisableAbleCommandHandler("shrug", shrug) dispatcher.add_handler(ID_HANDLER) dispatcher.add_handler(PING_HANDLER) dispatcher.add_handler(IP_HANDLER) dispatcher.add_handler(TIME_HANDLER) dispatcher.add_handler(RUNS_HANDLER) dispatcher.add_handler(SLAP_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(SAFEMODE_HANDLER) dispatcher.add_handler(GDPR_HANDLER) dispatcher.add_handler(GPS_HANDLER) dispatcher.add_handler(SHRUG_HANDLER)
add_warn_filter, filters=Filters.group) RM_WARN_HANDLER = CommandHandler(["nowarn", "stopwarn"], remove_warn_filter, filters=Filters.group) LIST_WARN_HANDLER = DisableAbleCommandHandler(["warnlist", "warnfilters"], list_warn_filters, filters=Filters.group, admin_ok=True) 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)