Captain Ezio commited on
Commit
c0ed2cf
·
1 Parent(s): 103c14b

`SORTED IMPORT` and minor changes

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. Powers/__init__.py +11 -9
  2. Powers/bot_class.py +8 -8
  3. Powers/database/__init__.py +2 -2
  4. Powers/database/antispam_db.py +2 -2
  5. Powers/database/approve_db.py +4 -3
  6. Powers/database/blacklist_db.py +4 -3
  7. Powers/database/chats_db.py +2 -2
  8. Powers/database/disable_db.py +6 -4
  9. Powers/database/filters_db.py +3 -2
  10. Powers/database/greetings_db.py +4 -3
  11. Powers/database/group_blacklist.py +1 -1
  12. Powers/database/notes_db.py +4 -3
  13. Powers/database/pins_db.py +2 -2
  14. Powers/database/reporting_db.py +6 -4
  15. Powers/database/rules_db.py +4 -3
  16. Powers/database/users_db.py +4 -3
  17. Powers/database/warns_db.py +12 -7
  18. Powers/plugins/admin.py +19 -16
  19. Powers/plugins/antispam.py +9 -9
  20. Powers/plugins/approve.py +11 -9
  21. Powers/plugins/bans.py +15 -14
  22. Powers/plugins/blacklist.py +13 -8
  23. Powers/plugins/botstaff.py +4 -4
  24. Powers/plugins/chat_blacklist.py +7 -6
  25. Powers/plugins/dev.py +12 -10
  26. Powers/plugins/disable.py +9 -7
  27. Powers/plugins/filters.py +19 -16
  28. Powers/plugins/formatting.py +3 -3
  29. Powers/plugins/fun.py +12 -8
  30. Powers/plugins/greetings.py +10 -10
  31. Powers/plugins/info.py +9 -16
  32. Powers/plugins/initial.py +10 -10
  33. Powers/plugins/locks.py +14 -8
  34. Powers/plugins/muting.py +12 -11
  35. Powers/plugins/notes.py +21 -16
  36. Powers/plugins/pin.py +28 -16
  37. Powers/plugins/purge.py +6 -5
  38. Powers/plugins/report.py +9 -7
  39. Powers/plugins/rules.py +11 -8
  40. Powers/plugins/start.py +20 -17
  41. Powers/plugins/stats.py +10 -10
  42. Powers/plugins/utils.py +12 -11
  43. Powers/plugins/warns.py +13 -11
  44. Powers/plugins/watchers.py +17 -14
  45. Powers/utils/admin_check.py +3 -3
  46. Powers/utils/caching.py +5 -5
  47. Powers/utils/custom_filters.py +10 -8
  48. Powers/utils/extract_user.py +3 -2
  49. Powers/utils/extras.py +2 -1
  50. Powers/utils/http_helper.py +1 -0
Powers/__init__.py CHANGED
@@ -1,12 +1,12 @@
1
- from time import time
2
  from datetime import datetime
3
- from traceback import format_exc
4
- from os import path, mkdir, environ
5
  from importlib import import_module as imp_mod
6
- from sys import exit as sysexit, stdout, version_info
7
- from logging import (
8
- INFO, WARNING, FileHandler, StreamHandler, getLogger, basicConfig)
9
-
 
 
 
10
 
11
  LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
12
  LOGDIR = f"{__name__}/logs"
@@ -103,7 +103,8 @@ async def load_cmds(all_plugins):
103
  for single in all_plugins:
104
  # If plugin in NO_LOAD, skip the plugin
105
  if single.lower() in [i.lower() for i in Config.NO_LOAD]:
106
- LOGGER.warning(f"Not loading '{single}' s it's added in NO_LOAD list")
 
107
  continue
108
 
109
  imported_module = imp_mod(f"Powers.plugins.{single}")
@@ -144,6 +145,7 @@ async def load_cmds(all_plugins):
144
  LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
145
 
146
  return (
147
- ", ".join((i.split(".")[1]).capitalize() for i in list(HELP_COMMANDS.keys()))
 
148
  + "\n"
149
  )
 
 
1
  from datetime import datetime
 
 
2
  from importlib import import_module as imp_mod
3
+ from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
4
+ getLogger)
5
+ from os import environ, mkdir, path
6
+ from sys import exit as sysexit
7
+ from sys import stdout, version_info
8
+ from time import time
9
+ from traceback import format_exc
10
 
11
  LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
12
  LOGDIR = f"{__name__}/logs"
 
103
  for single in all_plugins:
104
  # If plugin in NO_LOAD, skip the plugin
105
  if single.lower() in [i.lower() for i in Config.NO_LOAD]:
106
+ LOGGER.warning(
107
+ f"Not loading '{single}' s it's added in NO_LOAD list")
108
  continue
109
 
110
  imported_module = imp_mod(f"Powers.plugins.{single}")
 
145
  LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
146
 
147
  return (
148
+ ", ".join((i.split(".")[1]).capitalize()
149
+ for i in list(HELP_COMMANDS.keys()))
150
  + "\n"
151
  )
Powers/bot_class.py CHANGED
@@ -1,16 +1,16 @@
 
1
  from threading import RLock
2
- from Powers.vars import Config
 
3
  from aiohttp import ClientSession
 
4
  from pyrogram.raw.all import layer
 
 
 
5
  from Powers.database import MongoDB
6
- from platform import python_version
7
  from Powers.plugins import all_plugins
8
- from time import time, gmtime, strftime
9
- from pyrogram import Client, __version__
10
- from Powers import (
11
- API_ID, LOGGER, UPTIME, LOGFILE, NO_LOAD, WORKERS, API_HASH, BOT_TOKEN,
12
- LOG_DATETIME, MESSAGE_DUMP, load_cmds)
13
-
14
 
15
  INITIAL_LOCK = RLock()
16
 
 
1
+ from platform import python_version
2
  from threading import RLock
3
+ from time import gmtime, strftime, time
4
+
5
  from aiohttp import ClientSession
6
+ from pyrogram import Client, __version__
7
  from pyrogram.raw.all import layer
8
+
9
+ from Powers import (API_HASH, API_ID, BOT_TOKEN, LOG_DATETIME, LOGFILE, LOGGER,
10
+ MESSAGE_DUMP, NO_LOAD, UPTIME, WORKERS, load_cmds)
11
  from Powers.database import MongoDB
 
12
  from Powers.plugins import all_plugins
13
+ from Powers.vars import Config
 
 
 
 
 
14
 
15
  INITIAL_LOCK = RLock()
16
 
Powers/database/__init__.py CHANGED
@@ -1,8 +1,8 @@
1
  from sys import exit as exiter
 
 
2
  from pymongo import MongoClient
3
  from pymongo.errors import PyMongoError
4
- from Powers import DB_URI, LOGGER, DB_NAME
5
-
6
 
7
  try:
8
  Powers_db_client = MongoClient(DB_URI)
 
1
  from sys import exit as exiter
2
+
3
+ from Powers import DB_NAME, DB_URI, LOGGER
4
  from pymongo import MongoClient
5
  from pymongo.errors import PyMongoError
 
 
6
 
7
  try:
8
  Powers_db_client = MongoClient(DB_URI)
Powers/database/antispam_db.py CHANGED
@@ -1,7 +1,7 @@
1
- from threading import RLock
2
  from datetime import datetime
3
- from Powers.database import MongoDB
4
 
 
5
 
6
  INSERTION_LOCK = RLock()
7
  ANTISPAM_BANNED = set()
 
 
1
  from datetime import datetime
2
+ from threading import RLock
3
 
4
+ from Powers.database import MongoDB
5
 
6
  INSERTION_LOCK = RLock()
7
  ANTISPAM_BANNED = set()
Powers/database/approve_db.py CHANGED
@@ -1,7 +1,7 @@
1
- from Powers import LOGGER
2
  from threading import RLock
3
- from Powers.database import MongoDB
4
 
 
 
5
 
6
  INSERTION_LOCK = RLock()
7
 
@@ -66,7 +66,8 @@ class Approve(MongoDB):
66
  if not chat_data:
67
  new_data = {"_id": self.chat_id, "users": []}
68
  self.insert_one(new_data)
69
- LOGGER.info(f"Initialized Approve Document for chat {self.chat_id}")
 
70
  return new_data
71
  return chat_data
72
 
 
 
1
  from threading import RLock
 
2
 
3
+ from Powers import LOGGER
4
+ from Powers.database import MongoDB
5
 
6
  INSERTION_LOCK = RLock()
7
 
 
66
  if not chat_data:
67
  new_data = {"_id": self.chat_id, "users": []}
68
  self.insert_one(new_data)
69
+ LOGGER.info(
70
+ f"Initialized Approve Document for chat {self.chat_id}")
71
  return new_data
72
  return chat_data
73
 
Powers/database/blacklist_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
 
9
 
@@ -110,7 +110,8 @@ class Blacklist(MongoDB):
110
  "reason": "Automated blacklisted word: {{}}",
111
  }
112
  self.insert_one(new_data)
113
- LOGGER.info(f"Initialized Blacklist Document for chat {self.chat_id}")
 
114
  return new_data
115
  return chat_data
116
 
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
 
9
 
 
110
  "reason": "Automated blacklisted word: {{}}",
111
  }
112
  self.insert_one(new_data)
113
+ LOGGER.info(
114
+ f"Initialized Blacklist Document for chat {self.chat_id}")
115
  return new_data
116
  return chat_data
117
 
Powers/database/chats_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
 
9
 
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
 
9
 
Powers/database/disable_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
  DISABLED_CMDS = {}
9
 
@@ -146,9 +146,11 @@ class Disabling(MongoDB):
146
  "commands": [],
147
  "action": "none",
148
  }
149
- DISABLED_CMDS[self.chat_id] = {"commands": [], "action": "none"}
 
150
  self.insert_one(new_data)
151
- LOGGER.info(f"Initialized Disabling Document for chat {self.chat_id}")
 
152
  return new_data
153
  DISABLED_CMDS[self.chat_id] = chat_data
154
  return chat_data
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
  DISABLED_CMDS = {}
9
 
 
146
  "commands": [],
147
  "action": "none",
148
  }
149
+ DISABLED_CMDS[self.chat_id] = {
150
+ "commands": [], "action": "none"}
151
  self.insert_one(new_data)
152
+ LOGGER.info(
153
+ f"Initialized Disabling Document for chat {self.chat_id}")
154
  return new_data
155
  DISABLED_CMDS[self.chat_id] = chat_data
156
  return chat_data
Powers/database/filters_db.py CHANGED
@@ -1,8 +1,8 @@
1
  from threading import RLock
 
2
  from Powers.database import MongoDB
3
  from Powers.utils.msg_types import Types
4
 
5
-
6
  INSERTION_LOCK = RLock()
7
 
8
 
@@ -71,7 +71,8 @@ class Filters(MongoDB):
71
  curr = self.find_all()
72
  if curr:
73
  return len(
74
- [z for z in (i["keyword"].split("|") for i in curr) if len(z) >= 2],
 
75
  )
76
  return 0
77
 
 
1
  from threading import RLock
2
+
3
  from Powers.database import MongoDB
4
  from Powers.utils.msg_types import Types
5
 
 
6
  INSERTION_LOCK = RLock()
7
 
8
 
 
71
  curr = self.find_all()
72
  if curr:
73
  return len(
74
+ [z for z in (i["keyword"].split("|")
75
+ for i in curr) if len(z) >= 2],
76
  )
77
  return 0
78
 
Powers/database/greetings_db.py CHANGED
@@ -1,7 +1,7 @@
1
- from Powers import LOGGER
2
  from threading import RLock
3
- from Powers.database import MongoDB
4
 
 
 
5
 
6
  INSERTION_LOCK = RLock()
7
 
@@ -128,7 +128,8 @@ class Greetings(MongoDB):
128
  "goodbye": True,
129
  }
