|
import os |
|
|
|
import unidecode |
|
from PIL import Image, ImageChops, ImageDraw, ImageFont |
|
from pyrogram import filters |
|
from pyrogram.enums import ParseMode |
|
|
|
from Mikobot import DEMONS, DEV_USERS, DRAGONS, OWNER_ID, TIGERS, WOLVES, app |
|
|
|
|
|
async def circle(pfp, size=(900, 900)): |
|
pfp = pfp.resize(size, Image.ANTIALIAS).convert("RGBA") |
|
bigsize = (pfp.size[0] * 3, pfp.size[1] * 3) |
|
mask = Image.new("L", bigsize, 0) |
|
draw = ImageDraw.Draw(mask) |
|
draw.ellipse((0, 0) + bigsize, fill=255) |
|
mask = mask.resize(pfp.size, Image.ANTIALIAS) |
|
mask = ImageChops.darker(mask, pfp.split()[-1]) |
|
pfp.putalpha(mask) |
|
return pfp |
|
|
|
|
|
async def download_and_process_pfp(user): |
|
try: |
|
pic = await app.download_media( |
|
user.photo.big_file_id, file_name=f"pp{user.id}.png" |
|
) |
|
if pic: |
|
pfp = Image.open(pic).convert("RGBA") |
|
return await circle(pfp, size=(900, 900)) |
|
except Exception as e: |
|
print(e) |
|
finally: |
|
if "pic" in locals() and pic: |
|
os.remove(pic) |
|
return None |
|
|
|
|
|
async def userinfopic( |
|
user, |
|
user_x, |
|
user_y, |
|
user_id_x, |
|
user_id_y, |
|
pfp_x_offset=0, |
|
pfp_y_offset=0, |
|
pfp_size=(1218, 1385), |
|
): |
|
user_name = unidecode.unidecode(user.first_name) |
|
|
|
|
|
background = Image.open("Extra/user.jpg") |
|
background = background.resize( |
|
(background.size[0], background.size[1]), Image.ANTIALIAS |
|
) |
|
|
|
draw = ImageDraw.Draw(background) |
|
font = ImageFont.truetype("Extra/default.ttf", 100) |
|
|
|
try: |
|
pfp = await download_and_process_pfp(user) |
|
if pfp: |
|
|
|
pfp_x = 927 + pfp_x_offset |
|
pfp_y = (background.size[1] - pfp.size[1]) // 2 - 290 + pfp_y_offset |
|
|
|
|
|
pfp = await circle(pfp, size=pfp_size) |
|
background.paste(pfp, (pfp_x, pfp_y), pfp) |
|
|
|
user_text_width, user_text_height = draw.textsize(user_name, font=font) |
|
user_id_text_width, user_id_text_height = draw.textsize(str(user.id), font=font) |
|
|
|
draw.text((user_x, user_y), user_name, font=font, fill="white") |
|
draw.text((user_id_x, user_id_y), str(user.id), font=font, fill="white") |
|
|
|
userinfo = f"downloads/userinfo_{user.id}.png" |
|
background.save(userinfo) |
|
|
|
except Exception as e: |
|
print(e) |
|
userinfo = None |
|
|
|
return userinfo |
|
|
|
|
|
|
|
@app.on_message(filters.command("uinfo")) |
|
async def userinfo_command(client, message): |
|
user = message.from_user |
|
user_x, user_y = 1035, 2885 |
|
user_id_x, user_id_y = 1035, 2755 |
|
|
|
try: |
|
|
|
processing_message = await message.reply("Processing user information...") |
|
|
|
|
|
image_path = await userinfopic(user, user_x, user_y, user_id_x, user_id_y) |
|
|
|
|
|
await processing_message.delete() |
|
|
|
if image_path: |
|
|
|
caption = ( |
|
f"ใ **According to the Mikos analogy, the userinfo is...** : ใ\n\n" |
|
f"โ ๐๐: {user.id}\n" |
|
f"โ ๐๐ถ๐ฟ๐๐ ๐ก๐ฎ๐บ๐ฒ: {user.first_name}\n" |
|
f"โ ๐๐ฎ๐๐ ๐ก๐ฎ๐บ๐ฒ: {user.last_name}\n" |
|
f"โ ๐จ๐๐ฒ๐ฟ๐ป๐ฎ๐บ๐ฒ: {user.username}\n" |
|
f"โ ๐จ๐๐ฒ๐ฟ๐น๐ถ๐ป๐ธ: [link](https://t.me/{user.username})\n" |
|
) |
|
|
|
|
|
if user.id == OWNER_ID: |
|
caption += "\n\nใ The disaster level of this user is **Owner**.\n" |
|
elif user.id in DEV_USERS: |
|
caption += "\n\nใ This user is a member of **Developer**.\n" |
|
elif user.id in DRAGONS: |
|
caption += "\n\nใ The disaster level of this user is **Sudo**.\n" |
|
elif user.id in DEMONS: |
|
caption += "\n\nใ The disaster level of this user is **Demon**.\n" |
|
elif user.id in TIGERS: |
|
caption += "\n\nใ The disaster level of this user is **Tiger**.\n" |
|
elif user.id in WOLVES: |
|
caption += "\n\nใ The disaster level of this user is **Wolf**.\n" |
|
|
|
|
|
if ( |
|
user.id == OWNER_ID |
|
or user.id in DEV_USERS |
|
or user.id in DRAGONS |
|
or user.id in DEMONS |
|
or user.id in TIGERS |
|
or user.id in WOLVES |
|
): |
|
caption += "\n\nใ ๐ฅ๐ฎ๐ป๐ธ: " |
|
|
|
if user.id == OWNER_ID: |
|
caption += "**CREATOR**" |
|
elif user.id in DEV_USERS: |
|
caption += "**DEVELOPER**" |
|
elif user.id in DRAGONS: |
|
caption += "**DRAGON**" |
|
elif user.id in DEMONS: |
|
caption += "**DEMON**" |
|
elif user.id in TIGERS: |
|
caption += "**TIGER**" |
|
elif user.id in WOLVES: |
|
caption += "**WOLF**" |
|
|
|
caption += "\n" |
|
|
|
await message.reply_photo( |
|
photo=image_path, caption=caption, parse_mode=ParseMode.MARKDOWN |
|
) |
|
os.remove(image_path) |
|
|
|
except Exception as e: |
|
print(e) |
|
|