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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
|
| 3 |
+
from pyrogram.types import Message
|
| 4 |
+
|
| 5 |
+
from Powers import (DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF)
|
| 6 |
+
from Powers.bot_class import Gojo
|
| 7 |
+
from Powers.utils.custom_filters import command
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
async def get_user_info(user, already=False):
|
| 11 |
+
if not already:
|
| 12 |
+
user = await Gojo.get_users(user)
|
| 13 |
+
if not user.first_name:
|
| 14 |
+
return ["Deleted account", None]
|
| 15 |
+
user_id = user.id
|
| 16 |
+
username = user.username
|
| 17 |
+
first_name = user.first_name
|
| 18 |
+
mention = user.mention("first_name")
|
| 19 |
+
dc_id = user.dc_id
|
| 20 |
+
photo_id = user.photo.big_file_id if user.photo else None
|
| 21 |
+
is_support = user_id in SUPPORT_STAFF
|
| 22 |
+
if user_id in SUPPORT_STAFF:
|
| 23 |
+
if user_id in DEV_USERS:
|
| 24 |
+
omp = "User is in devs' list"
|
| 25 |
+
|
| 26 |
+
elif user_id in SUDO_USERS:
|
| 27 |
+
omp = "User is in sudo users' list"
|
| 28 |
+
elif user_id in WHITELIST_USERS:
|
| 29 |
+
omp = "User is in whitelist users' list"
|
| 30 |
+
else:
|
| 31 |
+
omp = "User is not even in SUPPORT_STAFF....."
|
| 32 |
+
is_bot = user.is_bot
|
| 33 |
+
is_fake = user.is_fake
|
| 34 |
+
status = user.status
|
| 35 |
+
if status == "offline":
|
| 36 |
+
last_date = user.last_online_date
|
| 37 |
+
else:
|
| 38 |
+
last_date = "User is currently online"
|
| 39 |
+
mention = user.mention()
|
| 40 |
+
body = {
|
| 41 |
+
"ID": user_id,
|
| 42 |
+
"DC": dc_id,
|
| 43 |
+
"Name": [first_name],
|
| 44 |
+
"Username": [("@" + username) if username else None],
|
| 45 |
+
"Mention": [mention],
|
| 46 |
+
"Support": is_support,
|
| 47 |
+
"Support user type": [omp],
|
| 48 |
+
"Bot" : is_bot,
|
| 49 |
+
"Fake" : is_fake,
|
| 50 |
+
"Status" : status,
|
| 51 |
+
"Last seen" : last_date,
|
| 52 |
+
}
|
| 53 |
+
caption = body
|
| 54 |
+
return [caption, photo_id]
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
async def get_chat_info(chat, already=False):
|
| 58 |
+
if not already:
|
| 59 |
+
chat = await Gojo.get_chat(chat)
|
| 60 |
+
chat_id = chat.id
|
| 61 |
+
username = chat.username
|
| 62 |
+
title = chat.title
|
| 63 |
+
type_ = chat.type
|
| 64 |
+
is_scam = chat.is_scam
|
| 65 |
+
is_fake = chat.is_fake
|
| 66 |
+
description = chat.description
|
| 67 |
+
members = chat.members_count
|
| 68 |
+
is_restricted = chat.is_restricted
|
| 69 |
+
link = f"[Link](t.me/{username})" if username else None
|
| 70 |
+
dc_id = chat.dc_id
|
| 71 |
+
photo_id = chat.photo.big_file_id if chat.photo else None
|
| 72 |
+
can_save = chat.has_protected_content
|
| 73 |
+
body = {
|
| 74 |
+
"ID": chat_id,
|
| 75 |
+
"DC": dc_id,
|
| 76 |
+
"Type": type_,
|
| 77 |
+
"Name": [title],
|
| 78 |
+
"Username": [("@" + username) if username else None],
|
| 79 |
+
"Mention": [link],
|
| 80 |
+
"Members": members,
|
| 81 |
+
"Scam": is_scam,
|
| 82 |
+
"Fake" : is_fake,
|
| 83 |
+
"Can save content" : can_save,
|
| 84 |
+
"Restricted": is_restricted,
|
| 85 |
+
"Description": [description],
|
| 86 |
+
}
|
| 87 |
+
caption = body
|
| 88 |
+
return [caption, photo_id]
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@Gojo.on_message(command("info"))
|
| 92 |
+
async def info_func(_, message: Message):
|
| 93 |
+
if message.reply_to_message:
|
| 94 |
+
user = message.reply_to_message.from_user.id
|
| 95 |
+
elif not message.reply_to_message and len(message.command) == 1:
|
| 96 |
+
user = message.from_user.id
|
| 97 |
+
elif not message.reply_to_message and len(message.command) != 1:
|
| 98 |
+
user = message.text.split(None, 1)[1]
|
| 99 |
+
|
| 100 |
+
m = await message.reply_text("Processing...")
|
| 101 |
+
|
| 102 |
+
try:
|
| 103 |
+
info_caption, photo_id = await get_user_info(user)
|
| 104 |
+
except Exception as e:
|
| 105 |
+
return await m.edit(str(e))
|
| 106 |
+
|
| 107 |
+
if not photo_id:
|
| 108 |
+
return await m.edit(
|
| 109 |
+
info_caption, disable_web_page_preview=True
|
| 110 |
+
)
|
| 111 |
+
photo = await Gojo.download_media(photo_id)
|
| 112 |
+
|
| 113 |
+
await message.reply_photo(
|
| 114 |
+
photo, caption=info_caption, quote=False
|
| 115 |
+
)
|
| 116 |
+
await m.delete()
|
| 117 |
+
os.remove(photo)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
@Gojo.on_message(command("chinfo"))
|
| 121 |
+
async def chat_info_func(_, message: Message):
|
| 122 |
+
try:
|
| 123 |
+
if len(message.command) > 2:
|
| 124 |
+
return await message.reply_text(
|
| 125 |
+
"**Usage:**cinfo <chat id/username>"
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
if len(message.command) == 1:
|
| 129 |
+
chat = message.chat.id
|
| 130 |
+
elif len(message.command) == 2:
|
| 131 |
+
chat = message.text.split(None, 1)[1]
|
| 132 |
+
|
| 133 |
+
m = await message.reply_text("Processing your order.....")
|
| 134 |
+
|
| 135 |
+
info_caption, photo_id = await get_chat_info(chat)
|
| 136 |
+
if not photo_id:
|
| 137 |
+
return await m.edit(
|
| 138 |
+
info_caption, disable_web_page_preview=True
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
photo = await Gojo.download_media(photo_id)
|
| 142 |
+
await message.reply_photo(
|
| 143 |
+
photo, caption=info_caption, quote=False
|
| 144 |
+
)
|
| 145 |
+
|
| 146 |
+
await m.delete()
|
| 147 |
+
os.remove(photo)
|
| 148 |
+
except Exception as e:
|
| 149 |
+
await m.edit(e)
|
| 150 |
+
|
| 151 |
+
__PLUGIN__ = "info"
|
| 152 |
+
_DISABLE_CMDS_ = [
|
| 153 |
+
"info",
|
| 154 |
+
"chinfo",
|
| 155 |
+
]
|