Captain Ezio commited on
Commit
e241f2e
·
1 Parent(s): 8d04f57

Looks good

Browse files
Powers/plugins/admin.py CHANGED
@@ -2,7 +2,6 @@ from os import remove
2
  from html import escape
3
  from asyncio import sleep
4
  from pyrogram import filters
5
- from pyrogram.enums import ChatMemberStatus as CMS
6
  from Powers.vars import Config
7
  from traceback import format_exc
8
  from Powers.bot_class import Gojo
@@ -12,6 +11,7 @@ from Powers.utils.parser import mention_html
12
  from Powers.database.approve_db import Approve
13
  from Powers.database.reporting_db import Reporting
14
  from Powers.utils.extract_user import extract_user
 
15
  from Powers import LOGGER, OWNER_ID, DEV_USERS, SUPPORT_GROUP, SUPPORT_STAFF
16
  from Powers.utils.caching import (
17
  ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload)
@@ -41,8 +41,7 @@ async def adminlist_show(_, m: Message):
41
  adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
42
 
43
  bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
44
- user_admins = [i for i in admin_list if not (
45
- i[1].lower()).endswith("bot")]
46
 
47
  # format is like: (user_id, username/name,anonyamous or not)
48
  mention_users = [
 
2
  from html import escape
3
  from asyncio import sleep
4
  from pyrogram import filters
 
5
  from Powers.vars import Config
6
  from traceback import format_exc
7
  from Powers.bot_class import Gojo
 
11
  from Powers.database.approve_db import Approve
12
  from Powers.database.reporting_db import Reporting
13
  from Powers.utils.extract_user import extract_user
14
+ from pyrogram.enums import ChatMemberStatus as CMS
15
  from Powers import LOGGER, OWNER_ID, DEV_USERS, SUPPORT_GROUP, SUPPORT_STAFF
16
  from Powers.utils.caching import (
17
  ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload)
 
41
  adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
42
 
43
  bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
44
+ user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
 
45
 
46
  # format is like: (user_id, username/name,anonyamous or not)
47
  mention_users = [
Powers/plugins/approve.py CHANGED
@@ -6,8 +6,8 @@ from Powers.utils.parser import mention_html
6
  from Powers.database.approve_db import Approve
7
  from pyrogram.types import Message, CallbackQuery
8
  from Powers.utils.extract_user import extract_user
9
- from pyrogram.errors import RPCError, PeerIdInvalid, UserNotParticipant
10
  from pyrogram.enums import ChatMemberStatus as CMS
 
11
  from Powers.utils.custom_filters import command, admin_filter, owner_filter
12
 
13
 
 
6
  from Powers.database.approve_db import Approve
7
  from pyrogram.types import Message, CallbackQuery
8
  from Powers.utils.extract_user import extract_user
 
9
  from pyrogram.enums import ChatMemberStatus as CMS
10
+ from pyrogram.errors import RPCError, PeerIdInvalid, UserNotParticipant
11
  from Powers.utils.custom_filters import command, admin_filter, owner_filter
12
 
13
 
Powers/plugins/blacklist.py CHANGED
@@ -4,8 +4,8 @@ from pyrogram import filters
4
  from Powers.bot_class import Gojo
5
  from Powers.utils.kbhelpers import ikb
6
  from pyrogram.types import Message, CallbackQuery
7
- from pyrogram.enums import ChatMemberStatus as CMS
8
  from Powers.database.blacklist_db import Blacklist
 
9
  from Powers.utils.custom_filters import command, owner_filter, restrict_filter
10
 
11
 
@@ -56,8 +56,7 @@ async def add_blacklist(_, m: Message):
56
  ", ".join([f"<code>{i}</code>" for i in bl_words])
57
  + " already added in blacklist, skipped them!"
58
  )
59
- LOGGER.info(
60
- f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
61
  trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
62
  await m.reply_text(
63
  text=f"Added <code>{trigger}</code> in blacklist words!"
@@ -112,12 +111,10 @@ async def rm_blacklist(_, m: Message):
112
 
113
  if non_found_words:
114
  rep_text = (
115
- "Could not find " +
116
- ", ".join(f"<code>{i}</code>" for i in non_found_words)
117
  ) + " in blcklisted words, skipped them."
118
 
119
- LOGGER.info(
120
- f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
121
  bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
122
  await m.reply_text(
123
  text=f"Removed <b>{bl_words}</b> from blacklist words!"
@@ -152,8 +149,7 @@ async def set_bl_action(_, m: Message):
152
  await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
153
  elif len(m.text.split()) == 1:
154
  action = db.get_action()
155
- LOGGER.info(
156
- f"{m.from_user.id} checking blacklist action in {m.chat.id}")
157
  await m.reply_text(
158
  text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
159
  All blacklist modes delete the message containing blacklist word."""
 
4
  from Powers.bot_class import Gojo
5
  from Powers.utils.kbhelpers import ikb
6
  from pyrogram.types import Message, CallbackQuery
 
7
  from Powers.database.blacklist_db import Blacklist
8
+ from pyrogram.enums import ChatMemberStatus as CMS
9
  from Powers.utils.custom_filters import command, owner_filter, restrict_filter
10
 
11
 
 
56
  ", ".join([f"<code>{i}</code>" for i in bl_words])
57
  + " already added in blacklist, skipped them!"
58
  )
59
+ LOGGER.info(f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
 
60
  trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
61
  await m.reply_text(
62
  text=f"Added <code>{trigger}</code> in blacklist words!"
 
111
 
112
  if non_found_words:
113
  rep_text = (
114
+ "Could not find " + ", ".join(f"<code>{i}</code>" for i in non_found_words)
 
115
  ) + " in blcklisted words, skipped them."
116
 
117
+ LOGGER.info(f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
 
118
  bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
119
  await m.reply_text(
120
  text=f"Removed <b>{bl_words}</b> from blacklist words!"
 
149
  await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
150
  elif len(m.text.split()) == 1:
151
  action = db.get_action()
152
+ LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
 
153
  await m.reply_text(
154
  text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
155
  All blacklist modes delete the message containing blacklist word."""
Powers/plugins/disable.py CHANGED
@@ -1,9 +1,9 @@
1
  from html import escape
2
  from pyrogram import filters
3
- from pyrogram.enums import ChatMemberStatus as CMS
4
  from Powers.bot_class import Gojo
5
  from Powers import LOGGER, HELP_COMMANDS
6
  from Powers.database.disable_db import Disabling
 
7
  from pyrogram.types import (
8
  Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
9
  from Powers.utils.custom_filters import (
@@ -117,8 +117,7 @@ async def rm_alldisbl(_, m: Message):
117
  "Confirm",
118
  callback_data="enableallcmds",
119
  ),
120
- InlineKeyboardButton(
121
- "Cancel", callback_data="close_admin"),
122
  ],
123
  ],
124
  ),
 
1
  from html import escape
2
  from pyrogram import filters
 
3
  from Powers.bot_class import Gojo
4
  from Powers import LOGGER, HELP_COMMANDS
5
  from Powers.database.disable_db import Disabling
6
+ from pyrogram.enums import ChatMemberStatus as CMS
7
  from pyrogram.types import (
8
  Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
9
  from Powers.utils.custom_filters import (
 
117
  "Confirm",
118
  callback_data="enableallcmds",
119
  ),
120
+ InlineKeyboardButton("Cancel", callback_data="close_admin"),
 
121
  ],
122
  ],
123
  ),
Powers/plugins/filters.py CHANGED
@@ -7,10 +7,10 @@ from Powers.utils.kbhelpers import ikb
7
  from Powers.bot_class import LOGGER, Gojo
8
  from Powers.utils.cmd_senders import send_cmd
9
  from Powers.database.filters_db import Filters
 
10
  from Powers.utils.regex_utils import regex_searcher
11
  from Powers.utils.msg_types import Types, get_filter_type
12
  from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
13
- from pyrogram.enums import ChatMemberStatus as CMS
14
  from Powers.utils.custom_filters import command, admin_filter, owner_filter
15
  from Powers.utils.string import (
16
  parse_button, split_quotes, build_keyboard,
@@ -96,8 +96,7 @@ async def add_filter(_, m: Message):
96
  )
97
 
98
  add = db.save_filter(m.chat.id, keyword, teks, msgtype, file_id)
99
- LOGGER.info(
100
- f"{m.from_user.id} added new filter ({keyword}) in {m.chat.id}")
101
  if add:
102
  await m.reply_text(
103
  f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
@@ -121,8 +120,7 @@ async def stop_filter(_, m: Message):
121
  for keyword in act_filters:
122
  if keyword == m.text.split(None, 1)[1].lower():
123
  db.rm_filter(m.chat.id, m.text.split(None, 1)[1].lower())
124
- LOGGER.info(
125
- f"{m.from_user.id} removed filter ({keyword}) in {m.chat.id}")
126
  await m.reply_text(
127
  f"Okay, I'll stop replying to that filter and it's aliases in <b>{m.chat.title}</b>.",
128
  )
@@ -283,8 +281,7 @@ async def filters_watcher(c: Gojo, m: Message):
283
  if match:
284
  try:
285
  msgtype = await send_filter_reply(c, m, trigger)
286
- LOGGER.info(
287
- f"Replied with {msgtype} to {trigger} in {m.chat.id}")
288
  except Exception as ef:
289
  await m.reply_text(f"Error: {ef}")
290
  LOGGER.error(ef)
 
7
  from Powers.bot_class import LOGGER, Gojo
8
  from Powers.utils.cmd_senders import send_cmd
9
  from Powers.database.filters_db import Filters
10
+ from pyrogram.enums import ChatMemberStatus as CMS
11
  from Powers.utils.regex_utils import regex_searcher
12
  from Powers.utils.msg_types import Types, get_filter_type
13
  from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
 
14
  from Powers.utils.custom_filters import command, admin_filter, owner_filter
15
  from Powers.utils.string import (
16
  parse_button, split_quotes, build_keyboard,
 
96
  )
97
 
98
  add = db.save_filter(m.chat.id, keyword, teks, msgtype, file_id)
99
+ LOGGER.info(f"{m.from_user.id} added new filter ({keyword}) in {m.chat.id}")
 
100
  if add:
101
  await m.reply_text(
102
  f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
 
120
  for keyword in act_filters:
121
  if keyword == m.text.split(None, 1)[1].lower():
122
  db.rm_filter(m.chat.id, m.text.split(None, 1)[1].lower())
123
+ LOGGER.info(f"{m.from_user.id} removed filter ({keyword}) in {m.chat.id}")
 
124
  await m.reply_text(
125
  f"Okay, I'll stop replying to that filter and it's aliases in <b>{m.chat.title}</b>.",
126
  )
 
281
  if match:
282
  try:
283
  msgtype = await send_filter_reply(c, m, trigger)
284
+ LOGGER.info(f"Replied with {msgtype} to {trigger} in {m.chat.id}")
 
285
  except Exception as ef:
286
  await m.reply_text(f"Error: {ef}")
287
  LOGGER.error(ef)
Powers/plugins/greetings.py CHANGED
@@ -7,9 +7,9 @@ from pyrogram import enums, filters
7
  from Powers.utils.chat_type import chattype
8
  from Powers.database.antispam_db import GBan
9
  from Powers.database.greetings_db import Greetings
 
10
  from Powers.utils.msg_types import Types, get_wlcm_type
11
  from pyrogram.errors import RPCError, ChatAdminRequired
12
- from pyrogram.enums import ChatMemberStatus as CMS
13
  from Powers.utils.parser import mention_html, escape_markdown
14
  from pyrogram.types import Message, ChatMemberUpdated, InlineKeyboardMarkup
15
  from Powers.utils.custom_filters import command, admin_filter, bot_admin_filter
 
7
  from Powers.utils.chat_type import chattype
8
  from Powers.database.antispam_db import GBan
9
  from Powers.database.greetings_db import Greetings
10
+ from pyrogram.enums import ChatMemberStatus as CMS
11
  from Powers.utils.msg_types import Types, get_wlcm_type
12
  from pyrogram.errors import RPCError, ChatAdminRequired
 
13
  from Powers.utils.parser import mention_html, escape_markdown
14
  from pyrogram.types import Message, ChatMemberUpdated, InlineKeyboardMarkup
15
  from Powers.utils.custom_filters import command, admin_filter, bot_admin_filter
Powers/plugins/notes.py CHANGED
@@ -5,9 +5,9 @@ from traceback import format_exc
5
  from Powers.bot_class import Gojo
6
  from pyrogram import enums, filters
7
  from pyrogram.errors import RPCError
8
- from pyrogram.enums import ChatMemberStatus as CMS
9
  from Powers.utils.kbhelpers import ikb
10
  from Powers.utils.cmd_senders import send_cmd
 
11
  from Powers.utils.msg_types import Types, get_note_type
12
  from Powers.database.notes_db import Notes, NotesSettings
13
  from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
@@ -74,8 +74,7 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
74
 
75
  if priv_notes_status:
76
 
77
- note_hash = next(i[1] for i in db.get_all_notes(
78
- m.chat.id) if i[0] == note_name)
79
  await reply_text(
80
  f"Click on the button to get the note <code>{note_name}</code>",
81
  reply_markup=ikb(
@@ -301,13 +300,11 @@ async def priv_notes(_, m: Message):
301
  option = (m.text.split())[1]
302
  if option in ("on", "yes"):
303
  db_settings.set_privatenotes(chat_id, True)
304
- LOGGER.info(
305
- f"{m.from_user.id} enabled privatenotes in {m.chat.id}")
306
  msg = "Set private notes to On"
307
  elif option in ("off", "no"):
308
  db_settings.set_privatenotes(chat_id, False)
309
- LOGGER.info(
310
- f"{m.from_user.id} disabled privatenotes in {m.chat.id}")
311
  msg = "Set private notes to Off"
312
  else:
313
  msg = "Enter correct option"
@@ -315,8 +312,7 @@ async def priv_notes(_, m: Message):
315
  elif len(m.text.split()) == 1:
316
  curr_pref = db_settings.get_privatenotes(m.chat.id)
317
  msg = msg = f"Private Notes: {curr_pref}"
318
- LOGGER.info(
319
- f"{m.from_user.id} fetched privatenotes preference in {m.chat.id}")
320
  await m.reply_text(msg)
321
  else:
322
  await m.replt_text("Check help on how to use this command!")
 
5
  from Powers.bot_class import Gojo
6
  from pyrogram import enums, filters
7
  from pyrogram.errors import RPCError
 
8
  from Powers.utils.kbhelpers import ikb
9
  from Powers.utils.cmd_senders import send_cmd
10
+ from pyrogram.enums import ChatMemberStatus as CMS
11
  from Powers.utils.msg_types import Types, get_note_type
12
  from Powers.database.notes_db import Notes, NotesSettings
13
  from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
 
74
 
75
  if priv_notes_status:
76
 
77
+ note_hash = next(i[1] for i in db.get_all_notes(m.chat.id) if i[0] == note_name)
 
78
  await reply_text(
79
  f"Click on the button to get the note <code>{note_name}</code>",
80
  reply_markup=ikb(
 
300
  option = (m.text.split())[1]
301
  if option in ("on", "yes"):
302
  db_settings.set_privatenotes(chat_id, True)
303
+ LOGGER.info(f"{m.from_user.id} enabled privatenotes in {m.chat.id}")
 
304
  msg = "Set private notes to On"
305
  elif option in ("off", "no"):
306
  db_settings.set_privatenotes(chat_id, False)
307
+ LOGGER.info(f"{m.from_user.id} disabled privatenotes in {m.chat.id}")
 
308
  msg = "Set private notes to Off"
309
  else:
310
  msg = "Enter correct option"
 
312
  elif len(m.text.split()) == 1:
313
  curr_pref = db_settings.get_privatenotes(m.chat.id)
314
  msg = msg = f"Private Notes: {curr_pref}"
315
+ LOGGER.info(f"{m.from_user.id} fetched privatenotes preference in {m.chat.id}")
 
316
  await m.reply_text(msg)
317
  else:
318
  await m.replt_text("Check help on how to use this command!")
Powers/plugins/start.py CHANGED
@@ -8,8 +8,8 @@ from Powers.utils.extras import StartPic
8
  from Powers.utils.chat_type import chattype
9
  from Powers.utils.custom_filters import command
10
  from pyrogram.types import Message, CallbackQuery
11
- from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
12
  from pyrogram.enums import ChatMemberStatus as CMS
 
13
  from Powers.utils.start_utils import (
14
  gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
15
  get_private_rules)
@@ -70,8 +70,7 @@ async def start(c: Gojo, m: Message):
70
  await get_private_note(c, m, help_option)
71
  return
72
  if help_option.startswith("rules"):
73
- LOGGER.info(
74
- f"{m.from_user.id} fetched privaterules in {m.chat.id}")
75
  await get_private_rules(c, m, help_option)
76
  return
77
 
@@ -183,8 +182,7 @@ async def help_menu(_, m: Message):
183
  help_msg, help_kb = await get_help_msg(m, help_option)
184
 
185
  if not help_msg:
186
- LOGGER.error(
187
- f"No help_msg found for help_option - {help_option}!!")
188
  return
189
 
190
  LOGGER.info(
 
8
  from Powers.utils.chat_type import chattype
9
  from Powers.utils.custom_filters import command
10
  from pyrogram.types import Message, CallbackQuery
 
11
  from pyrogram.enums import ChatMemberStatus as CMS
12
+ from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
13
  from Powers.utils.start_utils import (
14
  gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
15
  get_private_rules)
 
70
  await get_private_note(c, m, help_option)
71
  return
72
  if help_option.startswith("rules"):
73
+ LOGGER.info(f"{m.from_user.id} fetched privaterules in {m.chat.id}")
 
74
  await get_private_rules(c, m, help_option)
75
  return
76
 
 
182
  help_msg, help_kb = await get_help_msg(m, help_option)
183
 
184
  if not help_msg:
185
+ LOGGER.error(f"No help_msg found for help_option - {help_option}!!")
 
186
  return
187
 
188
  LOGGER.info(
Powers/utils/custom_filters.py CHANGED
@@ -3,12 +3,12 @@ from pyrogram import enums
3
  from Powers.vars import Config
4
  from typing import List, Union
5
  from pyrogram.filters import create
6
- from pyrogram.enums import ChatMemberStatus as CMS
7
  from Powers.utils.chat_type import chattype
8
  from re import escape, compile as compile_re
9
  from Powers.database.disable_db import Disabling
10
  from pyrogram.types import Message, CallbackQuery
11
  from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
 
12
  from pyrogram.errors import RPCError, UserNotParticipant
13
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
14
 
 
3
  from Powers.vars import Config
4
  from typing import List, Union
5
  from pyrogram.filters import create
 
6
  from Powers.utils.chat_type import chattype
7
  from re import escape, compile as compile_re
8
  from Powers.database.disable_db import Disabling
9
  from pyrogram.types import Message, CallbackQuery
10
  from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
11
+ from pyrogram.enums import ChatMemberStatus as CMS
12
  from pyrogram.errors import RPCError, UserNotParticipant
13
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
14