130
  self.insert_one(new_data)
131
- LOGGER.info(f"Initialized Greetings Document for chat {self.chat_id}")
 
132
  return new_data
133
  return chat_data
134
 
 
 
1
  from threading import RLock
 
2
 
3
+ from Powers import LOGGER
4
+ from Powers.database import MongoDB
5
 
6
  INSERTION_LOCK = RLock()
7
 
 
128
  "goodbye": True,
129
  }
130
  self.insert_one(new_data)
131
+ LOGGER.info(
132
+ f"Initialized Greetings Document for chat {self.chat_id}")
133
  return new_data
134
  return chat_data
135
 
Powers/database/group_blacklist.py CHANGED
@@ -1,8 +1,8 @@
1
  from threading import RLock
 
2
  from Powers.database import MongoDB
3
  from Powers.database.chats_db import Chats
4
 
5
-
6
  INSERTION_LOCK = RLock()
7
  BLACKLIST_CHATS = []
8
 
 
1
  from threading import RLock
2
+
3
  from Powers.database import MongoDB
4
  from Powers.database.chats_db import Chats
5
 
 
6
  INSERTION_LOCK = RLock()
7
  BLACKLIST_CHATS = []
8
 
Powers/database/notes_db.py CHANGED
@@ -1,10 +1,10 @@
1
- from time import time
2
  from hashlib import md5
3
  from threading import RLock
 
 
4
  from Powers.database import MongoDB
5
  from Powers.utils.msg_types import Types
6
 
7
-
8
  INSERTION_LOCK = RLock()
9
 
10
 
@@ -57,7 +57,8 @@ class Notes(MongoDB):
57
  def get_all_notes(self, chat_id: int):
58
  with INSERTION_LOCK:
59
  curr = self.find_all({"chat_id": chat_id})
60
- note_list = sorted([(note["note_name"], note["hash"]) for note in curr])
 
61
  return note_list
62
 
63
  def rm_note(self, chat_id: int, note_name: str):
 
 
1
  from hashlib import md5
2
  from threading import RLock
3
+ from time import time
4
+
5
  from Powers.database import MongoDB
6
  from Powers.utils.msg_types import Types
7
 
 
8
  INSERTION_LOCK = RLock()
9
 
10
 
 
57
  def get_all_notes(self, chat_id: int):
58
  with INSERTION_LOCK:
59
  curr = self.find_all({"chat_id": chat_id})
60
+ note_list = sorted([(note["note_name"], note["hash"])
61
+ for note in curr])
62
  return note_list
63
 
64
  def rm_note(self, chat_id: int, note_name: str):
Powers/database/pins_db.py CHANGED
@@ -1,7 +1,7 @@
1
- from Powers import LOGGER
2
  from threading import RLock
3
- from Powers.database import MongoDB
4
 
 
 
5
 
6
  INSERTION_LOCK = RLock()
7
 
 
 
1
  from threading import RLock
 
2
 
3
+ from Powers import LOGGER
4
+ from Powers.database import MongoDB
5
 
6
  INSERTION_LOCK = RLock()
7
 
Powers/database/reporting_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
 
9
 
@@ -42,9 +42,11 @@ class Reporting(MongoDB):
42
  chat_data = self.find_one({"_id": self.chat_id})
43
  if not chat_data:
44
  chat_type = self.get_chat_type()
45
- new_data = {"_id": self.chat_id, "status": True, "chat_type": chat_type}
 
46
  self.insert_one(new_data)
47
- LOGGER.info(f"Initialized Language Document for chat {self.chat_id}")
 
48
  return new_data
49
  return chat_data
50
 
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
 
9
 
 
42
  chat_data = self.find_one({"_id": self.chat_id})
43
  if not chat_data:
44
  chat_type = self.get_chat_type()
45
+ new_data = {"_id": self.chat_id,
46
+ "status": True, "chat_type": chat_type}
47
  self.insert_one(new_data)
48
+ LOGGER.info(
49
+ f"Initialized Language Document for chat {self.chat_id}")
50
  return new_data
51
  return chat_data
52
 
Powers/database/rules_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
 
9
 
@@ -68,7 +68,8 @@ class Rules(MongoDB):
68
  if not chat_data:
69
  new_data = {"_id": self.chat_id, "privrules": False, "rules": ""}
70
  self.insert_one(new_data)
71
- LOGGER.info(f"Initialized Language Document for chat {self.chat_id}")
 
72
  return new_data
73
  return chat_data
74
 
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
 
9
 
 
68
  if not chat_data:
69
  new_data = {"_id": self.chat_id, "privrules": False, "rules": ""}
70
  self.insert_one(new_data)
71
+ LOGGER.info(
72
+ f"Initialized Language Document for chat {self.chat_id}")
73
  return new_data
74
  return chat_data
75
 
Powers/database/users_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
 
9
 
@@ -67,7 +67,8 @@ class Users(MongoDB):
67
  def __ensure_in_db(self):
68
  chat_data = self.find_one({"_id": self.user_id})
69
  if not chat_data:
70
- new_data = {"_id": self.user_id, "username": "", "name": "unknown_till_now"}
 
71
  self.insert_one(new_data)
72
  LOGGER.info(f"Initialized User Document for {self.user_id}")
73
  return new_data
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
 
9
 
 
67
  def __ensure_in_db(self):
68
  chat_data = self.find_one({"_id": self.user_id})
69
  if not chat_data:
70
+ new_data = {"_id": self.user_id,
71
+ "username": "", "name": "unknown_till_now"}
72
  self.insert_one(new_data)
73
  LOGGER.info(f"Initialized User Document for {self.user_id}")
74
  return new_data
Powers/database/warns_db.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from time import time
 
2
  from Powers import LOGGER
3
- from threading import RLock
4
  from Powers.database import MongoDB
5
 
6
-
7
  INSERTION_LOCK = RLock()
8
 
9
 
@@ -89,12 +89,14 @@ class Warns(MongoDB):
89
  f"Repairing Approve Database - setting '{key}:{val}' for {data['user_id']} in {data['chat_id']}",
90
  )
91
  collection.update(
92
- {"chat_id": data["chat_id"], "user_id": data["user_id"]},
 
93
  {key: val},
94
  )
95
 
96
  def __ensure_in_db(self, user_id: int):
97
- chat_data = self.find_one({"chat_id": self.chat_id, "user_id": user_id})
 
98
  if not chat_data:
99
  new_data = {
100
  "chat_id": self.chat_id,
@@ -103,7 +105,8 @@ class Warns(MongoDB):
103
  "num_warns": 0,
104
  }
105
  self.insert_one(new_data)
106
- LOGGER.info(f"Initialized Warn Document for {user_id} in {self.chat_id}")
 
107
  return new_data
108
  return chat_data
109
 
@@ -119,9 +122,11 @@ class WarnSettings(MongoDB):
119
  def __ensure_in_db(self):
120
  chat_data = self.find_one({"_id": self.chat_id})
121
  if not chat_data:
122
- new_data = {"_id": self.chat_id, "warn_mode": "none", "warn_limit": 3}
 
123
  self.insert_one(new_data)
124
- LOGGER.info(f"Initialized Warn Settings Document for {self.chat_id}")
 
125
  return new_data
126
  return chat_data
127
 
 
1
+ from threading import RLock
2
  from time import time
3
+
4
  from Powers import LOGGER
 
5
  from Powers.database import MongoDB
6
 
 
7
  INSERTION_LOCK = RLock()
8
 
9
 
 
89
  f"Repairing Approve Database - setting '{key}:{val}' for {data['user_id']} in {data['chat_id']}",
90
  )
91
  collection.update(
92
+ {"chat_id": data["chat_id"],
93
+ "user_id": data["user_id"]},
94
  {key: val},
95
  )
96
 
97
  def __ensure_in_db(self, user_id: int):
98
+ chat_data = self.find_one(
99
+ {"chat_id": self.chat_id, "user_id": user_id})
100
  if not chat_data:
101
  new_data = {
102
  "chat_id": self.chat_id,
 
105
  "num_warns": 0,
106
  }
107
  self.insert_one(new_data)
108
+ LOGGER.info(
109
+ f"Initialized Warn Document for {user_id} in {self.chat_id}")
110
  return new_data
111
  return chat_data
112
 
 
122
  def __ensure_in_db(self):
123
  chat_data = self.find_one({"_id": self.chat_id})
124
  if not chat_data:
125
+ new_data = {"_id": self.chat_id,
126
+ "warn_mode": "none", "warn_limit": 3}
127
  self.insert_one(new_data)
128
+ LOGGER.info(
129
+ f"Initialized Warn Settings Document for {self.chat_id}")
130
  return new_data
131
  return chat_data
132
 
Powers/plugins/admin.py CHANGED
@@ -1,24 +1,26 @@
1
- from os import remove
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
8
- from Powers.utils.parser import mention_html
9
  from Powers.database.approve_db import Approve
10
  from Powers.database.reporting_db import Reporting
 
 
 
 
11
  from Powers.utils.extract_user import extract_user
12
- from pyrogram.types import Message, ChatPrivileges
13
- from pyrogram.enums import ChatType, ChatMemberStatus as CMS
14
- from Powers import LOGGER, OWNER_ID, DEV_USERS, SUPPORT_GROUP, SUPPORT_STAFF
15
- from Powers.utils.caching import (
16
- ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload)
17
- from Powers.utils.custom_filters import (
18
- DEV_LEVEL, command, admin_filter, owner_filter, promote_filter)
19
- from pyrogram.errors import (
20
- RPCError, FloodWait, RightForbidden, UserAdminInvalid, ChatAdminRequired,
21
- ChatAdminInviteRequired)
22
 
23
 
24
  @Gojo.on_message(command("adminlist"))
@@ -37,7 +39,8 @@ async def adminlist_show(_, m: Message):
37
  note = "<i>Note:</i> These are up-to-date values!"
38
  adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
39
  bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
40
- user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
 
41
  # format is like: (user_id, username/name,anonyamous or not)
