# @Sekai_Yoneya import os from .. import loader, utils from telethon.tl.functions.photos import GetUserPhotosRequest from telethon.tl.functions.users import GetFullUserRequest @loader.tds class WhoIsMod(loader.Module): """Получает информацию о пользователе.""" strings = {'name': 'Whois'} async def whoiscmd(self, message): """Используй .whois <@ или реплай>; ничего""" args = utils.get_args_raw(message) reply = await message.get_reply_message() await message.edit("Получаю информацию о пользователе...") try: if args: user = await message.client.get_entity(args if not args.isdigit() else int(args)) else: user = await message.client.get_entity(reply.sender_id) except: user = await message.client.get_me() user = await message.client(GetFullUserRequest(user.id)) photo, caption = await get_info(user, message) await message.client.send_file(message.chat_id, photo if photo else None, caption=caption, link_preview=False, reply_to=reply.id if reply else None) os.remove(photo) await message.delete() async def get_info(user, message): """Подробная информация о пользователе.""" uuser = user.user user_photos = await message.client(GetUserPhotosRequest(user_id=uuser.id, offset=42, max_id=0, limit=100)) user_photos_count = "У пользователя нет аватарки." try: user_photos_count = user_photos.count except: pass user_id = uuser.id first_name = uuser.first_name or "Пользователь не указал имя." last_name = uuser.last_name or "Пользователь не указал фамилию." username = uuser.username or "У пользователя нет юзернейма." user_bio = user.about or "У пользователя нет информации о себе." common_chat = user.common_chats_count is_bot = "Да" if uuser.bot else "Нет" restricted = "Да" if uuser.restricted else "Нет" verified = "Да" if uuser.verified else "Нет" photo = await message.client.download_profile_photo(user_id, str(user_id) + ".jpg", download_big=True) caption = (f"ИНФОРМАЦИЯ О ПОЛЬЗОВАТЕЛЕ:\n\n" f"Имя: {first_name}\n" f"Фамилия: {last_name}\n" f"Юзернейм: @{username}\n" f"ID: {user_id}\n" f"Бот: {is_bot}\n" f"Ограничен: {restricted}\n" f"Верифицирован: {verified}\n\n" f"О себе: \n{user_bio}\n\n" f"Кол-во аватарок в профиле: {user_photos_count}\n" f"Общие чаты: {common_chat}\n" f"Пермалинк: клик") return photo, caption