Captain Ezio commited on
Commit
83b0433
Β·
1 Parent(s): 277bcfe

Change in `info.py` file

Browse files
Files changed (1) hide show
  1. Powers/plugins/info.py +25 -18
Powers/plugins/info.py CHANGED
@@ -1,4 +1,5 @@
1
  import os
 
2
  from pyrogram import enums
3
  from datetime import datetime
4
  from traceback import format_exc
@@ -97,13 +98,13 @@ async def user_info(c: Gojo, user, already=False):
97
  last_date = "User is currently online"
98
 
99
  caption = f"""
100
- <b><i><u>⚑ Extracted User info From Telegram ⚑</b></i></u>
101
 
102
- <b>πŸ†”οΈ User ID</b>: <code>{user_id}</code>
103
  <b>πŸ“Ž Link To Profile</b>: <a href='tg://user?id={user_id}'>Click HereπŸšͺ</a>
104
- <b>πŸ—£οΈ Mention</b>: {mention}
105
- <b>πŸ—£οΈ First Name</b>: <code>{first_name}</code>
106
- <b>πŸ—£οΈ Second Name</b>: <code>{last_name}</code>
107
  <b>πŸ” Username</b>: {("@" + username) if username else "NA"}
108
  <b>πŸ₯Έ Support</b>: {is_support}
109
  <b>πŸ€“ Support user type</b>: <code>{omp}</code>
@@ -204,11 +205,14 @@ async def info_func(c: Gojo, message: Message):
204
  return await m.edit(str(e))
205
 
206
  if not photo_id:
207
- return await m.edit(info_caption, disable_web_page_preview=True)
208
- photo = await Gojo.download_media(photo_id)
 
 
209
 
210
- await message.reply_photo(photo, caption=info_caption, quote=False)
211
  await m.delete()
 
 
212
  os.remove(photo)
213
  LOGGER.info(
214
  f"{message.from_user.id} fetched user info of user {user_name} in {m.chat.id}"
@@ -226,12 +230,12 @@ async def chat_info_func(c: Gojo, message: Message):
226
  chat = splited[1]
227
 
228
  try:
229
- if chat.isnumeric():
230
- chat = int(chat)
231
- except Exception as e:
232
- return await message.reply_text(
233
- f"Got and exception {e}\n**Usage:**/chinfo [USERNAME|ID]"
234
- )
235
 
236
  m = await message.reply_text(
237
  f"Fetching chat info of chat **{message.chat.title}**....."
@@ -239,15 +243,18 @@ async def chat_info_func(c: Gojo, message: Message):
239
 
240
  info_caption, photo_id = await chat_info(c, chat=chat)
241
  if not photo_id:
242
- return await m.edit(info_caption, disable_web_page_preview=True)
 
 
243
 
244
- photo = await Gojo.download_media(photo_id)
 
 
245
  await message.reply_photo(photo, caption=info_caption, quote=False)
246
  LOGGER.info(
247
  f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}"
248
  )
249
 
250
- await m.delete()
251
  os.remove(photo)
252
  except Exception as e:
253
  await message.reply_text(text=e)
@@ -266,4 +273,4 @@ __HELP__ = """
266
 
267
  β€’ /info - To get info about the user
268
  β€’ /chinfo - To get info about the chat
269
- """
 
1
  import os
2
+ from asyncio import sleep
3
  from pyrogram import enums
4
  from datetime import datetime
5
  from traceback import format_exc
 
98
  last_date = "User is currently online"
99
 
100
  caption = f"""
101
+ <b><i><u>⚑️ Extracted User info From Telegram ⚑️</b></i></u>
102
 
103
+ <b>πŸ†” User ID</b>: <code>{user_id}</code>
104
  <b>πŸ“Ž Link To Profile</b>: <a href='tg://user?id={user_id}'>Click HereπŸšͺ</a>
105
+ <b>πŸ—£ Mention</b>: {mention}
106
+ <b>πŸ—£ First Name</b>: <code>{first_name}</code>
107
+ <b>πŸ—£ Second Name</b>: <code>{last_name}</code>
108
  <b>πŸ” Username</b>: {("@" + username) if username else "NA"}
109
  <b>πŸ₯Έ Support</b>: {is_support}
110
  <b>πŸ€“ Support user type</b>: <code>{omp}</code>
 
205
  return await m.edit(str(e))
206
 
207
  if not photo_id:
208
+ await m.delete()
209
+ sleep(2)
210
+ return await message.reply_text(info_caption, disable_web_page_preview=True)
211
+ photo = await c.download_media(photo_id)
212
 
 
213
  await m.delete()
214
+ sleep(2)
215
+ await message.reply_photo(photo, caption=info_caption, quote=False)
216
  os.remove(photo)
217
  LOGGER.info(
218
  f"{message.from_user.id} fetched user info of user {user_name} in {m.chat.id}"
 
230
  chat = splited[1]
231
 
232
  try:
233
+ chat = int(chat)
234
+ except (ValueError, Exception) as ef:
235
+ if "invalid literal for int() with base 10:" in str(ef):
236
+ chat = str(chat)
237
+ else:
238
+ return await message.reply_text(f"Got and exception {e}\n**Usage:**/chinfo [USERNAME|ID]")
239
 
240
  m = await message.reply_text(
241
  f"Fetching chat info of chat **{message.chat.title}**....."
 
243
 
244
  info_caption, photo_id = await chat_info(c, chat=chat)
245
  if not photo_id:
246
+ await m.delete()
247
+ sleep(2)
248
+ return await message.reply_text(info_caption, disable_web_page_preview=True)
249
 
250
+ photo = await c.download_media(photo_id)
251
+ await m.delete()
252
+ sleep(2)
253
  await message.reply_photo(photo, caption=info_caption, quote=False)
254
  LOGGER.info(
255
  f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}"
256
  )
257
 
 
258
  os.remove(photo)
259
  except Exception as e:
260
  await message.reply_text(text=e)
 
273
 
274
  β€’ /info - To get info about the user
275
  β€’ /chinfo - To get info about the chat
276
+ """