Spaces:
Paused
Paused
Merge branch 'main' of https://github.com/iamgojoof6eyes/Gojo_Satarou
Browse files- Powers/plugins/info.py +9 -6
Powers/plugins/info.py
CHANGED
|
@@ -43,13 +43,16 @@ def change(
|
|
| 43 |
async def user_info(c: Gojo, user, already=False):
|
| 44 |
if not already:
|
| 45 |
try:
|
| 46 |
-
user =
|
|
|
|
|
|
|
| 47 |
except KeyError:
|
| 48 |
-
LOGGER.warning(f"Calling api to fetch info about user {
|
| 49 |
user = await c.get_users(user_ids=user) # Fetch user info in traditional way if not available in db
|
|
|
|
| 50 |
if not user.first_name:
|
| 51 |
return ["Deleted account", None]
|
| 52 |
-
gbanned, reason_gban = gban_db.get_gban(
|
| 53 |
if gbanned:
|
| 54 |
gban=True
|
| 55 |
reason = f"The user is gbanned because {reason_gban}"
|
|
@@ -160,11 +163,11 @@ async def info_func(c: Gojo, message: Message):
|
|
| 160 |
if not user:
|
| 161 |
message.reply_text("Can't find user to fetch info!")
|
| 162 |
|
| 163 |
-
m = await message.reply_text(f"Fetching user info of user {
|
| 164 |
|
| 165 |
try:
|
| 166 |
info_caption, photo_id = await user_info(c , user=user)
|
| 167 |
-
LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {
|
| 168 |
except Exception as e:
|
| 169 |
LOGGER.error(e)
|
| 170 |
LOGGER.error(format_exc())
|
|
@@ -205,7 +208,7 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
| 205 |
|
| 206 |
photo = await Gojo.download_media(photo_id)
|
| 207 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 208 |
-
LOGGER.info(f"{message.from_user.id} fetched chat info of chat {chat
|
| 209 |
|
| 210 |
await m.delete()
|
| 211 |
os.remove(photo)
|
|
|
|
| 43 |
async def user_info(c: Gojo, user, already=False):
|
| 44 |
if not already:
|
| 45 |
try:
|
| 46 |
+
user = Users.get_user_info(int(user)) # Try to fetch user info form database if available give key error if user is not present
|
| 47 |
+
user = user["_id"]
|
| 48 |
+
user = await c.get_users(user_ids=user)
|
| 49 |
except KeyError:
|
| 50 |
+
LOGGER.warning(f"Calling api to fetch info about user {user}")
|
| 51 |
user = await c.get_users(user_ids=user) # Fetch user info in traditional way if not available in db
|
| 52 |
+
|
| 53 |
if not user.first_name:
|
| 54 |
return ["Deleted account", None]
|
| 55 |
+
gbanned, reason_gban = gban_db.get_gban(user)
|
| 56 |
if gbanned:
|
| 57 |
gban=True
|
| 58 |
reason = f"The user is gbanned because {reason_gban}"
|
|
|
|
| 163 |
if not user:
|
| 164 |
message.reply_text("Can't find user to fetch info!")
|
| 165 |
|
| 166 |
+
m = await message.reply_text(f"Fetching user info of user {message.from_user.id}...")
|
| 167 |
|
| 168 |
try:
|
| 169 |
info_caption, photo_id = await user_info(c , user=user)
|
| 170 |
+
LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {message.from_user.id} in {message.chat.id}")
|
| 171 |
except Exception as e:
|
| 172 |
LOGGER.error(e)
|
| 173 |
LOGGER.error(format_exc())
|
|
|
|
| 208 |
|
| 209 |
photo = await Gojo.download_media(photo_id)
|
| 210 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 211 |
+
LOGGER.info(f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}")
|
| 212 |
|
| 213 |
await m.delete()
|
| 214 |
os.remove(photo)
|