File size: 7,217 Bytes
618430a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# 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
# <https://github.com/TeamUltroid/pyUltroid/blob/main/LICENSE>.
# -----------------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 = "<b>Yes</b>" 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 = "โน๏ธ <b>[<u>CHAT INFO</u>]</b>\n"
caption += f"๐ <b>ID:</b> <code>{chat.id}</code>\n"
if chat_title is not None:
caption += f"๐ <b>{chat_type} name:</b> <code>{chat_title}</code>\n"
if chat.username:
caption += f"๐ <b>Link:</b> @{chat.username}\n"
else:
caption += f"๐ณ <b>{chat_type} type:</b> Private\n"
if creator_username:
caption += f"๐ <b>Creator:</b> {creator_username}\n"
elif creator_valid:
caption += f'๐ <b>Creator:</b> <a href="tg://user?id={creator_id}">{creator_firstname}</a>\n'
if created:
caption += f"๐ <b>Created:</b> <code>{created.date().strftime('%b %d, %Y')} - {created.time()}</code>\n"
else:
caption += f"๐ <b>Created:</b> <code>{chat.date.date().strftime('%b %d, %Y')} - {chat.date.time()}</code> โ \n"
caption += f"๐ก <b>Data Centre ID:</b> {dc_id}\n"
if exp_count is not None:
chat_level = int((1 + math.sqrt(1 + 7 * exp_count / 14)) / 2)
caption += f"โญ๏ธ <b>{chat_type} level:</b> <code>{chat_level}</code>\n"
if messages_viewable is not None:
caption += f"๐ฌ <b>Viewable messages:</b> <code>{messages_viewable}</code>\n"
if messages_sent:
caption += f"๐ฌ <b>Messages sent:</b> <code>{messages_sent}</code>\n"
elif messages_sent_alt:
caption += f"๐ฌ <b>Messages sent:</b> <code>{messages_sent_alt}</code> โ \n"
if members is not None:
caption += f"๐ฅ <b>Members:</b> <code>{members}</code>\n"
if admins:
caption += f"๐ฎ <b>Administrators:</b> <code>{admins}</code>\n"
if full.bot_info:
caption += f"๐ค <b>Bots:</b> <code>{len(full.bot_info)}</code>\n"
if members_online:
caption += f"๐ <b>Currently online:</b> <code>{members_online}</code>\n"
if restricted_users is not None:
caption += f"๐ <b>Restricted users:</b> <code>{restricted_users}</code>\n"
if banned_users:
caption += f"๐จ <b>Banned users:</b> <code>{banned_users}</code>\n"
if group_stickers:
caption += f'๐น <b>{chat_type} stickers:</b> <a href="t.me/addstickers/{full.stickerset.short_name}">{group_stickers}</a>\n'
if not broadcast:
if getattr(chat, "slowmode_enabled", None):
caption += f"๐ <b>Slow mode:</b> <code>True</code>"
caption += f", ๐ <code>{full.slowmode_seconds}s</code>\n"
else:
caption += f"๐ฆธโโ <b>Supergroup:</b> {supergroup}\n"
if getattr(chat, "restricted", None):
caption += f"๐ <b>Restricted:</b> {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 += "โ <b>Scam:</b> <b>Yes</b>\n"
if getattr(chat, "verified", None):
caption += f"โ
<b>Verified by Telegram:</b> <code>Yes</code>\n\n"
if full.about:
caption += f"๐ <b>Description:</b> \n<code>{full.about}</code>\n"
return chat_photo, caption
|