import requests from Yone import dispatcher from Yone.Plugins.disable import DisableAbleCommandHandler from telegram import ParseMode, Update from telegram.ext import CallbackContext, run_async def ud(update: Update, context: CallbackContext): message = update.effective_message text = message.text[len("/ud ") :] results = requests.get( f"https://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"], ud, run_async=True) dispatcher.add_handler(UD_HANDLER) __command_list__ = ["ud"] __handlers__ = [UD_HANDLER]
‣ `/shrug`*:* get shrug XD ‣ `/table`*:* get flip/unflip :v ‣ `/decide`*:* Randomly answers yes/no/maybe ‣ `/toss`*:* Tosses A coin ‣ `/bluetext`*:* check urself :V ‣ `/roll`*:* Roll a dice ‣ `/rlg`*:* Join ears,nose,mouth and create an emo ;-; ‣ `/shout <keyword>`*:* write anything you want to give loud shout ‣ `/weebify <text>`*:* returns a weebified text ‣ `/sanitize`*:* always use this before /pat or any contact ‣ `/pat`*:* pats a user, or get patted ‣ `/8ball`*:* predicts using 8ball method ‣ `/punchme or kickme`*:* punches the user who issued the command from the group """ SANITIZE_HANDLER = DisableAbleCommandHandler("sanitize", sanitize, run_async=True) RUNS_HANDLER = DisableAbleCommandHandler("runs", runs, run_async=True) SLAP_HANDLER = DisableAbleCommandHandler("slap", slap, run_async=True) PAT_HANDLER = DisableAbleCommandHandler("pat", pat, run_async=True) ROLL_HANDLER = DisableAbleCommandHandler("roll", roll, run_async=True) TOSS_HANDLER = DisableAbleCommandHandler("toss", toss, run_async=True) SHRUG_HANDLER = DisableAbleCommandHandler("shrug", shrug, run_async=True) BLUETEXT_HANDLER = DisableAbleCommandHandler("bluetext", bluetext, run_async=True) RLG_HANDLER = DisableAbleCommandHandler("rlg", rlg, run_async=True) DECIDE_HANDLER = DisableAbleCommandHandler("decide", decide, run_async=True) EIGHTBALL_HANDLER = DisableAbleCommandHandler("8ball", eightball, run_async=True) TABLE_HANDLER = DisableAbleCommandHandler("table", table, run_async=True) SHOUT_HANDLER = DisableAbleCommandHandler("shout", shout, run_async=True) WEEBIFY_HANDLER = DisableAbleCommandHandler("weebify", weebify, run_async=True) dispatcher.add_handler(WEEBIFY_HANDLER)
‣ `/unpinall`*:* unpins all the currently pinned messages in group ‣ `/invitelink`*:* gets invitelink ‣ `/promote`*:* promotes the user replied to ‣ `/fullpromote`*:* promotes the user with all rights ‣ `/demote`*:* demotes the user replied to ‣ `/title <title here>`*:* sets a custom title for an admin that the bot promoted ‣ `/admincache`*:* force refresh the admins list ‣ `/setgpic`*:* set new profile pic of the group (reply image) ‣ `/delgpic`*:* del the currently profile pic of the group ‣ `/setgtitle <New Name for Group>`*:* change the title of group ‣ `/setdescription <New Description for Group>`*:* change the Description of group ‣ `/setsticker`*:* set the stricker pack for group """ ADMINLIST_HANDLER = DisableAbleCommandHandler("admins", adminlist, run_async=True) PIN_HANDLER = CommandHandler("pin", pin, filters=Filters.chat_type.groups, run_async=True) UNPIN_HANDLER = CommandHandler("unpin", unpin, filters=Filters.chat_type.groups, run_async=True) UNPINALL_HANDLER = CommandHandler("unpinall", unpinall, filters=Filters.chat_type.groups, run_async=True) UNPINALL_BTN_HANDLER = CallbackQueryHandler(unpinallbtn,
query.answer("You need to be admin to do this.") __help__ = """ Sometimes, you might trust a user not to send unwanted content. Maybe not enough to make them admin, but you might be ok with locks, blacklists, and antiflood not applying to them. That's what approvals are for - approve of trustworthy users to allow them to send *Admin commands:* ‣ `/approval`*:* Check a user's approval status in this chat. ‣ `/approve`*:* Approve of a user. Locks, blacklists, and antiflood won't apply to them anymore. ‣ `/unapprove`*:* Unapprove of a user. They will now be subject to locks, blacklists, and antiflood again. ‣ `/approved`*:* List all approved users. ‣ `/unapproveall`*:* Unapprove *ALL* users in a chat. This cannot be undone. """ APPROVE = DisableAbleCommandHandler("approve", approve, run_async=True) DISAPPROVE = DisableAbleCommandHandler("unapprove", disapprove, run_async=True) APPROVED = DisableAbleCommandHandler("approved", approved, run_async=True) APPROVAL = DisableAbleCommandHandler("approval", approval, run_async=True) UNAPPROVEALL = DisableAbleCommandHandler("unapproveall", unapproveall, run_async=True) UNAPPROVEALL_BTN = CallbackQueryHandler(unapproveall_btn, pattern=r"unapproveall_.*", run_async=True) dispatcher.add_handler(APPROVE) dispatcher.add_handler(DISAPPROVE) dispatcher.add_handler(APPROVED) dispatcher.add_handler(APPROVAL) dispatcher.add_handler(UNAPPROVEALL)
‣ `/removeallfilters`*:* Remove all chat filters at once. *Note*: Filters also support markdown formatters like: {first}, {last} etc.. and buttons. Check ‣ `/markdownhelp` to know more! """ __mod_name__ = "Filters" FILTER_HANDLER = CommandHandler("filter", filters, run_async=True) STOP_HANDLER = CommandHandler("stop", stop_filter, run_async=True) RMALLFILTER_HANDLER = CommandHandler( "removeallfilters", rmall_filters, filters=Filters.chat_type.groups, run_async=True ) RMALLFILTER_CALLBACK = CallbackQueryHandler(rmall_callback, pattern=r"filters_.*", run_async=True) LIST_HANDLER = DisableAbleCommandHandler("filters", list_handlers, admin_ok=True, run_async=True) CUST_FILTER_HANDLER = MessageHandler( CustomFilters.has_text & ~Filters.update.edited_message, reply_filter, run_async=True ) dispatcher.add_handler(FILTER_HANDLER) dispatcher.add_handler(STOP_HANDLER) dispatcher.add_handler(LIST_HANDLER) dispatcher.add_handler(CUST_FILTER_HANDLER, HANDLER_GROUP) dispatcher.add_handler(RMALLFILTER_HANDLER) dispatcher.add_handler(RMALLFILTER_CALLBACK) __handlers__ = [ FILTER_HANDLER, STOP_HANDLER, LIST_HANDLER,
if not user.reason: res = "{} is afk.\n\nLast seen {} ago.".format( fst_name, time, ) update.effective_message.reply_text(res) else: res = "{} is afk.\nReason: <code>{}</code>\n\nLast seen {} ago.".format( html.escape(fst_name), html.escape(user.reason), time, ) update.effective_message.reply_text(res, parse_mode="html") AFK_HANDLER = DisableAbleCommandHandler("afk", afk, run_async=True) AFK_REGEX_HANDLER = DisableAbleMessageHandler( Filters.regex(r"^(?i)brb(.*)$"), afk, friendly="afk", ) NO_AFK_HANDLER = MessageHandler(Filters.all & Filters.chat_type.group, no_longer_afk, run_async=True) AFK_REPLY_HANDLER = MessageHandler(Filters.all & Filters.chat_type.group, reply_afk, run_async=True) dispatcher.add_handler(AFK_HANDLER, AFK_GROUP) dispatcher.add_handler(AFK_REGEX_HANDLER, AFK_GROUP) dispatcher.add_handler(NO_AFK_HANDLER, AFK_GROUP)
) except PageError as e: update.message.reply_text( f"<code>{e}</code>", parse_mode=ParseMode.HTML, ) if res: result = f"<b>{search}</b>\n\n" result += f"<i>{res}</i>\n" result += f"""<a href="https://en.wikipedia.org/wiki/{search.replace(" ", "%20")}">Read more...</a>""" if len(result) > 4000: with open("result.txt", "w") as f: f.write(f"{result}\n\nUwU OwO OmO UmU") with open("result.txt", "rb") as f: context.bot.send_document( document=f, filename=f.name, reply_to_message_id=update.message.message_id, chat_id=update.effective_chat.id, parse_mode=ParseMode.HTML, ) else: update.message.reply_text( result, parse_mode=ParseMode.HTML, disable_web_page_preview=True, ) WIKI_HANDLER = DisableAbleCommandHandler("wiki", wiki, run_async=True) dispatcher.add_handler(WIKI_HANDLER)
Stickers made easy with stickers module! ‣ `/stickers`: Find stickers for given term on combot sticker catalogue ‣ `/addsticker` or `/kang` or /steal`: Reply to a sticker to add it to your pack. ‣ `/delsticker`: Reply to your anime exist sticker to your pack to delete it. ‣ `/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. ‣ `/addfsticker` or `/afs <custom name>`: Reply to a sticker to add it into your favorite pack list. ‣ `/myfsticker` or `/mfs`: Get list of your favorite packs. ‣ `/removefsticke`r or `/rfs <custom name>`: Reply to a sticker to remove it into your favorite pack list. *Example:* `/addfsticker` my cool pack` """ __mod_name__ = "Stickers" KANG_HANDLER = DisableAbleCommandHandler(["addsticker", "kang", "steal"], addsticker, pass_args=True, run_async=True) DEL_HANDLER = DisableAbleCommandHandler("delsticker", delsticker, run_async=True) STICKERID_HANDLER = DisableAbleCommandHandler("stickerid", stickerid, run_async=True) ADD_FSTICKER_HANDLER = DisableAbleCommandHandler(["addfsticker", "afs"], add_fvrtsticker, pass_args=True, run_async=True) REMOVE_FSTICKER_HANDLER = DisableAbleCommandHandler(["removefsticker", "rfs"], remove_fvrtsticker, pass_args=True, run_async=True)
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:] update.effective_message.reply_text(curr_string) else: update.effective_message.reply_text( "Reply to some message to get grammar corrected text!") dispatcher.add_handler( DisableAbleCommandHandler("tts", gtts, pass_args=True, run_async=True)) dispatcher.add_handler( DisableAbleCommandHandler("splcheck", spellcheck, run_async=True)) __help__ = """ ‣ `/tts`: Convert Text in Bot Audio *Usage*: reply to text or write message with command. Example `/tts hello` ‣ `/slpcheck`: Check the right spelling of text """ __mod_name__ = "Speech Text" __command_list__ = ["tts"]
def __chat_settings__(chat_id, user_id): blacklisted = sql.num_blacklist_chat_filters(chat_id) return "There are {} blacklisted words.".format(blacklisted) def __stats__(): return "• {} blacklist triggers, across {} chats.".format( sql.num_blacklist_filters(), sql.num_blacklist_filter_chats()) __mod_name__ = "BlackList" BLACKLIST_HANDLER = DisableAbleCommandHandler("blacklist", blacklist, pass_args=True, admin_ok=True, run_async=True) ADD_BLACKLIST_HANDLER = CommandHandler("addblacklist", add_blacklist, run_async=True) UNBLACKLIST_HANDLER = CommandHandler("unblacklist", unblacklist, run_async=True) BLACKLISTMODE_HANDLER = CommandHandler("blacklistmode", blacklist_mode, pass_args=True, run_async=True) BLACKLIST_DEL_HANDLER = MessageHandler( (Filters.text | Filters.command | Filters.sticker | Filters.photo) & Filters.chat_type.groups,
if "//" in args: source = args.split("//")[0] dest = args.split("//")[1] else: source = trans.detect(to_translate) dest = args except IndexError: source = trans.detect(to_translate) dest = "en" translation = trans(to_translate, sourcelang=source, targetlang=dest) reply = f"<b>Translated from {source} to {dest}</b>:\n" \ f"<code>{translation.text}</code>" message.reply_text(reply, parse_mode=ParseMode.HTML) __help__ = """ You can translate messages on telegram in a simple way ‣ `/tr [List of Language Codes]`:- as reply to a long message. ‣ `/tl [List of Language Codes]`:- as reply to a long message. """ __mod_name__ = "Translator" TRANSLATE_HANDLER = DisableAbleCommandHandler(["tr", "tl"], totranslate, run_async=True) dispatcher.add_handler(TRANSLATE_HANDLER) __command_list__ = ["tr", "tl"] __handlers__ = [TRANSLATE_HANDLER]
""" __mod_name__ = "Notes" GET_HANDLER = CommandHandler("get", cmd_get, run_async=True) HASH_GET_HANDLER = MessageHandler(Filters.regex(r"^#[^\s]+"), hash_get, run_async=True) SLASH_GET_HANDLER = MessageHandler(Filters.regex(r"^/\d+$"), slash_get, run_async=True) SAVE_HANDLER = CommandHandler("save", save, run_async=True) DELETE_HANDLER = CommandHandler("clear", clear, run_async=True) LIST_HANDLER = DisableAbleCommandHandler(["notes", "saved"], list_notes, admin_ok=True, run_async=True) CLEARALL = DisableAbleCommandHandler("removeallnotes", clearall, run_async=True) CLEARALL_BTN = CallbackQueryHandler(clearall_btn, pattern=r"notes_.*", run_async=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) dispatcher.add_handler(SLASH_GET_HANDLER)
result = (f"**Horoscope for `{x}`**:\n" f"**Mood :** `{mood}`\n" f"**Lucky Time :** `{lt}`\n" f"**Lucky Color :** `{col}`\n" f"**Lucky Number :** `{ln}`\n" f"**Compatibility :** `{com}`\n" f"**Description :** `{desc}`\n") msg.edit_text(result, parse_mode=ParseMode.MARKDOWN) except Exception as e: msg.edit_text( f"Sorry i haven't found anything!\nmaybe you have given a wrong sign name please check help of horoscope.\nError - {e}" ) __help__ = """ ‣ `/hs <sign>`: Usage: it will show horoscope of daily of your sign. List of all signs - aries, taurus, gemini, cancer, leo, virgo, libra, scorpio, sagittarius, capricorn, aquarius and pisces. ‣ `/fakeid`: Usage: it will fake identity for you. """ __mod_name__ = "Identity" FAKER_HANDLER = DisableAbleCommandHandler("fakeid", fakeid, run_async=True) ASTRO_HANDLER = DisableAbleCommandHandler("hs", astro, run_async=True) dispatcher.add_handler(FAKER_HANDLER) dispatcher.add_handler(ASTRO_HANDLER)
pencil_sketch = cv2.divide(gray_image, inverted_blurred, scale=120.0) filename = 'my_sketch.png' cv2.imwrite(filename, pencil_sketch) ofile = open(filename, "rb") bot.send_photo(chat_id, ofile) if os.path.exists("getSketchfile.png"): os.remove("getSketchfile.png") if os.path.exists(filename): os.remove(filename) else: update.effective_message.reply_text( "Please reply to an image to make a sketch.", ) except Exception as e: message.reply_text(f'Error Report @Yone_Support, {e}') __help__ = """ ‣ `/sktech `*:* Create your image sktech by replying picture """ __mod_name__ = "Image" SKETCH_HANDLER = DisableAbleCommandHandler("sketch", sketch, run_async=True) dispatcher.add_handler(SKETCH_HANDLER)
name = result['name'] company = result['company'] bio = result['bio'] created_at = result['created_at'] avatar_url = result['avatar_url'] blog = result['blog'] location = result['location'] repositories = result['public_repos'] followers = result['followers'] following = result['following'] caption = f"""**Info Of {name}** **Username:** `{username}` **Bio:** `{bio}` **Profile Link:** [Here]({url}) **Company:** `{company}` **Created On:** `{created_at}` **Repositories:** `{repositories}` **Blog:** `{blog}` **Location:** `{location}` **Followers:** `{followers}` **Following:** `{following}`""" except Exception as e: print(str(e)) pass message.reply_photo(photo=avatar_url, caption=caption, parse_mode=ParseMode.MARKDOWN) GIT_HANDLER = DisableAbleCommandHandler("github", github, run_async=True) dispatcher.add_handler(GIT_HANDLER)
__mod_name__ = "Warnings" WARN_HANDLER = CommandHandler(["warn", "dwarn"], warn_user, filters=Filters.chat_type.groups, run_async=True) RESET_WARN_HANDLER = CommandHandler(["resetwarn", "resetwarns"], reset_warns, filters=Filters.chat_type.groups, run_async=True) CALLBACK_QUERY_HANDLER = CallbackQueryHandler(button, pattern=r"rm_warn", run_async=True) MYWARNS_HANDLER = DisableAbleCommandHandler("warns", warns, filters=Filters.chat_type.groups, run_async=True) ADD_WARN_HANDLER = CommandHandler("addwarn", add_warn_filter, filters=Filters.chat_type.groups, run_async=True) RM_WARN_HANDLER = CommandHandler(["nowarn", "stopwarn"], remove_warn_filter, filters=Filters.chat_type.groups, run_async=True) LIST_WARN_HANDLER = DisableAbleCommandHandler(["warnlist", "warnfilters"], list_warn_filters, filters=Filters.chat_type.groups, admin_ok=True, run_async=True) WARN_FILTER_HANDLER = MessageHandler(
def __user_info__(user_id): bio = html.escape(sql.get_user_bio(user_id) or "") me = html.escape(sql.get_user_me_info(user_id) or "") result = "" if me: result += f"┣|• <b>About user:</b>\n{me}\n" if bio: result += f"┣|• <b>What others say:</b>\n{bio}\n" result = result.strip("\n") return result SET_BIO_HANDLER = DisableAbleCommandHandler("setbio", set_about_bio, run_async=True) GET_BIO_HANDLER = DisableAbleCommandHandler("bio", about_bio, run_async=True) STATS_HANDLER = CommandHandler("stats", stats, run_async=True) ID_HANDLER = DisableAbleCommandHandler("id", get_id, run_async=True) GIFID_HANDLER = DisableAbleCommandHandler("gifid", gifid, run_async=True) INFO_HANDLER = DisableAbleCommandHandler(("info", "book"), info, run_async=True) GINFO_HANDLER = DisableAbleCommandHandler("ginfo", group_info, run_async=True) SET_ABOUT_HANDLER = DisableAbleCommandHandler("setme", set_about_me, run_async=True) GET_ABOUT_HANDLER = DisableAbleCommandHandler("me", about_me, run_async=True) dispatcher.add_handler(STATS_HANDLER) dispatcher.add_handler(ID_HANDLER) dispatcher.add_handler(GIFID_HANDLER)
replymsg = "SpeedTest Results:" if query.data == "speedtest_image": speedtest_image = speed.results.share() update.effective_message.reply_photo(photo=speedtest_image, caption=replymsg) msg.delete() elif query.data == "speedtest_text": result = speed.results.dict() replymsg += f"\nDownload: `{convert(result['download'])}Mb/s`\nUpload: `{convert(result['upload'])}Mb/s`\nPing: `{result['ping']}`" update.effective_message.edit_text(replymsg, parse_mode=ParseMode.MARKDOWN) else: query.answer( "You are required to join Heroes Association to use this command.") SPEED_TEST_HANDLER = DisableAbleCommandHandler("speedtest", speedtestxyz, run_async=True) SPEED_TEST_CALLBACKHANDLER = CallbackQueryHandler(speedtestxyz_callback, pattern="speedtest_.*", run_async=True) dispatcher.add_handler(SPEED_TEST_HANDLER) dispatcher.add_handler(SPEED_TEST_CALLBACKHANDLER) __mod_name__ = "SpeedTest" __command_list__ = ["speedtest"] __handlers__ = [SPEED_TEST_HANDLER, SPEED_TEST_CALLBACKHANDLER]
‣ `/punch <userhandle>`*:* Punches a user out of the group, (via handle, or reply) *Admins only:* ‣ `/mute <userhandle>`*:* silences a user. Can also be used as a reply, muting the replied to user. ‣ `/tmute <userhandle> x(m/h/d)`*:* mutes a user for x time. (via handle, or reply). `m` = `minutes`, `h` = `hours`, `d` = `days`. ‣ `/unmute <userhandle>`*:* unmutes a user. Can also be used as a reply, muting the replied to user. """ BAN_HANDLER = CommandHandler(["ban", "sban"], ban, run_async=True) CALLBACK_QUERY_HANDLER = CallbackQueryHandler(button, pattern=r"un_ban", run_async=True) TEMPBAN_HANDLER = CommandHandler(["tban"], temp_ban, run_async=True) PUNCH_HANDLER = CommandHandler(["punch", "kick"], punch, run_async=True) UNBAN_HANDLER = CommandHandler("unban", unban, run_async=True) ROAR_HANDLER = CommandHandler("roar", selfunban, run_async=True) PUNCHME_HANDLER = DisableAbleCommandHandler("punchme", punchme, filters=Filters.chat_type.groups, run_async=True) dispatcher.add_handler(BAN_HANDLER) dispatcher.add_handler(CALLBACK_QUERY_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__ = "Ban" __handlers__ = [ BAN_HANDLER, TEMPBAN_HANDLER, PUNCH_HANDLER, UNBAN_HANDLER,
‣ `/unlock <type>`*:* Unlock items of a certain type (not available in private) ‣ `/locks`*:* The current list of locks in this chat. Locks can be used to restrict a group's users. eg: Locking urls will auto-delete all messages with urls, locking stickers will restrict all \ non-admin users from sending stickers, etc. Locking bots will stop non-admins from adding bots to the chat. *Note:* ‣ Unlocking permission *info* will allow members (non-admins) to change the group information, such as the description or the group name ‣ Unlocking permission *pin* will allow members (non-admins) to pinned a message in a group """ __mod_name__ = "Locks" LOCKTYPES_HANDLER = DisableAbleCommandHandler("locktypes", locktypes, run_async=True) LOCK_HANDLER = CommandHandler("lock", lock, pass_args=True, run_async=True) # , filters=Filters.group) UNLOCK_HANDLER = CommandHandler("unlock", unlock, pass_args=True, run_async=True) # , filters=Filters.group) LOCKED_HANDLER = CommandHandler("locks", list_locks, run_async=True) # , filters=Filters.group) dispatcher.add_handler(LOCK_HANDLER) dispatcher.add_handler(UNLOCK_HANDLER) dispatcher.add_handler(LOCKTYPES_HANDLER) dispatcher.add_handler(LOCKED_HANDLER)