iamgojoof6eyes commited on
Commit
dfdebb3
·
1 Parent(s): b7d0333

Looks good

Browse files
Files changed (2) hide show
  1. Powers/__init__.py +2 -2
  2. Powers/plugins/info.py +16 -25
Powers/__init__.py CHANGED
@@ -101,12 +101,12 @@ async def load_cmds(all_plugins):
101
  LOGGER.warning(f"Not loading '{single}' s it's added in NO_LOAD list")
102
  continue
103
 
104
- imported_module = imp_mod("Powers.plugins." + single)
105
  if not hasattr(imported_module, "__PLUGIN__"):
106
  continue
107
 
108
  plugin_name = imported_module.__PLUGIN__.lower()
109
- plugin_dict_name = f"plugins.{plugin_name}.main"
110
  plugin_help = imported_module.__HELP__
111
 
112
  if plugin_dict_name in HELP_COMMANDS:
 
101
  LOGGER.warning(f"Not loading '{single}' s it's added in NO_LOAD list")
102
  continue
103
 
104
+ imported_module = imp_mod(f"Powers.plugins.{single}")
105
  if not hasattr(imported_module, "__PLUGIN__"):
106
  continue
107
 
108
  plugin_name = imported_module.__PLUGIN__.lower()
109
+ plugin_dict_name = f"plugins.{plugin_name}"
110
  plugin_help = imported_module.__HELP__
111
 
112
  if plugin_dict_name in HELP_COMMANDS:
Powers/plugins/info.py CHANGED
@@ -43,15 +43,16 @@ def change(
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"
@@ -101,7 +102,7 @@ async def user_info(c: Gojo, user, already=False):
101
  "ID": user_id,
102
  "DC": dc_id,
103
  "Name": [first_name],
104
- "Username": [("@" + username) if username else None],
105
  "Mention": [mention],
106
  "Support": is_support,
107
  "Support user type": [omp],
@@ -117,7 +118,7 @@ async def user_info(c: Gojo, user, already=False):
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
@@ -151,20 +152,10 @@ async def chat_info(c: Gojo, chat, already=False):
151
 
152
  @Gojo.on_message(command(["info","whois"]))
153
  async def info_func(c: Gojo, message: Message):
154
- if len(message.text.split()) == 1 and not message.reply_to_message:
155
- await message.reply_text(text="I can't info fecth of nothing!")
156
- await message.stop_propagation()
157
- elif len(message.text.split()) > 2 and not message.reply_to_message:
158
- await message.reply_text("You are not providing proper arguments.......**Usage:**/info [USERNAME|ID]....Example /info @iamgojoof6eyes")
159
- await message.stop_propagation()
160
-
161
- if message.reply_to_message and not message.reply_to_message.from_user:
162
- user = message.reply_to_message.from_user.id
163
- else:
164
- try:
165
- user, _ , _= await extract_user(c , message)
166
- except Exception as e:
167
- return await message.reply_text(f"Got an error while running extract_user function error is {e}.....Give this message in supoort group")
168
 
169
  if not user:
170
  message.reply_text("Can't find user to fetch info!")
@@ -192,19 +183,19 @@ async def info_func(c: Gojo, message: Message):
192
 
193
  @Gojo.on_message(command(["chinfo","chatinfo","chat_info"]))
194
  async def chat_info_func(c: Gojo, message: Message):
195
- splited = message.text.split()
196
  try:
197
  if len(splited) == 1:
198
  chat = message.chat.id
199
 
200
- elif len(splited) > 2:
201
- return await message.reply_text(
202
- "**Usage:**/chinfo [USERNAME|ID]"
203
- )
204
-
205
  else:
206
  chat = splited[1]
207
 
 
 
 
 
 
208
 
209
  m = await message.reply_text(f"Fetching chat info of chat **{message.chat.title}**.....")
210
 
 
43
  async def user_info(c: Gojo, user, already=False):
44
  if not already:
45
  try:
46
+ user = await 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
+ LOGGER.warning(f"Calling api to fetch info about user {user_id}")
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(user_id)
53
  if gbanned:
54
  gban=True
55
+ reason = f"The user is gbanned because {reason_gban}"
56
  else:
57
  gban=False
58
  reason = "User is not gbanned"
 
102
  "ID": user_id,
103
  "DC": dc_id,
104
  "Name": [first_name],
105
+ "Username": [("@" + username) if username else "NA"],
106
  "Mention": [mention],
107
  "Support": is_support,
108
  "Support user type": [omp],
 
118
 
119
  async def chat_info(c: Gojo, chat, already=False):
120
  if not already:
121
+ chat = await c.get_chat(chat)
122
  chat_id = chat.id
123
  username = chat.username
124
  title = chat.title
 
152
 
153
  @Gojo.on_message(command(["info","whois"]))
154
  async def info_func(c: Gojo, message: Message):
155
+ try:
156
+ user, _ , _= await extract_user(c , message)
157
+ except Exception as e:
158
+ return await message.reply_text(f"Got an error while running extract_user function error is {e}.....Give this message in supoort group")
 
 
 
 
 
 
 
 
 
 
159
 
160
  if not user:
161
  message.reply_text("Can't find user to fetch info!")
 
183
 
184
  @Gojo.on_message(command(["chinfo","chatinfo","chat_info"]))
185
  async def chat_info_func(c: Gojo, message: Message):
186
+ splited = message.text.split()
187
  try:
188
  if len(splited) == 1:
189
  chat = message.chat.id
190
 
 
 
 
 
 
191
  else:
192
  chat = splited[1]
193
 
194
+ try:
195
+ chat = int(chat)
196
+ except ValueError:
197
+ return await message.reply_text("**Usage:**/chinfo [USERNAME|ID]")
198
+
199
 
200
  m = await message.reply_text(f"Fetching chat info of chat **{message.chat.title}**.....")
201