Captain Ezio commited on
Commit
42a7e92
·
1 Parent(s): bcda3eb

Update info.py

Browse files
Files changed (1) hide show
  1. Powers/plugins/info.py +37 -24
Powers/plugins/info.py CHANGED
@@ -1,10 +1,13 @@
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)
10
  if not user.first_name:
@@ -19,7 +22,7 @@ async def get_user_info(user_id, already=False):
19
  if user_id in SUPPORT_STAFF:
20
  if user_id in DEV_USERS:
21
  omp = "User is in devs' list"
22
-
23
  elif user_id in SUDO_USERS:
24
  omp = "User is in sudo users' list"
25
  elif user_id in WHITELIST_USERS:
@@ -49,7 +52,9 @@ async def get_user_info(user_id, already=False):
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)
55
  chat_id = chat.id
@@ -81,62 +86,70 @@ async def get_chat_info(chat_id, already=False):
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
127
  )
128
- LOGGER.info(f"{message.from_user.id} fetched chat info of chat {message.chat.id} in {message.chat.id}")
129
  await m.delete()
130
  os.remove(photo)
131
  except Exception as e:
132
  await m.edit(e)
133
- LOGGER.error(e)
134
- LOGGER.error(format_exc())
135
-
136
  __PLUGIN__ = "info"
137
  _DISABLE_CMDS_ = [
138
  "info",
139
  "chinfo",
140
- ]
141
- __HELP__ = """/info - to get info about an user
142
- /chinfo - to get info about a group or channel"""
 
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
  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:
 
52
  }
53
  caption = body
54
  return [caption, photo_id]
55
+
56
+
57
+ async def get_chat_info(chat, already=False):
58
  if not already:
59
  chat = await Gojo.get_chat(chat)
60
  chat_id = chat.id
 
86
  }
87
  caption = body
88
  return [caption, photo_id]
89
+
90
+
91
  @Gojo.on_message(command("info"))
92
  async def info_func(_, message: Message):
93
  if message.reply_to_message:
94
  user = message.reply_to_message.from_user.id
 
95
  elif not message.reply_to_message and len(message.command) == 1:
96
  user = message.from_user.id
 
97
  elif not message.reply_to_message and len(message.command) != 1:
98
  user = message.text.split(None, 1)[1]
 
99
 
100
  m = await message.reply_text("Processing...")
101
 
102
  try:
103
  info_caption, photo_id = await get_user_info(user)
 
 
 
104
  except Exception as e:
105
+ return await m.edit(str(e))
106
+
107
+ if not photo_id:
108
+ return await m.edit(
109
+ info_caption, disable_web_page_preview=True
110
+ )
111
+ photo = await Gojo.download_media(photo_id)
112
+
113
+ await message.reply_photo(
114
+ photo, caption=info_caption, quote=False
115
+ )
116
+ await m.delete()
117
+ os.remove(photo)
118
+
119
+
120
+ @Gojo.on_message(command("chinfo"))
121
+ async def chat_info_func(_, message: Message):
122
+ try:
123
+ if len(message.command) > 2:
124
+ return await message.reply_text(
125
+ "**Usage:**cinfo <chat id/username>"
126
  )
127
 
128
  if len(message.command) == 1:
129
  chat = message.chat.id
 
130
  elif len(message.command) == 2:
131
  chat = message.text.split(None, 1)[1]
 
132
 
133
  m = await message.reply_text("Processing your order.....")
134
 
135
  info_caption, photo_id = await get_chat_info(chat)
 
136
  if not photo_id:
137
  return await m.edit(
138
  info_caption, disable_web_page_preview=True
139
  )
140
+
141
  photo = await Gojo.download_media(photo_id)
142
  await message.reply_photo(
143
  photo, caption=info_caption, quote=False
144
  )
145
+
146
  await m.delete()
147
  os.remove(photo)
148
  except Exception as e:
149
  await m.edit(e)
150
+
 
 
151
  __PLUGIN__ = "info"
152
  _DISABLE_CMDS_ = [
153
  "info",
154
  "chinfo",
155
+ ]