Co-authored-by: Danish <danish@ultroid.tech> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: Amit Sharma <48654350+buddhhu@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: divkix <divkix@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: Programming Error <error@notavailable.live>
47 lines
1.2 KiB
Python
47 lines
1.2 KiB
Python
# Ultroid - UserBot
|
|
# Copyright (C) 2021 TeamUltroid
|
|
#
|
|
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
|
# PLease read the GNU Affero General Public License in
|
|
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
|
|
|
"""
|
|
✘ Commands Available -
|
|
|
|
`{i}write <text or reply to text>`
|
|
It will write on a paper.
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
from PIL import Image, ImageDraw, ImageFont
|
|
|
|
from . import *
|
|
|
|
|
|
@ultroid_cmd(pattern="write ?(.*)")
|
|
async def writer(e):
|
|
if e.reply_to:
|
|
reply = await e.get_reply_message()
|
|
text = reply.message
|
|
elif e.pattern_match.group(1):
|
|
text = e.text.split(maxsplit=1)[1]
|
|
else:
|
|
return await eod(e, "`Give Some Texts Too`")
|
|
k = await eor(e, "`Processing...`")
|
|
img = Image.open("resources/extras/template.jpg")
|
|
draw = ImageDraw.Draw(img)
|
|
font = ImageFont.truetype("resources/fonts/assfont.ttf", 30)
|
|
x, y = 150, 140
|
|
lines = text_set(text)
|
|
line_height = font.getsize("hg")[1]
|
|
for line in lines:
|
|
draw.text((x, y), line, fill=(1, 22, 55), font=font)
|
|
y = y + line_height - 5
|
|
file = "ult.jpg"
|
|
img.save(file)
|
|
await e.reply(file=file)
|
|
os.remove(file)
|
|
await k.delete()
|