azils3/bash
0
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7 8"""9✘ Commands Available -10 11• `{i}write <text or reply to text>`12 It will write on a paper.13 14• `{i}image <text or reply to html or any doc file>`15 Write a image from html or any text.16"""17 18import os19 20from htmlwebshot import WebShot21from PIL import Image, ImageDraw, ImageFont22 23from . import async_searcher, eod, get_string, text_set, ultroid_cmd24 25 26@ultroid_cmd(pattern="gethtml( (.*)|$)")27async def ghtml(e):28 if txt := e.pattern_match.group(1).strip():29 link = e.text.split(maxsplit=1)[1]30 else:31 return await eod(e, "`Either reply to any file or give any text`")32 k = await async_searcher(link)33 with open("file.html", "w+") as f:34 f.write(k)35 await e.reply(file="file.html")36 37 38@ultroid_cmd(pattern="image( (.*)|$)")39async def f2i(e):40 txt = e.pattern_match.group(1).strip()41 html = None42 if txt:43 html = e.text.split(maxsplit=1)[1]44 elif e.reply_to:45 r = await e.get_reply_message()46 if r.media:47 html = await e.client.download_media(r.media)48 elif r.text:49 html = r.text50 if not html:51 return await eod(e, "`Either reply to any file or give any text`")52 html = html.replace("\n", "<br>")53 shot = WebShot(quality=85)54 css = "body {background: white;} p {color: red;}"55 pic = await shot.create_pic_async(html=html, css=css)56 await e.reply(file=pic, force_document=True)57 os.remove(pic)58 if os.path.exists(html):59 os.remove(html)60 61 62@ultroid_cmd(pattern="write( (.*)|$)")63async def writer(e):64 if e.reply_to:65 reply = await e.get_reply_message()66 text = reply.message67 elif e.pattern_match.group(1).strip():68 text = e.text.split(maxsplit=1)[1]69 else:70 return await eod(e, get_string("writer_1"))71 k = await e.eor(get_string("com_1"))72 img = Image.open("resources/extras/template.jpg")73 draw = ImageDraw.Draw(img)74 font = ImageFont.truetype("resources/fonts/assfont.ttf", 30)75 x, y = 150, 14076 lines = text_set(text)77 bbox = font.getbbox("hg")78 line_height = bbox[3] - bbox[1]79 for line in lines:80 draw.text((x, y), line, fill=(1, 22, 55), font=font)81 y = y + line_height - 582 file = "ult.jpg"83 img.save(file)84 await e.reply(file=file)85 os.remove(file)86 await k.delete()87 