# Ultroid - UserBot # Copyright (C) 2021-2025 TeamUltroid # # This file is a part of < https://github.com/TeamUltroid/Ultroid/ > # PLease read the GNU Affero General Public License in # . # -----------------Random Stuff-------------- import math from telethon.tl import functions, types from .. import LOGS # ----------- # @buddhhu async def get_uinfo(e): user, data = None, None reply = await e.get_reply_message() if reply: user = await e.client.get_entity(reply.sender_id) data = e.pattern_match.group(1) else: ok = e.pattern_match.group(1).split(maxsplit=1) if len(ok) > 1: data = ok[1] try: user = await e.client.get_entity(await e.client.parse_id(ok[0])) except IndexError: pass except ValueError as er: await e.eor(str(er)) return None, None return user, data # Random stuffs dk who added async def get_chat_info(chat, event): if isinstance(chat, types.Channel): chat_info = await event.client(functions.channels.GetFullChannelRequest(chat)) elif isinstance(chat, types.Chat): chat_info = await event.client(functions.messages.GetFullChatRequest(chat)) else: return await event.eor("`Use this for Group/Channel.`") full = chat_info.full_chat chat_photo = full.chat_photo broadcast = getattr(chat, "broadcast", False) chat_type = "Channel" if broadcast else "Group" chat_title = chat.title try: msg_info = await event.client( functions.messages.GetHistoryRequest( peer=chat.id, offset_id=0, offset_date=None, add_offset=-0, limit=0, max_id=0, min_id=0, hash=0, ) ) except Exception as er: msg_info = None if not event.client._bot: LOGS.exception(er) first_msg_valid = bool( msg_info and msg_info.messages and msg_info.messages[0].id == 1 ) creator_valid = bool(first_msg_valid and msg_info.users) creator_id = msg_info.users[0].id if creator_valid else None creator_firstname = ( msg_info.users[0].first_name if creator_valid and msg_info.users[0].first_name is not None else "Deleted Account" ) creator_username = ( msg_info.users[0].username if creator_valid and msg_info.users[0].username is not None else None ) created = msg_info.messages[0].date if first_msg_valid else None if not isinstance(chat.photo, types.ChatPhotoEmpty): dc_id = chat.photo.dc_id else: dc_id = "Null" restricted_users = getattr(full, "banned_count", None) members = getattr(full, "participants_count", chat.participants_count) admins = getattr(full, "admins_count", None) banned_users = getattr(full, "kicked_count", None) members_online = getattr(full, "online_count", 0) group_stickers = ( full.stickerset.title if getattr(full, "stickerset", None) else None ) messages_viewable = msg_info.count if msg_info else None messages_sent = getattr(full, "read_inbox_max_id", None) messages_sent_alt = getattr(full, "read_outbox_max_id", None) exp_count = getattr(full, "pts", None) supergroup = "Yes" if getattr(chat, "megagroup", None) else "No" creator_username = "@{}".format(creator_username) if creator_username else None if admins is None: try: participants_admins = await event.client( functions.channels.GetParticipantsRequest( channel=chat.id, filter=types.ChannelParticipantsAdmins(), offset=0, limit=0, hash=0, ) ) admins = participants_admins.count if participants_admins else None except Exception as e: LOGS.info(f"Exception: {e}") caption = "â„šī¸ [CHAT INFO]\n" caption += f"🆔 ID: {chat.id}\n" if chat_title is not None: caption += f"📛 {chat_type} name: {chat_title}\n" if chat.username: caption += f"🔗 Link: @{chat.username}\n" else: caption += f"đŸ—ŗ {chat_type} type: Private\n" if creator_username: caption += f"🖌 Creator: {creator_username}\n" elif creator_valid: caption += f'🖌 Creator: {creator_firstname}\n' if created: caption += f"🖌 Created: {created.date().strftime('%b %d, %Y')} - {created.time()}\n" else: caption += f"🖌 Created: {chat.date.date().strftime('%b %d, %Y')} - {chat.date.time()} ⚠\n" caption += f"🗡 Data Centre ID: {dc_id}\n" if exp_count is not None: chat_level = int((1 + math.sqrt(1 + 7 * exp_count / 14)) / 2) caption += f"â­ī¸ {chat_type} level: {chat_level}\n" if messages_viewable is not None: caption += f"đŸ’Ŧ Viewable messages: {messages_viewable}\n" if messages_sent: caption += f"đŸ’Ŧ Messages sent: {messages_sent}\n" elif messages_sent_alt: caption += f"đŸ’Ŧ Messages sent: {messages_sent_alt} ⚠\n" if members is not None: caption += f"đŸ‘Ĩ Members: {members}\n" if admins: caption += f"👮 Administrators: {admins}\n" if full.bot_info: caption += f"🤖 Bots: {len(full.bot_info)}\n" if members_online: caption += f"👀 Currently online: {members_online}\n" if restricted_users is not None: caption += f"🔕 Restricted users: {restricted_users}\n" if banned_users: caption += f"📨 Banned users: {banned_users}\n" if group_stickers: caption += f'📹 {chat_type} stickers: {group_stickers}\n' if not broadcast: if getattr(chat, "slowmode_enabled", None): caption += f"👉 Slow mode: True" caption += f", 🕐 {full.slowmode_seconds}s\n" else: caption += f"đŸĻ¸â€â™‚ Supergroup: {supergroup}\n" if getattr(chat, "restricted", None): caption += f"🎌 Restricted: {chat.restricted}\n" rist = chat.restriction_reason[0] caption += f"> Platform: {rist.platform}\n" caption += f"> Reason: {rist.reason}\n" caption += f"> Text: {rist.text}\n\n" if getattr(chat, "scam", None): caption += "⚠ Scam: Yes\n" if getattr(chat, "verified", None): caption += f"✅ Verified by Telegram: Yes\n\n" if full.about: caption += f"🗒 Description: \n{full.about}\n" return chat_photo, caption