42
  mention_users = [
43
  (
 
 
 
1
  from asyncio import sleep
2
+ from html import escape
3
+ from os import remove
4
  from traceback import format_exc
5
+
6
+ from Powers import DEV_USERS, LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
7
  from Powers.bot_class import Gojo
 
8
  from Powers.database.approve_db import Approve
9
  from Powers.database.reporting_db import Reporting
10
+ from Powers.utils.caching import (ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK,
11
+ admin_cache_reload)
12
+ from Powers.utils.custom_filters import (DEV_LEVEL, admin_filter, command,
13
+ owner_filter, promote_filter)
14
  from Powers.utils.extract_user import extract_user
15
+ from Powers.utils.parser import mention_html
16
+ from Powers.vars import Config
17
+ from pyrogram import filters
18
+ from pyrogram.enums import ChatMemberStatus as CMS
19
+ from pyrogram.enums import ChatType
20
+ from pyrogram.errors import (ChatAdminInviteRequired, ChatAdminRequired,
21
+ FloodWait, RightForbidden, RPCError,
22
+ UserAdminInvalid)
23
+ from pyrogram.types import ChatPrivileges, Message
 
24
 
25
 
26
  @Gojo.on_message(command("adminlist"))
 
39
  note = "<i>Note:</i> These are up-to-date values!"
40
  adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
41
  bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
42
+ user_admins = [i for i in admin_list if not (
43
+ i[1].lower()).endswith("bot")]
44
  # format is like: (user_id, username/name,anonyamous or not)
45
  mention_users = [
46
  (
Powers/plugins/antispam.py CHANGED
@@ -1,18 +1,18 @@
1
- from io import BytesIO
2
  from datetime import datetime
3
- from Powers.vars import Config
4
  from traceback import format_exc
 
 
5
  from Powers.bot_class import Gojo
6
- from pyrogram.types import Message
7
- from Powers.database.users_db import Users
8
  from Powers.database.antispam_db import GBan
9
- from Powers.utils.parser import mention_html
 
10
  from Powers.utils.custom_filters import command
11
  from Powers.utils.extract_user import extract_user
12
- from Powers.utils.clean_file import remove_markdown_and_html
13
- from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF
14
- from pyrogram.errors import PeerIdInvalid, UserIsBlocked, MessageTooLong
15
-
16
 
17
  # Initialize
18
  db = GBan()
 
 
1
  from datetime import datetime
2
+ from io import BytesIO
3
  from traceback import format_exc
4
+
5
+ from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF
6
  from Powers.bot_class import Gojo
 
 
7
  from Powers.database.antispam_db import GBan
8
+ from Powers.database.users_db import Users
9
+ from Powers.utils.clean_file import remove_markdown_and_html
10
  from Powers.utils.custom_filters import command
11
  from Powers.utils.extract_user import extract_user
12
+ from Powers.utils.parser import mention_html
13
+ from Powers.vars import Config
14
+ from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
15
+ from pyrogram.types import Message
16
 
17
  # Initialize
18
  db = GBan()
Powers/plugins/approve.py CHANGED
@@ -1,14 +1,14 @@
1
- from pyrogram import filters
2
- from Powers.bot_class import Gojo
3
- from Powers.utils.kbhelpers import ikb
4
  from Powers import LOGGER, SUPPORT_GROUP
5
- 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.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
 
14
  @Gojo.on_message(command("approve") & admin_filter)
@@ -89,7 +89,8 @@ async def disapprove_user(c: Gojo, m: Message):
89
  except UserNotParticipant:
90
  if already_approved: # If user is approved and not in chat, unapprove them.
91
  db.remove_approve(user_id)
92
- LOGGER.info(f"{user_id} disapproved in {m.chat.id} as UserNotParticipant")
 
93
  await m.reply_text("This user is not in this chat, unapproved them.")
94
  return
95
  except RPCError as ef:
@@ -159,7 +160,8 @@ async def check_approval(c: Gojo, m: Message):
159
  except Exception:
160
  return
161
  check_approve = db.check_approve(user_id)
162
- LOGGER.info(f"{m.from_user.id} checking approval of {user_id} in {m.chat.id}")
 
163
 
164
  if not user_id:
165
  await m.reply_text(
 
 
 
 
1
  from Powers import LOGGER, SUPPORT_GROUP
2
+ from Powers.bot_class import Gojo
3
  from Powers.database.approve_db import Approve
4
+ from Powers.utils.custom_filters import admin_filter, command, owner_filter
5
  from Powers.utils.extract_user import extract_user
6
+ from Powers.utils.kbhelpers import ikb
7
+ from Powers.utils.parser import mention_html
8
+ from pyrogram import filters
9
  from pyrogram.enums import ChatMemberStatus as CMS
10
+ from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
11
+ from pyrogram.types import CallbackQuery, Message
12
 
13
 
14
  @Gojo.on_message(command("approve") & admin_filter)
 
89
  except UserNotParticipant:
90
  if already_approved: # If user is approved and not in chat, unapprove them.
91
  db.remove_approve(user_id)
92
+ LOGGER.info(
93
+ f"{user_id} disapproved in {m.chat.id} as UserNotParticipant")
94
  await m.reply_text("This user is not in this chat, unapproved them.")
95
  return
96
  except RPCError as ef:
 
160
  except Exception:
161
  return
162
  check_approve = db.check_approve(user_id)
163
+ LOGGER.info(
164
+ f"{m.from_user.id} checking approval of {user_id} in {m.chat.id}")
165
 
166
  if not user_id:
167
  await m.reply_text(
Powers/plugins/bans.py CHANGED
@@ -1,21 +1,21 @@
1
  from random import choice
2
- from pyrogram import enums
3
- from Powers.vars import Config
4
  from traceback import format_exc
 
 
5
  from Powers.bot_class import Gojo
6
- from pyrogram.filters import regex
7
- from Powers.utils.parser import mention_html
8
- from Powers.utils.string import extract_time
9
- from Powers.utils.extract_user import extract_user
10
- from Powers.utils.extras import BAN_GIFS, KICK_GIFS
11
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
12
  from Powers.utils.custom_filters import command, restrict_filter
13
- from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
14
- from pyrogram.types import (
15
- Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
16
- from pyrogram.errors import (
17
- RPCError, PeerIdInvalid, RightForbidden, UserAdminInvalid,
18
- ChatAdminRequired)
 
 
 
 
 
19
 
20
 
21
  @Gojo.on_message(command("tban") & restrict_filter)
@@ -908,7 +908,8 @@ async def kickme(_, m: Message):
908
  if len(m.text.split()) >= 2:
909
  reason = m.text.split(None, 1)[1]
910
  try:
911
- LOGGER.info(f"{m.from_user.id} kickme used by {m.from_user.id} in {m.chat.id}")
 
912
  await m.chat.ban_member(m.from_user.id)
913
  txt = "Why not let me help you!"
914
  txt += f"\n<b>Reason</b>: {reason}" if reason else ""
 
1
  from random import choice
 
 
2
  from traceback import format_exc
3
+
4
+ from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
5
  from Powers.bot_class import Gojo
 
 
 
 
 
6
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
7
  from Powers.utils.custom_filters import command, restrict_filter
8
+ from Powers.utils.extract_user import extract_user
9
+ from Powers.utils.extras import BAN_GIFS, KICK_GIFS
10
+ from Powers.utils.parser import mention_html
11
+ from Powers.utils.string import extract_time
12
+ from Powers.vars import Config
13
+ from pyrogram import enums
14
+ from pyrogram.errors import (ChatAdminRequired, PeerIdInvalid, RightForbidden,
15
+ RPCError, UserAdminInvalid)
16
+ from pyrogram.filters import regex
17
+ from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
18
+ InlineKeyboardMarkup, Message)
19
 
20
 
21
  @Gojo.on_message(command("tban") & restrict_filter)
 
908
  if len(m.text.split()) >= 2:
909
  reason = m.text.split(None, 1)[1]
910
  try:
911
+ LOGGER.info(
912
+ f"{m.from_user.id} kickme used by {m.from_user.id} in {m.chat.id}")
913
  await m.chat.ban_member(m.from_user.id)
914
  txt = "Why not let me help you!"
915
  txt += f"\n<b>Reason</b>: {reason}" if reason else ""
Powers/plugins/blacklist.py CHANGED
@@ -1,12 +1,13 @@
1
  from html import escape
 
2
  from Powers import LOGGER
3
- 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 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
 
12
  @Gojo.on_message(command("blacklist") & filters.group)
@@ -56,7 +57,8 @@ 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(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,10 +113,12 @@ async def rm_blacklist(_, m: Message):
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,7 +153,8 @@ async def set_bl_action(_, m: Message):
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."""
 
1
  from html import escape
2
+
3
  from Powers import LOGGER
 
4
  from Powers.bot_class import Gojo
 
 
5
  from Powers.database.blacklist_db import Blacklist
 
6
  from Powers.utils.custom_filters import command, owner_filter, restrict_filter
7
+ from Powers.utils.kbhelpers import ikb
8
+ from pyrogram import filters
9
+ from pyrogram.enums import ChatMemberStatus as CMS
10
+ from pyrogram.types import CallbackQuery, Message
11
 
12
 
13
  @Gojo.on_message(command("blacklist") & filters.group)
 
57
  ", ".join([f"<code>{i}</code>" for i in bl_words])
58
  + " already added in blacklist, skipped them!"
59
  )
60
+ LOGGER.info(
61
+ f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
62
  trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
63
  await m.reply_text(
64
  text=f"Added <code>{trigger}</code> in blacklist words!"
 
113
 
114
  if non_found_words:
115
  rep_text = (
116
+ "Could not find " +
117
+ ", ".join(f"<code>{i}</code>" for i in non_found_words)
118
  ) + " in blcklisted words, skipped them."
119
 
120
+ LOGGER.info(
121
+ f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
122
  bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
123
  await m.reply_text(
124
  text=f"Removed <b>{bl_words}</b> from blacklist words!"
 
153
  await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
154
  elif len(m.text.split()) == 1:
155
  action = db.get_action()
156
+ LOGGER.info(
157
+ f"{m.from_user.id} checking blacklist action in {m.chat.id}")
158
  await m.reply_text(
159
  text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
160
  All blacklist modes delete the message containing blacklist word."""
Powers/plugins/botstaff.py CHANGED
@@ -1,9 +1,9 @@
 
1
  from Powers.bot_class import Gojo
2
- from pyrogram.types import Message
3
- from pyrogram.errors import RPCError
4
- from Powers.utils.parser import mention_html
5
  from Powers.utils.custom_filters import command
6
- from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS, WHITELIST_USERS
 
 
7
 
8
 
9
  @Gojo.on_message(command("botstaff", dev_cmd=True))
 
1
+ from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, WHITELIST_USERS
2
  from Powers.bot_class import Gojo
 
 
 
3
  from Powers.utils.custom_filters import command
4
+ from Powers.utils.parser import mention_html
5
+ from pyrogram.errors import RPCError
6
+ from pyrogram.types import Message
7
 
8
 
9
  @Gojo.on_message(command("botstaff", dev_cmd=True))
Powers/plugins/chat_blacklist.py CHANGED
@@ -1,11 +1,11 @@
1
- from Powers import LOGGER
2
  from traceback import format_exc
 
 
3
  from Powers.bot_class import Gojo
4
- from pyrogram.types import Message
5
- from Powers.utils.custom_filters import command
6
- from pyrogram.errors import RPCError, PeerIdInvalid
7
  from Powers.database.group_blacklist import GroupBlacklist
8
-
 
 
9
 
10
  # initialise database
11
  db = GroupBlacklist()
@@ -42,7 +42,8 @@ async def unblacklist_chat(c: Gojo, m: Message):
42
  if len(m.text.split()) >= 2:
43
  chat_ids = m.text.split()[1:]
44
  replymsg = await m.reply_text(f"Removing {len(chat_ids)} chats from blacklist")
45
- LOGGER.info(f"{m.from_user.id} removed blacklisted {chat_ids} groups for bot")
 
46
  bl_chats = db.list_all_chats()
47
  for chat in chat_ids:
48
  try:
 
 
1
  from traceback import format_exc
2
+
3
+ from Powers import LOGGER
4
  from Powers.bot_class import Gojo
 
 
 
5
  from Powers.database.group_blacklist import GroupBlacklist
6
+ from Powers.utils.custom_filters import command
7
+ from pyrogram.errors import PeerIdInvalid, RPCError
8
+ from pyrogram.types import Message
9
 
10
  # initialise database
11
  db = GroupBlacklist()
 
42
  if len(m.text.split()) >= 2:
43
  chat_ids = m.text.split()[1:]
44
  replymsg = await m.reply_text(f"Removing {len(chat_ids)} chats from blacklist")
45
+ LOGGER.info(
46
+ f"{m.from_user.id} removed blacklisted {chat_ids} groups for bot")
47
  bl_chats = db.list_all_chats()
48
  for chat in chat_ids:
49
  try:
Powers/plugins/dev.py CHANGED
@@ -1,19 +1,20 @@
1
  import sys
 
2
  from io import BytesIO, StringIO
 
3
  from traceback import format_exc
 
 
4
  from Powers.bot_class import Gojo
5
- from pyrogram.types import Message
6
- from Powers.utils.http_helper import *
7
- from time import time, gmtime, strftime
8
  from Powers.database.chats_db import Chats
 
9
  from Powers.utils.custom_filters import command
 
10
  from Powers.utils.parser import mention_markdown
11
- from Powers import LOGGER, UPTIME, LOGFILE, MESSAGE_DUMP
12
- from Powers.utils.clean_file import remove_markdown_and_html
13
- from asyncio import sleep, subprocess, create_subprocess_shell
14
- from pyrogram.errors import (
15
- RPCError, FloodWait, PeerIdInvalid, ChannelInvalid, ChannelPrivate,
16
- MessageTooLong, ChatAdminRequired, EntityBoundsInvalid)
17
 
18
 
19
  @Gojo.on_message(command("ping", sudo_cmd=True))
@@ -139,7 +140,8 @@ async def evaluate_code(c: Gojo, m: Message):
139
 
140
 
141
  async def aexec(code, c, m):
142
- exec("async def __aexec(c, m): " + "".join(f"\n {l}" for l in code.split("\n")))
 
143
  return await locals()["__aexec"](c, m)
144
 
145
 
 
1
  import sys
2
+ from asyncio import create_subprocess_shell, sleep, subprocess
3
  from io import BytesIO, StringIO
4
+ from time import gmtime, strftime, time
5
  from traceback import format_exc
6
+
7
+ from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
8
  from Powers.bot_class import Gojo
 
 
 
9
  from Powers.database.chats_db import Chats
10
+ from Powers.utils.clean_file import remove_markdown_and_html
11
  from Powers.utils.custom_filters import command
12
+ from Powers.utils.http_helper import *
13
  from Powers.utils.parser import mention_markdown
14
+ from pyrogram.errors import (ChannelInvalid, ChannelPrivate, ChatAdminRequired,
15
+ EntityBoundsInvalid, FloodWait, MessageTooLong,
16
+ PeerIdInvalid, RPCError)
17
+ from pyrogram.types import Message
 
 
18
 
19
 
20
  @Gojo.on_message(command("ping", sudo_cmd=True))
 
140
 
141
 
142
  async def aexec(code, c, m):
143
+ exec("async def __aexec(c, m): " +
144
+ "".join(f"\n {l}" for l in code.split("\n")))
145
  return await locals()["__aexec"](c, m)
146
 
147
 
Powers/plugins/disable.py CHANGED
@@ -1,13 +1,14 @@
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 (
10
- command, admin_filter, owner_filter, can_change_filter)
11
 
12
 
13
  @Gojo.on_message(command("disable") & can_change_filter)
@@ -117,7 +118,8 @@ async def rm_alldisbl(_, m: Message):
117
  "Confirm",
118
  callback_data="enableallcmds",
119
  ),
120
- InlineKeyboardButton("Cancel", callback_data="close_admin"),
 
121
  ],
122
  ],
123
  ),
 
1
  from html import escape
2
+
3
+ from Powers import HELP_COMMANDS, LOGGER
4
  from Powers.bot_class import Gojo
 
5
  from Powers.database.disable_db import Disabling
6
+ from Powers.utils.custom_filters import (admin_filter, can_change_filter,
7
+ command, owner_filter)
8
+ from pyrogram import filters
9
  from pyrogram.enums import ChatMemberStatus as CMS
10
+ from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
11
+ InlineKeyboardMarkup, Message)
 
 
12
 
13
 
14
  @Gojo.on_message(command("disable") & can_change_filter)
 
118
  "Confirm",
119
  callback_data="enableallcmds",
120
  ),
121
+ InlineKeyboardButton(
122
+ "Cancel", callback_data="close_admin"),
123
  ],
