iamgojoof6eyes commited on
Commit
fa6f4d3
·
1 Parent(s): 9969375

Looks good

Browse files
Powers/plugins/info.py CHANGED
@@ -6,10 +6,13 @@ 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
  from Powers.utils.extract_user import extract_user
11
  from Powers.utils.chat_type import c_type
12
 
 
13
 
14
  escape = "\n"
15
  empty = " "
@@ -37,11 +40,22 @@ def change(
37
  return text
38
 
39
 
40
- async def user_info(user, already=False):
41
  if not already:
42
- user = await Gojo.get_users(user_ids=user)
 
 
 
43
  if not user.first_name:
44
  return ["Deleted account", None]
 
 
 
 
 
 
 
 
45
  user_id = user.id
46
  username = user.username
47
  first_name = user.first_name
@@ -92,6 +106,8 @@ async def user_info(user, already=False):
92
  "Support": is_support,
93
  "Support user type": [omp],
94
  "Bot" : is_bot,
 
 
95
  "Fake" : is_fake,
96
  "Last seen" : [last_date],
97
  }
@@ -99,13 +115,13 @@ async def user_info(user, already=False):
99
  return [caption, photo_id]
100
 
101
 
102
- async def chat_info(chat, already=False):
103
  if not already:
104
  chat = await Gojo.get_chat(chat)
105
  chat_id = chat.id
106
  username = chat.username
107
  title = chat.title
108
- type_ = c_type(chat)
109
  is_scam = chat.is_scam
110
  is_fake = chat.is_fake
111
  description = chat.description
@@ -156,7 +172,7 @@ async def info_func(c: Gojo, message: Message):
156
  m = await message.reply_text(f"Fetching user info of user {user.username}...")
157
 
158
  try:
159
- info_caption, photo_id = await user_info(user)
160
  LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {user.username} in {m.chat.id}")
161
  except Exception as e:
162
  LOGGER.error(e)
@@ -175,7 +191,7 @@ async def info_func(c: Gojo, message: Message):
175
 
176
 
177
  @Gojo.on_message(command("chinfo"))
178
- async def chat_info_func(_, message: Message):
179
  splited = message.text.split()
180
  try:
181
  if len(splited) == 1:
@@ -192,7 +208,7 @@ async def chat_info_func(_, message: Message):
192
 
193
  m = await message.reply_text(f"Fetching chat info of chat {chat}.....")
194
 
195
- info_caption, photo_id = await chat_info(chat)
196
  if not photo_id:
197
  return await m.edit(info_caption, disable_web_page_preview=True)
198
 
 
6
 
7
  from Powers import DEV_USERS, SUDO_USERS, WHITELIST_USERS, SUPPORT_STAFF, LOGGER
8
  from Powers.bot_class import Gojo
9
+ from Powers.database.antispam_db import GBan
10
+ from Powers.database.users_db import Users
11
  from Powers.utils.custom_filters import command
12
  from Powers.utils.extract_user import extract_user
13
  from Powers.utils.chat_type import c_type
14
 
15
+ gban_db=GBan()
16
 
17
  escape = "\n"
18
  empty = " "
 
40
  return text
41
 
42
 
43
+ async def user_info(c: Gojo, user, already=False):
44
  if not already:
45
+ try:
46
+ user = Users.get_user_info(int(user_id)) # Try to fetch user info form database if available give key error if user is not present
47
+ except KeyError:
48
+ user = await Gojo.get_users(user_ids=user) # Fetch user info in traditional way if not available in db
49
  if not user.first_name:
50
  return ["Deleted account", None]
51
+ gbanned, reason_gban = gban_db.get_gban(user_id)
52
+ if gbanned:
53
+ gban=True
54
+ reason = f"The user is gbanned because{reason_gban}"
55
+ else:
56
+ gban=False
57
+ reason = "User is not gbanned"
58
+
59
  user_id = user.id
60
  username = user.username
61
  first_name = user.first_name
 
106
  "Support": is_support,
107
  "Support user type": [omp],
108
  "Bot" : is_bot,
109
+ "Gbanned": gban,
110
+ "Gban reason":[reason],
111
  "Fake" : is_fake,
112
  "Last seen" : [last_date],
113
  }
 
115
  return [caption, photo_id]
116
 
117
 
118
+ async def chat_info(c: Gojo, chat, already=False):
119
  if not already:
120
  chat = await Gojo.get_chat(chat)
121
  chat_id = chat.id
122
  username = chat.username
123
  title = chat.title
124
+ type_ = c_type(c, chat_id=chat)
125
  is_scam = chat.is_scam
126
  is_fake = chat.is_fake
127
  description = chat.description
 
172
  m = await message.reply_text(f"Fetching user info of user {user.username}...")
173
 
174
  try:
175
+ info_caption, photo_id = await user_info(c , user=user)
176
  LOGGER.info(f"{message.from_user.id} tried to fetch user info of user {user.username} in {m.chat.id}")
177
  except Exception as e:
178
  LOGGER.error(e)
 
191
 
192
 
193
  @Gojo.on_message(command("chinfo"))
194
+ async def chat_info_func(c: Gojo, message: Message):
195
  splited = message.text.split()
196
  try:
197
  if len(splited) == 1:
 
208
 
209
  m = await message.reply_text(f"Fetching chat info of chat {chat}.....")
210
 
211
+ info_caption, photo_id = await chat_info(c, chat=chat)
212
  if not photo_id:
213
  return await m.edit(info_caption, disable_web_page_preview=True)
214
 
Powers/plugins/utils.py CHANGED
@@ -18,7 +18,6 @@ from pyrogram.types import Message,InlineKeyboardButton, InlineKeyboardMarkup
18
 
19
  from Powers import *
20
  from Powers.bot_class import Gojo
21
- from Powers.database.antispam_db import GBan
22
  from Powers.database.users_db import Users
23
  from Powers.utils.clean_file import remove_markdown_and_html
24
  from Powers.utils.custom_filters import command
@@ -29,7 +28,7 @@ from Powers.utils.parser import mention_html
29
  from Powers.utils.extract_user import extract_user
30
  from Powers.vars import Config
31
 
32
- gban_db = GBan()
33
 
34
 
35
  @Gojo.on_message(command("wiki"))
 
18
 
19
  from Powers import *
20
  from Powers.bot_class import Gojo
 
21
  from Powers.database.users_db import Users
22
  from Powers.utils.clean_file import remove_markdown_and_html
23
  from Powers.utils.custom_filters import command
 
28
  from Powers.utils.extract_user import extract_user
29
  from Powers.vars import Config
30
 
31
+
32
 
33
 
34
  @Gojo.on_message(command("wiki"))
Powers/utils/chat_type.py CHANGED
@@ -24,7 +24,7 @@ async def chattype(m: Message):
24
 
25
  return ct
26
 
27
- async def c_type(chat_id):
28
  # To get chat type with chat id
29
 
30
  c = await Gojo.get_chat(chat_id)
 
24
 
25
  return ct
26
 
27
+ async def c_type(c: Gojo, chat_id):
28
  # To get chat type with chat id
29
 
30
  c = await Gojo.get_chat(chat_id)