from os import path from app import app, isAnAdmin from pyrogram import filters from pyrogram.types import Message from pyrogram.client import Client from pyrogram.errors import bad_request_400 from pyrogram.enums.chat_action import ChatAction from classes.errors.holo_user import UserNotFoundError, UserInvalidError from classes.holo_user import HoloUser from modules.utils import jsonLoad, should_quote, logWrite, locale, download_tmp, create_tmp, find_user from modules import custom_filters # Identify command ============================================================================================================= @app.on_message((custom_filters.enabled_applications | custom_filters.enabled_sponsorships) & ~filters.scheduled & filters.command("identify", prefixes=["/"]) & custom_filters.admin) async def cmd_identify(app: Client, msg: Message): if len(msg.command) != 2: await msg.reply_text(locale("identify_invalid_syntax", "message", locale=msg.from_user)) return try: try: holo_user = HoloUser(int(msg.command[1])) except ValueError: holo_user = HoloUser(await find_user(app, msg.command[1])) except (UserInvalidError, UserNotFoundError, bad_request_400.UsernameInvalid, bad_request_400.PeerIdInvalid, bad_request_400.UsernameNotOccupied, TypeError): await msg.reply_text(locale("identify_not_found", "message", locale=msg.from_user).format(msg.command[1])) return role = holo_user.label has_application = locale("yes", "message", locale=msg.from_user) if holo_user.application_approved() is True else locale("no", "message", locale=msg.from_user) has_sponsorship = locale("yes", "message", locale=msg.from_user) if holo_user.sponsorship_valid() is True else locale("no", "message", locale=msg.from_user) username = holo_user.username if holo_user.username is not None else "N/A" in_chat = locale("yes", "message", locale=msg.from_user) if (holo_user.id in jsonLoad(path.join("cache", "group_members"))) else locale("no", "message", locale=msg.from_user) is_admin = locale("yes", "message", locale=msg.from_user) if (await isAnAdmin(holo_user.id)) else locale("no", "message", locale=msg.from_user) output = locale("identify_success", "message", locale=msg.from_user).format( holo_user.id, holo_user.name, username, in_chat, is_admin, role, has_application, has_sponsorship ) user = await app.get_users(holo_user.id) if user.photo is not None: await app.send_chat_action(msg.chat.id, action=ChatAction.UPLOAD_PHOTO) await msg.reply_photo( create_tmp(await download_tmp(app, user.photo.big_file_id), kind="image"), quote=should_quote(msg), caption=output ) else: await app.send_chat_action(msg.chat.id, action=ChatAction.TYPING) await msg.reply_text( output, quote=should_quote(msg) ) logWrite(f"User {msg.from_user.id} identified user {holo_user.id}") # ==============================================================================================================================