Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
bcda3eb
1
Parent(s):
b8de44c
Update info.py
Browse files- Powers/plugins/info.py +9 -33
Powers/plugins/info.py
CHANGED
@@ -1,14 +1,9 @@
|
|
1 |
import os
|
2 |
-
|
3 |
from traceback import format_exc
|
4 |
-
|
5 |
from pyrogram.types import Message
|
6 |
-
|
7 |
from Powers import DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF, LOGGER
|
8 |
from Powers.bot_class import Gojo
|
9 |
from Powers.utils.custom_filters import command
|
10 |
-
|
11 |
-
|
12 |
async def get_user_info(user_id, already=False):
|
13 |
if not already:
|
14 |
user = await Gojo.get_users(user)
|
@@ -54,8 +49,6 @@ async def get_user_info(user_id, already=False):
|
|
54 |
}
|
55 |
caption = body
|
56 |
return [caption, photo_id]
|
57 |
-
|
58 |
-
|
59 |
async def get_chat_info(chat_id, already=False):
|
60 |
if not already:
|
61 |
chat = await Gojo.get_chat(chat)
|
@@ -88,62 +81,46 @@ async def get_chat_info(chat_id, already=False):
|
|
88 |
}
|
89 |
caption = body
|
90 |
return [caption, photo_id]
|
91 |
-
|
92 |
-
|
93 |
@Gojo.on_message(command("info"))
|
94 |
async def info_func(_, message: Message):
|
95 |
if message.reply_to_message:
|
|
|
96 |
user_id = message.reply_to_message.from_user.id
|
97 |
elif not message.reply_to_message and len(message.command) == 1:
|
|
|
98 |
user_id = message.from_user.id
|
99 |
elif not message.reply_to_message and len(message.command) != 1:
|
|
|
100 |
user_id = message.text.split(None, 1)[1]
|
101 |
|
102 |
m = await message.reply_text("Processing...")
|
103 |
|
104 |
try:
|
|
|
|
|
105 |
info_caption, photo_id = await get_user_info(user_id)
|
106 |
LOGGER.info(f"{message.from_user.id} fetched user info of {user_id} in {message.chat.id}")
|
107 |
except Exception as e:
|
108 |
await m.edit(str(e))
|
109 |
LOGGER.error(e)
|
110 |
-
|
111 |
-
return
|
112 |
-
|
113 |
-
if not photo_id:
|
114 |
-
return await m.edit(
|
115 |
-
info_caption, disable_web_page_preview=True
|
116 |
-
)
|
117 |
-
photo = await Gojo.download_media(photo_id)
|
118 |
-
|
119 |
-
await message.reply_photo(
|
120 |
-
photo, caption=info_caption, quote=False
|
121 |
-
)
|
122 |
-
await m.delete()
|
123 |
-
os.remove(photo)
|
124 |
-
|
125 |
-
|
126 |
-
@Gojo.on_message(command("chinfo"))
|
127 |
-
async def chat_info_func(_, message: Message):
|
128 |
-
try:
|
129 |
-
if len(message.command) > 2:
|
130 |
-
return await message.reply_text(
|
131 |
-
"**Usage:**cinfo <chat id/username>"
|
132 |
)
|
133 |
|
134 |
if len(message.command) == 1:
|
|
|
135 |
chat_id = message.chat.id
|
136 |
elif len(message.command) == 2:
|
|
|
137 |
chat_id = message.text.split(None, 1)[1]
|
138 |
|
139 |
m = await message.reply_text("Processing your order.....")
|
140 |
|
|
|
141 |
info_caption, photo_id = await get_chat_info(chat_id)
|
142 |
if not photo_id:
|
143 |
return await m.edit(
|
144 |
info_caption, disable_web_page_preview=True
|
145 |
)
|
146 |
-
|
147 |
photo = await Gojo.download_media(photo_id)
|
148 |
await message.reply_photo(
|
149 |
photo, caption=info_caption, quote=False
|
@@ -161,6 +138,5 @@ _DISABLE_CMDS_ = [
|
|
161 |
"info",
|
162 |
"chinfo",
|
163 |
]
|
164 |
-
|
165 |
__HELP__ = """/info - to get info about an user
|
166 |
/chinfo - to get info about a group or channel"""
|
|
|
1 |
import os
|
|
|
2 |
from traceback import format_exc
|
|
|
3 |
from pyrogram.types import Message
|
|
|
4 |
from Powers import DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF, LOGGER
|
5 |
from Powers.bot_class import Gojo
|
6 |
from Powers.utils.custom_filters import command
|
|
|
|
|
7 |
async def get_user_info(user_id, already=False):
|
8 |
if not already:
|
9 |
user = await Gojo.get_users(user)
|
|
|
49 |
}
|
50 |
caption = body
|
51 |
return [caption, photo_id]
|
|
|
|
|
52 |
async def get_chat_info(chat_id, already=False):
|
53 |
if not already:
|
54 |
chat = await Gojo.get_chat(chat)
|
|
|
81 |
}
|
82 |
caption = body
|
83 |
return [caption, photo_id]
|
|
|
|
|
84 |
@Gojo.on_message(command("info"))
|
85 |
async def info_func(_, message: Message):
|
86 |
if message.reply_to_message:
|
87 |
+
user = message.reply_to_message.from_user.id
|
88 |
user_id = message.reply_to_message.from_user.id
|
89 |
elif not message.reply_to_message and len(message.command) == 1:
|
90 |
+
user = message.from_user.id
|
91 |
user_id = message.from_user.id
|
92 |
elif not message.reply_to_message and len(message.command) != 1:
|
93 |
+
user = message.text.split(None, 1)[1]
|
94 |
user_id = message.text.split(None, 1)[1]
|
95 |
|
96 |
m = await message.reply_text("Processing...")
|
97 |
|
98 |
try:
|
99 |
+
info_caption, photo_id = await get_user_info(user)
|
100 |
+
LOGGER.info(f"{message.from_user.id} fetched user info of {user} in {message.chat.id}")
|
101 |
info_caption, photo_id = await get_user_info(user_id)
|
102 |
LOGGER.info(f"{message.from_user.id} fetched user info of {user_id} in {message.chat.id}")
|
103 |
except Exception as e:
|
104 |
await m.edit(str(e))
|
105 |
LOGGER.error(e)
|
106 |
+
@@ -132,13 +132,13 @@ async def chat_info_func(_, message: Message):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
)
|
108 |
|
109 |
if len(message.command) == 1:
|
110 |
+
chat = message.chat.id
|
111 |
chat_id = message.chat.id
|
112 |
elif len(message.command) == 2:
|
113 |
+
chat = message.text.split(None, 1)[1]
|
114 |
chat_id = message.text.split(None, 1)[1]
|
115 |
|
116 |
m = await message.reply_text("Processing your order.....")
|
117 |
|
118 |
+
info_caption, photo_id = await get_chat_info(chat)
|
119 |
info_caption, photo_id = await get_chat_info(chat_id)
|
120 |
if not photo_id:
|
121 |
return await m.edit(
|
122 |
info_caption, disable_web_page_preview=True
|
123 |
)
|
|
|
124 |
photo = await Gojo.download_media(photo_id)
|
125 |
await message.reply_photo(
|
126 |
photo, caption=info_caption, quote=False
|
|
|
138 |
"info",
|
139 |
"chinfo",
|
140 |
]
|
|
|
141 |
__HELP__ = """/info - to get info about an user
|
142 |
/chinfo - to get info about a group or channel"""
|