124
  ],
125
  ),
Powers/plugins/filters.py CHANGED
@@ -1,21 +1,21 @@
 
1
  from secrets import choice
2
- from pyrogram import filters
3
  from traceback import format_exc
4
- from re import escape as re_escape
5
- from pyrogram.errors import RPCError
6
- 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 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,
17
- escape_mentions_using_curly_brackets)
18
-
 
 
19
 
20
  # Initialise
21
  db = Filters()
@@ -96,7 +96,8 @@ async def add_filter(_, m: Message):
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,7 +121,8 @@ async def stop_filter(_, m: Message):
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,7 +283,8 @@ async def filters_watcher(c: Gojo, m: Message):
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)
 
1
+ from re import escape as re_escape
2
  from secrets import choice
 
3
  from traceback import format_exc
4
+
 
 
5
  from Powers.bot_class import LOGGER, Gojo
 
6
  from Powers.database.filters_db import Filters
7
+ from Powers.utils.cmd_senders import send_cmd
8
+ from Powers.utils.custom_filters import admin_filter, command, owner_filter
9
+ from Powers.utils.kbhelpers import ikb
10
  from Powers.utils.msg_types import Types, get_filter_type
11
+ from Powers.utils.regex_utils import regex_searcher
12
+ from Powers.utils.string import (build_keyboard,
13
+ escape_mentions_using_curly_brackets,
14
+ parse_button, split_quotes)
15
+ from pyrogram import filters
16
+ from pyrogram.enums import ChatMemberStatus as CMS
17
+ from pyrogram.errors import RPCError
18
+ from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, Message
19
 
20
  # Initialise
21
  db = Filters()
 
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
  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
  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)
Powers/plugins/formatting.py CHANGED
@@ -1,9 +1,9 @@
1
  from Powers import LOGGER
2
  from Powers.bot_class import Gojo
3
- from pyrogram import enums, filters
4
- from Powers.utils.kbhelpers import ikb
5
  from Powers.utils.custom_filters import command
6
- from pyrogram.types import Message, CallbackQuery
 
 
7
 
8
 
9
  async def gen_formatting_kb(m):
 
1
  from Powers import LOGGER
2
  from Powers.bot_class import Gojo
 
 
3
  from Powers.utils.custom_filters import command
4
+ from Powers.utils.kbhelpers import ikb
5
+ from pyrogram import enums, filters
6
+ from pyrogram.types import CallbackQuery, Message
7
 
8
 
9
  async def gen_formatting_kb(m):
Powers/plugins/fun.py CHANGED
@@ -1,14 +1,16 @@
1
  from html import escape
2
  from random import choice
3
- from pyrogram import enums
4
- from Powers.utils import extras
5
  from Powers.bot_class import Gojo
6
- from pyrogram.types import Message
7
- from Powers import LOGGER, DEV_USERS
8
- from pyrogram.errors import MessageTooLong
9
  from Powers.utils.custom_filters import command
10
  from Powers.utils.extract_user import extract_user
11
- from Powers.utils.extras import NOWYES as NO, YESWNO as YES
 
 
 
 
12
 
13
 
14
  @Gojo.on_message(command("shout"))
@@ -72,7 +74,8 @@ async def fun_slap(c: Gojo, m: Message):
72
  hit = choice(extras.HIT)
73
  throw = choice(extras.THROW)
74
 
75
- reply = temp.format(user1=user1, user2=user2, item=item, hits=hit, throws=throw)
 
76
  await reply_text(reply)
77
  LOGGER.info(f"{m.from_user.id} slaped in {m.chat.id}")
78
  return
@@ -111,7 +114,8 @@ async def insult(c: Gojo, m: Message):
111
  m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
112
  )
113
  await reply_text(Insult_omp)
114
- LOGGER.info(f"{m.from_user.id} insulted {user_first_name} in {m.chat.id}")
 
115
 
116
 
117
  @Gojo.on_message(command("yes"))
 
1
  from html import escape
2
  from random import choice
3
+
4
+ from Powers import DEV_USERS, LOGGER
5
  from Powers.bot_class import Gojo
6
+ from Powers.utils import extras
 
 
7
  from Powers.utils.custom_filters import command
8
  from Powers.utils.extract_user import extract_user
9
+ from Powers.utils.extras import NOWYES as NO
10
+ from Powers.utils.extras import YESWNO as YES
11
+ from pyrogram import enums
12
+ from pyrogram.errors import MessageTooLong
13
+ from pyrogram.types import Message
14
 
15
 
16
  @Gojo.on_message(command("shout"))
 
74
  hit = choice(extras.HIT)
75
  throw = choice(extras.THROW)
76
 
77
+ reply = temp.format(user1=user1, user2=user2,
78
+ item=item, hits=hit, throws=throw)
79
  await reply_text(reply)
80
  LOGGER.info(f"{m.from_user.id} slaped in {m.chat.id}")
81
  return
 
114
  m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
115
  )
116
  await reply_text(Insult_omp)
117
+ LOGGER.info(
118
+ f"{m.from_user.id} insulted {user_first_name} in {m.chat.id}")
119
 
120
 
121
  @Gojo.on_message(command("yes"))
Powers/plugins/greetings.py CHANGED
@@ -1,20 +1,20 @@
1
  from html import escape
2
  from secrets import choice
 
3
  from Powers import DEV_USERS
4
- from Powers.vars import Config
5
  from Powers.bot_class import Gojo
6
- from pyrogram import enums, filters
7
  from Powers.database.antispam_db import GBan
8
  from Powers.database.greetings_db import Greetings
9
- from pyrogram.enums import ChatMemberStatus as CMS
10
  from Powers.utils.msg_types import Types, get_wlcm_type
11
- from pyrogram.errors import RPCError, ChatAdminRequired
12
- from Powers.utils.parser import mention_html, escape_markdown
13
- from pyrogram.types import Message, ChatMemberUpdated, InlineKeyboardMarkup
14
- from Powers.utils.custom_filters import command, admin_filter, bot_admin_filter
15
- from Powers.utils.string import (
16
- parse_button, build_keyboard, escape_invalid_curly_brackets)
17
-
 
18
 
19
  # Initialize
20
  gdb = GBan()
 
1
  from html import escape
2
  from secrets import choice
3
+
4
  from Powers import DEV_USERS
 
5
  from Powers.bot_class import Gojo
 
6
  from Powers.database.antispam_db import GBan
7
  from Powers.database.greetings_db import Greetings
8
+ from Powers.utils.custom_filters import admin_filter, bot_admin_filter, command
9
  from Powers.utils.msg_types import Types, get_wlcm_type
10
+ from Powers.utils.parser import escape_markdown, mention_html
11
+ from Powers.utils.string import (build_keyboard, escape_invalid_curly_brackets,
12
+ parse_button)
13
+ from Powers.vars import Config
14
+ from pyrogram import enums, filters
15
+ from pyrogram.enums import ChatMemberStatus as CMS
16
+ from pyrogram.errors import ChatAdminRequired, RPCError
17
+ from pyrogram.types import ChatMemberUpdated, InlineKeyboardMarkup, Message
18
 
19
  # Initialize
20
  gdb = GBan()
Powers/plugins/info.py CHANGED
@@ -1,20 +1,18 @@
1
  import os
2
  from asyncio import sleep
3
- from pyrogram import enums
4
  from datetime import datetime
5
- from Powers.vars import Config
6
  from traceback import format_exc
 
 
 
7
  from Powers.bot_class import Gojo
8
- from pyrogram.types import Message
9
- from pyrogram.enums import ChatType
10
  from Powers.database.antispam_db import GBan
11
  from Powers.utils.custom_filters import command
12
  from Powers.utils.extract_user import extract_user
13
- from Powers import (
14
- LOGGER, DEV_USERS, SUDO_USERS, SUPPORT_STAFF, WHITELIST_USERS)
15
- from pyrogram.errors import (
16
- RPCError, MessageTooLong, EntityBoundsInvalid, MediaCaptionTooLong)
17
-
18
 
19
  gban_db = GBan()
20
 
@@ -189,17 +187,12 @@ async def chat_info(c: Gojo, chat, already=False):
189
 
190
  @Gojo.on_message(command(["info", "whois"]))
191
  async def info_func(c: Gojo, message: Message):
192
- try:
193
- user, _, user_name = await extract_user(c, message)
194
- except Exception as e:
195
- return await message.reply_text(
196
- f"Got an error while running extract_user function error is {e}.....Give this message in supoort group"
197
- )
198
 
199
  if not user:
200
  await message.reply_text("Can't find user to fetch info!")
201
 
202
- m = await message.reply_text(f"Fetching user info from telegram's database...")
203
 
204
  try:
205
  info_caption, photo_id = await user_info(c, user)
 
1
  import os
