Captain Ezio commited on
Commit
28a690f
·
1 Parent(s): b6baddb

Update info.py

Browse files
Files changed (1) hide show
  1. Powers/plugins/info.py +21 -21
Powers/plugins/info.py CHANGED
@@ -1,13 +1,14 @@
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:
@@ -22,7 +23,6 @@ async def get_user_info(user, already=False):
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:
@@ -53,7 +53,7 @@ async def get_user_info(user, already=False):
53
  return [caption, photo_id]
54
 
55
 
56
- async def get_chat_info(chat, already=False):
57
  if not already:
58
  chat = await Gojo.get_chat(chat)
59
  chat_id = chat.id
@@ -87,7 +87,8 @@ async def get_chat_info(chat, already=False):
87
  return [caption, photo_id]
88
 
89
 
90
- @Gojo.on_message(command("info"))
 
91
  async def info_func(_, message: Message):
92
  if message.reply_to_message:
93
  user = message.reply_to_message.from_user.id
@@ -99,29 +100,29 @@ async def info_func(_, message: Message):
99
  m = await message.reply_text(f"Fetching user info of user {user}...")
100
 
101
  try:
102
- info_caption, photo_id = await get_user_info(user)
 
103
  except Exception as e:
 
 
104
  return await m.edit(str(e))
105
 
106
  if not photo_id:
107
- return await m.edit(
108
- info_caption, disable_web_page_preview=True
109
- )
110
  photo = await Gojo.download_media(photo_id)
111
 
112
- await message.reply_photo(
113
- photo, caption=info_caption, quote=False
114
- )
115
  await m.delete()
116
  os.remove(photo)
 
117
 
118
 
119
- @Gojo.on_message(command("chinfo"))
120
  async def chat_info_func(_, message: Message):
121
  try:
122
  if len(message.command) > 2:
123
  return await message.reply_text(
124
- "**Usage:**chinfo <chat id/username>"
125
  )
126
 
127
  if len(message.command) == 1:
@@ -131,21 +132,20 @@ async def chat_info_func(_, message: Message):
131
 
132
  m = await message.reply_text(f"Fetching chat info of chat {chat}.....")
133
 
134
- info_caption, photo_id = await get_chat_info(chat)
135
  if not photo_id:
136
- return await m.edit(
137
- info_caption, disable_web_page_preview=True
138
- )
139
 
140
  photo = await Gojo.download_media(photo_id)
141
- await message.reply_photo(
142
- photo, caption=info_caption, quote=False
143
- )
144
 
145
  await m.delete()
146
  os.remove(photo)
147
  except Exception as e:
148
  await m.edit(e)
 
 
149
 
150
  __PLUGIN__ = "info"
151
  __alt_name__ = [
 
1
  import os
2
+ from traceback import format_exc
3
 
4
  from pyrogram.types import Message
5
 
6
+ from Powers import DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF, LOGGER
7
  from Powers.bot_class import Gojo
8
  from Powers.utils.custom_filters import command
9
 
10
 
11
+ async def info(user, already=False):
12
  if not already:
13
  user = await Gojo.get_users(user)
14
  if not user.first_name:
 
23
  if user_id in SUPPORT_STAFF:
24
  if user_id in DEV_USERS:
25
  omp = "User is in devs' list"
 
26
  elif user_id in SUDO_USERS:
27
  omp = "User is in sudo users' list"
28
  elif user_id in WHITELIST_USERS:
 
53
  return [caption, photo_id]
54
 
55
 
56
+ async def chat_info(chat, already=False):
57
  if not already:
58
  chat = await Gojo.get_chat(chat)
59
  chat_id = chat.id
 
87
  return [caption, photo_id]
88
 
89
 
90
+
91
+ @Gojo.on_message(command("info") & ~filters.edited)
92
  async def info_func(_, message: Message):
93
  if message.reply_to_message:
94
  user = message.reply_to_message.from_user.id
 
100
  m = await message.reply_text(f"Fetching user info of user {user}...")
101
 
102
  try:
103
+ info_caption, photo_id = await info(user)
104
+ LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {user} in {m.chat.id}")
105
  except Exception as e:
106
+ LOGGER.error(e)
107
+ LOGGER.error(format_exc())
108
  return await m.edit(str(e))
109
 
110
  if not photo_id:
111
+ return await m.edit(info_caption, disable_web_page_preview=True)
 
 
112
  photo = await Gojo.download_media(photo_id)
113
 
114
+ await message.reply_photo(photo, caption=info_caption, quote=False)
 
 
115
  await m.delete()
116
  os.remove(photo)
117
+ LOGGER.info(f"{message.from_user.id} fetched user info of user {user} in {m.chat.id}")
118
 
119
 
120
+ @Gojo.on_message(command("chinfo") & ~filters.edited)
121
  async def chat_info_func(_, message: Message):
122
  try:
123
  if len(message.command) > 2:
124
  return await message.reply_text(
125
+ "**Usage:**/chat_info [USERNAME|ID]"
126
  )
127
 
128
  if len(message.command) == 1:
 
132
 
133
  m = await message.reply_text(f"Fetching chat info of chat {chat}.....")
134
 
135
+ info_caption, photo_id = await chat_info(chat)
136
  if not photo_id:
137
+ return await m.edit(info_caption, disable_web_page_preview=True)
 
 
138
 
139
  photo = await Gojo.download_media(photo_id)
140
+ await message.reply_photo(photo, caption=info_caption, quote=False)
141
+ LOGGER.info(f"{message.from_user.id} fetched chat info of user {chat} in {m.chat.id}")
 
142
 
143
  await m.delete()
144
  os.remove(photo)
145
  except Exception as e:
146
  await m.edit(e)
147
+ LOGGER.error(e)
148
+ LOGGER.error(format_exc())
149
 
150
  __PLUGIN__ = "info"
151
  __alt_name__ = [