async def crbn(event): xxxx = await eor(event, "Processing") if event.reply_to_msg_id: temp = await event.get_reply_message() if temp.media: b = await event.client.download_media(temp) a = open(b) code = a.read() a.close() os.remove(b) else: code = temp.message else: code = event.text.split(" ", maxsplit=1)[1] col = random.choice(all_col) webs = requests.get("https://carbonara.vercel.app/api/cook") if webs.status_code == 502: return await eor( event, "`Temporary Server Error has Occured !\nPlease Try Again Later`") carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=code, background=col) xx = await carbon.memorize("ultroid_carbon") await xxxx.delete() await event.reply( f"Carbonised by {inline_mention(event.sender)}", file=xx, )
async def crbn(event): xxxx = await eor(event, get_string("com_1")) te = event.text col = random.choice(all_col) if te[1] == "r" else None if event.reply_to_msg_id: temp = await event.get_reply_message() if temp.media: b = await event.client.download_media(temp) with open(b) as a: code = a.read() os.remove(b) else: code = temp.message else: try: code = event.text.split(" ", maxsplit=1)[1] except IndexError: return await eor(xxxx, get_string("carbon_2")) carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=code, background=col) xx = await carbon.memorize("ultroid_carbon") await xxxx.delete() await event.reply( f"Carbonised by {inline_mention(event.sender)}", file=xx, )
async def crbn(event): xxxx = await eor(event, "Processing") if event.reply_to_msg_id: temp = await event.get_reply_message() if temp.media: b = await ultroid_bot.download_media(temp) a = open(b) code = a.read() a.close() os.remove(b) else: code = temp.message else: code = event.text.split(" ", maxsplit=1)[1] col = random.choice(all_col) carbon = Carbon(code=code, background=col) xx = await carbon.save("ultroid_carbon") await xxxx.delete() await ultroid_bot.send_file( event.chat_id, xx, caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})", force_document=True, ) os.remove(xx)
async def crbn(event): match = event.pattern_match.group(1) if not match: return await eor(event, get_string("carbon_3")) msg = await eor(event, get_string("com_1")) if event.reply_to_msg_id: temp = await event.get_reply_message() if temp.media: b = await event.client.download_media(temp) with open(b) as a: code = a.read() os.remove(b) else: code = temp.message else: try: match = match.split(" ", maxsplit=1) code = match[1] match = match[0] except IndexError: return await eor(msg, get_string("carbon_2")) carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=code, background=match) try: xx = await carbon.memorize("ultroid_carbon") except Exception as er: return await msg.edit(str(er)) await msg.delete() await event.reply( f"Carbonised by {inline_mention(event.sender)}", file=xx, )
async def crbn(event): xxxx = await eor(event, get_string("com_1")) if event.reply_to_msg_id: temp = await event.get_reply_message() if temp.media: b = await ultroid_bot.download_media(temp) a = open(b) code = a.read() a.close() os.remove(b) else: code = temp.message else: code = event.text.split(" ", maxsplit=1)[1] webs = requests.get("https://carbonara.vercel.app/api/cook") if webs.status_code == 502: return await eor( event, "`Temporary Server Error has Occured !\nPlease Try Again Later`" ) carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=code) xx = await carbon.memorize("ultroid_carbon") await xxxx.delete() await ultroid_bot.send_file( event.chat_id, xx, caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})", )
async def _(e): x, y = await bash("neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt") with open("neo.txt", "r") as neo: p = (neo.read()).replace("\n\n", "") ok = Carbon(code=p) haa = await ok.save("neofetch") await e.client.send_file(e.chat_id, haa) remove("neofetch.jpg") remove("neo.txt")
async def _(e): xxnx = await edit_or_reply(e, "`Processing...`") x, y = await bash("neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt") with open("neo.txt", "r") as neo: p = (neo.read()).replace("\n\n", "") ok = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=p) haa = await ok.memorize("neofetch") await e.reply(file=haa) await xxnx.delete() remove("neo.txt")
async def _(e): xx = await eor(e, "`Sending...`") x, y = await bash( "neofetch|sed 's/\x1B\\[[0-9;\\?]*[a-zA-Z]//g' >> neo.txt") with open("neo.txt", "r") as neo: p = (neo.read()).replace("\n\n", "") ok = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=p) haa = await ok.save("neofetch") await e.client.send_file(e.chat_id, haa) await xx.delete() remove("neofetch.jpg") remove("neo.txt")
async def changes(okk): await okk.answer(get_string("clst_3")) repo = Repo.init() ac_br = repo.active_branch button = (Button.inline("Update Now", data="updatenow"), ) changelog, tl_chnglog = gen_chlog(repo, f"HEAD..upstream/{ac_br}") cli = "\n\nClick the below button to update!" if Carbon: try: await okk.edit("• Writing Changelogs 📝 •") carbon = Carbon( base_url="https://carbonara-42.herokuapp.com/api/cook", code=tl_chnglog, background=choice(ATRA_COL), language="md", ) img = await carbon.memorize("changelog") return await okk.edit(f"**• Ultroid Userbot •**{cli}", file=img, buttons=button) except Exception as er: LOGS.exception(er) changelog_str = changelog + cli if len(changelog_str) > 1024: await okk.edit(get_string("upd_4")) await asyncio.sleep(2) with open("ultroid_updates.txt", "w+") as file: file.write(tl_chnglog) await okk.edit( get_string("upd_5"), file="ultroid_updates.txt", buttons=Button.inline("Update Now", data="updatenow"), ) remove("ultroid_updates.txt") return await okk.edit( changelog_str, buttons=button, parse_mode="html", )
async def color_button(client, query): await query.message.delete() keyboard = ReplyKeyboard(row_width=1) keyboard.add( KeyboardButton('Yes'), KeyboardButton('No'), ) watermarker = await client.ask( query.message.chat.id, "Would you like to have a WaterMark on the carbonized code?", reply_markup=keyboard) color[str(query.from_user.id) + "color"] = query.data.split("_")[1] if watermarker.text.lower() == "no": watermark = False elif watermarker.text.lower() == "yes": watermark = True else: await query.message.reply("Can't get that, I assume you said no") watermark = False final = await client.ask( query.message.chat.id, "Okay, Now send me the Code to parse on carbon.now.sh", reply_markup=ForceReply(True)) carbon = Carbon( code=final.text, theme=caches[str(query.from_user.id) + "theme"], background=color[str(query.from_user.id) + "color"], language="auto", drop_shadow=True, drop_shadow_blur='68px', drop_shadow_offset='20px', font_family='Fira Code', width_adjustment=True, watermark=watermark, ) await query.message.reply_chat_action("upload_photo") photo = await carbon.memorize(str(client.rnd_id())) await query.message.reply_photo(photo) await query.message.reply( "if you like it and want to try again you can send me /start again :D")
async def crbn(event): xxxx = await eor(event, get_string("com_1")) if event.reply_to_msg_id: temp = await event.get_reply_message() if temp.media: b = await ultroid_bot.download_media(temp) a = open(b) code = a.read() a.close() os.remove(b) else: code = temp.message else: code = event.text.split(" ", maxsplit=1)[1] carbon = Carbon(code=code) xx = await carbon.save("infinato_carbon") await xxxx.delete() await ultroid_bot.send_file( event.chat_id, xx, caption=f"Carbonised by [{OWNER_NAME}](tg://user?id={OWNER_ID})", force_document=True, ) os.remove(xx)
async def main(): carbon = Carbon( code=code, # Required: Code background='#4a90e6', # Optional: Hex-Color for Background drop_shadow=True, # Optional: Drop Shadow on div Box drop_shadow_blur='68px', # Optional: Drop Shadow Blur on div Box drop_shadow_offset='20px', # Optional: Drop Shadow Offset on div Box export_size='4x', # Optional: Export Size (1x, 2x, 4x) font_size='14px', # Optional: Font size font_family='Fira Code', # Optional: support FontFamily on carbon.now.sh first_line_number= 1, # Optional: Starting Line Numbers if Line Numbers Exist language='javascript', # Optional: Programming Language of Choice line_height='133%', # Optional: Line Height line_numbers=False, # Optional: Line Numbers padding_horizontal='56px', # Optional: Horizontal Padding padding_vertical='56px', # Optional: Vertical Padding theme='Material', # Optional: Carbon Theme watermark=False, # Optional: Carbon Watermark width_adjustment=True, # Optional: Width Adjustment window_controls=False, # Optional: Window Controls window_theme='Material', # Optional: Window Theme ) print(await carbon.save('carbon_photo')) # Print Path of the file
async def make_carbon(code): carbon = Carbon(code=code) image = await carbon.save(str(randint(1000, 10000))) return image
async def hehe(args): ultroid_bot = args.client xx = await eor(args, "`Processing...`") user = ultroid_bot.me if not user.username: user.username = user.first_name message = await args.get_reply_message() photo = None is_anim = False emoji = None if not message: return await eor(xx, "`Reply to message/media...`") if message.photo: photo = io.BytesIO() photo = await ultroid_bot.download_media(message.photo, photo) elif message.file and "image" in message.file.mime_type.split("/"): photo = io.BytesIO() await ultroid_bot.download_file(message.media.document, photo) if (DocumentAttributeFilename(file_name="sticker.webp") in message.media.document.attributes): emoji = message.media.document.attributes[1].alt elif message.file and "video" in message.file.mime_type.split("/"): xy = await message.download_media() y = cv2.VideoCapture(xy) heh, lol = y.read() cv2.imwrite("ult.webp", lol) photo = "ult.webp" elif message.file and "tgsticker" in message.file.mime_type: await ultroid_bot.download_file( message.media.document, "AnimatedSticker.tgs", ) attributes = message.media.document.attributes for attribute in attributes: if isinstance(attribute, DocumentAttributeSticker): emoji = attribute.alt is_anim = True photo = 1 elif message.message: carbon = Carbon(base_url="https://carbonara.vercel.app/api/cook", code=message.message) photo = await carbon.memorize("carbon_kang") else: return await xx.edit("`Unsupported File!`") await xx.edit(f"`{random.choice(KANGING_STR)}`") if photo: splat = args.text.split() pack = 1 if not emoji: emoji = "🏵" if len(splat) == 3: pack = splat[2] # User sent ultroid_both emoji = splat[1] elif len(splat) == 2: if splat[1].isnumeric(): pack = int(splat[1]) else: emoji = splat[1] packname = f"ult_{user.id}_{pack}" packnick = f"@{user.username}'s Pack {pack}" cmd = "/newpack" file = io.BytesIO() if not is_anim: image = await resize_photo(photo) file.name = "sticker.png" image.save(file, "PNG") else: packname += "_anim" packnick += " (Animated)" cmd = "/newanimated" response = requests.get(f"http://t.me/addstickers/{packname}") htmlstr = response.text.split("\n") if (" A <strong>Telegram</strong> user has created the <strong>Sticker Set</strong>." not in htmlstr): async with ultroid_bot.conversation("@Stickers") as conv: try: await conv.send_message("/addsticker") except YouBlockedUserError: LOGS.info("Unblocking @Stickers for kang...") await ultroid_bot( functions.contacts.UnblockRequest("stickers")) await conv.send_message("/addsticker") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packname) x = await conv.get_response() while "120" in x.text: pack += 1 packname = f"ult_{user.id}_{pack}" packnick = f"@{user.username}'s Pack {pack}" await xx.edit( "`Switching to Pack " + str(pack) + " due to insufficient space`", ) await conv.send_message(packname) x = await conv.get_response() if x.text == "Invalid pack selected.": await conv.send_message(cmd) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) await conv.get_response() await conv.send_message(emoji) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await xx.edit( f"`Sticker added in a Different Pack !\ \nThis Pack is Newly created!\ \nYour pack can be found` [here](t.me/addstickers/{packname})", parse_mode="md", ) return if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await xx.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`", ) return await conv.send_message(emoji) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/done") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) else: await xx.edit("`Brewing a new Pack...`") async with ultroid_bot.conversation("Stickers") as conv: await conv.send_message(cmd) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message(packnick) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) if is_anim: await conv.send_file("AnimatedSticker.tgs") remove("AnimatedSticker.tgs") else: file.seek(0) await conv.send_file(file, force_document=True) rsp = await conv.get_response() if "Sorry, the file type is invalid." in rsp.text: await xx.edit( "`Failed to add sticker, use` @Stickers `bot to add the sticker manually.`", ) return await conv.send_message(emoji) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message("/publish") if is_anim: await conv.get_response() await conv.send_message(f"<{packnick}>") await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.send_message("/skip") await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await conv.send_message(packname) await ultroid_bot.send_read_acknowledge(conv.chat_id) await conv.get_response() await ultroid_bot.send_read_acknowledge(conv.chat_id) await xx.edit( f"`Kanged!`\ \n`Emoji` - {emoji}\ \n`Sticker Pack` [here](t.me/addstickers/{packname})", parse_mode="md", ) try: os.remove(photo) except BaseException: pass