2
  from asyncio import sleep
 
3
  from datetime import datetime
 
4
  from traceback import format_exc
5
+
6
+ from Powers import (DEV_USERS, LOGGER, SUDO_USERS, SUPPORT_STAFF,
7
+ WHITELIST_USERS)
8
  from Powers.bot_class import Gojo
 
 
9
  from Powers.database.antispam_db import GBan
10
  from Powers.utils.custom_filters import command
11
  from Powers.utils.extract_user import extract_user
12
+ from Powers.vars import Config
13
+ from pyrogram import enums
14
+ from pyrogram.errors import EntityBoundsInvalid, MediaCaptionTooLong, RPCError
15
+ from pyrogram.types import Message
 
16
 
17
  gban_db = GBan()
18
 
 
187
 
188
  @Gojo.on_message(command(["info", "whois"]))
189
  async def info_func(c: Gojo, message: Message):
190
+ user, _, user_name = await extract_user(c, message)
 
 
 
 
 
191
 
192
  if not user:
193
  await message.reply_text("Can't find user to fetch info!")
194
 
195
+ m = await message.reply_text(f"Fetching {('@' + user_name) if user_name else 'user'} info from telegram's database...")
196
 
197
  try:
198
  info_caption, photo_id = await user_info(c, user)
Powers/plugins/initial.py CHANGED
@@ -1,19 +1,19 @@
1
  from Powers import LOGGER
2
- from pyrogram import filters
3
  from Powers.bot_class import Gojo
4
- from pyrogram.types import Message
5
- from pyrogram.errors import RPCError
6
- from Powers.database.pins_db import Pins
7
- from Powers.database.chats_db import Chats
8
- from Powers.database.rules_db import Rules
9
- from Powers.database.users_db import Users
10
  from Powers.database.approve_db import Approve
11
- from Powers.database.filters_db import Filters
12
- from Powers.database.disable_db import Disabling
13
  from Powers.database.blacklist_db import Blacklist
 
 
 
14
  from Powers.database.greetings_db import Greetings
15
- from Powers.database.reporting_db import Reporting
16
  from Powers.database.notes_db import Notes, NotesSettings
 
 
 
 
 
 
 
17
 
18
 
19
  @Gojo.on_message(filters.group, group=4)
 
1
  from Powers import LOGGER
 
2
  from Powers.bot_class import Gojo
 
 
 
 
 
 
3
  from Powers.database.approve_db import Approve
 
 
4
  from Powers.database.blacklist_db import Blacklist
5
+ from Powers.database.chats_db import Chats
6
+ from Powers.database.disable_db import Disabling
7
+ from Powers.database.filters_db import Filters
8
  from Powers.database.greetings_db import Greetings
 
9
  from Powers.database.notes_db import Notes, NotesSettings
10
+ from Powers.database.pins_db import Pins
11
+ from Powers.database.reporting_db import Reporting
12
+ from Powers.database.rules_db import Rules
13
+ from Powers.database.users_db import Users
14
+ from pyrogram import filters
15
+ from pyrogram.errors import RPCError
16
+ from pyrogram.types import Message
17
 
18
 
19
  @Gojo.on_message(filters.group, group=4)
Powers/plugins/locks.py CHANGED
@@ -1,10 +1,11 @@
1
- from Powers import LOGGER
2
  from asyncio import sleep
 
 
3
  from Powers.bot_class import Gojo
4
  from Powers.database.approve_db import Approve
5
- from pyrogram.types import Message, ChatPermissions
6
  from Powers.utils.custom_filters import command, restrict_filter
7
- from pyrogram.errors import RPCError, ChatNotModified, ChatAdminRequired
 
8
 
9
 
10
  @Gojo.on_message(command("locktypes"))
@@ -55,7 +56,8 @@ async def lock_perm(c: Gojo, m: Message):
55
  if lock_type == "all":
56
  try:
57
  await c.set_chat_permissions(chat_id, ChatPermissions())
58
- LOGGER.info(f"{m.from_user.id} locked all permissions in {m.chat.id}")
 
59
  except ChatNotModified:
60
  pass
61
  except ChatAdminRequired:
@@ -122,7 +124,8 @@ async def lock_perm(c: Gojo, m: Message):
122
  ChatPermissions(
123
  can_send_messages=msg,
124
  can_send_media_messages=media,
125
- can_send_other_messages=any([stickers, animations, games, inlinebots]),
 
126
  can_add_web_page_previews=webprev,
127
  can_send_polls=polls,
128
  can_change_info=info,
@@ -130,7 +133,8 @@ async def lock_perm(c: Gojo, m: Message):
130
  can_pin_messages=pin,
131
  ),
132
  )
133
- LOGGER.info(f"{m.from_user.id} locked selected permissions in {m.chat.id}")
 
134
  except ChatNotModified:
135
  pass
136
  except ChatAdminRequired:
@@ -212,7 +216,8 @@ async def unlock_perm(c: Gojo, m: Message):
212
  can_pin_messages=True,
213
  ),
214
  )
215
- LOGGER.info(f"{m.from_user.id} unlocked all permissions in {m.chat.id}")
 
216
  except ChatNotModified:
217
  pass
218
  except ChatAdminRequired:
@@ -285,7 +290,8 @@ async def unlock_perm(c: Gojo, m: Message):
285
  return
286
 
287
  try:
288
- LOGGER.info(f"{m.from_user.id} unlocked selected permissions in {m.chat.id}")
 
289
  await c.set_chat_permissions(
290
  chat_id,
291
  ChatPermissions(
 
 
1
  from asyncio import sleep
2
+
3
+ from Powers import LOGGER
4
  from Powers.bot_class import Gojo
5
  from Powers.database.approve_db import Approve
 
6
  from Powers.utils.custom_filters import command, restrict_filter
7
+ from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
8
+ from pyrogram.types import ChatPermissions, Message
9
 
10
 
11
  @Gojo.on_message(command("locktypes"))
 
56
  if lock_type == "all":
57
  try:
58
  await c.set_chat_permissions(chat_id, ChatPermissions())
59
+ LOGGER.info(
60
+ f"{m.from_user.id} locked all permissions in {m.chat.id}")
61
  except ChatNotModified:
62
  pass
63
  except ChatAdminRequired:
 
124
  ChatPermissions(
125
  can_send_messages=msg,
126
  can_send_media_messages=media,
127
+ can_send_other_messages=any(
128
+ [stickers, animations, games, inlinebots]),
129
  can_add_web_page_previews=webprev,
130
  can_send_polls=polls,
131
  can_change_info=info,
 
133
  can_pin_messages=pin,
134
  ),
135
  )
136
+ LOGGER.info(
137
+ f"{m.from_user.id} locked selected permissions in {m.chat.id}")
138
  except ChatNotModified:
139
  pass
140
  except ChatAdminRequired:
 
216
  can_pin_messages=True,
217
  ),
218
  )
219
+ LOGGER.info(
220
+ f"{m.from_user.id} unlocked all permissions in {m.chat.id}")
221
  except ChatNotModified:
222
  pass
223
  except ChatAdminRequired:
 
290
  return
291
 
292
  try:
