Spaces:
Sleeping
Sleeping
File size: 8,547 Bytes
0d887f0 28a690f 3fb2204 42a7e92 0d887f0 aa46d17 42a7e92 28a690f fac74eb fa6f4d3 0d887f0 3925c05 8f3b78a 42a7e92 fa6f4d3 42a7e92 aa46d17 6adc97f fa6f4d3 0d887f0 fa6f4d3 0d2200c f1a7d0b fa6f4d3 e2a1a0a 769060e f1a7d0b 0d887f0 18c86d3 6548a6d fa6f4d3 769060e fa6f4d3 0d887f0 18c86d3 fac74eb 0d887f0 18c86d3 0d887f0 fac74eb c68d102 fac74eb c68d102 fac74eb c68d102 fac74eb 8956518 fac74eb 3fb2204 aa45406 3fb2204 aa45406 3fb2204 aa45406 3fb2204 aa45406 3fb2204 aa45406 3fb2204 fac74eb 3fb2204 18c86d3 42a7e92 fa6f4d3 0d887f0 769060e aa46d17 0d887f0 aa46d17 0d887f0 fa6f4d3 0d887f0 fac74eb 0d887f0 18c86d3 0d887f0 fac74eb 18c86d3 2cf0846 aa46d17 18c86d3 2cf0846 18c86d3 2cf0846 18c86d3 42a7e92 227a712 3925c05 769060e 3925c05 a7e8a54 6fefa14 fa6f4d3 a7e8a54 6fefa14 9969375 6fefa14 fac74eb 227a712 fa6f4d3 769060e 42a7e92 725787c 9969375 725787c 769060e 0d887f0 3972d11 0d887f0 fa6f4d3 0d887f0 28a690f 42a7e92 fac74eb 28a690f a7e8a54 42a7e92 0d887f0 c224902 fac74eb 0d887f0 a06c0e6 0d887f0 42a7e92 8a5a595 709df35 8e6421c 709df35 8e6421c 78610ac |
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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
import os
from traceback import format_exc
from datetime import datetime
from pyrogram.types import Message
from pyrogram import enums
from Powers import DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF, LOGGER
from Powers.bot_class import Gojo
from Powers.database.antispam_db import GBan
from Powers.database.users_db import Users
from Powers.utils.custom_filters import command
from Powers.utils.extract_user import extract_user
from Powers.utils.chat_type import c_type
gban_db=GBan()
async def admin_bot_count(c: Gojo, chat):
administrator = []
async for admin in c.get_chat_members(chat_id=chat, filter = enums.ChatMembersFilter.ADMINISTRATORS):
total_admin = administrator.append(admin)
bot = []
async for tbot in c.get_chat_members(chat_id=chat, filter= enums.ChatMembersFilter.BOTS):
total_bot = bot.append(tbot)
bot_admin = 0
for x in total_admin:
for y in total_bot:
if x == y:
bot_admin += 1
total_admin = len(total_admin)
total_bot = len(total_bot)
return total_bot, total_admin, bot_admin
async def user_info(c: Gojo, user, already=False):
if not already:
try:
user = Users.get_user_info(int(user)) # Try to fetch user info form database if available give key error if user is not present
user = user["_id"]
user = await c.get_users(user_ids=user)
except KeyError:
LOGGER.warning(f"Calling api to fetch info about user {user}")
user = await c.get_users(user_ids=user) # Fetch user info in traditional way if not available in db
if not user.first_name:
return ["Deleted account", None]
gbanned, reason_gban = gban_db.get_gban(user)
if gbanned:
gban=True
reason = f"The user is gbanned because {reason_gban}"
else:
gban=False
reason = "User is not gbanned"
user_id = user.id
username = user.username
first_name = user.first_name
last_name = user.last_name
mention = user.mention(f"{first_name}")
dc_id = user.dc_id
is_verified = user.is_verified
is_restricted = user.is_restricted
photo_id = user.photo.big_file_id if user.photo else None
is_support = user_id in SUPPORT_STAFF
if user_id in SUPPORT_STAFF:
if user_id in DEV_USERS:
omp = "User is dev"
elif user_id in SUDO_USERS:
omp = "User is sudoer"
elif user_id in WHITELIST_USERS:
omp = "User is in whitelist"
else:
omp = "Hmmm.......Who is that again?"
is_bot = user.is_bot
is_fake = user.is_fake
status = user.status
if is_bot is True:
last_date = "Targeted user is a bot"
elif status == "recently":
last_date = "Last seen Recently"
elif status == "within_week":
last_date = "Last seen within the last week"
elif status == "within_month":
last_date = "Last seen within the last month"
elif status == "long_time_ago":
last_date = "Last seen a long time ago or may be I am blocked by the user :("
elif status == "online":
last_date = "User is currently Online"
elif status == "offline":
last_date = datetime.fromtimestamp(user.status.date).strftime(
"%a, %d %b %Y, %H:%M:%S"
)
else:
last_date = "User is currently online"
caption = f"""
<b><i><u>β‘ Extracted User info From Telegram β‘</b></i></u>
<b>ποΈ User ID</b>: <code>{user_id}</code>
<b>π Link To Profile</b>: <a href='tg://user?id={user_id}'>Click Hereπͺ</a>
<b>π£οΈ Mention</b>: {mention}
<b>π£οΈ First Name</b>: <code>{first_name}</code>
<b>π£οΈ Second Name</b>: <code>{last_name}</code>
<b>π Username</b>: {("@" + username) if username else "NA"}
<b>π₯Έ Support</b>: {is_support}
<b>π€ Support user type</b>: <code>{omp}</code>
<b>π£ Gbanned</b>: {gban}
<b>π€ Gban reason</b>: <code>{reason}</code>
<b>π DC ID</b>: {dc_id}
<b>π§ RESTRICTED</b>: {is_restricted}
<b>β
VERIFIED</b>: {is_verified}
<b>π§ FAKE</b> : {is_fake}
<b>π€ BOT</b>: {is_bot}
<b>π Last seen</b>: <code>{last_date}</code>
"""
return caption, photo_id
async def chat_info(c: Gojo, chat, already=False):
if not already:
chat = await c.get_chat(chat)
online_mem = c.get_chat_online_count(chat)
chat_id = chat.id
username = chat.username
total_bot, total_admin, total_bot_admin = await admin_bot_count(c,chat)
title = chat.title
type_ = c_type(c, chat_id=chat)
is_scam = chat.is_scam
is_fake = chat.is_fake
description = chat.description
members = chat.members_count
is_restricted = chat.is_restricted
if is_restricted:
reasons = chat.restrictions
else:
reasons = "Chat is not restricted..."
invite_link = chat.invite_link
dc_id = chat.dc_id
photo_id = chat.photo.big_file_id if chat.photo else None
can_save = chat.has_protected_content
sticker_set = chat.sticker_set_name
linked_chat = chat.linked_chat
reactions = chat.available_reactions
caption = f"""
π° <b>CHAT INFO</b> π°
<b>π ID</b>: <code>{chat_id}</code>
<b>π Chat Title</b>: {title}
<b>β¨ Chat Type</b>: {type_}
<b>π DataCentre ID</b>: {dc_id}
<b>π Username</b>: {("@" + username) if username else "NA"}
<b>βοΈ Administrators</b>: {total_admin}
<b>π€ Bots</b>: {total_bot}
<b>βοΈ Admin π€ Bots</b>: {total_bot_admin}
<b>π¨βπ» Currently online</b>: {online_mem}
<b>π§ Scam</b>: {is_scam}
<b>π€¨ Fake</b>: {is_fake}
<b>π§ Restricted</b>: {is_restricted}
<b>π€ Reasons</b>: {reasons}
<b>π¨πΏβπ» Description: <code>{description}</code>
<b>πͺ Total members</b>: {members}
<b>π Link to the chat</b>: <a href={invite_link}>Click Hereπͺ</a>
<b>π« Can Save Content</b>: {can_save}
<b>π Sticker set</b>: {sticker_set}
<b>π Linked Chat</b>: {linked_chat if linked_chat else "Not Linked"}
<b>π₯ Reactions</b>: {reactions}
"""
return caption, photo_id
@Gojo.on_message(command(["info","whois"]))
async def info_func(c: Gojo, message: Message):
try:
user, _ , _= await extract_user(c , message)
except Exception as e:
return await message.reply_text(f"Got an error while running extract_user function error is {e}.....Give this message in supoort group")
if not user:
message.reply_text("Can't find user to fetch info!")
m = await message.reply_text(f"Fetching user info of user {message.from_user.id}...")
try:
info_caption, photo_id = await user_info(c , user=user)
LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {message.from_user.id} in {message.chat.id}")
except Exception as e:
LOGGER.error(e)
LOGGER.error(format_exc())
return await m.edit(str(e))
if not photo_id:
return await m.edit(info_caption, disable_web_page_preview=True)
photo = await Gojo.download_media(photo_id)
await message.reply_photo(photo, caption=info_caption, quote=False)
await m.delete()
os.remove(photo)
LOGGER.info(f"{message.from_user.id} fetched user info of user {user.username} in {m.chat.id}")
@Gojo.on_message(command(["chinfo","chatinfo","chat_info"]))
async def chat_info_func(c: Gojo, message: Message):
splited = message.text.split()
try:
if len(splited) == 1:
chat = message.chat.id
else:
chat = splited[1]
try:
chat = int(chat)
except ValueError:
return await message.reply_text("**Usage:**/chinfo [USERNAME|ID]")
m = await message.reply_text(f"Fetching chat info of chat **{message.chat.title}**.....")
info_caption, photo_id = await chat_info(c, chat=chat)
if not photo_id:
return await m.edit(info_caption, disable_web_page_preview=True)
photo = await Gojo.download_media(photo_id)
await message.reply_photo(photo, caption=info_caption, quote=False)
LOGGER.info(f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}")
await m.delete()
os.remove(photo)
except Exception as e:
await message.reply_text(text=e)
LOGGER.error(e)
LOGGER.error(format_exc())
__PLUGIN__ = "info"
__alt_name__ = [
"info",
"chinfo",
]
__HELP__ = """
***Information***
* /info - To get info about the user
* /chinfo - To get info about the chat
"""
|