from telegram import Update, Bot from telegram.ext import CallbackContext, CommandHandler, run_async from natalie_bot.modules.disable import DisableAbleCommandHandler from natalie_bot import dispatcher, CMD_PREFIX from requests import get @run_async def ud(update: Update, context: CallbackContext): 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__ = """ Urban Dictionary is made for fun; Urban Dictionary is a crowdsourced online dictionary for slang words and phrases. \ Search for any definition of words. {} sends you results of top most voted definition from Urban Dictionary. - /ud <keyword>: search for dictionary. """.format(dispatcher.bot.first_name) __mod_name__ = "Urban dictionary" ud_handle = DisableAbleCommandHandler(CMD_PREFIX, "ud", ud) dispatcher.add_handler(ud_handle)
so using different lines will allow you to add multiple domains. - /unwhitelist <domains>: Remove domains from the whitelist. Same newline logic applies here, \ so you can remove multiple domains at once. - /rmwhitelist <domains>: Same as above. 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 & Whitelists" LOCKTYPES_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "locktypes", locktypes) LOCK_HANDLER = CustomCommandHandler(CMD_PREFIX, "lock", lock, filters=Filters.group) UNLOCK_HANDLER = CustomCommandHandler(CMD_PREFIX, "unlock", unlock, filters=Filters.group) LOCKED_HANDLER = CustomCommandHandler(CMD_PREFIX, "locks", list_locks, filters=Filters.group) dispatcher.add_handler(LOCK_HANDLER) dispatcher.add_handler(UNLOCK_HANDLER)
fst_name, user.reason) message.reply_text(res) def __gdpr__(user_id): sql.rm_afk(user_id) __help__ = """ When marked as AFK, any mentions will be replied to with a message to say you're not available! - /afk <reason>: mark yourself as AFK. - brb <reason>: same as the afk command - but not a command. """ __mod_name__ = "AFK" AFK_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "afk", afk) AFK_REGEX_HANDLER = MessageHandler(Filters.regex("(?i)brb"), afk, friendly="afk") NO_AFK_HANDLER = MessageHandler(Filters.all & Filters.group, no_longer_afk) AFK_REPLY_HANDLER = MessageHandler( Filters.entity(MessageEntity.MENTION) | Filters.entity(MessageEntity.TEXT_MENTION), 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)
for domain in all_whitelisted: filter_list += " • <code>{}</code>\n".format(html.escape(domain)) split_text = split_message(filter_list) for text in split_text: if text == BASE_WHITELIST_STRING: msg.reply_text("There are no whitelisted domains here!") return msg.reply_text(text.format(chat_name), parse_mode=ParseMode.HTML) ADD_URL_WHITELIST_HANDLER = CustomCommandHandler(CMD_PREFIX, "addwhitelist", add_whitelist_url, filters=Filters.group) RM_WHITELIST_URL_HANDLER = CustomCommandHandler(CMD_PREFIX, ["unwhitelist", "rmwhitelist"], rm_whitelist_url, filters=Filters.group) GET_WHITELISTED_URLS = DisableAbleCommandHandler(CMD_PREFIX, "whitelist", get_whitelisted_urls, filters=Filters.group, admin_ok=True) __mod_name__ = "Domain whitelists" dispatcher.add_handler(ADD_URL_WHITELIST_HANDLER) dispatcher.add_handler(RM_WHITELIST_URL_HANDLER) dispatcher.add_handler(GET_WHITELISTED_URLS)
"ban", ban, filters=Filters.group) TEMPBAN_HANDLER = CustomCommandHandler(CMD_PREFIX, ["tban", "tempban"], temp_ban, filters=Filters.group) KICK_HANDLER = CustomCommandHandler(CMD_PREFIX, "kick", kick, filters=Filters.group) UNBAN_HANDLER = CustomCommandHandler(CMD_PREFIX, "unban", unban, filters=Filters.group) KICKME_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "kickme", kickme, filters=Filters.group) BANME_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "banme", banme, filters=Filters.group) SBAN_HANDLER = CustomCommandHandler(CMD_PREFIX, "sban", sban, 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)
An example of how to save a note would be via: `/save data This is some data!` Now, anyone using "/get notedata", or "#notedata" will be replied to with "This is some data!". If you want to save an image, gif, or sticker, or any other data, do the following: `/save notename` while replying to a sticker or whatever data you'd like. Now, the note at "#notename" contains a sticker which will be sent as a reply. Tip: to retrieve a note without the formatting, use /get <notename> noformat This will retrieve the note and send it without formatting it; getting you the raw markdown, allowing you to make easy edits. """ __mod_name__ = "Notes" GET_HANDLER = CustomCommandHandler(CMD_PREFIX, "get", cmd_get) HASH_GET_HANDLER = MessageHandler(Filters.regex(r"^#[^\s]+"), hash_get) SAVE_HANDLER = CustomCommandHandler(CMD_PREFIX, "save", save) DELETE_HANDLER = CustomCommandHandler(CMD_PREFIX, "clear", clear) LIST_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, ["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)
__help__ = """ Every chat works with different rules; this module will help make those rules clearer! - /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. - /chatrules <yes/no/on/off>: should the rules be sent to chat. Default: no. """ __mod_name__ = "Rules" GET_RULES_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "rules", get_rules, filters=Filters.group) SET_RULES_MODE = CustomCommandHandler(CMD_PREFIX, "chatrules", chat_rules, filters=Filters.group) SET_RULES_HANDLER = CustomCommandHandler(CMD_PREFIX, "setrules", set_rules, filters=Filters.group) RESET_RULES_HANDLER = CustomCommandHandler(CMD_PREFIX, "clearrules", clear_rules, filters=Filters.group) dispatcher.add_handler(GET_RULES_HANDLER)
- /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 - /setnick <text>: will set your nickname. - /nick: will get your or another user's nickname. An example of setting a bio for yourself: `/setme I work for Telegram`; Bio is set to yourself. An example of writing someone else' bio: Reply to user's message: `/setbio He is such cool person`. *Notice:* Do not use /setbio against yourself! """ __mod_name__ = "Bios and Abouts" SET_BIO_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "setbio", set_about_bio) GET_BIO_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "bio", about_bio) SET_ABOUT_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "setme", set_about_me) GET_ABOUT_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "me", about_me) dispatcher.add_handler(SET_BIO_HANDLER) dispatcher.add_handler(GET_BIO_HANDLER) dispatcher.add_handler(SET_ABOUT_HANDLER) dispatcher.add_handler(GET_ABOUT_HANDLER)
tidy and simplified. Here is an example of using buttons: You can create a button using `[Name of button text](buttonurl://example.com)`. If you wish to add more than 1 buttons simply do the following: `[Button 1](buttonurl://example.com)` `[Button 2](buttonurl://github.com:same)` `[Button 3](buttonurl://google.com)` The `:same` end of the link merges 2 buttons on same line as 1 button, resulting in 3 button to be separated \ from same line. """.format(dispatcher.bot.first_name, dispatcher.bot.first_name) __mod_name__ = "Filters" FILTER_HANDLER = CustomCommandHandler(CMD_PREFIX, "filter", filters) STOP_HANDLER = CustomCommandHandler(CMD_PREFIX, "stop", stop_filter) LIST_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "filters", list_handlers, admin_ok=True) CUST_FILTER_HANDLER = MessageHandler(CustomFilters.has_text, reply_filter, Filters.update.edited_message) dispatcher.add_handler(FILTER_HANDLER) dispatcher.add_handler(STOP_HANDLER) dispatcher.add_handler(LIST_HANDLER) dispatcher.add_handler(CUST_FILTER_HANDLER, HANDLER_GROUP)
"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.") __help__ = """ Kanging or fetching ID of stickers are made easy! With this stickers command you simply can grab \ raw png file, creating new pack or fetch ID of sticker. - /stickerid: reply to a sticker to me to tell you its file ID. - /getsticker: reply to a sticker to me to upload its raw PNG file. - /kang: reply to a sticker to add it to your pack. """ __mod_name__ = "Stickers" STICKERID_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "stickerid", stickerid) GETSTICKER_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "getsticker", getsticker) KANG_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "kang", kang, admin_ok=True) dispatcher.add_handler(STICKERID_HANDLER) dispatcher.add_handler(GETSTICKER_HANDLER) dispatcher.add_handler(KANG_HANDLER)
- /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. Tip: To copy list of saved blacklist simply use `/blacklist copy`, {} will send non-bulleted list of blacklist. """.format(dispatcher.bot.first_name) BLACKLIST_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "blacklist", blacklist, filters=Filters.group, admin_ok=True) ADD_BLACKLIST_HANDLER = CustomCommandHandler(CMD_PREFIX, "addblacklist", add_blacklist, filters=Filters.group) UNBLACKLIST_HANDLER = CustomCommandHandler(CMD_PREFIX, ["unblacklist", "rmblacklist"], unblacklist, filters=Filters.group) BLACKLIST_DEL_HANDLER = MessageHandler( (Filters.text | Filters.command | Filters.sticker | Filters.photo) & Filters.group, del_blacklist) dispatcher.add_handler(BLACKLIST_HANDLER)
__mod_name__ = "Warnings" WARN_HANDLER = CustomCommandHandler(CMD_PREFIX, "warn", warn_user, filters=Filters.group) RESET_WARN_HANDLER = CustomCommandHandler(CMD_PREFIX, ["resetwarn", "resetwarns"], reset_warns, filters=Filters.group) REMOVE_WARNS_HANDLER = CustomCommandHandler(CMD_PREFIX, ["rmwarn", "unwarn"], remove_warns, filters=Filters.group) CALLBACK_QUERY_HANDLER = CallbackQueryHandler(button, pattern=r"rm_warn") MYWARNS_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "warns", warns, filters=Filters.group) ADD_WARN_HANDLER = CustomCommandHandler(CMD_PREFIX, "addwarn", add_warn_filter, filters=Filters.group) RM_WARN_HANDLER = CustomCommandHandler(CMD_PREFIX, ["nowarn", "stopwarn"], remove_warn_filter, filters=Filters.group) LIST_WARN_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, ["warnlist", "warnfilters"], list_warn_filters, filters=Filters.group, admin_ok=True) WARN_FILTER_HANDLER = MessageHandler(CustomFilters.has_text & Filters.group, reply_filter)
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 args- try Artist - Title!", failed=True) __help__ = """ Do you simply want to find the lyrics of your favourite songs? This command grabs you chunk of \ paragraphs for lyrics. - /lyrics <keyword> Find your favourite songs' lyrics An example of using lyrics: `/lyrics Ariana Grande - God is a woman`; this sends you the lyrics. `/lyrics Artist - Song title`. """ __mod_name__ = "Lyrics" LYRICS_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "lyrics", lyrics) dispatcher.add_handler(LYRICS_HANDLER)
- /promote: promotes the user replied to - /demote: demotes the user replied to An example of set a link: `/setlink https://t.me/joinchat/HwiIk1RADK5gRMr9FBdOrwtae` An example of promoting someone to admins: `/promote @username`; this promotes a user to admins. """.format(dispatcher.bot.first_name) __mod_name__ = "Admin" PIN_HANDLER = CustomCommandHandler(CMD_PREFIX, "pin", pin, filters=Filters.group) UNPIN_HANDLER = CustomCommandHandler(CMD_PREFIX, "unpin", unpin, filters=Filters.group) LINK_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, "link", link_public) SET_LINK_HANDLER = CustomCommandHandler(CMD_PREFIX, "setlink", set_link, filters=Filters.group) LINKMODE_HANDLER = CustomCommandHandler(CMD_PREFIX, "linkmode", linkmode, filters=Filters.group) RESET_LINK_HANDLER = CustomCommandHandler(CMD_PREFIX, "clearlink", clear_link, filters=Filters.group) HASH_LINK_HANDLER = MessageHandler(Filters.regex(r"#link"), link_public) INVITE_HANDLER = CustomCommandHandler(CMD_PREFIX, "invitelink", invite, filters=Filters.group) PERMAPIN_HANDLER = CustomCommandHandler(CMD_PREFIX, ["permapin", "perma"], permapin, filters=Filters.group) PROMOTE_HANDLER = CustomCommandHandler(CMD_PREFIX, "promote", promote, filters=Filters.group) DEMOTE_HANDLER = CustomCommandHandler(CMD_PREFIX, "demote", demote, filters=Filters.group) ADMINLIST_HANDLER = DisableAbleCommandHandler(CMD_PREFIX, ["adminlist", "staff"], adminlist, filters=Filters.group) dispatcher.add_handler(PIN_HANDLER) dispatcher.add_handler(UNPIN_HANDLER) dispatcher.add_handler(INVITE_HANDLER) dispatcher.add_handler(LINK_HANDLER) dispatcher.add_handler(SET_LINK_HANDLER)