293
+ LOGGER.info(
294
+ f"{m.from_user.id} unlocked selected permissions in {m.chat.id}")
295
  await c.set_chat_permissions(
296
  chat_id,
297
  ChatPermissions(
Powers/plugins/muting.py CHANGED
@@ -1,19 +1,20 @@
1
  from random import choice
2
- from Powers.vars import Config
 
3
  from Powers.bot_class import Gojo
4
- from pyrogram.filters import regex
 
 
5
  from Powers.utils.extras import MUTE_GIFS
6
  from Powers.utils.parser import mention_html
7
  from Powers.utils.string import extract_time
8
- from Powers.utils.extract_user import extract_user
9
- from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
10
- from Powers.utils.custom_filters import command, restrict_filter
11
- from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
12
- from pyrogram.errors import (
13
- RPCError, RightForbidden, ChatAdminRequired, UserNotParticipant)
14
- from pyrogram.types import (
15
- Message, CallbackQuery, ChatPermissions, InlineKeyboardButton,
16
- InlineKeyboardMarkup)
17
 
18
 
19
  @Gojo.on_message(command("tmute") & restrict_filter)
 
1
  from random import choice
2
+
3
+ from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
4
  from Powers.bot_class import Gojo
5
+ from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
6
+ from Powers.utils.custom_filters import command, restrict_filter
7
+ from Powers.utils.extract_user import extract_user
8
  from Powers.utils.extras import MUTE_GIFS
9
  from Powers.utils.parser import mention_html
10
  from Powers.utils.string import extract_time
11
+ from Powers.vars import Config
12
+ from pyrogram.errors import (ChatAdminRequired, RightForbidden, RPCError,
13
+ UserNotParticipant)
14
+ from pyrogram.filters import regex
15
+ from pyrogram.types import (CallbackQuery, ChatPermissions,
16
+ InlineKeyboardButton, InlineKeyboardMarkup,
17
+ Message)
 
 
18
 
19
 
20
  @Gojo.on_message(command("tmute") & restrict_filter)
Powers/plugins/notes.py CHANGED
@@ -1,20 +1,21 @@
1
- from Powers import LOGGER
2
  from secrets import choice
3
- from Powers.vars import Config
4
  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 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
14
- from Powers.utils.custom_filters import command, admin_filter, owner_filter
15
- from Powers.utils.string import (
16
- parse_button, build_keyboard, escape_mentions_using_curly_brackets)
17
-
 
 
18
 
19
  # Initialise
20
  db = Notes()
@@ -74,7 +75,8 @@ 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(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,11 +302,13 @@ async def priv_notes(_, m: Message):
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,7 +316,8 @@ async def priv_notes(_, m: Message):
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!")
 
 
1
  from secrets import choice
 
2
  from traceback import format_exc
3
+
4
+ from Powers import LOGGER
5
  from Powers.bot_class import Gojo
6
+ from Powers.database.notes_db import Notes, NotesSettings
 
 
7
  from Powers.utils.cmd_senders import send_cmd
8
+ from Powers.utils.custom_filters import admin_filter, command, owner_filter
9
+ from Powers.utils.kbhelpers import ikb
10
  from Powers.utils.msg_types import Types, get_note_type
11
+ from Powers.utils.string import (build_keyboard,
12
+ escape_mentions_using_curly_brackets,
13
+ parse_button)
14
+ from Powers.vars import Config
15
+ from pyrogram import enums, filters
16
+ from pyrogram.enums import ChatMemberStatus as CMS
17
+ from pyrogram.errors import RPCError
18
+ from pyrogram.types import CallbackQuery, InlineKeyboardMarkup, Message
19
 
20
  # Initialise
21
  db = Notes()
 
75
 
76
  if priv_notes_status:
77
 
78
+ note_hash = next(i[1] for i in db.get_all_notes(
79
+ m.chat.id) if i[0] == note_name)
80
  await reply_text(
81
  f"Click on the button to get the note <code>{note_name}</code>",
82
  reply_markup=ikb(
 
302
  option = (m.text.split())[1]
303
  if option in ("on", "yes"):
304
  db_settings.set_privatenotes(chat_id, True)
305
+ LOGGER.info(
306
+ f"{m.from_user.id} enabled privatenotes in {m.chat.id}")
307
  msg = "Set private notes to On"
308
  elif option in ("off", "no"):
309
  db_settings.set_privatenotes(chat_id, False)
310
+ LOGGER.info(
311
+ f"{m.from_user.id} disabled privatenotes in {m.chat.id}")
312
  msg = "Set private notes to Off"
313
  else:
314
  msg = "Enter correct option"
 
316
  elif len(m.text.split()) == 1:
317
  curr_pref = db_settings.get_privatenotes(m.chat.id)
318
  msg = msg = f"Private Notes: {curr_pref}"
319
+ LOGGER.info(
320
+ f"{m.from_user.id} fetched privatenotes preference in {m.chat.id}")
321
  await m.reply_text(msg)
322
  else:
323
  await m.replt_text("Check help on how to use this command!")
Powers/plugins/pin.py CHANGED
@@ -1,14 +1,15 @@
1
- from Powers.bot_class import Gojo
2
- from pyrogram.filters import regex
3
- from Powers.utils.kbhelpers import ikb
4
  from html import escape as escape_html
 
5
  from Powers import LOGGER, SUPPORT_GROUP
 
6
  from Powers.database.pins_db import Pins
7
- from pyrogram.types import Message, CallbackQuery
 
 
8
  from pyrogram.enums import ChatMemberStatus as CMS
9
- from Powers.utils.string import parse_button, build_keyboard
10
- from Powers.utils.custom_filters import command, admin_filter
11
- from pyrogram.errors import RPCError, RightForbidden, ChatAdminRequired
12
 
13
 
14
  @Gojo.on_message(command("pin") & admin_filter)
@@ -36,10 +37,16 @@ async def pin_message(_, m: Message):
36
  # If chat does not have a username, use this
37
  link_chat_id = (str(m.chat.id)).replace("-100", "")
38
  message_link = f"https://t.me/c/{link_chat_id}/{m.reply_to_message.id}"
39
- await m.reply_text(
40
- text=f"I have Pinned [this message]({message_link})!",
41
- disable_web_page_preview=True,
42
- )
 
 
 
 
 
 
43
 
44
  except ChatAdminRequired:
45
  await m.reply_text(text="I'm not admin or I don't have rights.")
@@ -89,7 +96,8 @@ async def unpin_message(c: Gojo, m: Message):
89
  async def unpinall_message(_, m: Message):
90
  await m.reply_text(
91
  "Do you really want to unpin all messages in this chat?",
92
- reply_markup=ikb([[("Yes", "unpin all in this chat"), ("No", "close_admin")]]),
 
93
  )
94
  return
95
 
@@ -112,7 +120,8 @@ async def unpinall_calllback(c: Gojo, q: CallbackQuery):
112
  return
113
  try:
114
  await c.unpin_all_chat_messages(q.message.chat.id)
115
- LOGGER.info(f"{q.from_user.id} unpinned all messages in {q.message.chat.id}")
 
116
  await q.message.edit_text(text="Unpinned all messages in this chat.")
117
  except ChatAdminRequired:
118
  await q.message.edit_text(text="I'm not admin or I don't have rights.")
@@ -140,11 +149,13 @@ async def anti_channel_pin(_, m: Message):
140
  if len(m.text.split()) == 2:
141
  if m.command[1] in ("yes", "on", "true"):
142
  pinsdb.antichannelpin_on()
143
- LOGGER.info(f"{m.from_user.id} enabled antichannelpin in {m.chat.id}")
 
144
  msg = "Turned on AntiChannelPin, now all message pinned by channel will be unpinned automtically!"
145
  elif m.command[1] in ("no", "off", "false"):
146
  pinsdb.antichannelpin_off()
147
- LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
 
148
  msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
149
  else:
150
  await m.reply_text(
@@ -196,7 +207,8 @@ async def clean_linked(_, m: Message):
196
  msg = "Turned on CleanLinked! Now all the messages from linked channel will be deleted!"
197
  elif m.command[1] in ("no", "off", "false"):
198
  pinsdb.cleanlinked_off()
199
- LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
 
200
  msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
201
  else:
202
  await m.reply_text(
 
 
 
 
1
  from html import escape as escape_html
2
+
3
  from Powers import LOGGER, SUPPORT_GROUP
4
+ from Powers.bot_class import Gojo
5
  from Powers.database.pins_db import Pins
6
+ from Powers.utils.custom_filters import admin_filter, command
7
+ from Powers.utils.kbhelpers import ikb
8
+ from Powers.utils.string import build_keyboard, parse_button
9
  from pyrogram.enums import ChatMemberStatus as CMS
10
+ from pyrogram.errors import ChatAdminRequired, RightForbidden, RPCError
11
+ from pyrogram.filters import regex
12
+ from pyrogram.types import CallbackQuery, Message
13
 
14
 
15
  @Gojo.on_message(command("pin") & admin_filter)
 
37
  # If chat does not have a username, use this
38
  link_chat_id = (str(m.chat.id)).replace("-100", "")
39
  message_link = f"https://t.me/c/{link_chat_id}/{m.reply_to_message.id}"
40
+ if not disable_notification:
41
+ await m.reply_text(
42
+ text=f"I have Pinned and Notified [this message]({message_link})!",
43
+ disable_web_page_preview=True,
44
+ )
45
+ else:
46
+ await m.reply_text(
47
+ text=f"I have Pinned [this message]({message_link})!",
48
+ disable_web_page_preview=True,
49
+ )
50
 
51
  except ChatAdminRequired:
52
  await m.reply_text(text="I'm not admin or I don't have rights.")
 
96
  async def unpinall_message(_, m: Message):
97
  await m.reply_text(
98
  "Do you really want to unpin all messages in this chat?",
99
+ reply_markup=ikb(
100
+ [[("Yes", "unpin all in this chat"), ("No", "close_admin")]]),
101
  )
102
  return
103
 
 
120
  return
121
  try:
122
  await c.unpin_all_chat_messages(q.message.chat.id)
123
+ LOGGER.info(
124
+ f"{q.from_user.id} unpinned all messages in {q.message.chat.id}")
125
  await q.message.edit_text(text="Unpinned all messages in this chat.")
126
  except ChatAdminRequired:
127
  await q.message.edit_text(text="I'm not admin or I don't have rights.")
 
149
  if len(m.text.split()) == 2:
150
  if m.command[1] in ("yes", "on", "true"):
151
  pinsdb.antichannelpin_on()
152
+ LOGGER.info(
153
+ f"{m.from_user.id} enabled antichannelpin in {m.chat.id}")
154
  msg = "Turned on AntiChannelPin, now all message pinned by channel will be unpinned automtically!"
155
  elif m.command[1] in ("no", "off", "false"):
156
  pinsdb.antichannelpin_off()
157
+ LOGGER.info(
158
+ f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
159
  msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
160
  else:
161
  await m.reply_text(
 
207
  msg = "Turned on CleanLinked! Now all the messages from linked channel will be deleted!"
208
  elif m.command[1] in ("no", "off", "false"):
209
  pinsdb.cleanlinked_off()
210
+ LOGGER.info(
211
+ f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
212
  msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
213
  else:
214
  await m.reply_text(
Powers/plugins/purge.py CHANGED
@@ -1,10 +1,11 @@
1
  from asyncio import sleep
 
2
  from Powers import SUPPORT_GROUP
3
  from Powers.bot_class import Gojo
4
- from pyrogram.types import Message
5
  from pyrogram.enums import ChatType
6
- from pyrogram.errors import RPCError, MessageDeleteForbidden
7
- from Powers.utils.custom_filters import command, admin_filter
8
 
9
 
10
  @Gojo.on_message(command("purge") & admin_filter)
@@ -19,7 +20,7 @@ async def purge(c: Gojo, m: Message):
19
 
20
  def divide_chunks(l: list, n: int = 100):
21
  for i in range(0, len(l), n):
22
- yield l[i : i + n]
23
 
24
  # Dielete messages in chunks of 100 messages
25
  m_list = list(divide_chunks(message_ids))
@@ -66,7 +67,7 @@ async def spurge(c: Gojo, m: Message):
66
 
67
  def divide_chunks(l: list, n: int = 100):
68
  for i in range(0, len(l), n):
69
- yield l[i : i + n]
70
 
71
  # Dielete messages in chunks of 100 messages
72
  m_list = list(divide_chunks(message_ids))
 
1
  from asyncio import sleep
2
+
3
  from Powers import SUPPORT_GROUP
4
  from Powers.bot_class import Gojo
5
+ from Powers.utils.custom_filters import admin_filter, command
6
  from pyrogram.enums import ChatType
7
+ from pyrogram.errors import MessageDeleteForbidden, RPCError
8
+ from pyrogram.types import Message
9
 
10
 
11
  @Gojo.on_message(command("purge") & admin_filter)
 
20
 
21
  def divide_chunks(l: list, n: int = 100):
22
  for i in range(0, len(l), n):
23
+ yield l[i: i + n]
24
 
25
  # Dielete messages in chunks of 100 messages
26
  m_list = list(divide_chunks(message_ids))
 
67
 
68
  def divide_chunks(l: list, n: int = 100):
69
  for i in range(0, len(l), n):
70
+ yield l[i: i + n]
71
 
72
  # Dielete messages in chunks of 100 messages
73
  m_list = list(divide_chunks(message_ids))
Powers/plugins/report.py CHANGED
@@ -1,14 +1,16 @@
1
- from pyrogram import filters
2
  from traceback import format_exc
 
 
3
  from Powers.bot_class import Gojo
4
- from pyrogram.errors import RPCError
 
5
  from Powers.utils.kbhelpers import ikb
6
- from Powers import LOGGER, SUPPORT_STAFF
7
  from Powers.utils.parser import mention_html
8
- from pyrogram.types import Message, CallbackQuery
9
- from Powers.database.reporting_db import Reporting
10
- from Powers.utils.custom_filters import command, admin_filter
11
- from pyrogram.enums import ChatType, ChatMembersFilter as cmf
 
12
 
13
 
14
  @Gojo.on_message(
 
 
1
  from traceback import format_exc
2
+
3
+ from Powers import LOGGER, SUPPORT_STAFF
4
  from Powers.bot_class import Gojo
5
+ from Powers.database.reporting_db import Reporting
6
+ from Powers.utils.custom_filters import admin_filter, command
7
  from Powers.utils.kbhelpers import ikb
 
8
  from Powers.utils.parser import mention_html
9
+ from pyrogram import filters
10
+ from pyrogram.enums import ChatMembersFilter as cmf
11
+ from pyrogram.enums import ChatType
12
+ from pyrogram.errors import RPCError
13
+ from pyrogram.types import CallbackQuery, Message
14
 
15
 
16
  @Gojo.on_message(
Powers/plugins/rules.py CHANGED
@@ -1,11 +1,11 @@
1
  from Powers import LOGGER
2
- from pyrogram import filters
3
- from Powers.vars import Config
4
  from Powers.bot_class import Gojo
5
- from Powers.utils.kbhelpers import ikb
6
  from Powers.database.rules_db import Rules
7
- from pyrogram.types import Message, CallbackQuery
8
- from Powers.utils.custom_filters import command, admin_filter
 
 
 
9
 
10
 
11
  @Gojo.on_message(command("rules") & filters.group)
@@ -93,11 +93,13 @@ async def priv_rules(_, m: Message):
93
  option = (m.text.split())[1]
94
  if option in ("on", "yes"):
95
  db.set_privrules(True)
96
- LOGGER.info(f"{m.from_user.id} enabled privaterules in {m.chat.id}")
 
97
  msg = f"Private Rules have been turned <b>on</b> for chat <b>{m.chat.title}</b>"
98
  elif option in ("off", "no"):
99
  db.set_privrules(False)
100
- LOGGER.info(f"{m.from_user.id} disbaled privaterules in {m.chat.id}")
 
101
  msg = f"Private Rules have been turned <b>off</b> for chat <b>{m.chat.title}</b>"
102
  else:
103
  msg = "Option not valid, choose from <code>on</code>, <code>yes</code>, <code>off</code>, <code>no</code>"
@@ -107,7 +109,8 @@ async def priv_rules(_, m: Message):
107
  msg = (
108
  f"Current Preference for Private rules in this chat is: <b>{curr_pref}</b>"
109
  )
110
- LOGGER.info(f"{m.from_user.id} fetched privaterules preference in {m.chat.id}")
 
111
  await m.reply_text(msg)
112
  else:
113
  await m.reply_text(text="Please check help on how to use this this command.")
 
1
  from Powers import LOGGER
 
 
2
  from Powers.bot_class import Gojo
 
3
  from Powers.database.rules_db import Rules
4
+ from Powers.utils.custom_filters import admin_filter, command
5
+ from Powers.utils.kbhelpers import ikb
6
+ from Powers.vars import Config
7
+ from pyrogram import filters
8
+ from pyrogram.types import CallbackQuery, Message
9
 
10
 
11
  @Gojo.on_message(command("rules") & filters.group)
 
93
  option = (m.text.split())[1]
94
  if option in ("on", "yes"):
95
  db.set_privrules(True)
96
+ LOGGER.info(
97
+ f"{m.from_user.id} enabled privaterules in {m.chat.id}")
98
  msg = f"Private Rules have been turned <b>on</b> for chat <b>{m.chat.title}</b>"
99
  elif option in ("off", "no"):
100
  db.set_privrules(False)
101
+ LOGGER.info(
102
+ f"{m.from_user.id} disbaled privaterules in {m.chat.id}")
103
  msg = f"Private Rules have been turned <b>off</b> for chat <b>{m.chat.title}</b>"
104
  else:
105
  msg = "Option not valid, choose from <code>on</code>, <code>yes</code>, <code>off</code>, <code>no</code>"
 
109
  msg = (
110
  f"Current Preference for Private rules in this chat is: <b>{curr_pref}</b>"
111
  )
112
+ LOGGER.info(
113
+ f"{m.from_user.id} fetched privaterules preference in {m.chat.id}")
114
  await m.reply_text(msg)
115
  else:
116
  await m.reply_text(text="Please check help on how to use this this command.")
Powers/plugins/start.py CHANGED
@@ -1,17 +1,18 @@
1
  from random import choice
2
- from Powers.vars import Config
 
3
  from Powers.bot_class import Gojo
4
- from pyrogram import enums, filters
5
- from Powers.utils.kbhelpers import ikb
6
- from Powers import LOGGER, HELP_COMMANDS
7
- from Powers.utils.extras import StartPic
8
  from Powers.utils.custom_filters import command
9
- from pyrogram.types import Message, CallbackQuery
10
- from pyrogram.enums import ChatType, ChatMemberStatus as CMS
11
- from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
12
- from Powers.utils.start_utils import (
13
- gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
14
- get_private_rules)
 
 
 
 
15
 
16
 
17
  @Gojo.on_message(
@@ -69,7 +70,8 @@ async def start(c: Gojo, m: Message):
69
  await get_private_note(c, m, help_option)
70
  return
71
  if help_option.startswith("rules"):
72
- LOGGER.info(f"{m.from_user.id} fetched privaterules in {m.chat.id}")
 
73
  await get_private_rules(c, m, help_option)
74
  return
75
 
@@ -92,7 +94,7 @@ Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! My self Gojo
92
  I'm here to help you manage your groups!
93
  Hit /help to find out more about how to use me in my full potential!
94
 
95
- Join my [News Channel](https://t.me/gojo_updates) to get information on all the latest updates."""
96
 
97
  await m.reply_photo(
98
  photo=choice(StartPic),
@@ -131,7 +133,7 @@ Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! My name is G
131
  I'm here to help you manage your groups!
132
  Hit /help to find out more about how to use me in my full potential!
133
 
134
- Join my [News Channel](http://t.me/gojo_updates) to get information on all the latest updates."""
135
 
136
  await q.edit_message_caption(
137
  caption=cpt,
@@ -147,7 +149,7 @@ Join my [News Channel](http://t.me/gojo_updates) to get information on all the l
147
  async def commands_menu(_, q: CallbackQuery):
148
  cmds = sorted(list(HELP_COMMANDS.keys()))
149
  kb = [cmd.lower() for cmd in cmds]
150
- ou = [kb[i : i + 3] for i in range(0, len(kb), 3)]
151
  keyboard = ikb(ou, True)
152
  try:
153
  cpt = f"""
@@ -179,7 +181,8 @@ async def help_menu(_, m: Message):
179
  help_msg, help_kb = await get_help_msg(m, help_option)
180
 
181
  if not help_msg:
182
- LOGGER.error(f"No help_msg found for help_option - {help_option}!!")
 
183
  return
184
 
185
  LOGGER.info(
@@ -220,7 +223,7 @@ async def help_menu(_, m: Message):
220
  if m.chat.type == ChatType.PRIVATE:
221
  cmds = sorted(list(HELP_COMMANDS.keys()))
222
  kb = [cmd.lower() for cmd in cmds]
223
- ou = [kb[i : i + 3] for i in range(0, len(kb), 3)]
224
  keyboard = ikb(ou, True)
225
  msg = f"""
226
  Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!My name is Gojo✨.
 
1
  from random import choice
2
+
3
+ from Powers import HELP_COMMANDS, LOGGER
4
  from Powers.bot_class import Gojo
 
 
 
 
5
  from Powers.utils.custom_filters import command
6
+ from Powers.utils.extras import StartPic
7
+ from Powers.utils.kbhelpers import ikb
8
+ from Powers.utils.start_utils import (gen_cmds_kb, gen_start_kb, get_help_msg,
9
+ get_private_note, get_private_rules)
10
+ from Powers.vars import Config
11
+ from pyrogram import enums, filters
12
+ from pyrogram.enums import ChatMemberStatus as CMS
13
+ from pyrogram.enums import ChatType
14
+ from pyrogram.errors import MessageNotModified, QueryIdInvalid, UserIsBlocked
15
+ from pyrogram.types import CallbackQuery, Message
16
 
17
 
18
  @Gojo.on_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
 
 
94
  I'm here to help you manage your groups!
95
  Hit /help to find out more about how to use me in my full potential!
96
 
97
+ Join my [News Channel](https://t.me/gojo_bots_network) to get information on all the latest updates."""
98
 
99
  await m.reply_photo(
100
  photo=choice(StartPic),
 
133
  I'm here to help you manage your groups!
134
  Hit /help to find out more about how to use me in my full potential!
135
 
136
+ Join my [News Channel](http://t.me/gojo_bots_network) to get information on all the latest updates."""
137
 
138
  await q.edit_message_caption(
139
  caption=cpt,
 
149
  async def commands_menu(_, q: CallbackQuery):
150
  cmds = sorted(list(HELP_COMMANDS.keys()))
151
  kb = [cmd.lower() for cmd in cmds]
152
+ ou = [kb[i: i + 3] for i in range(0, len(kb), 3)]
153
  keyboard = ikb(ou, True)
154
  try:
155
  cpt = f"""
 
181
  help_msg, help_kb = await get_help_msg(m, help_option)
182
 
183
  if not help_msg:
184
+ LOGGER.error(
185
+ f"No help_msg found for help_option - {help_option}!!")
186
  return
187
 
188
  LOGGER.info(
 
223
  if m.chat.type == ChatType.PRIVATE:
224
  cmds = sorted(list(HELP_COMMANDS.keys()))
225
  kb = [cmd.lower() for cmd in cmds]
226
+ ou = [kb[i: i + 3] for i in range(0, len(kb), 3)]
227
  keyboard = ikb(ou, True)
228
  msg = f"""
229
  Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!My name is Gojo✨.
Powers/plugins/stats.py CHANGED
@@ -1,19 +1,19 @@
1
- from pyrogram import enums
2
  from Powers.bot_class import Gojo
3
- from pyrogram.types import Message
4
- from Powers.database.pins_db import Pins
5
- from Powers.database.chats_db import Chats
6
- from Powers.database.rules_db import Rules
7
- from Powers.database.users_db import Users
8
  from Powers.database.antispam_db import GBan
9
  from Powers.database.approve_db import Approve
10
- from Powers.database.filters_db import Filters
11
- from Powers.utils.custom_filters import command
12
- from Powers.database.disable_db import Disabling
13
  from Powers.database.blacklist_db import Blacklist
 
 
 
14
  from Powers.database.greetings_db import Greetings
15
- from Powers.database.warns_db import Warns, WarnSettings
16
  from Powers.database.notes_db import Notes, NotesSettings
 
 
 
 
 
 
 
17
 
18
 
19
  @Gojo.on_message(command("stats", dev_cmd=True))
 
 
1
  from Powers.bot_class import Gojo
 
 
 
 
 
2
  from Powers.database.antispam_db import GBan
3
  from Powers.database.approve_db import Approve
 
 
 
4
  from Powers.database.blacklist_db import Blacklist
5
+ from Powers.database.chats_db import Chats
6
+ from Powers.database.disable_db import Disabling
7
+ from Powers.database.filters_db import Filters
8
  from Powers.database.greetings_db import Greetings
 
9
  from Powers.database.notes_db import Notes, NotesSettings
10
+ from Powers.database.pins_db import Pins
11
+ from Powers.database.rules_db import Rules
12
+ from Powers.database.users_db import Users
13
+ from Powers.database.warns_db import Warns, WarnSettings
14
+ from Powers.utils.custom_filters import command
15
+ from pyrogram import enums
16
+ from pyrogram.types import Message
17
 
18
 
19
  @Gojo.on_message(command("stats", dev_cmd=True))
Powers/plugins/utils.py CHANGED
@@ -1,21 +1,22 @@
1
- import re
2
  import asyncio
 
 
 
 
3
  import aiofiles
 
4
  from Powers import *
5
- from os import remove
6
- from io import BytesIO
7
- from wikipedia import summary
8
  from Powers.bot_class import Gojo
9
- from gpytranslate import Translator
 
 
 
10
  from pyrogram import enums, filters
11
  from pyrogram.enums import ChatType
12
- from Powers.utils.http_helper import *
13
- from Powers.database.users_db import Users
14
  from pyrogram.errors import MessageTooLong
15
- from Powers.utils.custom_filters import command
16
- from Powers.utils.clean_file import remove_markdown_and_html
17
- from wikipedia.exceptions import PageError, DisambiguationError
18
- from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
19
 
20
 
21
  @Gojo.on_message(command("wiki"))
 
 
1
  import asyncio
2
+ import re
3
+ from io import BytesIO
4
+ from os import remove
5
+
6
  import aiofiles
7
+ from gpytranslate import Translator
8
  from Powers import *
 
 
 
9
  from Powers.bot_class import Gojo
10
+ from Powers.database.users_db import Users
11
+ from Powers.utils.clean_file import remove_markdown_and_html
12
+ from Powers.utils.custom_filters import command
13
+ from Powers.utils.http_helper import *
14
  from pyrogram import enums, filters
15
  from pyrogram.enums import ChatType
 
 
16
  from pyrogram.errors import MessageTooLong
17
+ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
18
+ from wikipedia import summary
19
+ from wikipedia.exceptions import DisambiguationError, PageError
 
20
 
21
 
22
  @Gojo.on_message(command("wiki"))
Powers/plugins/warns.py CHANGED
@@ -1,19 +1,20 @@
1
  from time import time
2
- from pyrogram import filters
3
- from Powers.vars import Config
4
- from Powers.bot_class import Gojo
5
- from pyrogram.errors import RPCError
6
  from Powers import LOGGER, SUPPORT_STAFF
 
7
  from Powers.database.rules_db import Rules
8
  from Powers.database.users_db import Users
9
- from Powers.utils.parser import mention_html
10
- from Powers.utils.extract_user import extract_user
11
  from Powers.database.warns_db import Warns, WarnSettings
12
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
13
- from Powers.utils.custom_filters import command, admin_filter, restrict_filter
14
- from pyrogram.types import (
15
- Message, CallbackQuery, ChatPermissions, InlineKeyboardButton,
16
- InlineKeyboardMarkup)
 
 
 
 
 
17
 
18
 
19
  @Gojo.on_message(
@@ -204,7 +205,8 @@ async def list_warns(c: Gojo, m: Message):
204
  await m.reply_text("This user has no warns!")
205
  return
206
  msg = f"{(await mention_html(user_first_name,user_id))} has <b>{num_warns}/{warn_settings['warn_limit']}</b> warns!\n\n<b>Reasons:</b>\n"
207
- msg += "\n".join([("- No reason" if i is None else f" - {i}") for i in warns])
 
208
  await m.reply_text(msg)
209
  return
210
 
 
1
  from time import time
2
+
 
 
 
3
  from Powers import LOGGER, SUPPORT_STAFF
4
+ from Powers.bot_class import Gojo
5
  from Powers.database.rules_db import Rules
6
  from Powers.database.users_db import Users
 
 
7
  from Powers.database.warns_db import Warns, WarnSettings
8
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
9
+ from Powers.utils.custom_filters import admin_filter, command, restrict_filter
10
+ from Powers.utils.extract_user import extract_user
11
+ from Powers.utils.parser import mention_html
12
+ from Powers.vars import Config
13
+ from pyrogram import filters
14
+ from pyrogram.errors import RPCError
15
+ from pyrogram.types import (CallbackQuery, ChatPermissions,
16
+ InlineKeyboardButton, InlineKeyboardMarkup,
17
+ Message)
18
 
19
 
20
  @Gojo.on_message(
 
205
  await m.reply_text("This user has no warns!")
206
  return
207
  msg = f"{(await mention_html(user_first_name,user_id))} has <b>{num_warns}/{warn_settings['warn_limit']}</b> warns!\n\n<b>Reasons:</b>\n"
208
+ msg += "\n".join(
209
+ [("- No reason" if i is None else f" - {i}") for i in warns])
210
  await m.reply_text(msg)
211
  return
212
 
Powers/plugins/watchers.py CHANGED
@@ -1,21 +1,21 @@
 
1
  from time import time
2
- from pyrogram import filters
3
  from traceback import format_exc
 
 
4
  from Powers.bot_class import Gojo
5
- from re import escape as re_escape
6
- from Powers.database.pins_db import Pins
7
- from Powers.utils.parser import mention_html
8
  from Powers.database.approve_db import Approve
9
  from Powers.database.blacklist_db import Blacklist
10
- from Powers.utils.regex_utils import regex_searcher
11
- from pyrogram.types import Message, ChatPermissions
12
- from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
13
- from Powers.database.warns_db import Warns, WarnSettings
14
  from Powers.database.group_blacklist import BLACKLIST_CHATS
15
- from Powers.database.antispam_db import ANTISPAM_BANNED, GBan
 
16
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
17
- from pyrogram.errors import RPCError, UserAdminInvalid, ChatAdminRequired
18
-
 
 
 
19
 
20
  # Initialise
21
  gban_db = GBan()
@@ -29,7 +29,8 @@ async def antichanpin_cleanlinked(c: Gojo, m: Message):
29
  curr = pins_db.get_settings()
30
  if curr["antichannelpin"]:
31
  await c.unpin_chat_message(chat_id=m.chat.id, message_id=msg_id)
32
- LOGGER.info(f"AntiChannelPin: msgid-{m.id} unpinned in {m.chat.id}")
 
33
  if curr["cleanlinked"]:
34
  await c.delete_messages(m.chat.id, msg_id)
35
  LOGGER.info(f"CleanLinked: msgid-{m.id} cleaned in {m.chat.id}")
@@ -38,7 +39,8 @@ async def antichanpin_cleanlinked(c: Gojo, m: Message):
38
  "Disabled antichannelpin as I don't have enough admin rights!",
39
  )
40
  pins_db.antichannelpin_off()
41
- LOGGER.warning(f"Disabled antichannelpin in {m.chat.id} as i'm not an admin.")
 
42
  except Exception as ef:
43
  LOGGER.error(ef)
44
  LOGGER.error(format_exc())
@@ -189,7 +191,8 @@ async def gban_watcher(c: Gojo, m: Message):
189
 
190
  To get unbanned, appeal at @{SUPPORT_GROUP}"""
191
  )
192
- LOGGER.info(f"Banned user {m.from_user.id} in {m.chat.id} due to antispam")
 
193
  return
194
  except (ChatAdminRequired, UserAdminInvalid):
195
  # Bot not admin in group and hence cannot ban users!
 
1
+ from re import escape as re_escape
2
  from time import time
 
3
  from traceback import format_exc
4
+
5
+ from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
6
  from Powers.bot_class import Gojo
7
+ from Powers.database.antispam_db import ANTISPAM_BANNED, GBan
 
 
8
  from Powers.database.approve_db import Approve
9
  from Powers.database.blacklist_db import Blacklist
 
 
 
 
10
  from Powers.database.group_blacklist import BLACKLIST_CHATS
11
+ from Powers.database.pins_db import Pins
12
+ from Powers.database.warns_db import Warns, WarnSettings
13
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
14
+ from Powers.utils.parser import mention_html
15
+ from Powers.utils.regex_utils import regex_searcher
16
+ from pyrogram import filters
17
+ from pyrogram.errors import ChatAdminRequired, RPCError, UserAdminInvalid
18
+ from pyrogram.types import ChatPermissions, Message
19
 
20
  # Initialise
21
  gban_db = GBan()
 
29
  curr = pins_db.get_settings()
30
  if curr["antichannelpin"]:
31
  await c.unpin_chat_message(chat_id=m.chat.id, message_id=msg_id)
32
+ LOGGER.info(
33
+ f"AntiChannelPin: msgid-{m.id} unpinned in {m.chat.id}")
34
  if curr["cleanlinked"]:
35
  await c.delete_messages(m.chat.id, msg_id)
36
  LOGGER.info(f"CleanLinked: msgid-{m.id} cleaned in {m.chat.id}")
 
39
  "Disabled antichannelpin as I don't have enough admin rights!",
40
  )
41
  pins_db.antichannelpin_off()
42
+ LOGGER.warning(
43
+ f"Disabled antichannelpin in {m.chat.id} as i'm not an admin.")
44
  except Exception as ef:
45
  LOGGER.error(ef)
46
  LOGGER.error(format_exc())
 
191
 
192
  To get unbanned, appeal at @{SUPPORT_GROUP}"""
193
  )
194
+ LOGGER.info(
195
+ f"Banned user {m.from_user.id} in {m.chat.id} due to antispam")
196
  return
197
  except (ChatAdminRequired, UserAdminInvalid):
198
  # Bot not admin in group and hence cannot ban users!
Powers/utils/admin_check.py CHANGED
@@ -1,8 +1,8 @@
1
  from traceback import format_exc
2
- from pyrogram.types import Message, CallbackQuery
3
- from pyrogram.enums import ChatMemberStatus as CMS
4
- from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS
5
 
 
 
 
6
 
7
  SUDO_LEVEL = SUDO_USERS + DEV_USERS + [int(OWNER_ID)]
8
  DEV_LEVEL = DEV_USERS + [int(OWNER_ID)]
 
1
  from traceback import format_exc
 
 
 
2
 
3
+ from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS
4
+ from pyrogram.enums import ChatMemberStatus as CMS
5
+ from pyrogram.types import CallbackQuery, Message
6
 
7
  SUDO_LEVEL = SUDO_USERS + DEV_USERS + [int(OWNER_ID)]
8
  DEV_LEVEL = DEV_USERS + [int(OWNER_ID)]
Powers/utils/caching.py CHANGED
@@ -1,13 +1,13 @@
1
- from typing import List
2
- from Powers import LOGGER
3
  from threading import RLock
 
 
 
4
  from cachetools import TTLCache
5
- from time import time, perf_counter
6
- from pyrogram.types import CallbackQuery
7
  from pyrogram.enums import ChatMembersFilter
 
8
  from pyrogram.types.messages_and_media.message import Message
9
 
10
-
11
  THREAD_LOCK = RLock()
12
 
13
  # admins stay cached for 30 mins
 
 
 
1
  from threading import RLock
2
+ from time import perf_counter, time
3
+ from typing import List
4
+
5
  from cachetools import TTLCache
6
+ from Powers import LOGGER
 
7
  from pyrogram.enums import ChatMembersFilter
8
+ from pyrogram.types import CallbackQuery
9
  from pyrogram.types.messages_and_media.message import Message
10
 
 
11
  THREAD_LOCK = RLock()
12
 
13
  # admins stay cached for 30 mins
Powers/utils/custom_filters.py CHANGED
@@ -1,15 +1,17 @@
 
 
1
  from shlex import split
2
- from Powers.vars import Config
3
  from typing import List, Union
4
- from pyrogram.filters import create
5
- from re import escape, compile as compile_re
6
  from Powers.database.disable_db import Disabling
7
- from pyrogram.types import Message, CallbackQuery
8
- from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
9
- from pyrogram.errors import RPCError, UserNotParticipant
10
- from pyrogram.enums import ChatType, ChatMemberStatus as CMS
11
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
12
-
 
 
 
 
 
13
 
14
  SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
15
  DEV_LEVEL = set(DEV_USERS + [int(OWNER_ID)])
 
1
+ from re import compile as compile_re
2
+ from re import escape
3
  from shlex import split
 
4
  from typing import List, Union
5
+
6
+ from Powers import DEV_USERS, OWNER_ID, SUDO_USERS
7
  from Powers.database.disable_db import Disabling
 
 
 
 
8
  from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
9
+ from Powers.vars import Config
10
+ from pyrogram.enums import ChatMemberStatus as CMS
11
+ from pyrogram.enums import ChatType
12
+ from pyrogram.errors import RPCError, UserNotParticipant
13
+ from pyrogram.filters import create
14
+ from pyrogram.types import CallbackQuery, Message
15
 
16
  SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
17
  DEV_LEVEL = set(DEV_USERS + [int(OWNER_ID)])
Powers/utils/extract_user.py CHANGED
@@ -1,6 +1,7 @@
 
1
  from typing import Tuple
 
2
  from Powers import LOGGER
3
- from traceback import format_exc
4
  from Powers.bot_class import Gojo
5
  from Powers.database.users_db import Users
6
  from pyrogram.enums import MessageEntityType as entity
@@ -28,7 +29,7 @@ async def extract_user(c: Gojo, m: Message) -> Tuple[int, str, str]:
28
  elif required_entity.type in (entity.MENTION, entity.PHONE_NUMBER):
29
  # new long user ids are identified as phone_number
30
  user_found = m.text[
31
- required_entity.offset : (
32
  required_entity.offset + required_entity.length
33
  )
34
  ]
 
1
+ from traceback import format_exc
2
  from typing import Tuple
3
+
4
  from Powers import LOGGER
 
5
  from Powers.bot_class import Gojo
6
  from Powers.database.users_db import Users
7
  from pyrogram.enums import MessageEntityType as entity
 
29
  elif required_entity.type in (entity.MENTION, entity.PHONE_NUMBER):
30
  # new long user ids are identified as phone_number
31
  user_found = m.text[
32
+ required_entity.offset: (
33
  required_entity.offset + required_entity.length
34
  )
35
  ]
Powers/utils/extras.py CHANGED
@@ -514,7 +514,8 @@ TOSS = (
514
  )
515
 
516
 
517
- DECIDE = ("Yes.", "No.", "Maybe.", "Who the hell cares?", "No one give a damn about it")
 
518
 
519
  INSULT_STRINGS = [
520
  "`Owww ... Such a stupid idiot.`",
 
514
  )
515
 
516
 
517
+ DECIDE = ("Yes.", "No.", "Maybe.", "Who the hell cares?",
518
+ "No one give a damn about it")
519
 
520
  INSULT_STRINGS = [
521
  "`Owww ... Such a stupid idiot.`",
Powers/utils/http_helper.py CHANGED
@@ -1,4 +1,5 @@
1
  from asyncio import gather
 
2
  from Powers.bot_class import aiohttpsession as session
3
 
4
 
 
1
  from asyncio import gather
2
+
3
  from Powers.bot_class import aiohttpsession as session
4
 
5