Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
5896d7f
1
Parent(s):
5b650ec
Update info.py
Browse files- Powers/plugins/info.py +22 -54
Powers/plugins/info.py
CHANGED
|
@@ -9,87 +9,61 @@ from Powers.bot_class import Gojo
|
|
| 9 |
from Powers.utils.custom_filters import command
|
| 10 |
|
| 11 |
|
| 12 |
-
async def
|
| 13 |
if not already:
|
| 14 |
-
user = await
|
| 15 |
if not user.first_name:
|
| 16 |
return ["Deleted account", None]
|
| 17 |
user_id = user.id
|
| 18 |
username = user.username
|
| 19 |
first_name = user.first_name
|
| 20 |
-
mention = user.mention(
|
| 21 |
dc_id = user.dc_id
|
| 22 |
photo_id = user.photo.big_file_id if user.photo else None
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
if user_id in DEV_USERS:
|
| 26 |
-
omp = "User is in devs' list"
|
| 27 |
-
elif user_id in SUDO_USERS:
|
| 28 |
-
omp = "User is in sudo users' list"
|
| 29 |
-
elif user_id in WHITELIST_USERS:
|
| 30 |
-
omp = "User is in whitelist users' list"
|
| 31 |
-
else:
|
| 32 |
-
omp = "User is not even in SUPPORT_STAFF....."
|
| 33 |
-
is_bot = user.is_bot
|
| 34 |
-
is_fake = user.is_fake
|
| 35 |
-
status = user.status
|
| 36 |
-
if status == "offline":
|
| 37 |
-
last_date = user.last_online_date
|
| 38 |
-
else:
|
| 39 |
-
last_date = "User is currently online"
|
| 40 |
body = {
|
| 41 |
"ID": user_id,
|
| 42 |
"DC": dc_id,
|
| 43 |
"Name": [first_name],
|
| 44 |
-
"Username": [("@" + username) if username else
|
| 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
|
| 58 |
if not already:
|
| 59 |
-
chat = await
|
| 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
|
| 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
|
| 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 |
-
|
| 92 |
-
@Gojo.on_message(command("info") & ~filters.edited)
|
| 93 |
async def info_func(_, message: Message):
|
| 94 |
if message.reply_to_message:
|
| 95 |
user = message.reply_to_message.from_user.id
|
|
@@ -98,27 +72,23 @@ async def info_func(_, message: Message):
|
|
| 98 |
elif not message.reply_to_message and len(message.command) != 1:
|
| 99 |
user = message.text.split(None, 1)[1]
|
| 100 |
|
| 101 |
-
m = await message.reply_text(
|
| 102 |
|
| 103 |
try:
|
| 104 |
-
info_caption, photo_id = await
|
| 105 |
-
LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {user} in {m.chat.id}")
|
| 106 |
except Exception as e:
|
| 107 |
-
LOGGER.error(e)
|
| 108 |
-
LOGGER.error(format_exc())
|
| 109 |
return await m.edit(str(e))
|
| 110 |
|
| 111 |
if not photo_id:
|
| 112 |
return await m.edit(info_caption, disable_web_page_preview=True)
|
| 113 |
-
photo = await
|
| 114 |
|
| 115 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 116 |
await m.delete()
|
| 117 |
os.remove(photo)
|
| 118 |
-
LOGGER.info(f"{message.from_user.id} fetched user info of user {user} in {m.chat.id}")
|
| 119 |
|
| 120 |
|
| 121 |
-
@
|
| 122 |
async def chat_info_func(_, message: Message):
|
| 123 |
try:
|
| 124 |
if len(message.command) > 2:
|
|
@@ -131,23 +101,21 @@ async def chat_info_func(_, message: Message):
|
|
| 131 |
elif len(message.command) == 2:
|
| 132 |
chat = message.text.split(None, 1)[1]
|
| 133 |
|
| 134 |
-
m = await message.reply_text(
|
| 135 |
|
| 136 |
-
info_caption, photo_id = await
|
| 137 |
if not photo_id:
|
| 138 |
return await m.edit(info_caption, disable_web_page_preview=True)
|
| 139 |
|
| 140 |
-
photo = await
|
| 141 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 142 |
-
LOGGER.info(f"{message.from_user.id} fetched chat info of user {chat} in {m.chat.id}")
|
| 143 |
|
| 144 |
await m.delete()
|
| 145 |
os.remove(photo)
|
| 146 |
except Exception as e:
|
| 147 |
await m.edit(e)
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
__PLUGIN__ = "info"
|
| 152 |
__alt_name__ = [
|
| 153 |
"info",
|
|
|
|
| 9 |
from Powers.utils.custom_filters import command
|
| 10 |
|
| 11 |
|
| 12 |
+
async def get_user_info(user, already=False):
|
| 13 |
if not already:
|
| 14 |
+
user = await app.get_users(user)
|
| 15 |
if not user.first_name:
|
| 16 |
return ["Deleted account", None]
|
| 17 |
user_id = user.id
|
| 18 |
username = user.username
|
| 19 |
first_name = user.first_name
|
| 20 |
+
mention = user.mention("Link")
|
| 21 |
dc_id = user.dc_id
|
| 22 |
photo_id = user.photo.big_file_id if user.photo else None
|
| 23 |
+
|
| 24 |
+
karma = await user_global_karma(user_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
body = {
|
| 26 |
"ID": user_id,
|
| 27 |
"DC": dc_id,
|
| 28 |
"Name": [first_name],
|
| 29 |
+
"Username": [("@" + username) if username else "Null"],
|
| 30 |
"Mention": [mention],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
+
caption = section("User info", body)
|
| 33 |
return [caption, photo_id]
|
| 34 |
|
| 35 |
|
| 36 |
+
async def get_chat_info(chat, already=False):
|
| 37 |
if not already:
|
| 38 |
+
chat = await app.get_chat(chat)
|
| 39 |
chat_id = chat.id
|
| 40 |
username = chat.username
|
| 41 |
title = chat.title
|
| 42 |
type_ = chat.type
|
| 43 |
is_scam = chat.is_scam
|
|
|
|
| 44 |
description = chat.description
|
| 45 |
members = chat.members_count
|
| 46 |
is_restricted = chat.is_restricted
|
| 47 |
+
link = f"[Link](t.me/{username})" if username else "Null"
|
| 48 |
dc_id = chat.dc_id
|
| 49 |
photo_id = chat.photo.big_file_id if chat.photo else None
|
|
|
|
| 50 |
body = {
|
| 51 |
"ID": chat_id,
|
| 52 |
"DC": dc_id,
|
| 53 |
"Type": type_,
|
| 54 |
"Name": [title],
|
| 55 |
+
"Username": [("@" + username) if username else "Null"],
|
| 56 |
"Mention": [link],
|
| 57 |
"Members": members,
|
| 58 |
"Scam": is_scam,
|
|
|
|
|
|
|
| 59 |
"Restricted": is_restricted,
|
| 60 |
"Description": [description],
|
| 61 |
}
|
| 62 |
+
caption = section("Chat info", body)
|
| 63 |
return [caption, photo_id]
|
| 64 |
|
| 65 |
|
| 66 |
+
@app.on_message(command("info") & ~filters.edited)
|
|
|
|
| 67 |
async def info_func(_, message: Message):
|
| 68 |
if message.reply_to_message:
|
| 69 |
user = message.reply_to_message.from_user.id
|
|
|
|
| 72 |
elif not message.reply_to_message and len(message.command) != 1:
|
| 73 |
user = message.text.split(None, 1)[1]
|
| 74 |
|
| 75 |
+
m = await message.reply_text("Processing")
|
| 76 |
|
| 77 |
try:
|
| 78 |
+
info_caption, photo_id = await get_user_info(user)
|
|
|
|
| 79 |
except Exception as e:
|
|
|
|
|
|
|
| 80 |
return await m.edit(str(e))
|
| 81 |
|
| 82 |
if not photo_id:
|
| 83 |
return await m.edit(info_caption, disable_web_page_preview=True)
|
| 84 |
+
photo = await app.download_media(photo_id)
|
| 85 |
|
| 86 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 87 |
await m.delete()
|
| 88 |
os.remove(photo)
|
|
|
|
| 89 |
|
| 90 |
|
| 91 |
+
@app.on_message(command("chat_info") & ~filters.edited)
|
| 92 |
async def chat_info_func(_, message: Message):
|
| 93 |
try:
|
| 94 |
if len(message.command) > 2:
|
|
|
|
| 101 |
elif len(message.command) == 2:
|
| 102 |
chat = message.text.split(None, 1)[1]
|
| 103 |
|
| 104 |
+
m = await message.reply_text("Processing")
|
| 105 |
|
| 106 |
+
info_caption, photo_id = await get_chat_info(chat)
|
| 107 |
if not photo_id:
|
| 108 |
return await m.edit(info_caption, disable_web_page_preview=True)
|
| 109 |
|
| 110 |
+
photo = await app.download_media(photo_id)
|
| 111 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
|
|
|
| 112 |
|
| 113 |
await m.delete()
|
| 114 |
os.remove(photo)
|
| 115 |
except Exception as e:
|
| 116 |
await m.edit(e)
|
| 117 |
+
|
| 118 |
+
|
|
|
|
| 119 |
__PLUGIN__ = "info"
|
| 120 |
__alt_name__ = [
|
| 121 |
"info",
|