async def shutup( self, ctx, member: Optional[FuzzyMember] = None, *, text: commands.clean_content(fix_channel_mentions=True), ): """Will you shutup, man""" text = " ".join(text.split()) if not member: biden = None member = ctx.author else: biden = ctx.author async with ctx.typing(): trump = await self.get_avatar(member) if biden: biden = await self.get_avatar(biden) task = functools.partial(self.gen_shut, ctx, trump, text, biden_avatar=biden) image = await self.generate_image(ctx, task) if isinstance(image, str): await ctx.send(image) else: await ctx.send(file=image)
async def emojify( self, ctx, *, message: commands.clean_content(fix_channel_mentions=True)): """Emojify text""" table = str.maketrans("".join(EMOJIFY_CHARS.keys()), "".join(EMOJIFY_CHARS.values())) message = message.translate(table) message = "".join( map( lambda c: f":regional_indicator_{c.lower()}:" if c in string.ascii_letters else c, message, )) message = "".join( map( lambda c: f"{c}\N{COMBINING ENCLOSING KEYCAP}" if c in string.digits else c, message, )) message = (message.replace(" ", " ").replace( "#", "#\N{COMBINING ENCLOSING KEYCAP}").replace( "*", "*\N{COMBINING ENCLOSING KEYCAP}")) await ctx.send( message, allowed_mentions=discord.AllowedMentions.none(), )
async def _leet(self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """Translates provided text to 1337""" text = text.upper() dic = { "A": random.choice(["/-|", "4"]), "B": "8", "C": random.choice(["(", "["]), "D": "|)", "E": "3", "F": random.choice(["|=", "ph"]), "G": "6", "H": "|-|", "I": random.choice(["|", "!", "1"]), "J": ")", "K": random.choice(["|<", "|("]), "L": random.choice(["|_", "1"]), "M": random.choice(["|\\/|", "/\\/\\"]), "N": random.choice(["|\\|", "/\\/"]), "O": random.choice(["0", "()"]), "P": "|>", "Q": random.choice(["9", "0"]), "R": random.choice(["|?", "|2"]), "S": random.choice(["5", "$"]), "T": random.choice(["7", "+"]), "U": "|_|", "V": "\\/", "W": random.choice(["\\/\\/", "\\X/"]), "X": random.choice(["*", "><"]), "Y": "'/", "Z": "2", } pattern = re.compile("|".join(dic.keys())) result = pattern.sub(lambda x: dic[x.group()], text) await ctx.send(chat.box(result))
async def eciho(self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """Translates text (cyrillic/latin) to "eciho" eciho - language created by Фражуз#2170 (255682413445906433) This is unusable shit, i know, but whatever""" char = "сзчшщжуюваёяэкгфйыъьд" tran = "ццццццооооееехххииииб" table = str.maketrans(char, tran) text = text.translate(table) char = char.upper() tran = tran.upper() table = str.maketrans(char, tran) text = text.translate(table) text = "".join(c for c, _ in itertools.groupby(text)) char = "uavwjyqkhfxdzs" tran = "ooooiigggggbcc" table = str.maketrans(char, tran) text = text.translate(table) char = char.upper() tran = tran.upper() table = str.maketrans(char, tran) text = text.translate(table) await ctx.send(text, allowed_mentions=discord.AllowedMentions.none())
async def kabhi(self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """kabhi aisa lagta hai""" text = self.parse_text(text) data = await self.get(ctx, f"/kabhi?text={text}") if isinstance(data, dict): return await self.send_error(ctx, data) data.name = "kabhi.png" await self.send_img(ctx, discord.File(data))
async def abandon(self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """Abandoning your son?""" text = self.parse_text(text) data = await self.get(ctx, f"/abandon?text={text}") if isinstance(data, dict): return await self.send_error(ctx, data) data.name = "abandon.png" await self.send_img(ctx, discord.File(data))
async def emergencymeeting( self, ctx, *, text: commands.clean_content(fix_channel_mentions=True) ): """Call an emergency meeting.""" text = self.parse_text(text) data = await self.get(ctx, f"/emergencymeeting?text={text}") if isinstance(data, dict): return await self.send_error(ctx, data) data.name = "emergencymeeting.png" await self.send_img(ctx, discord.File(data))
async def fullwidth( self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """Switches text to Full-width characters""" halfwidth = "qwertyuiopasdfghjklzxcvbnm1234567890!?@#$%^&*()_+-=<>.,/;:'\"[]{}|\\`~ " fullwidth = "qwertyuiopasdfghjklzxcvbnm1234567890!?@#$%^&*()_+-=<>.,/;:'"[]{}|\`~ " table = str.maketrans(halfwidth, fullwidth) text = text.translate(table) halfwidth = halfwidth.upper() fullwidth = fullwidth.upper() table = str.maketrans(halfwidth, fullwidth) text = text.translate(table) await ctx.send(text)
async def fliptext( self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """Flips text upside-down Based on https://unicode-table.com/en/tools/flip/""" # https://s.unicode-table.com/static/js/tools/Flip.js up = "abcdefghijklmnopqrstuvwxyzабвгдежзиклмнопрстуфхцчшщъьэя.,!?()[]{}_‿⁅∴" down = "ɐqɔpǝɟƃɥıɾʞlɯuodᕹɹsʇnʌʍxʎzɐƍʚɹɓǝжεиʞvwноudɔɯʎȸхǹҺmmqqєʁ˙‘¡¿)(][}{‾⁀⁆∵" text = text.casefold() char = up + down tran = down + up table = str.maketrans(char, tran) text = text.translate(table)[::-1] dic = {"ю": "oı", "ы": "ıq", "ё": "ǝ̤", "й": "n̯"} pattern = re.compile("|".join(dic.keys())) result = pattern.sub(lambda x: dic[x.group()], text) await ctx.send(result)
async def stoptalking( self, ctx, member: Optional[FuzzyMember] = None, *, text: commands.clean_content(fix_channel_mentions=True), ): """Tell someone to stop blabbering away""" text = " ".join(text.split()) if not member: member = ctx.author async with ctx.typing(): avatar = await self.get_avatar(member) task = functools.partial(self.gen_stop, ctx, avatar, text) image = await self.generate_image(ctx, task) if isinstance(image, str): await ctx.send(image) else: await ctx.send(file=image)
async def cs(self, ctx, *, text: commands.clean_content(fix_channel_mentions=True)): """Translate cyrillic to 1337""" text = text.upper() dic_cs = { "А": "A", "Б": "6", "В": "B", "Г": "r", "Д": random.choice(["D", "g"]), "Е": "E", "Ё": "E", "Ж": random.choice(["}|{", ">|<"]), "З": "3", "И": random.choice(["u", "N"]), "Й": "u*", "К": "K", "Л": random.choice(["JI", "/I"]), "М": "M", "Н": "H", "О": "O", "П": random.choice(["II", "n", "/7"]), "Р": "P", "С": "C", "Т": random.choice(["T", "m"]), "У": random.choice(["Y", "y"]), "Ф": random.choice(["cp", "(|)", "qp"]), "Х": "X", "Ц": random.choice(["U", "LL", "L|"]), "Ч": "4", "Ш": random.choice(["W", "LLI"]), "Щ": random.choice(["W", "LLL"]), "Ъ": random.choice(["~b", "`b"]), "Ы": "bl", "Ь": "b", "Э": "-)", "Ю": random.choice(["IO", "10"]), "Я": random.choice(["9", "9I"]), "%": "o\\o", } pattern = re.compile("|".join(dic_cs.keys())) result = pattern.sub(lambda x: dic_cs[x.group()], text) await ctx.send(chat.box(result))
async def nickel( self, ctx, member: Optional[FuzzyMember] = None, *, text: commands.clean_content(fix_channel_mentions=True), ): """If I had a nickel for everytime someone ran this command.. I'd probably have a lot.""" text = " ".join(text.split()) if not member: member = ctx.author async with ctx.typing(): avatar = await self.get_avatar(member) task = functools.partial(self.gen_nickel, ctx, avatar, text[:29]) image = await self.generate_image(ctx, task) if isinstance(image, str): await ctx.send(image) else: await ctx.send(file=image)
async def googlesay( self, ctx, lang: str, *, text: commands.clean_content(fix_channel_mentions=True)): """Say something via Google Translate lang arg must be two-letters google-translate language code Not all languages support tts If text contains more than 200 symbols, it will be cut""" text = text[:200] async with ctx.typing(): try: async with self.session.get( "http://translate.google.com/translate_tts", params={ "ie": "utf-8", "q": text, "tl": lang, "client": "tw-ob" }, headers={"User-Agent": USERAGENT}, raise_for_status=True, ) as data: speech = await data.read() except aiohttp.ClientResponseError as e: if e.status == 404: await ctx.send( _("Language {} is not supported or incorrect").format( lang.lower())) else: await ctx.send( _("Unable to get data from Google Translate TTS: {}"). format(e.status)) return speechfile = BytesIO(speech) file = discord.File(speechfile, filename="{}.mp3".format(text[:32])) await ctx.send(file=file) speechfile.close()
async def dmurl(self, ctx, *, url: commands.clean_content(fix_channel_mentions=True)): """Set the DankMemer API Url. Ensure the url ends in API without the backslash - Example: https://imgen.flaree.xyz/api Only use this if you have an instance already. """ if not validators.url(url): return await ctx.send(f"{url} doesn't seem to be a valid URL. Please try again.") await ctx.send( "This has the ability to make every command fail if the URL is not reachable and/or not working. Only use this if you're experienced enough to understand. Type yes to continue, otherwise type no." ) try: pred = MessagePredicate.yes_or_no(ctx, user=ctx.author) await ctx.bot.wait_for("message", check=pred, timeout=20) except asyncio.TimeoutError: await ctx.send("Exiting operation.") return if pred.result: await self.config.url.set(url) await ctx.tick() await self.initalize() else: await ctx.send("Operation cancelled.")