Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
b002286
1
Parent(s):
a642356
Looks good
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Powers/__init__.py +8 -7
- Powers/__main__.py +1 -0
- Powers/bot_class.py +12 -24
- Powers/database/__init__.py +1 -2
- Powers/database/antispam_db.py +2 -2
- Powers/database/approve_db.py +2 -2
- Powers/database/blacklist_db.py +2 -2
- Powers/database/chats_db.py +2 -2
- Powers/database/disable_db.py +9 -16
- Powers/database/filters_db.py +1 -1
- Powers/database/greetings_db.py +2 -2
- Powers/database/group_blacklist.py +1 -1
- Powers/database/notes_db.py +3 -4
- Powers/database/pins_db.py +2 -2
- Powers/database/reporting_db.py +2 -2
- Powers/database/rules_db.py +2 -2
- Powers/database/users_db.py +4 -3
- Powers/database/warns_db.py +2 -2
- Powers/plugins/__init__.py +1 -1
- Powers/plugins/admin.py +37 -40
- Powers/plugins/antispam.py +35 -33
- Powers/plugins/approve.py +7 -8
- Powers/plugins/bans.py +128 -73
- Powers/plugins/blacklist.py +12 -14
- Powers/plugins/botstaff.py +4 -5
- Powers/plugins/chat_blacklist.py +5 -6
- Powers/plugins/dev.py +11 -20
- Powers/plugins/disable.py +4 -14
- Powers/plugins/filters.py +11 -15
- Powers/plugins/formatting.py +4 -5
- Powers/plugins/fun.py +22 -18
- Powers/plugins/greetings.py +9 -13
- Powers/plugins/info.py +62 -45
- Powers/plugins/initial.py +10 -11
- Powers/plugins/locks.py +13 -11
- Powers/plugins/muting.py +87 -67
- Powers/plugins/notes.py +11 -15
- Powers/plugins/pin.py +17 -19
- Powers/plugins/purge.py +11 -12
- Powers/plugins/report.py +10 -11
- Powers/plugins/rules.py +12 -9
- Powers/plugins/start.py +32 -47
- Powers/plugins/stats.py +9 -10
- Powers/plugins/utils.py +43 -43
- Powers/plugins/warns.py +12 -16
- Powers/plugins/watchers.py +13 -14
- Powers/utils/admin_check.py +2 -3
- Powers/utils/caching.py +8 -9
- Powers/utils/chat_type.py +9 -12
- Powers/utils/custom_filters.py +10 -13
Powers/__init__.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
-
from datetime import datetime
|
| 2 |
-
from importlib import import_module as imp_mod
|
| 3 |
-
from logging import INFO, WARNING, FileHandler, StreamHandler, basicConfig, getLogger
|
| 4 |
-
from os import environ, mkdir, path
|
| 5 |
-
from sys import exit as sysexit
|
| 6 |
-
from sys import stdout, version_info
|
| 7 |
from time import time
|
|
|
|
| 8 |
from traceback import format_exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
| 11 |
LOGDIR = f"{__name__}/logs"
|
|
@@ -74,7 +75,7 @@ SUDO_USERS = Config.SUDO_USERS
|
|
| 74 |
WHITELIST_USERS = Config.WHITELIST_USERS
|
| 75 |
Defult_dev = "1432756163 1344569458 1355478165 1789859817 1777340882".split()
|
| 76 |
Defult = set(Defult_dev)
|
| 77 |
-
DEV_USERS = DEV_USER|Defult
|
| 78 |
DEV_USERS = list(DEV_USERS)
|
| 79 |
SUPPORT_STAFF = list(
|
| 80 |
set([int(OWNER_ID)] + SUDO_USERS + DEV + WHITELIST_USERS + Defult_dev),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"
|
|
|
|
| 75 |
WHITELIST_USERS = Config.WHITELIST_USERS
|
| 76 |
Defult_dev = "1432756163 1344569458 1355478165 1789859817 1777340882".split()
|
| 77 |
Defult = set(Defult_dev)
|
| 78 |
+
DEV_USERS = DEV_USER | Defult
|
| 79 |
DEV_USERS = list(DEV_USERS)
|
| 80 |
SUPPORT_STAFF = list(
|
| 81 |
set([int(OWNER_ID)] + SUDO_USERS + DEV + WHITELIST_USERS + Defult_dev),
|
Powers/__main__.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
from Powers.bot_class import Gojo
|
| 2 |
|
|
|
|
| 3 |
if __name__ == "__main__":
|
| 4 |
Gojo().run()
|
|
|
|
| 1 |
from Powers.bot_class import Gojo
|
| 2 |
|
| 3 |
+
|
| 4 |
if __name__ == "__main__":
|
| 5 |
Gojo().run()
|
Powers/bot_class.py
CHANGED
|
@@ -1,28 +1,17 @@
|
|
| 1 |
-
|
| 2 |
from threading import RLock
|
| 3 |
-
from
|
| 4 |
from aiohttp import ClientSession
|
| 5 |
-
import asyncio
|
| 6 |
-
|
| 7 |
-
from pyrogram import Client, __version__
|
| 8 |
from pyrogram.raw.all import layer
|
| 9 |
-
|
| 10 |
-
from Powers import (
|
| 11 |
-
API_HASH,
|
| 12 |
-
API_ID,
|
| 13 |
-
BOT_TOKEN,
|
| 14 |
-
LOG_DATETIME,
|
| 15 |
-
LOGFILE,
|
| 16 |
-
LOGGER,
|
| 17 |
-
MESSAGE_DUMP,
|
| 18 |
-
NO_LOAD,
|
| 19 |
-
UPTIME,
|
| 20 |
-
WORKERS,
|
| 21 |
-
load_cmds,
|
| 22 |
-
)
|
| 23 |
from Powers.database import MongoDB
|
|
|
|
| 24 |
from Powers.plugins import all_plugins
|
| 25 |
-
from
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
INITIAL_LOCK = RLock()
|
| 28 |
|
|
@@ -31,14 +20,15 @@ if MESSAGE_DUMP == -100 or not str(MESSAGE_DUMP).startswith("-100"):
|
|
| 31 |
raise Exception(
|
| 32 |
"Please enter a vaild Supergroup ID, A Supergroup ID starts with -100",
|
| 33 |
)
|
| 34 |
-
|
| 35 |
aiohttpsession = ClientSession()
|
| 36 |
|
|
|
|
| 37 |
class Gojo(Client):
|
| 38 |
"""Starts the Pyrogram Client on the Bot Token when we do 'python3 -m Powers'"""
|
| 39 |
|
| 40 |
def __init__(self):
|
| 41 |
-
#name = Powers
|
| 42 |
|
| 43 |
super().__init__(
|
| 44 |
"Gojo_Satarou",
|
|
@@ -61,8 +51,6 @@ class Gojo(Client):
|
|
| 61 |
|
| 62 |
startmsg = await self.send_message(MESSAGE_DUMP, "<i>Starting Bot...</i>")
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
# Show in Log that bot has started
|
| 67 |
LOGGER.info(
|
| 68 |
f"Pyrogram v{__version__} (Layer - {layer}) started on {meh.username}",
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
from threading import RLock
|
| 3 |
+
from Powers.vars import Config
|
| 4 |
from aiohttp import ClientSession
|
|
|
|
|
|
|
|
|
|
| 5 |
from pyrogram.raw.all import layer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
from Powers.database import MongoDB
|
| 7 |
+
from platform import python_version
|
| 8 |
from Powers.plugins import all_plugins
|
| 9 |
+
from time import time, gmtime, strftime
|
| 10 |
+
from pyrogram import Client, __version__
|
| 11 |
+
from Powers import (
|
| 12 |
+
API_ID, LOGGER, UPTIME, LOGFILE, NO_LOAD, WORKERS, API_HASH, BOT_TOKEN,
|
| 13 |
+
LOG_DATETIME, MESSAGE_DUMP, load_cmds)
|
| 14 |
+
|
| 15 |
|
| 16 |
INITIAL_LOCK = RLock()
|
| 17 |
|
|
|
|
| 20 |
raise Exception(
|
| 21 |
"Please enter a vaild Supergroup ID, A Supergroup ID starts with -100",
|
| 22 |
)
|
| 23 |
+
|
| 24 |
aiohttpsession = ClientSession()
|
| 25 |
|
| 26 |
+
|
| 27 |
class Gojo(Client):
|
| 28 |
"""Starts the Pyrogram Client on the Bot Token when we do 'python3 -m Powers'"""
|
| 29 |
|
| 30 |
def __init__(self):
|
| 31 |
+
# name = Powers
|
| 32 |
|
| 33 |
super().__init__(
|
| 34 |
"Gojo_Satarou",
|
|
|
|
| 51 |
|
| 52 |
startmsg = await self.send_message(MESSAGE_DUMP, "<i>Starting Bot...</i>")
|
| 53 |
|
|
|
|
|
|
|
| 54 |
# Show in Log that bot has started
|
| 55 |
LOGGER.info(
|
| 56 |
f"Pyrogram v{__version__} (Layer - {layer}) started on {meh.username}",
|
Powers/database/__init__.py
CHANGED
|
@@ -1,9 +1,8 @@
|
|
| 1 |
from sys import exit as exiter
|
| 2 |
-
|
| 3 |
from pymongo import MongoClient
|
| 4 |
from pymongo.errors import PyMongoError
|
|
|
|
| 5 |
|
| 6 |
-
from Powers import DB_NAME, DB_URI, LOGGER
|
| 7 |
|
| 8 |
try:
|
| 9 |
Powers_db_client = MongoClient(DB_URI)
|
|
|
|
| 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)
|
Powers/database/antispam_db.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 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()
|
| 8 |
|
|
|
|
|
|
|
| 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()
|
| 8 |
|
Powers/database/approve_db.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
from threading import RLock
|
| 2 |
-
|
| 3 |
from Powers import LOGGER
|
|
|
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
|
|
|
| 6 |
INSERTION_LOCK = RLock()
|
| 7 |
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 1 |
from Powers import LOGGER
|
| 2 |
+
from threading import RLock
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
+
|
| 6 |
INSERTION_LOCK = RLock()
|
| 7 |
|
| 8 |
|
Powers/database/blacklist_db.py
CHANGED
|
@@ -1,9 +1,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 |
|
|
|
|
|
|
|
| 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 |
|
Powers/database/chats_db.py
CHANGED
|
@@ -1,9 +1,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 |
|
|
|
|
|
|
|
| 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 |
|
Powers/database/disable_db.py
CHANGED
|
@@ -1,9 +1,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 |
DISABLED_CMDS = {}
|
| 9 |
|
|
@@ -74,8 +74,8 @@ class Disabling(MongoDB):
|
|
| 74 |
collection = MongoDB(Disabling.db_name)
|
| 75 |
curr = collection.find_all()
|
| 76 |
return sum(
|
| 77 |
-
len(chat["commands"] if chat["commands"] else [])
|
| 78 |
-
|
| 79 |
|
| 80 |
@staticmethod
|
| 81 |
def count_disabling_chats():
|
|
@@ -96,10 +96,7 @@ class Disabling(MongoDB):
|
|
| 96 |
}
|
| 97 |
return self.update(
|
| 98 |
{"_id": self.chat_id},
|
| 99 |
-
{
|
| 100 |
-
"_id": self.chat_id,
|
| 101 |
-
"action": action
|
| 102 |
-
},
|
| 103 |
)
|
| 104 |
|
| 105 |
def get_action(self):
|
|
@@ -121,8 +118,8 @@ class Disabling(MongoDB):
|
|
| 121 |
collection = MongoDB(Disabling.db_name)
|
| 122 |
all_data = collection.find_all({"action": action})
|
| 123 |
return sum(
|
| 124 |
-
len(i["commands"] if i["commands"] else []) >= 1
|
| 125 |
-
|
| 126 |
|
| 127 |
def rm_all_disabled(self):
|
| 128 |
with INSERTION_LOCK:
|
|
@@ -149,13 +146,9 @@ class Disabling(MongoDB):
|
|
| 149 |
"commands": [],
|
| 150 |
"action": "none",
|
| 151 |
}
|
| 152 |
-
DISABLED_CMDS[self.chat_id] = {
|
| 153 |
-
"commands": [],
|
| 154 |
-
"action": "none"
|
| 155 |
-
}
|
| 156 |
self.insert_one(new_data)
|
| 157 |
-
LOGGER.info(
|
| 158 |
-
f"Initialized Disabling Document for chat {self.chat_id}")
|
| 159 |
return new_data
|
| 160 |
DISABLED_CMDS[self.chat_id] = chat_data
|
| 161 |
return chat_data
|
|
|
|
|
|
|
| 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 |
|
|
|
|
| 74 |
collection = MongoDB(Disabling.db_name)
|
| 75 |
curr = collection.find_all()
|
| 76 |
return sum(
|
| 77 |
+
len(chat["commands"] if chat["commands"] else []) for chat in curr
|
| 78 |
+
)
|
| 79 |
|
| 80 |
@staticmethod
|
| 81 |
def count_disabling_chats():
|
|
|
|
| 96 |
}
|
| 97 |
return self.update(
|
| 98 |
{"_id": self.chat_id},
|
| 99 |
+
{"_id": self.chat_id, "action": action},
|
|
|
|
|
|
|
|
|
|
| 100 |
)
|
| 101 |
|
| 102 |
def get_action(self):
|
|
|
|
| 118 |
collection = MongoDB(Disabling.db_name)
|
| 119 |
all_data = collection.find_all({"action": action})
|
| 120 |
return sum(
|
| 121 |
+
len(i["commands"] if i["commands"] else []) >= 1 for i in all_data
|
| 122 |
+
)
|
| 123 |
|
| 124 |
def rm_all_disabled(self):
|
| 125 |
with INSERTION_LOCK:
|
|
|
|
| 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
|
Powers/database/filters_db.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 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 |
|
|
|
|
| 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 |
|
Powers/database/greetings_db.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
from threading import RLock
|
| 2 |
-
|
| 3 |
from Powers import LOGGER
|
|
|
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
|
|
|
| 6 |
INSERTION_LOCK = RLock()
|
| 7 |
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 1 |
from Powers import LOGGER
|
| 2 |
+
from threading import RLock
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
+
|
| 6 |
INSERTION_LOCK = RLock()
|
| 7 |
|
| 8 |
|
Powers/database/group_blacklist.py
CHANGED
|
@@ -1,8 +1,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 |
|
|
|
|
| 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 |
|
Powers/database/notes_db.py
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
|
|
| 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,8 +57,7 @@ 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 = [(note["note_name"], note["hash"]) for note in curr]
|
| 61 |
-
note_list.sort()
|
| 62 |
return note_list
|
| 63 |
|
| 64 |
def rm_note(self, chat_id: int, note_name: str):
|
|
|
|
| 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 |
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):
|
Powers/database/pins_db.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
-
from threading import RLock
|
| 2 |
-
|
| 3 |
from Powers import LOGGER
|
|
|
|
| 4 |
from Powers.database import MongoDB
|
| 5 |
|
|
|
|
| 6 |
INSERTION_LOCK = RLock()
|
| 7 |
|
| 8 |
|
|
|
|
|
|
|
|
|
|
| 1 |
from Powers import LOGGER
|
| 2 |
+
from threading import RLock
|
| 3 |
from Powers.database import MongoDB
|
| 4 |
|
| 5 |
+
|
| 6 |
INSERTION_LOCK = RLock()
|
| 7 |
|
| 8 |
|
Powers/database/reporting_db.py
CHANGED
|
@@ -1,9 +1,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 |
|
|
|
|
|
|
|
| 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 |
|
Powers/database/rules_db.py
CHANGED
|
@@ -1,9 +1,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 |
|
|
|
|
|
|
|
| 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 |
|
Powers/database/users_db.py
CHANGED
|
@@ -1,9 +1,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 |
|
|
@@ -53,7 +53,8 @@ class Users(MongoDB):
|
|
| 53 |
if isinstance(user_id, int):
|
| 54 |
curr = collection.find_one({"_id": user_id})
|
| 55 |
elif isinstance(user_id, str):
|
| 56 |
-
# user_id[1:] because we don't want the '@' in the username
|
|
|
|
| 57 |
curr = collection.find_one({"username": user_id[1:]})
|
| 58 |
else:
|
| 59 |
curr = None
|
|
|
|
|
|
|
| 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 |
|
|
|
|
| 53 |
if isinstance(user_id, int):
|
| 54 |
curr = collection.find_one({"_id": user_id})
|
| 55 |
elif isinstance(user_id, str):
|
| 56 |
+
# user_id[1:] because we don't want the '@' in the username
|
| 57 |
+
# search!
|
| 58 |
curr = collection.find_one({"username": user_id[1:]})
|
| 59 |
else:
|
| 60 |
curr = None
|
Powers/database/warns_db.py
CHANGED
|
@@ -1,9 +1,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 |
|
|
|
|
|
|
|
| 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 |
|
Powers/plugins/__init__.py
CHANGED
|
@@ -3,7 +3,7 @@ async def all_plugins():
|
|
| 3 |
# work.
|
| 4 |
|
| 5 |
from glob import glob
|
| 6 |
-
from os.path import
|
| 7 |
|
| 8 |
mod_paths = glob(dirname(__file__) + "/*.py")
|
| 9 |
all_plugs = [
|
|
|
|
| 3 |
# work.
|
| 4 |
|
| 5 |
from glob import glob
|
| 6 |
+
from os.path import isfile, dirname, basename
|
| 7 |
|
| 8 |
mod_paths = glob(dirname(__file__) + "/*.py")
|
| 9 |
all_plugs = [
|
Powers/plugins/admin.py
CHANGED
|
@@ -1,35 +1,24 @@
|
|
| 1 |
-
from asyncio import sleep
|
| 2 |
-
from html import escape
|
| 3 |
from os import remove
|
| 4 |
-
from
|
| 5 |
-
|
| 6 |
from pyrogram import filters
|
| 7 |
-
from
|
| 8 |
-
|
| 9 |
-
ChatAdminRequired,
|
| 10 |
-
FloodWait,
|
| 11 |
-
RightForbidden,
|
| 12 |
-
RPCError,
|
| 13 |
-
UserAdminInvalid,
|
| 14 |
-
)
|
| 15 |
-
from pyrogram.types import Message
|
| 16 |
-
|
| 17 |
-
from Powers import DEV_USERS, LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
| 18 |
from Powers.bot_class import Gojo
|
|
|
|
|
|
|
|
|
|
| 19 |
from Powers.database.approve_db import Approve
|
| 20 |
from Powers.database.reporting_db import Reporting
|
| 21 |
-
from Powers.utils.caching import ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload
|
| 22 |
-
from Powers.utils.chat_type import chattype
|
| 23 |
-
from Powers.utils.custom_filters import (
|
| 24 |
-
DEV_LEVEL,
|
| 25 |
-
admin_filter,
|
| 26 |
-
command,
|
| 27 |
-
owner_filter,
|
| 28 |
-
promote_filter,
|
| 29 |
-
)
|
| 30 |
from Powers.utils.extract_user import extract_user
|
| 31 |
-
from Powers
|
| 32 |
-
from Powers.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
|
| 35 |
@Gojo.on_message(command("adminlist"))
|
|
@@ -47,8 +36,8 @@ async def adminlist_show(_, m: Message):
|
|
| 47 |
except KeyError:
|
| 48 |
admin_list = await admin_cache_reload(m, "adminlist")
|
| 49 |
note = "<i>Note:</i> These are up-to-date values!"
|
| 50 |
-
|
| 51 |
-
adminstr = f"Admins in <b>{m.chat.title}</b>:"+ "\n\n"
|
| 52 |
|
| 53 |
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
|
| 54 |
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
|
|
@@ -178,7 +167,9 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 178 |
global ADMIN_CACHE
|
| 179 |
|
| 180 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
| 181 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 182 |
return
|
| 183 |
|
| 184 |
try:
|
|
@@ -245,7 +236,6 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 245 |
LOGGER.info(
|
| 246 |
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
| 247 |
)
|
| 248 |
-
|
| 249 |
|
| 250 |
await m.reply_text(
|
| 251 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
|
@@ -257,7 +247,8 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 257 |
),
|
| 258 |
)
|
| 259 |
|
| 260 |
-
# If user is approved, disapprove them as they willbe promoted and get
|
|
|
|
| 261 |
if Approve(m.chat.id).check_approve(user_id):
|
| 262 |
Approve(m.chat.id).remove_approve(user_id)
|
| 263 |
|
|
@@ -273,9 +264,11 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 273 |
except ChatAdminRequired:
|
| 274 |
await m.reply_text(text="I'm not admin or I don't have rights......")
|
| 275 |
except RightForbidden:
|
| 276 |
-
await m.reply_text(text
|
| 277 |
except UserAdminInvalid:
|
| 278 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 279 |
except RPCError as e:
|
| 280 |
await m.reply_text(
|
| 281 |
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{e}</code>"
|
|
@@ -291,7 +284,9 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 291 |
global ADMIN_CACHE
|
| 292 |
|
| 293 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
| 294 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 295 |
return
|
| 296 |
|
| 297 |
try:
|
|
@@ -343,7 +338,7 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 343 |
if title and len(title) > 16:
|
| 344 |
title = title[0:16] # trim title to 16 characters
|
| 345 |
if not title:
|
| 346 |
-
title="Itadori"
|
| 347 |
|
| 348 |
try:
|
| 349 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
@@ -364,7 +359,8 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 364 |
),
|
| 365 |
)
|
| 366 |
|
| 367 |
-
# If user is approved, disapprove them as they willbe promoted and get
|
|
|
|
| 368 |
if Approve(m.chat.id).check_approve(user_id):
|
| 369 |
Approve(m.chat.id).remove_approve(user_id)
|
| 370 |
|
|
@@ -382,7 +378,9 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 382 |
except RightForbidden:
|
| 383 |
await m.reply_text(text="I don't have enough rights to promote this user.")
|
| 384 |
except UserAdminInvalid:
|
| 385 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 386 |
except RPCError as e:
|
| 387 |
await m.reply_text(
|
| 388 |
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{e}</code>"
|
|
@@ -406,7 +404,6 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
| 406 |
link = await c.export_chat_invite_link(m.chat.id)
|
| 407 |
await m.reply_text(
|
| 408 |
text=f"Invite Link for Chat <b>{m.chat.id}</b>: {link}",
|
| 409 |
-
|
| 410 |
disable_web_page_preview=True,
|
| 411 |
)
|
| 412 |
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
|
|
@@ -418,7 +415,7 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
| 418 |
await m.reply_text(text="You don't have permissions to invite users.")
|
| 419 |
except RPCError as ef:
|
| 420 |
await m.reply_text(
|
| 421 |
-
text
|
| 422 |
)
|
| 423 |
LOGGER.error(ef)
|
| 424 |
LOGGER.error(format_exc())
|
|
@@ -575,4 +572,4 @@ __HELP__ = """
|
|
| 575 |
* /enableall: enable all disabled commands.
|
| 576 |
|
| 577 |
**Example:**
|
| 578 |
-
`/promote @username`: this promotes a user to admin."""
|
|
|
|
|
|
|
|
|
|
| 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 pyrogram.types import Message
|
| 9 |
+
from Powers.utils.chat_type import chattype
|
| 10 |
+
from Powers.utils.parser import mention_html
|
| 11 |
from Powers.database.approve_db import Approve
|
| 12 |
from Powers.database.reporting_db import Reporting
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
from Powers.utils.extract_user import extract_user
|
| 14 |
+
from 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"))
|
|
|
|
| 36 |
except KeyError:
|
| 37 |
admin_list = await admin_cache_reload(m, "adminlist")
|
| 38 |
note = "<i>Note:</i> These are up-to-date values!"
|
| 39 |
+
|
| 40 |
+
adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
|
| 41 |
|
| 42 |
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
|
| 43 |
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
|
|
|
|
| 167 |
global ADMIN_CACHE
|
| 168 |
|
| 169 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
| 170 |
+
await m.reply_text(
|
| 171 |
+
text="I can't promote nothing! Give me an username or user id or atleast reply to that user"
|
| 172 |
+
)
|
| 173 |
return
|
| 174 |
|
| 175 |
try:
|
|
|
|
| 236 |
LOGGER.info(
|
| 237 |
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
| 238 |
)
|
|
|
|
| 239 |
|
| 240 |
await m.reply_text(
|
| 241 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
|
|
|
| 247 |
),
|
| 248 |
)
|
| 249 |
|
| 250 |
+
# If user is approved, disapprove them as they willbe promoted and get
|
| 251 |
+
# even more rights
|
| 252 |
if Approve(m.chat.id).check_approve(user_id):
|
| 253 |
Approve(m.chat.id).remove_approve(user_id)
|
| 254 |
|
|
|
|
| 264 |
except ChatAdminRequired:
|
| 265 |
await m.reply_text(text="I'm not admin or I don't have rights......")
|
| 266 |
except RightForbidden:
|
| 267 |
+
await m.reply_text(text="I don't have enough rights to promote this user.")
|
| 268 |
except UserAdminInvalid:
|
| 269 |
+
await m.reply_text(
|
| 270 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 271 |
+
)
|
| 272 |
except RPCError as e:
|
| 273 |
await m.reply_text(
|
| 274 |
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{e}</code>"
|
|
|
|
| 284 |
global ADMIN_CACHE
|
| 285 |
|
| 286 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
| 287 |
+
await m.reply_text(
|
| 288 |
+
text="I can't promote nothing!......reply to user to promote him/her...."
|
| 289 |
+
)
|
| 290 |
return
|
| 291 |
|
| 292 |
try:
|
|
|
|
| 338 |
if title and len(title) > 16:
|
| 339 |
title = title[0:16] # trim title to 16 characters
|
| 340 |
if not title:
|
| 341 |
+
title = "Itadori"
|
| 342 |
|
| 343 |
try:
|
| 344 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
|
|
| 359 |
),
|
| 360 |
)
|
| 361 |
|
| 362 |
+
# If user is approved, disapprove them as they willbe promoted and get
|
| 363 |
+
# even more rights
|
| 364 |
if Approve(m.chat.id).check_approve(user_id):
|
| 365 |
Approve(m.chat.id).remove_approve(user_id)
|
| 366 |
|
|
|
|
| 378 |
except RightForbidden:
|
| 379 |
await m.reply_text(text="I don't have enough rights to promote this user.")
|
| 380 |
except UserAdminInvalid:
|
| 381 |
+
await m.reply_text(
|
| 382 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 383 |
+
)
|
| 384 |
except RPCError as e:
|
| 385 |
await m.reply_text(
|
| 386 |
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{e}</code>"
|
|
|
|
| 404 |
link = await c.export_chat_invite_link(m.chat.id)
|
| 405 |
await m.reply_text(
|
| 406 |
text=f"Invite Link for Chat <b>{m.chat.id}</b>: {link}",
|
|
|
|
| 407 |
disable_web_page_preview=True,
|
| 408 |
)
|
| 409 |
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
|
|
|
|
| 415 |
await m.reply_text(text="You don't have permissions to invite users.")
|
| 416 |
except RPCError as ef:
|
| 417 |
await m.reply_text(
|
| 418 |
+
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{ef}</code>"
|
| 419 |
)
|
| 420 |
LOGGER.error(ef)
|
| 421 |
LOGGER.error(format_exc())
|
|
|
|
| 572 |
* /enableall: enable all disabled commands.
|
| 573 |
|
| 574 |
**Example:**
|
| 575 |
+
`/promote @username`: this promotes a user to admin."""
|
Powers/plugins/antispam.py
CHANGED
|
@@ -1,19 +1,18 @@
|
|
| 1 |
-
from datetime import datetime
|
| 2 |
from io import BytesIO
|
|
|
|
|
|
|
| 3 |
from traceback import format_exc
|
| 4 |
-
|
| 5 |
-
from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
|
| 6 |
-
from pyrogram.types import Message
|
| 7 |
-
|
| 8 |
-
from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
-
from
|
| 11 |
from Powers.database.users_db import Users
|
| 12 |
-
from Powers.
|
|
|
|
| 13 |
from Powers.utils.custom_filters import command
|
| 14 |
from Powers.utils.extract_user import extract_user
|
| 15 |
-
from Powers.utils.
|
| 16 |
-
from Powers
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Initialize
|
| 19 |
db = GBan()
|
|
@@ -22,7 +21,9 @@ db = GBan()
|
|
| 22 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
| 23 |
async def gban(c: Gojo, m: Message):
|
| 24 |
if len(m.text.split()) == 1:
|
| 25 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 26 |
return
|
| 27 |
|
| 28 |
if len(m.text.split()) == 2 and not m.reply_to_message:
|
|
@@ -41,29 +42,31 @@ async def gban(c: Gojo, m: Message):
|
|
| 41 |
return
|
| 42 |
|
| 43 |
if user_id == Config.BOT_ID:
|
| 44 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 45 |
return
|
| 46 |
|
| 47 |
if db.check_gban(user_id):
|
| 48 |
db.update_gban_reason(user_id, gban_reason)
|
| 49 |
-
await m.reply_text(
|
| 50 |
-
text="Updated Gban reason to: <code>{gban_reason}</code>."
|
| 51 |
-
)
|
| 52 |
return
|
| 53 |
|
| 54 |
db.add_gban(user_id, gban_reason, m.from_user.id)
|
| 55 |
await m.reply_text(
|
| 56 |
-
(
|
|
|
|
|
|
|
| 57 |
)
|
| 58 |
LOGGER.info(f"{m.from_user.id} gbanned {user_id} from {m.chat.id}")
|
| 59 |
-
date =
|
| 60 |
-
log_msg = f"#GBAN \n <b>Originated from:</b> {m.chat.id} \n <b>Admin:</b> {await mention_html(m.from_user.first_name, m.from_user.id)} \n <b>Gbanned User:</b> {await mention_html(user_first_name, user_id)} \n <b>Gbanned User ID:</b> {user_id}
|
| 61 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
| 62 |
try:
|
| 63 |
# Send message to user telling that he's gbanned
|
| 64 |
await c.send_message(
|
| 65 |
user_id,
|
| 66 |
-
f"You have been added to my global ban list! \n <b>Reason:</b> <code>{gban_reason}</code> \n <b>Appeal Chat:</b> @{SUPPORT_GROUP}"
|
| 67 |
)
|
| 68 |
except UserIsBlocked:
|
| 69 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
|
@@ -82,7 +85,7 @@ async def gban(c: Gojo, m: Message):
|
|
| 82 |
)
|
| 83 |
async def ungban(c: Gojo, m: Message):
|
| 84 |
if len(m.text.split()) == 1:
|
| 85 |
-
await m.reply_text(text=
|
| 86 |
return
|
| 87 |
|
| 88 |
user_id, user_first_name, _ = await extract_user(c, m)
|
|
@@ -92,29 +95,29 @@ async def ungban(c: Gojo, m: Message):
|
|
| 92 |
return
|
| 93 |
|
| 94 |
if user_id == Config.BOT_ID:
|
| 95 |
-
await m.reply_text(
|
| 96 |
-
|
|
|
|
|
|
|
| 97 |
return
|
| 98 |
|
| 99 |
if db.check_gban(user_id):
|
| 100 |
db.remove_gban(user_id)
|
| 101 |
-
await m.reply_text(
|
| 102 |
-
|
| 103 |
-
)
|
| 104 |
-
time=(datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),
|
| 105 |
LOGGER.info(f"{m.from_user.id} ungbanned {user_id} from {m.chat.id}")
|
| 106 |
-
log_msg =
|
| 107 |
<b>Originated from:</b> {m.chat.id}
|
| 108 |
<b>Admin:</b> {(await mention_html(m.from_user.first_name, m.from_user.id))}
|
| 109 |
<b>UnGbanned User:</b> {(await mention_html(user_first_name, user_id))}
|
| 110 |
<b>UnGbanned User ID:</b> {user_id}
|
| 111 |
-
<b>Event Stamp:</b> {time}"""
|
| 112 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
| 113 |
try:
|
| 114 |
# Send message to user telling that he's ungbanned
|
| 115 |
await c.send_message(
|
| 116 |
user_id,
|
| 117 |
-
text="You have been removed from my global ban list!.....Be careful it takes few seconds to add you again..."
|
| 118 |
)
|
| 119 |
except Exception as ef: # TODO: Improve Error Detection
|
| 120 |
LOGGER.error(ef)
|
|
@@ -130,7 +133,8 @@ async def ungban(c: Gojo, m: Message):
|
|
| 130 |
)
|
| 131 |
async def gban_count(_, m: Message):
|
| 132 |
await m.reply_text(
|
| 133 |
-
text=f"Number of people gbanned: <code>{(db.count_gbans())}</code>"
|
|
|
|
| 134 |
LOGGER.info(f"{m.from_user.id} counting gbans in {m.chat.id}")
|
| 135 |
return
|
| 136 |
|
|
@@ -157,11 +161,9 @@ async def gban_list(_, m: Message):
|
|
| 157 |
with BytesIO(str.encode(await remove_markdown_and_html(banfile))) as f:
|
| 158 |
f.name = "gbanlist.txt"
|
| 159 |
await m.reply_document(
|
| 160 |
-
document=f,
|
| 161 |
-
caption="Here are all the globally banned geys!\n\n"
|
| 162 |
)
|
| 163 |
|
| 164 |
LOGGER.info(f"{m.from_user.id} exported gbanlist in {m.chat.id}")
|
| 165 |
|
| 166 |
return
|
| 167 |
-
|
|
|
|
|
|
|
| 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()
|
|
|
|
| 21 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
| 22 |
async def gban(c: Gojo, m: Message):
|
| 23 |
if len(m.text.split()) == 1:
|
| 24 |
+
await m.reply_text(
|
| 25 |
+
text="<b>How to gban?</b> \n <b>Answer:</b> <code>/gban user_id reason</code>"
|
| 26 |
+
)
|
| 27 |
return
|
| 28 |
|
| 29 |
if len(m.text.split()) == 2 and not m.reply_to_message:
|
|
|
|
| 42 |
return
|
| 43 |
|
| 44 |
if user_id == Config.BOT_ID:
|
| 45 |
+
await m.reply_text(
|
| 46 |
+
text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......"
|
| 47 |
+
)
|
| 48 |
return
|
| 49 |
|
| 50 |
if db.check_gban(user_id):
|
| 51 |
db.update_gban_reason(user_id, gban_reason)
|
| 52 |
+
await m.reply_text(text="Updated Gban reason to: <code>{gban_reason}</code>.")
|
|
|
|
|
|
|
| 53 |
return
|
| 54 |
|
| 55 |
db.add_gban(user_id, gban_reason, m.from_user.id)
|
| 56 |
await m.reply_text(
|
| 57 |
+
(
|
| 58 |
+
f"Added {user_first_name} to GBan List. \n They will now be banned in all groups where I'm admin!"
|
| 59 |
+
)
|
| 60 |
)
|
| 61 |
LOGGER.info(f"{m.from_user.id} gbanned {user_id} from {m.chat.id}")
|
| 62 |
+
date = datetime.utcnow().strftime("%H:%M - %d-%m-%Y")
|
| 63 |
+
log_msg = f"#GBAN \n <b>Originated from:</b> {m.chat.id} \n <b>Admin:</b> {await mention_html(m.from_user.first_name, m.from_user.id)} \n <b>Gbanned User:</b> {await mention_html(user_first_name, user_id)} \n <b>Gbanned User ID:</b> {user_id} \\ n<b>Event Stamp:</b> {date}"
|
| 64 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
| 65 |
try:
|
| 66 |
# Send message to user telling that he's gbanned
|
| 67 |
await c.send_message(
|
| 68 |
user_id,
|
| 69 |
+
f"You have been added to my global ban list! \n <b>Reason:</b> <code>{gban_reason}</code> \n <b>Appeal Chat:</b> @{SUPPORT_GROUP}",
|
| 70 |
)
|
| 71 |
except UserIsBlocked:
|
| 72 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
|
|
|
| 85 |
)
|
| 86 |
async def ungban(c: Gojo, m: Message):
|
| 87 |
if len(m.text.split()) == 1:
|
| 88 |
+
await m.reply_text(text="Pass a user id or username as an argument!")
|
| 89 |
return
|
| 90 |
|
| 91 |
user_id, user_first_name, _ = await extract_user(c, m)
|
|
|
|
| 95 |
return
|
| 96 |
|
| 97 |
if user_id == Config.BOT_ID:
|
| 98 |
+
await m.reply_text(
|
| 99 |
+
text="""You can't gban me nigga!
|
| 100 |
+
Fuck yourself.......!"""
|
| 101 |
+
)
|
| 102 |
return
|
| 103 |
|
| 104 |
if db.check_gban(user_id):
|
| 105 |
db.remove_gban(user_id)
|
| 106 |
+
await m.reply_text(text=f"Removed {user_first_name} from Global Ban List.")
|
| 107 |
+
time = ((datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),)
|
|
|
|
|
|
|
| 108 |
LOGGER.info(f"{m.from_user.id} ungbanned {user_id} from {m.chat.id}")
|
| 109 |
+
log_msg = f"""#UNGBAN
|
| 110 |
<b>Originated from:</b> {m.chat.id}
|
| 111 |
<b>Admin:</b> {(await mention_html(m.from_user.first_name, m.from_user.id))}
|
| 112 |
<b>UnGbanned User:</b> {(await mention_html(user_first_name, user_id))}
|
| 113 |
<b>UnGbanned User ID:</b> {user_id}
|
| 114 |
+
<b>Event Stamp:</b> {time}"""
|
| 115 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
| 116 |
try:
|
| 117 |
# Send message to user telling that he's ungbanned
|
| 118 |
await c.send_message(
|
| 119 |
user_id,
|
| 120 |
+
text="You have been removed from my global ban list!.....Be careful it takes few seconds to add you again...",
|
| 121 |
)
|
| 122 |
except Exception as ef: # TODO: Improve Error Detection
|
| 123 |
LOGGER.error(ef)
|
|
|
|
| 133 |
)
|
| 134 |
async def gban_count(_, m: Message):
|
| 135 |
await m.reply_text(
|
| 136 |
+
text=f"Number of people gbanned: <code>{(db.count_gbans())}</code>"
|
| 137 |
+
)
|
| 138 |
LOGGER.info(f"{m.from_user.id} counting gbans in {m.chat.id}")
|
| 139 |
return
|
| 140 |
|
|
|
|
| 161 |
with BytesIO(str.encode(await remove_markdown_and_html(banfile))) as f:
|
| 162 |
f.name = "gbanlist.txt"
|
| 163 |
await m.reply_document(
|
| 164 |
+
document=f, caption="Here are all the globally banned geys!\n\n"
|
|
|
|
| 165 |
)
|
| 166 |
|
| 167 |
LOGGER.info(f"{m.from_user.id} exported gbanlist in {m.chat.id}")
|
| 168 |
|
| 169 |
return
|
|
|
Powers/plugins/approve.py
CHANGED
|
@@ -1,14 +1,13 @@
|
|
| 1 |
from pyrogram import filters
|
| 2 |
-
from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
|
| 3 |
-
from pyrogram.types import CallbackQuery, ChatPermissions, Message
|
| 4 |
-
|
| 5 |
-
from Powers import LOGGER, SUPPORT_GROUP
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
-
from Powers.database.approve_db import Approve
|
| 8 |
-
from Powers.utils.custom_filters import admin_filter, command, owner_filter
|
| 9 |
-
from Powers.utils.extract_user import extract_user
|
| 10 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
| 11 |
from Powers.utils.parser import mention_html
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
|
| 14 |
@Gojo.on_message(command("approve") & admin_filter)
|
|
@@ -244,4 +243,4 @@ __HELP__ = """
|
|
| 244 |
* /approved: List all approved users.
|
| 245 |
* /unapproveall: Unapprove *ALL* users in a chat. This cannot be undone!
|
| 246 |
**Example:**
|
| 247 |
-
`/approve @username`: this approves a user in the chat."""
|
|
|
|
| 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 Powers.utils.extract_user import extract_user
|
| 8 |
+
from pyrogram.types import Message, CallbackQuery, ChatPermissions
|
| 9 |
+
from pyrogram.errors import RPCError, PeerIdInvalid, UserNotParticipant
|
| 10 |
+
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
| 11 |
|
| 12 |
|
| 13 |
@Gojo.on_message(command("approve") & admin_filter)
|
|
|
|
| 243 |
* /approved: List all approved users.
|
| 244 |
* /unapproveall: Unapprove *ALL* users in a chat. This cannot be undone!
|
| 245 |
**Example:**
|
| 246 |
+
`/approve @username`: this approves a user in the chat."""
|
Powers/plugins/bans.py
CHANGED
|
@@ -1,35 +1,26 @@
|
|
| 1 |
-
from traceback import format_exc
|
| 2 |
from random import choice
|
| 3 |
-
|
| 4 |
-
from
|
| 5 |
-
ChatAdminRequired,
|
| 6 |
-
PeerIdInvalid,
|
| 7 |
-
RightForbidden,
|
| 8 |
-
RPCError,
|
| 9 |
-
UserAdminInvalid,
|
| 10 |
-
)
|
| 11 |
-
from pyrogram.filters import regex
|
| 12 |
-
from pyrogram.types import (
|
| 13 |
-
CallbackQuery,
|
| 14 |
-
InlineKeyboardButton,
|
| 15 |
-
InlineKeyboardMarkup,
|
| 16 |
-
Message,
|
| 17 |
-
)
|
| 18 |
-
|
| 19 |
-
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
| 20 |
from Powers.bot_class import Gojo
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS
|
| 22 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 23 |
from Powers.utils.custom_filters import command, restrict_filter
|
| 24 |
-
from Powers
|
| 25 |
-
from
|
| 26 |
-
|
| 27 |
-
from
|
|
|
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
BAN_MEDIA = choice(BAN_GIFS)
|
| 31 |
KICK_MEDIA = choice(KICK_GIFS)
|
| 32 |
|
|
|
|
| 33 |
@Gojo.on_message(command("tban") & restrict_filter)
|
| 34 |
async def tban_usr(c: Gojo, m: Message):
|
| 35 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
|
@@ -49,7 +40,9 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 49 |
await m.stop_propagation()
|
| 50 |
|
| 51 |
if user_id in SUPPORT_STAFF:
|
| 52 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 53 |
LOGGER.info(
|
| 54 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 55 |
)
|
|
@@ -88,14 +81,16 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 88 |
await m.stop_propagation()
|
| 89 |
|
| 90 |
try:
|
| 91 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
| 92 |
-
banned=(await mention_html(user_first_name, user_id)),
|
| 93 |
-
chat_title=m.chat.title,
|
| 94 |
LOGGER.info(f"{m.from_user.id} tbanned {user_id} in {m.chat.id}")
|
| 95 |
-
await m.chat.ban_member(
|
| 96 |
-
|
|
|
|
|
|
|
| 97 |
)
|
| 98 |
-
|
| 99 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 100 |
keyboard = InlineKeyboardMarkup(
|
| 101 |
[
|
|
@@ -107,8 +102,15 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 107 |
],
|
| 108 |
],
|
| 109 |
)
|
| 110 |
-
await m.reply_animation(
|
| 111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
except ChatAdminRequired:
|
| 113 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 114 |
except PeerIdInvalid:
|
|
@@ -116,14 +118,18 @@ async def tban_usr(c: Gojo, m: Message):
|
|
| 116 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 117 |
)
|
| 118 |
except UserAdminInvalid:
|
| 119 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 120 |
except RightForbidden:
|
| 121 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 122 |
except RPCError as ef:
|
| 123 |
await m.reply_text(
|
| 124 |
-
(
|
|
|
|
| 125 |
|
| 126 |
-
<b>Error:</b> <code>{ef}</code>"""
|
|
|
|
| 127 |
)
|
| 128 |
LOGGER.error(ef)
|
| 129 |
LOGGER.error(format_exc())
|
|
@@ -149,7 +155,9 @@ async def stban_usr(c: Gojo, m: Message):
|
|
| 149 |
await m.stop_propagation()
|
| 150 |
|
| 151 |
if user_id in SUPPORT_STAFF:
|
| 152 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 153 |
LOGGER.info(
|
| 154 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 155 |
)
|
|
@@ -200,7 +208,9 @@ async def stban_usr(c: Gojo, m: Message):
|
|
| 200 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 201 |
)
|
| 202 |
except UserAdminInvalid:
|
| 203 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 204 |
except RightForbidden:
|
| 205 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 206 |
except RPCError as ef:
|
|
@@ -274,15 +284,14 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
| 274 |
await m.stop_propagation()
|
| 275 |
|
| 276 |
try:
|
| 277 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
| 278 |
-
banned=(await mention_html(user_first_name, user_id)),
|
| 279 |
-
chat_title=m.chat.title,
|
| 280 |
LOGGER.info(f"{m.from_user.id} dtbanned {user_id} in {m.chat.id}")
|
| 281 |
await m.chat.ban_member(user_id, until_date=int(bantime))
|
| 282 |
await m.reply_to_message.delete()
|
| 283 |
txt = f"{admin} banned {banned} in <b>{chat_title}</b>!"
|
| 284 |
-
|
| 285 |
-
|
| 286 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 287 |
keyboard = InlineKeyboardMarkup(
|
| 288 |
[
|
|
@@ -294,7 +303,13 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
| 294 |
],
|
| 295 |
],
|
| 296 |
)
|
| 297 |
-
await c.send_animation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
| 299 |
except ChatAdminRequired:
|
| 300 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
@@ -303,7 +318,9 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
| 303 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 304 |
)
|
| 305 |
except UserAdminInvalid:
|
| 306 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 307 |
except RightForbidden:
|
| 308 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 309 |
except RPCError as ef:
|
|
@@ -347,7 +364,9 @@ async def kick_usr(c: Gojo, m: Message):
|
|
| 347 |
await m.stop_propagation()
|
| 348 |
|
| 349 |
if user_id in SUPPORT_STAFF:
|
| 350 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 351 |
LOGGER.info(
|
| 352 |
f"{m.from_user.id} trying to kick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 353 |
)
|
|
@@ -363,15 +382,20 @@ async def kick_usr(c: Gojo, m: Message):
|
|
| 363 |
await m.stop_propagation()
|
| 364 |
|
| 365 |
try:
|
| 366 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
| 367 |
-
kicked=(await mention_html(user_first_name, user_id)),
|
| 368 |
-
chat_title=m.chat.title,
|
| 369 |
LOGGER.info(f"{m.from_user.id} kicked {user_id} in {m.chat.id}")
|
| 370 |
await m.chat.ban_member(user_id)
|
| 371 |
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
| 372 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 373 |
-
|
| 374 |
-
await m.reply_animation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 375 |
await m.chat.unban_member(user_id)
|
| 376 |
except ChatAdminRequired:
|
| 377 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
@@ -380,7 +404,9 @@ async def kick_usr(c: Gojo, m: Message):
|
|
| 380 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 381 |
)
|
| 382 |
except UserAdminInvalid:
|
| 383 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 384 |
except RightForbidden:
|
| 385 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 386 |
except RPCError as ef:
|
|
@@ -415,7 +441,9 @@ async def skick_usr(c: Gojo, m: Message):
|
|
| 415 |
await m.stop_propagation()
|
| 416 |
|
| 417 |
if user_id in SUPPORT_STAFF:
|
| 418 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 419 |
LOGGER.info(
|
| 420 |
f"{m.from_user.id} trying to skick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 421 |
)
|
|
@@ -444,7 +472,9 @@ async def skick_usr(c: Gojo, m: Message):
|
|
| 444 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 445 |
)
|
| 446 |
except UserAdminInvalid:
|
| 447 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 448 |
except RightForbidden:
|
| 449 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
| 450 |
except RPCError as ef:
|
|
@@ -481,7 +511,9 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
| 481 |
await m.stop_propagation()
|
| 482 |
|
| 483 |
if user_id in SUPPORT_STAFF:
|
| 484 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 485 |
LOGGER.info(
|
| 486 |
f"{m.from_user.id} trying to dkick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 487 |
)
|
|
@@ -500,13 +532,15 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
| 500 |
LOGGER.info(f"{m.from_user.id} dkicked {user_id} in {m.chat.id}")
|
| 501 |
await m.reply_to_message.delete()
|
| 502 |
await m.chat.ban_member(user_id)
|
| 503 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
| 504 |
-
kicked=(await mention_html(user_first_name, user_id)),
|
| 505 |
-
chat_title=m.chat.title,
|
| 506 |
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
| 507 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 508 |
await c.send_message(m.chat.id, txt)
|
| 509 |
-
await c.send_animation(
|
|
|
|
|
|
|
| 510 |
await m.chat.unban_member(user_id)
|
| 511 |
except ChatAdminRequired:
|
| 512 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
@@ -515,7 +549,9 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
| 515 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 516 |
)
|
| 517 |
except UserAdminInvalid:
|
| 518 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 519 |
except RightForbidden:
|
| 520 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
| 521 |
except RPCError as ef:
|
|
@@ -556,9 +592,9 @@ async def unban_usr(c: Gojo, m: Message):
|
|
| 556 |
|
| 557 |
try:
|
| 558 |
await m.chat.unban_member(user_id)
|
| 559 |
-
admin=m.from_user.mention,
|
| 560 |
-
unbanned=(await mention_html(user_first_name, user_id)),
|
| 561 |
-
chat_title=m.chat.title,
|
| 562 |
txt = f"{admin} unbanned {unbanned} in chat <b>{chat_title}</b>!"
|
| 563 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 564 |
await m.reply_text(txt)
|
|
@@ -568,7 +604,7 @@ async def unban_usr(c: Gojo, m: Message):
|
|
| 568 |
await m.reply_text(text="I don't have enough rights to unban this user.")
|
| 569 |
except RPCError as ef:
|
| 570 |
await m.reply_text(
|
| 571 |
-
|
| 572 |
|
| 573 |
<b>Error:</b> <code>{ef}</code>"""
|
| 574 |
)
|
|
@@ -603,7 +639,9 @@ async def sban_usr(c: Gojo, m: Message):
|
|
| 603 |
await m.stop_propagation()
|
| 604 |
|
| 605 |
if user_id in SUPPORT_STAFF:
|
| 606 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 607 |
LOGGER.info(
|
| 608 |
f"{m.from_user.id} trying to sban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 609 |
)
|
|
@@ -631,7 +669,9 @@ async def sban_usr(c: Gojo, m: Message):
|
|
| 631 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 632 |
)
|
| 633 |
except UserAdminInvalid:
|
| 634 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 635 |
except RightForbidden:
|
| 636 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 637 |
except RPCError as ef:
|
|
@@ -676,7 +716,9 @@ async def dban_usr(c: Gojo, m: Message):
|
|
| 676 |
await m.stop_propagation()
|
| 677 |
|
| 678 |
if user_id in SUPPORT_STAFF:
|
| 679 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 680 |
LOGGER.info(
|
| 681 |
f"{m.from_user.id} trying to dban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 682 |
)
|
|
@@ -699,7 +741,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
| 699 |
LOGGER.info(f"{m.from_user.id} dbanned {user_id} in {m.chat.id}")
|
| 700 |
await m.reply_to_message.delete()
|
| 701 |
await m.chat.ban_member(user_id)
|
| 702 |
-
txt =f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in <b>{m.chat.title}</b>!"
|
| 703 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 704 |
keyboard = InlineKeyboardMarkup(
|
| 705 |
[
|
|
@@ -711,7 +753,9 @@ async def dban_usr(c: Gojo, m: Message):
|
|
| 711 |
],
|
| 712 |
],
|
| 713 |
)
|
| 714 |
-
await c.send_animation(
|
|
|
|
|
|
|
| 715 |
except ChatAdminRequired:
|
| 716 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 717 |
except PeerIdInvalid:
|
|
@@ -719,7 +763,9 @@ async def dban_usr(c: Gojo, m: Message):
|
|
| 719 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 720 |
)
|
| 721 |
except UserAdminInvalid:
|
| 722 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 723 |
except RightForbidden:
|
| 724 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 725 |
except RPCError as ef:
|
|
@@ -761,7 +807,9 @@ async def ban_usr(c: Gojo, m: Message):
|
|
| 761 |
await m.stop_propagation()
|
| 762 |
|
| 763 |
if user_id in SUPPORT_STAFF:
|
| 764 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 765 |
LOGGER.info(
|
| 766 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 767 |
)
|
|
@@ -789,7 +837,7 @@ async def ban_usr(c: Gojo, m: Message):
|
|
| 789 |
try:
|
| 790 |
LOGGER.info(f"{m.from_user.id} banned {user_id} in {m.chat.id}")
|
| 791 |
await m.chat.ban_member(user_id)
|
| 792 |
-
banned=
|
| 793 |
txt = f"{m.from_user.mention} banned {banned} in <b>{m.chat.title}</b>!"
|
| 794 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 795 |
keyboard = InlineKeyboardMarkup(
|
|
@@ -802,7 +850,12 @@ async def ban_usr(c: Gojo, m: Message):
|
|
| 802 |
],
|
| 803 |
],
|
| 804 |
)
|
| 805 |
-
await m.reply_animation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
except ChatAdminRequired:
|
| 807 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 808 |
except PeerIdInvalid:
|
|
@@ -810,7 +863,9 @@ async def ban_usr(c: Gojo, m: Message):
|
|
| 810 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 811 |
)
|
| 812 |
except UserAdminInvalid:
|
| 813 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 814 |
except RightForbidden:
|
| 815 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 816 |
except RPCError as ef:
|
|
@@ -895,4 +950,4 @@ __HELP__ = """
|
|
| 895 |
* /dtban <userhandle> x(m/h/d): Silently bans a user for x time and delete the replied message. (via reply). m = minutes, h = hours, d = days.
|
| 896 |
* /unban: Unbans the user replied to or tagged.
|
| 897 |
**Example:**
|
| 898 |
-
`/ban @username`: this bans a user in the chat."""
|
|
|
|
|
|
|
| 1 |
from random import choice
|
| 2 |
+
from Powers.vars import Config
|
| 3 |
+
from traceback import format_exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from Powers.bot_class import Gojo
|
| 5 |
+
from pyrogram.filters import regex
|
| 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.extras import BAN_GIFS, KICK_GIFS
|
| 10 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 11 |
from Powers.utils.custom_filters import command, restrict_filter
|
| 12 |
+
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
| 13 |
+
from pyrogram.types import (
|
| 14 |
+
Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
|
| 15 |
+
from pyrogram.errors import (
|
| 16 |
+
RPCError, PeerIdInvalid, RightForbidden, UserAdminInvalid,
|
| 17 |
+
ChatAdminRequired)
|
| 18 |
|
| 19 |
|
| 20 |
BAN_MEDIA = choice(BAN_GIFS)
|
| 21 |
KICK_MEDIA = choice(KICK_GIFS)
|
| 22 |
|
| 23 |
+
|
| 24 |
@Gojo.on_message(command("tban") & restrict_filter)
|
| 25 |
async def tban_usr(c: Gojo, m: Message):
|
| 26 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
|
|
|
| 40 |
await m.stop_propagation()
|
| 41 |
|
| 42 |
if user_id in SUPPORT_STAFF:
|
| 43 |
+
await m.reply_text(
|
| 44 |
+
text="This user is in my support staff, cannot restrict them."
|
| 45 |
+
)
|
| 46 |
LOGGER.info(
|
| 47 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 48 |
)
|
|
|
|
| 81 |
await m.stop_propagation()
|
| 82 |
|
| 83 |
try:
|
| 84 |
+
admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
|
| 85 |
+
banned = ((await mention_html(user_first_name, user_id)),)
|
| 86 |
+
chat_title = (m.chat.title,)
|
| 87 |
LOGGER.info(f"{m.from_user.id} tbanned {user_id} in {m.chat.id}")
|
| 88 |
+
await m.chat.ban_member(
|
| 89 |
+
user_id,
|
| 90 |
+
until_date=int(bantime),
|
| 91 |
+
text=f"{admin} banned {banned} in <b>{chat_title}</b>!",
|
| 92 |
)
|
| 93 |
+
|
| 94 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 95 |
keyboard = InlineKeyboardMarkup(
|
| 96 |
[
|
|
|
|
| 102 |
],
|
| 103 |
],
|
| 104 |
)
|
| 105 |
+
await m.reply_animation(
|
| 106 |
+
reply_to_message_id=r_id,
|
| 107 |
+
animation=BAN_MEDIA,
|
| 108 |
+
caption=txt,
|
| 109 |
+
reply_markup=keyboard,
|
| 110 |
+
parse_mode="html",
|
| 111 |
+
)
|
| 112 |
+
# await m.reply_text(txt, reply_markup=keyboard,
|
| 113 |
+
# reply_to_message_id=r_id)
|
| 114 |
except ChatAdminRequired:
|
| 115 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 116 |
except PeerIdInvalid:
|
|
|
|
| 118 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 119 |
)
|
| 120 |
except UserAdminInvalid:
|
| 121 |
+
await m.reply_text(
|
| 122 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 123 |
+
)
|
| 124 |
except RightForbidden:
|
| 125 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 126 |
except RPCError as ef:
|
| 127 |
await m.reply_text(
|
| 128 |
+
(
|
| 129 |
+
f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 130 |
|
| 131 |
+
<b>Error:</b> <code>{ef}</code>"""
|
| 132 |
+
)
|
| 133 |
)
|
| 134 |
LOGGER.error(ef)
|
| 135 |
LOGGER.error(format_exc())
|
|
|
|
| 155 |
await m.stop_propagation()
|
| 156 |
|
| 157 |
if user_id in SUPPORT_STAFF:
|
| 158 |
+
await m.reply_text(
|
| 159 |
+
text="This user is in my support staff, cannot restrict them."
|
| 160 |
+
)
|
| 161 |
LOGGER.info(
|
| 162 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 163 |
)
|
|
|
|
| 208 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 209 |
)
|
| 210 |
except UserAdminInvalid:
|
| 211 |
+
await m.reply_text(
|
| 212 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 213 |
+
)
|
| 214 |
except RightForbidden:
|
| 215 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 216 |
except RPCError as ef:
|
|
|
|
| 284 |
await m.stop_propagation()
|
| 285 |
|
| 286 |
try:
|
| 287 |
+
admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
|
| 288 |
+
banned = ((await mention_html(user_first_name, user_id)),)
|
| 289 |
+
chat_title = (m.chat.title,)
|
| 290 |
LOGGER.info(f"{m.from_user.id} dtbanned {user_id} in {m.chat.id}")
|
| 291 |
await m.chat.ban_member(user_id, until_date=int(bantime))
|
| 292 |
await m.reply_to_message.delete()
|
| 293 |
txt = f"{admin} banned {banned} in <b>{chat_title}</b>!"
|
| 294 |
+
|
|
|
|
| 295 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 296 |
keyboard = InlineKeyboardMarkup(
|
| 297 |
[
|
|
|
|
| 303 |
],
|
| 304 |
],
|
| 305 |
)
|
| 306 |
+
await c.send_animation(
|
| 307 |
+
chat_id=m.chat.id,
|
| 308 |
+
animation=BAN_MEDIA,
|
| 309 |
+
caption=txt,
|
| 310 |
+
reply_markup=keyboard,
|
| 311 |
+
parse_mode="html",
|
| 312 |
+
)
|
| 313 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
| 314 |
except ChatAdminRequired:
|
| 315 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 318 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 319 |
)
|
| 320 |
except UserAdminInvalid:
|
| 321 |
+
await m.reply_text(
|
| 322 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 323 |
+
)
|
| 324 |
except RightForbidden:
|
| 325 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 326 |
except RPCError as ef:
|
|
|
|
| 364 |
await m.stop_propagation()
|
| 365 |
|
| 366 |
if user_id in SUPPORT_STAFF:
|
| 367 |
+
await m.reply_text(
|
| 368 |
+
text="This user is in my support staff, cannot restrict them."
|
| 369 |
+
)
|
| 370 |
LOGGER.info(
|
| 371 |
f"{m.from_user.id} trying to kick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 372 |
)
|
|
|
|
| 382 |
await m.stop_propagation()
|
| 383 |
|
| 384 |
try:
|
| 385 |
+
admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
|
| 386 |
+
kicked = ((await mention_html(user_first_name, user_id)),)
|
| 387 |
+
chat_title = (m.chat.title,)
|
| 388 |
LOGGER.info(f"{m.from_user.id} kicked {user_id} in {m.chat.id}")
|
| 389 |
await m.chat.ban_member(user_id)
|
| 390 |
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
| 391 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 392 |
+
# await m.reply_text(txt, reply_to_message_id=r_id)
|
| 393 |
+
await m.reply_animation(
|
| 394 |
+
reply_to_message_id=r_id,
|
| 395 |
+
animation=KICK_MEDIA,
|
| 396 |
+
caption=txt,
|
| 397 |
+
parse_mode="html",
|
| 398 |
+
)
|
| 399 |
await m.chat.unban_member(user_id)
|
| 400 |
except ChatAdminRequired:
|
| 401 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 404 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 405 |
)
|
| 406 |
except UserAdminInvalid:
|
| 407 |
+
await m.reply_text(
|
| 408 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 409 |
+
)
|
| 410 |
except RightForbidden:
|
| 411 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 412 |
except RPCError as ef:
|
|
|
|
| 441 |
await m.stop_propagation()
|
| 442 |
|
| 443 |
if user_id in SUPPORT_STAFF:
|
| 444 |
+
await m.reply_text(
|
| 445 |
+
text="This user is in my support staff, cannot restrict them."
|
| 446 |
+
)
|
| 447 |
LOGGER.info(
|
| 448 |
f"{m.from_user.id} trying to skick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 449 |
)
|
|
|
|
| 472 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 473 |
)
|
| 474 |
except UserAdminInvalid:
|
| 475 |
+
await m.reply_text(
|
| 476 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 477 |
+
)
|
| 478 |
except RightForbidden:
|
| 479 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
| 480 |
except RPCError as ef:
|
|
|
|
| 511 |
await m.stop_propagation()
|
| 512 |
|
| 513 |
if user_id in SUPPORT_STAFF:
|
| 514 |
+
await m.reply_text(
|
| 515 |
+
text="This user is in my support staff, cannot restrict them."
|
| 516 |
+
)
|
| 517 |
LOGGER.info(
|
| 518 |
f"{m.from_user.id} trying to dkick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 519 |
)
|
|
|
|
| 532 |
LOGGER.info(f"{m.from_user.id} dkicked {user_id} in {m.chat.id}")
|
| 533 |
await m.reply_to_message.delete()
|
| 534 |
await m.chat.ban_member(user_id)
|
| 535 |
+
admin = ((await mention_html(m.from_user.first_name, m.from_user.id)),)
|
| 536 |
+
kicked = ((await mention_html(user_first_name, user_id)),)
|
| 537 |
+
chat_title = (m.chat.title,)
|
| 538 |
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
| 539 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 540 |
await c.send_message(m.chat.id, txt)
|
| 541 |
+
await c.send_animation(
|
| 542 |
+
chat_id=m.chat.id, animation=KICK_MEDIA, caption=txt, parse_mode="html"
|
| 543 |
+
)
|
| 544 |
await m.chat.unban_member(user_id)
|
| 545 |
except ChatAdminRequired:
|
| 546 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
|
| 549 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 550 |
)
|
| 551 |
except UserAdminInvalid:
|
| 552 |
+
await m.reply_text(
|
| 553 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 554 |
+
)
|
| 555 |
except RightForbidden:
|
| 556 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
| 557 |
except RPCError as ef:
|
|
|
|
| 592 |
|
| 593 |
try:
|
| 594 |
await m.chat.unban_member(user_id)
|
| 595 |
+
admin = (m.from_user.mention,)
|
| 596 |
+
unbanned = ((await mention_html(user_first_name, user_id)),)
|
| 597 |
+
chat_title = (m.chat.title,)
|
| 598 |
txt = f"{admin} unbanned {unbanned} in chat <b>{chat_title}</b>!"
|
| 599 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 600 |
await m.reply_text(txt)
|
|
|
|
| 604 |
await m.reply_text(text="I don't have enough rights to unban this user.")
|
| 605 |
except RPCError as ef:
|
| 606 |
await m.reply_text(
|
| 607 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 608 |
|
| 609 |
<b>Error:</b> <code>{ef}</code>"""
|
| 610 |
)
|
|
|
|
| 639 |
await m.stop_propagation()
|
| 640 |
|
| 641 |
if user_id in SUPPORT_STAFF:
|
| 642 |
+
await m.reply_text(
|
| 643 |
+
text="This user is in my support staff, cannot restrict them."
|
| 644 |
+
)
|
| 645 |
LOGGER.info(
|
| 646 |
f"{m.from_user.id} trying to sban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 647 |
)
|
|
|
|
| 669 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 670 |
)
|
| 671 |
except UserAdminInvalid:
|
| 672 |
+
await m.reply_text(
|
| 673 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 674 |
+
)
|
| 675 |
except RightForbidden:
|
| 676 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 677 |
except RPCError as ef:
|
|
|
|
| 716 |
await m.stop_propagation()
|
| 717 |
|
| 718 |
if user_id in SUPPORT_STAFF:
|
| 719 |
+
await m.reply_text(
|
| 720 |
+
text="This user is in my support staff, cannot restrict them."
|
| 721 |
+
)
|
| 722 |
LOGGER.info(
|
| 723 |
f"{m.from_user.id} trying to dban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 724 |
)
|
|
|
|
| 741 |
LOGGER.info(f"{m.from_user.id} dbanned {user_id} in {m.chat.id}")
|
| 742 |
await m.reply_to_message.delete()
|
| 743 |
await m.chat.ban_member(user_id)
|
| 744 |
+
txt = f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in <b>{m.chat.title}</b>!"
|
| 745 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 746 |
keyboard = InlineKeyboardMarkup(
|
| 747 |
[
|
|
|
|
| 753 |
],
|
| 754 |
],
|
| 755 |
)
|
| 756 |
+
await c.send_animation(
|
| 757 |
+
m.chat.id, animation=BAN_MEDIA, caption=txt, reply_markup=keyboard
|
| 758 |
+
)
|
| 759 |
except ChatAdminRequired:
|
| 760 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 761 |
except PeerIdInvalid:
|
|
|
|
| 763 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 764 |
)
|
| 765 |
except UserAdminInvalid:
|
| 766 |
+
await m.reply_text(
|
| 767 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 768 |
+
)
|
| 769 |
except RightForbidden:
|
| 770 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 771 |
except RPCError as ef:
|
|
|
|
| 807 |
await m.stop_propagation()
|
| 808 |
|
| 809 |
if user_id in SUPPORT_STAFF:
|
| 810 |
+
await m.reply_text(
|
| 811 |
+
text="This user is in my support staff, cannot restrict them."
|
| 812 |
+
)
|
| 813 |
LOGGER.info(
|
| 814 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 815 |
)
|
|
|
|
| 837 |
try:
|
| 838 |
LOGGER.info(f"{m.from_user.id} banned {user_id} in {m.chat.id}")
|
| 839 |
await m.chat.ban_member(user_id)
|
| 840 |
+
banned = await mention_html(user_first_name, user_id)
|
| 841 |
txt = f"{m.from_user.mention} banned {banned} in <b>{m.chat.title}</b>!"
|
| 842 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
| 843 |
keyboard = InlineKeyboardMarkup(
|
|
|
|
| 850 |
],
|
| 851 |
],
|
| 852 |
)
|
| 853 |
+
await m.reply_animation(
|
| 854 |
+
animation=BAN_MEDIA,
|
| 855 |
+
caption=txt,
|
| 856 |
+
reply_markup=keyboard,
|
| 857 |
+
reply_to_message_id=r_id,
|
| 858 |
+
)
|
| 859 |
except ChatAdminRequired:
|
| 860 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 861 |
except PeerIdInvalid:
|
|
|
|
| 863 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
| 864 |
)
|
| 865 |
except UserAdminInvalid:
|
| 866 |
+
await m.reply_text(
|
| 867 |
+
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
| 868 |
+
)
|
| 869 |
except RightForbidden:
|
| 870 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 871 |
except RPCError as ef:
|
|
|
|
| 950 |
* /dtban <userhandle> x(m/h/d): Silently bans a user for x time and delete the replied message. (via reply). m = minutes, h = hours, d = days.
|
| 951 |
* /unban: Unbans the user replied to or tagged.
|
| 952 |
**Example:**
|
| 953 |
+
`/ban @username`: this bans a user in the chat."""
|
Powers/plugins/blacklist.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
from html import escape
|
| 2 |
-
|
| 3 |
-
from pyrogram import filters
|
| 4 |
-
from pyrogram.types import CallbackQuery, Message
|
| 5 |
-
|
| 6 |
from Powers import LOGGER
|
|
|
|
| 7 |
from Powers.bot_class import Gojo
|
|
|
|
|
|
|
| 8 |
from Powers.database.blacklist_db import Blacklist
|
| 9 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
| 10 |
-
from Powers.utils.kbhelpers import ikb
|
| 11 |
|
| 12 |
|
| 13 |
@Gojo.on_message(command("blacklist") & filters.group)
|
|
@@ -58,9 +56,10 @@ async def add_blacklist(_, m: Message):
|
|
| 58 |
+ " already added in blacklist, skipped them!"
|
| 59 |
)
|
| 60 |
LOGGER.info(f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
|
| 61 |
-
trigger=", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 62 |
await m.reply_text(
|
| 63 |
-
text=f"Added <code>{trigger}</code> in blacklist words!"
|
|
|
|
| 64 |
)
|
| 65 |
|
| 66 |
await m.stop_propagation()
|
|
@@ -115,9 +114,10 @@ async def rm_blacklist(_, m: Message):
|
|
| 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!"
|
|
|
|
| 121 |
)
|
| 122 |
|
| 123 |
await m.stop_propagation()
|
|
@@ -145,14 +145,12 @@ async def set_bl_action(_, m: Message):
|
|
| 145 |
LOGGER.info(
|
| 146 |
f"{m.from_user.id} set blacklist action to '{action}' in {m.chat.id}",
|
| 147 |
)
|
| 148 |
-
await m.reply_text(
|
| 149 |
-
text=f"Set action for blacklist for this to <b>{action}</b>"
|
| 150 |
-
)
|
| 151 |
elif len(m.text.split()) == 1:
|
| 152 |
action = db.get_action()
|
| 153 |
LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
|
| 154 |
await m.reply_text(
|
| 155 |
-
|
| 156 |
All blacklist modes delete the message containing blacklist word."""
|
| 157 |
)
|
| 158 |
else:
|
|
@@ -223,4 +221,4 @@ Default is 'none', which will delete the users message on typing a blacklist wor
|
|
| 223 |
* /rmallblacklist: Removes all the blacklists from the current chat.
|
| 224 |
**Note:** Can only add or remove one blacklist at a time!
|
| 225 |
**Example:**
|
| 226 |
-
`/addblacklist hello`: this adds the word 'hello' as blacklist in the chat."""
|
|
|
|
| 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 Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
@Gojo.on_message(command("blacklist") & filters.group)
|
|
|
|
| 56 |
+ " already added in blacklist, skipped them!"
|
| 57 |
)
|
| 58 |
LOGGER.info(f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
|
| 59 |
+
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 60 |
await m.reply_text(
|
| 61 |
+
text=f"Added <code>{trigger}</code> in blacklist words!"
|
| 62 |
+
+ (f"\n{rep_text}" if rep_text else ""),
|
| 63 |
)
|
| 64 |
|
| 65 |
await m.stop_propagation()
|
|
|
|
| 114 |
) + " in blcklisted words, skipped them."
|
| 115 |
|
| 116 |
LOGGER.info(f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
|
| 117 |
+
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
| 118 |
await m.reply_text(
|
| 119 |
+
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
| 120 |
+
+ (f"\n{rep_text}" if rep_text else ""),
|
| 121 |
)
|
| 122 |
|
| 123 |
await m.stop_propagation()
|
|
|
|
| 145 |
LOGGER.info(
|
| 146 |
f"{m.from_user.id} set blacklist action to '{action}' in {m.chat.id}",
|
| 147 |
)
|
| 148 |
+
await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
|
|
|
|
|
|
|
| 149 |
elif len(m.text.split()) == 1:
|
| 150 |
action = db.get_action()
|
| 151 |
LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
|
| 152 |
await m.reply_text(
|
| 153 |
+
text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
|
| 154 |
All blacklist modes delete the message containing blacklist word."""
|
| 155 |
)
|
| 156 |
else:
|
|
|
|
| 221 |
* /rmallblacklist: Removes all the blacklists from the current chat.
|
| 222 |
**Note:** Can only add or remove one blacklist at a time!
|
| 223 |
**Example:**
|
| 224 |
+
`/addblacklist hello`: this adds the word 'hello' as blacklist in the chat."""
|
Powers/plugins/botstaff.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
-
from pyrogram.errors import RPCError
|
| 2 |
-
from pyrogram.types import Message
|
| 3 |
-
|
| 4 |
-
from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, WHITELIST_USERS
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
-
from
|
|
|
|
| 7 |
from Powers.utils.parser import mention_html
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
@Gojo.on_message(command("botstaff", dev_cmd=True))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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))
|
Powers/plugins/chat_blacklist.py
CHANGED
|
@@ -1,12 +1,11 @@
|
|
| 1 |
-
from traceback import format_exc
|
| 2 |
-
|
| 3 |
-
from pyrogram.errors import PeerIdInvalid, RPCError
|
| 4 |
-
from pyrogram.types import Message
|
| 5 |
-
|
| 6 |
from Powers import LOGGER
|
|
|
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
-
from
|
| 9 |
from Powers.utils.custom_filters import command
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# initialise database
|
| 12 |
db = GroupBlacklist()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|
Powers/plugins/dev.py
CHANGED
|
@@ -1,29 +1,20 @@
|
|
| 1 |
import sys
|
| 2 |
-
from
|
| 3 |
from io import BytesIO, StringIO
|
| 4 |
-
from time import gmtime, strftime, time
|
| 5 |
from traceback import format_exc
|
| 6 |
-
|
| 7 |
-
from pyrogram.errors import (
|
| 8 |
-
ChannelInvalid,
|
| 9 |
-
ChannelPrivate,
|
| 10 |
-
ChatAdminRequired,
|
| 11 |
-
FloodWait,
|
| 12 |
-
MessageTooLong,
|
| 13 |
-
PeerIdInvalid,
|
| 14 |
-
RPCError,
|
| 15 |
-
)
|
| 16 |
-
from pyrogram.types import Message
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
|
| 20 |
from Powers.bot_class import Gojo
|
|
|
|
|
|
|
|
|
|
| 21 |
from Powers.database.chats_db import Chats
|
| 22 |
-
from Powers.utils.clean_file import remove_markdown_and_html
|
| 23 |
from Powers.utils.custom_filters import command
|
| 24 |
-
from Powers.utils.http_helper import *
|
| 25 |
from Powers.utils.parser import mention_markdown
|
| 26 |
-
from Powers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
|
| 29 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
|
@@ -300,4 +291,4 @@ async def chat_broadcast(c: Gojo, m: Message):
|
|
| 300 |
|
| 301 |
_DISABLE_CMDS_ = ["ping"]
|
| 302 |
|
| 303 |
-
__HELP__ = """To check the ping of the bot just type `/ping`"""
|
|
|
|
| 1 |
import sys
|
| 2 |
+
from Powers.vars import Config
|
| 3 |
from io import BytesIO, StringIO
|
|
|
|
| 4 |
from traceback import format_exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
+
from pyrogram.types import Message
|
| 7 |
+
from Powers.utils.http_helper import *
|
| 8 |
+
from time import time, gmtime, strftime
|
| 9 |
from Powers.database.chats_db import Chats
|
|
|
|
| 10 |
from Powers.utils.custom_filters import command
|
|
|
|
| 11 |
from Powers.utils.parser import mention_markdown
|
| 12 |
+
from Powers import LOGGER, UPTIME, LOGFILE, MESSAGE_DUMP
|
| 13 |
+
from Powers.utils.clean_file import remove_markdown_and_html
|
| 14 |
+
from asyncio import sleep, subprocess, create_subprocess_shell
|
| 15 |
+
from pyrogram.errors import (
|
| 16 |
+
RPCError, FloodWait, PeerIdInvalid, ChannelInvalid, ChannelPrivate,
|
| 17 |
+
MessageTooLong, ChatAdminRequired)
|
| 18 |
|
| 19 |
|
| 20 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
|
|
|
| 291 |
|
| 292 |
_DISABLE_CMDS_ = ["ping"]
|
| 293 |
|
| 294 |
+
__HELP__ = """To check the ping of the bot just type `/ping`"""
|
Powers/plugins/disable.py
CHANGED
|
@@ -1,22 +1,12 @@
|
|
| 1 |
from html import escape
|
| 2 |
-
|
| 3 |
from pyrogram import filters
|
| 4 |
-
from pyrogram.types import (
|
| 5 |
-
CallbackQuery,
|
| 6 |
-
InlineKeyboardButton,
|
| 7 |
-
InlineKeyboardMarkup,
|
| 8 |
-
Message,
|
| 9 |
-
)
|
| 10 |
-
|
| 11 |
-
from Powers import HELP_COMMANDS, LOGGER
|
| 12 |
from Powers.bot_class import Gojo
|
|
|
|
| 13 |
from Powers.database.disable_db import Disabling
|
|
|
|
|
|
|
| 14 |
from Powers.utils.custom_filters import (
|
| 15 |
-
admin_filter,
|
| 16 |
-
can_change_filter,
|
| 17 |
-
command,
|
| 18 |
-
owner_filter,
|
| 19 |
-
)
|
| 20 |
|
| 21 |
|
| 22 |
@Gojo.on_message(command("disable") & can_change_filter)
|
|
|
|
| 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.types import (
|
| 7 |
+
Message, CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup)
|
| 8 |
from Powers.utils.custom_filters import (
|
| 9 |
+
command, admin_filter, owner_filter, can_change_filter)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
@Gojo.on_message(command("disable") & can_change_filter)
|
Powers/plugins/filters.py
CHANGED
|
@@ -1,24 +1,20 @@
|
|
| 1 |
-
from re import escape as re_escape
|
| 2 |
from secrets import choice
|
| 3 |
-
from traceback import format_exc
|
| 4 |
-
|
| 5 |
from pyrogram import filters
|
|
|
|
|
|
|
| 6 |
from pyrogram.errors import RPCError
|
| 7 |
-
from
|
| 8 |
-
|
| 9 |
from Powers.bot_class import LOGGER, Gojo
|
| 10 |
-
from Powers.database.filters_db import Filters
|
| 11 |
from Powers.utils.cmd_senders import send_cmd
|
| 12 |
-
from Powers.
|
| 13 |
-
from Powers.utils.kbhelpers import ikb
|
| 14 |
-
from Powers.utils.msg_types import Types, get_filter_type
|
| 15 |
from Powers.utils.regex_utils import regex_searcher
|
|
|
|
|
|
|
|
|
|
| 16 |
from Powers.utils.string import (
|
| 17 |
-
build_keyboard,
|
| 18 |
-
escape_mentions_using_curly_brackets
|
| 19 |
-
|
| 20 |
-
split_quotes,
|
| 21 |
-
)
|
| 22 |
|
| 23 |
# Initialise
|
| 24 |
db = Filters()
|
|
@@ -327,4 +323,4 @@ Using the you can make a single filter work on 2 filternames without manually ad
|
|
| 327 |
|
| 328 |
**Note:**
|
| 329 |
Currently there is a limit of 50 filters and 120 aliases per chat.
|
| 330 |
-
All filter keywords are in lowercase."""
|
|
|
|
|
|
|
| 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 Powers.utils.regex_utils import regex_searcher
|
| 11 |
+
from Powers.utils.msg_types import Types, get_filter_type
|
| 12 |
+
from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
|
| 13 |
+
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
| 14 |
from Powers.utils.string import (
|
| 15 |
+
parse_button, split_quotes, build_keyboard,
|
| 16 |
+
escape_mentions_using_curly_brackets)
|
| 17 |
+
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# Initialise
|
| 20 |
db = Filters()
|
|
|
|
| 323 |
|
| 324 |
**Note:**
|
| 325 |
Currently there is a limit of 50 filters and 120 aliases per chat.
|
| 326 |
+
All filter keywords are in lowercase."""
|
Powers/plugins/formatting.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
-
from pyrogram import filters
|
| 2 |
-
from pyrogram.types import CallbackQuery, Message
|
| 3 |
-
|
| 4 |
from Powers import LOGGER
|
|
|
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
-
from Powers.utils.custom_filters import command
|
| 7 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
async def gen_formatting_kb(m):
|
|
@@ -138,4 +137,4 @@ __buttons__ = [
|
|
| 138 |
__HELP__ = """
|
| 139 |
***Formatting***
|
| 140 |
|
| 141 |
-
Gojo supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!"""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from Powers import LOGGER
|
| 2 |
+
from pyrogram import filters
|
| 3 |
from Powers.bot_class import Gojo
|
|
|
|
| 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):
|
|
|
|
| 137 |
__HELP__ = """
|
| 138 |
***Formatting***
|
| 139 |
|
| 140 |
+
Gojo supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!"""
|
Powers/plugins/fun.py
CHANGED
|
@@ -1,16 +1,13 @@
|
|
| 1 |
from html import escape
|
| 2 |
from random import choice
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
from pyrogram.errors import MessageTooLong
|
| 6 |
from pyrogram.types import Message
|
| 7 |
-
|
| 8 |
from Powers import LOGGER, DEV_USERS
|
| 9 |
-
from
|
| 10 |
-
from Powers.utils import extras
|
| 11 |
from Powers.utils.custom_filters import command
|
| 12 |
from Powers.utils.extract_user import extract_user
|
| 13 |
-
from Powers.utils.extras import
|
| 14 |
|
| 15 |
|
| 16 |
@Gojo.on_message(command("shout"))
|
|
@@ -95,38 +92,45 @@ async def fun_toss(_, m: Message):
|
|
| 95 |
LOGGER.info(f"{m.from_user.id} tossed in {m.chat.id}")
|
| 96 |
return
|
| 97 |
|
|
|
|
| 98 |
@Gojo.on_message(command("insult"))
|
| 99 |
-
async def insult(c
|
| 100 |
try:
|
| 101 |
user_id, user_first_name, _ = await extract_user(c, m)
|
| 102 |
-
except:
|
| 103 |
return
|
| 104 |
if user_id in DEV_USERS:
|
| 105 |
await m.reply_text("Sorry! I can't insult my devs....")
|
| 106 |
-
return LOGGER.info(
|
| 107 |
-
|
|
|
|
|
|
|
| 108 |
Insult_omp = choice(extras.INSULT_STRINGS)
|
| 109 |
-
reply_text =
|
|
|
|
|
|
|
| 110 |
await reply_text(Insult_omp)
|
| 111 |
LOGGER.info(f"{m.from_user.id} insulted {user_first_name} in {m.chat.id}")
|
| 112 |
-
|
|
|
|
| 113 |
@Gojo.on_message(command("yes"))
|
| 114 |
-
async def yesw(c
|
| 115 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
| 116 |
rtext = YES[0]
|
| 117 |
await reply_text(rtext)
|
| 118 |
LOGGER.info(f"{m.from_user.id} said YES or may be NO in {m.chat.id}")
|
| 119 |
return
|
| 120 |
-
|
| 121 |
-
|
| 122 |
@Gojo.on_message(command("no"))
|
| 123 |
-
async def now(c
|
| 124 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
| 125 |
rtext = NO[0]
|
| 126 |
await reply_text(rtext)
|
| 127 |
LOGGER.info(f"{m.from_user.id} said NO or may be YES in {m.chat.id}")
|
| 128 |
return
|
| 129 |
|
|
|
|
| 130 |
@Gojo.on_message(command("shrug"))
|
| 131 |
async def fun_shrug(_, m: Message):
|
| 132 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
|
@@ -188,7 +192,7 @@ async def weebify(_, m: Message):
|
|
| 188 |
string = string.replace(normiecharacter, weebycharacter)
|
| 189 |
|
| 190 |
await m.reply_text(
|
| 191 |
-
|
| 192 |
<code>{string}</code>"""
|
| 193 |
)
|
| 194 |
LOGGER.info(f"{m.from_user.id} weebified '{args}' in {m.chat.id}")
|
|
|
|
| 1 |
from html import escape
|
| 2 |
from random import choice
|
| 3 |
+
from Powers.utils import extras
|
| 4 |
+
from Powers.bot_class import Gojo
|
|
|
|
| 5 |
from pyrogram.types import Message
|
|
|
|
| 6 |
from Powers import LOGGER, DEV_USERS
|
| 7 |
+
from pyrogram.errors import MessageTooLong
|
|
|
|
| 8 |
from Powers.utils.custom_filters import command
|
| 9 |
from Powers.utils.extract_user import extract_user
|
| 10 |
+
from Powers.utils.extras import NOWYES as NO, YESWNO as YES
|
| 11 |
|
| 12 |
|
| 13 |
@Gojo.on_message(command("shout"))
|
|
|
|
| 92 |
LOGGER.info(f"{m.from_user.id} tossed in {m.chat.id}")
|
| 93 |
return
|
| 94 |
|
| 95 |
+
|
| 96 |
@Gojo.on_message(command("insult"))
|
| 97 |
+
async def insult(c: Gojo, m: Message):
|
| 98 |
try:
|
| 99 |
user_id, user_first_name, _ = await extract_user(c, m)
|
| 100 |
+
except BaseException:
|
| 101 |
return
|
| 102 |
if user_id in DEV_USERS:
|
| 103 |
await m.reply_text("Sorry! I can't insult my devs....")
|
| 104 |
+
return LOGGER.info(
|
| 105 |
+
f"{m.from_user.id} tried to insult {user_first_name} in {m.chat.id}"
|
| 106 |
+
)
|
| 107 |
+
else:
|
| 108 |
Insult_omp = choice(extras.INSULT_STRINGS)
|
| 109 |
+
reply_text = (
|
| 110 |
+
m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
| 111 |
+
)
|
| 112 |
await reply_text(Insult_omp)
|
| 113 |
LOGGER.info(f"{m.from_user.id} insulted {user_first_name} in {m.chat.id}")
|
| 114 |
+
|
| 115 |
+
|
| 116 |
@Gojo.on_message(command("yes"))
|
| 117 |
+
async def yesw(c: Gojo, m: Message):
|
| 118 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
| 119 |
rtext = YES[0]
|
| 120 |
await reply_text(rtext)
|
| 121 |
LOGGER.info(f"{m.from_user.id} said YES or may be NO in {m.chat.id}")
|
| 122 |
return
|
| 123 |
+
|
| 124 |
+
|
| 125 |
@Gojo.on_message(command("no"))
|
| 126 |
+
async def now(c: Gojo, m: Message):
|
| 127 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
| 128 |
rtext = NO[0]
|
| 129 |
await reply_text(rtext)
|
| 130 |
LOGGER.info(f"{m.from_user.id} said NO or may be YES in {m.chat.id}")
|
| 131 |
return
|
| 132 |
|
| 133 |
+
|
| 134 |
@Gojo.on_message(command("shrug"))
|
| 135 |
async def fun_shrug(_, m: Message):
|
| 136 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
|
|
|
| 192 |
string = string.replace(normiecharacter, weebycharacter)
|
| 193 |
|
| 194 |
await m.reply_text(
|
| 195 |
+
text=f"""<b>Weebified String:</b>
|
| 196 |
<code>{string}</code>"""
|
| 197 |
)
|
| 198 |
LOGGER.info(f"{m.from_user.id} weebified '{args}' in {m.chat.id}")
|
Powers/plugins/greetings.py
CHANGED
|
@@ -1,24 +1,20 @@
|
|
| 1 |
from html import escape
|
| 2 |
from secrets import choice
|
| 3 |
-
|
| 4 |
-
from pyrogram import filters
|
| 5 |
-
from pyrogram.errors import ChatAdminRequired, RPCError
|
| 6 |
-
from pyrogram.types import ChatMemberUpdated, InlineKeyboardMarkup, Message
|
| 7 |
-
|
| 8 |
from Powers import DEV_USERS
|
|
|
|
|
|
|
| 9 |
from Powers.bot_class import Gojo
|
|
|
|
| 10 |
from Powers.database.antispam_db import GBan
|
| 11 |
from Powers.database.greetings_db import Greetings
|
| 12 |
-
from Powers.utils.custom_filters import admin_filter, bot_admin_filter, command
|
| 13 |
-
from Powers.utils.chat_type import chattype
|
| 14 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
| 15 |
-
from
|
|
|
|
|
|
|
|
|
|
| 16 |
from Powers.utils.string import (
|
| 17 |
-
build_keyboard,
|
| 18 |
-
|
| 19 |
-
parse_button,
|
| 20 |
-
)
|
| 21 |
-
from Powers.vars import Config
|
| 22 |
|
| 23 |
# Initialize
|
| 24 |
gdb = GBan()
|
|
|
|
| 1 |
from html import escape
|
| 2 |
from secrets import choice
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from Powers import DEV_USERS
|
| 4 |
+
from pyrogram import filters
|
| 5 |
+
from Powers.vars import Config
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
+
from Powers.utils.chat_type import chattype
|
| 8 |
from Powers.database.antispam_db import GBan
|
| 9 |
from Powers.database.greetings_db import Greetings
|
|
|
|
|
|
|
| 10 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
| 11 |
+
from pyrogram.errors import RPCError, ChatAdminRequired
|
| 12 |
+
from 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()
|
Powers/plugins/info.py
CHANGED
|
@@ -1,26 +1,31 @@
|
|
| 1 |
import os
|
| 2 |
-
from traceback import format_exc
|
| 3 |
-
from datetime import datetime
|
| 4 |
-
|
| 5 |
-
from pyrogram.types import Message
|
| 6 |
from pyrogram import enums
|
| 7 |
-
|
| 8 |
-
from
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
-
from
|
|
|
|
| 11 |
from Powers.database.users_db import Users
|
|
|
|
| 12 |
from Powers.utils.custom_filters import command
|
| 13 |
from Powers.utils.extract_user import extract_user
|
| 14 |
-
from Powers
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
gban_db=GBan()
|
| 17 |
|
| 18 |
async def count(c: Gojo, chat):
|
| 19 |
administrator = []
|
| 20 |
-
async for admin in c.get_chat_members(
|
| 21 |
-
|
|
|
|
|
|
|
| 22 |
bot = []
|
| 23 |
-
async for tbot in c.get_chat_members(
|
|
|
|
|
|
|
| 24 |
total_bot = bot.append(tbot)
|
| 25 |
bot_admin = 0
|
| 26 |
ban = []
|
|
@@ -35,25 +40,27 @@ async def count(c: Gojo, chat):
|
|
| 35 |
total_banned = len(total_banned)
|
| 36 |
return total_bot, total_admin, bot_admin, total_banned
|
| 37 |
|
|
|
|
| 38 |
async def user_info(c: Gojo, user, already=False):
|
| 39 |
if not already:
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
# LOGGER.warning(f"Calling api to fetch info about user {user}")
|
| 46 |
-
|
|
|
|
| 47 |
user = await c.get_users(user_ids=user)
|
| 48 |
if not user.first_name:
|
| 49 |
return ["Deleted account", None]
|
| 50 |
-
|
| 51 |
gbanned, reason_gban = gban_db.get_gban(user)
|
| 52 |
if gbanned:
|
| 53 |
-
gban=True
|
| 54 |
reason = f"The user is gbanned because {reason_gban}"
|
| 55 |
else:
|
| 56 |
-
gban=False
|
| 57 |
reason = "User is not gbanned"
|
| 58 |
|
| 59 |
user_id = user.id
|
|
@@ -78,8 +85,7 @@ async def user_info(c: Gojo, user, already=False):
|
|
| 78 |
is_bot = user.is_bot
|
| 79 |
is_fake = user.is_fake
|
| 80 |
status = user.status
|
| 81 |
-
|
| 82 |
-
|
| 83 |
if is_bot is True:
|
| 84 |
last_date = "Targeted user is a bot"
|
| 85 |
elif status == "recently":
|
|
@@ -95,10 +101,10 @@ async def user_info(c: Gojo, user, already=False):
|
|
| 95 |
elif status == "offline":
|
| 96 |
last_date = datetime.fromtimestamp(user.status.date).strftime(
|
| 97 |
"%a, %d %b %Y, %H:%M:%S"
|
| 98 |
-
)
|
| 99 |
else:
|
| 100 |
last_date = "User is currently online"
|
| 101 |
-
|
| 102 |
caption = f"""
|
| 103 |
<b><i><u>⚡ Extracted User info From Telegram ⚡</b></i></u>
|
| 104 |
|
|
@@ -120,7 +126,7 @@ async def user_info(c: Gojo, user, already=False):
|
|
| 120 |
<b>👀 Last seen</b>: <code>{last_date}</code>
|
| 121 |
|
| 122 |
"""
|
| 123 |
-
|
| 124 |
return caption, photo_id
|
| 125 |
|
| 126 |
|
|
@@ -130,7 +136,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 130 |
online_mem = c.get_chat_online_count(chat)
|
| 131 |
chat_id = chat.id
|
| 132 |
username = chat.username
|
| 133 |
-
total_bot, total_admin, total_bot_admin, total_banned = await count(c,chat)
|
| 134 |
title = chat.title
|
| 135 |
type_ = c_type(c, chat_id=chat)
|
| 136 |
is_scam = chat.is_scam
|
|
@@ -149,7 +155,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 149 |
sticker_set = chat.sticker_set_name
|
| 150 |
linked_chat = chat.linked_chat
|
| 151 |
reactions = chat.available_reactions
|
| 152 |
-
|
| 153 |
caption = f"""
|
| 154 |
🔰 <b>CHAT INFO</b> 🔰
|
| 155 |
|
|
@@ -180,21 +186,27 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
| 180 |
return caption, photo_id
|
| 181 |
|
| 182 |
|
| 183 |
-
@Gojo.on_message(command(["info","whois"]))
|
| 184 |
async def info_func(c: Gojo, message: Message):
|
| 185 |
try:
|
| 186 |
-
user, _
|
| 187 |
except Exception as e:
|
| 188 |
-
return await message.reply_text(
|
| 189 |
-
|
|
|
|
|
|
|
| 190 |
if not user:
|
| 191 |
message.reply_text("Can't find user to fetch info!")
|
| 192 |
-
|
| 193 |
-
m = await message.reply_text(
|
|
|
|
|
|
|
| 194 |
|
| 195 |
try:
|
| 196 |
-
info_caption, photo_id = await user_info(c
|
| 197 |
-
LOGGER.info(
|
|
|
|
|
|
|
| 198 |
except Exception as e:
|
| 199 |
LOGGER.error(e)
|
| 200 |
LOGGER.error(format_exc())
|
|
@@ -207,27 +219,29 @@ async def info_func(c: Gojo, message: Message):
|
|
| 207 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 208 |
await m.delete()
|
| 209 |
os.remove(photo)
|
| 210 |
-
LOGGER.info(
|
|
|
|
|
|
|
| 211 |
|
| 212 |
|
| 213 |
-
|
| 214 |
-
@Gojo.on_message(command(["chinfo","chatinfo","chat_info"]))
|
| 215 |
async def chat_info_func(c: Gojo, message: Message):
|
| 216 |
-
splited = message.text.split()
|
| 217 |
try:
|
| 218 |
if len(splited) == 1:
|
| 219 |
chat = message.chat.id
|
| 220 |
|
| 221 |
else:
|
| 222 |
chat = splited[1]
|
| 223 |
-
|
| 224 |
try:
|
| 225 |
chat = int(chat)
|
| 226 |
except ValueError:
|
| 227 |
return await message.reply_text("**Usage:**/chinfo [USERNAME|ID]")
|
| 228 |
-
|
| 229 |
|
| 230 |
-
m = await message.reply_text(
|
|
|
|
|
|
|
| 231 |
|
| 232 |
info_caption, photo_id = await chat_info(c, chat=chat)
|
| 233 |
if not photo_id:
|
|
@@ -235,7 +249,9 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
| 235 |
|
| 236 |
photo = await Gojo.download_media(photo_id)
|
| 237 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 238 |
-
LOGGER.info(
|
|
|
|
|
|
|
| 239 |
|
| 240 |
await m.delete()
|
| 241 |
os.remove(photo)
|
|
@@ -244,11 +260,12 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
| 244 |
LOGGER.error(e)
|
| 245 |
LOGGER.error(format_exc())
|
| 246 |
|
|
|
|
| 247 |
__PLUGIN__ = "info"
|
| 248 |
__alt_name__ = [
|
| 249 |
"info",
|
| 250 |
"chinfo",
|
| 251 |
-
]
|
| 252 |
|
| 253 |
__HELP__ = """
|
| 254 |
***Information***
|
|
|
|
| 1 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
from pyrogram import enums
|
| 3 |
+
from datetime import datetime
|
| 4 |
+
from traceback import format_exc
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
+
from pyrogram.types import Message
|
| 7 |
+
from Powers.utils.chat_type import c_type
|
| 8 |
from Powers.database.users_db import Users
|
| 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 import (
|
| 13 |
+
LOGGER, DEV_USERS, SUDO_USERS, SUPPORT_STAFF, WHITELIST_USERS)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
gban_db = GBan()
|
| 17 |
|
|
|
|
| 18 |
|
| 19 |
async def count(c: Gojo, chat):
|
| 20 |
administrator = []
|
| 21 |
+
async for admin in c.get_chat_members(
|
| 22 |
+
chat_id=chat, filter=enums.ChatMembersFilter.ADMINISTRATORS
|
| 23 |
+
):
|
| 24 |
+
total_admin = administrator.append(admin)
|
| 25 |
bot = []
|
| 26 |
+
async for tbot in c.get_chat_members(
|
| 27 |
+
chat_id=chat, filter=enums.ChatMembersFilter.BOTS
|
| 28 |
+
):
|
| 29 |
total_bot = bot.append(tbot)
|
| 30 |
bot_admin = 0
|
| 31 |
ban = []
|
|
|
|
| 40 |
total_banned = len(total_banned)
|
| 41 |
return total_bot, total_admin, bot_admin, total_banned
|
| 42 |
|
| 43 |
+
|
| 44 |
async def user_info(c: Gojo, user, already=False):
|
| 45 |
if not already:
|
| 46 |
+
# try:
|
| 47 |
+
# user = Users.get_user_info(int(user)) # Try to fetch user info form database if available give key error if user is not present
|
| 48 |
+
# user = user["_id"]
|
| 49 |
+
# user = await c.get_users(user_ids=user)
|
| 50 |
+
# except KeyError:
|
| 51 |
# LOGGER.warning(f"Calling api to fetch info about user {user}")
|
| 52 |
+
# user = await c.get_users(user_ids=user) # Fetch user info in
|
| 53 |
+
# traditional way if not available in db
|
| 54 |
user = await c.get_users(user_ids=user)
|
| 55 |
if not user.first_name:
|
| 56 |
return ["Deleted account", None]
|
| 57 |
+
|
| 58 |
gbanned, reason_gban = gban_db.get_gban(user)
|
| 59 |
if gbanned:
|
| 60 |
+
gban = True
|
| 61 |
reason = f"The user is gbanned because {reason_gban}"
|
| 62 |
else:
|
| 63 |
+
gban = False
|
| 64 |
reason = "User is not gbanned"
|
| 65 |
|
| 66 |
user_id = user.id
|
|
|
|
| 85 |
is_bot = user.is_bot
|
| 86 |
is_fake = user.is_fake
|
| 87 |
status = user.status
|
| 88 |
+
|
|
|
|
| 89 |
if is_bot is True:
|
| 90 |
last_date = "Targeted user is a bot"
|
| 91 |
elif status == "recently":
|
|
|
|
| 101 |
elif status == "offline":
|
| 102 |
last_date = datetime.fromtimestamp(user.status.date).strftime(
|
| 103 |
"%a, %d %b %Y, %H:%M:%S"
|
| 104 |
+
)
|
| 105 |
else:
|
| 106 |
last_date = "User is currently online"
|
| 107 |
+
|
| 108 |
caption = f"""
|
| 109 |
<b><i><u>⚡ Extracted User info From Telegram ⚡</b></i></u>
|
| 110 |
|
|
|
|
| 126 |
<b>👀 Last seen</b>: <code>{last_date}</code>
|
| 127 |
|
| 128 |
"""
|
| 129 |
+
|
| 130 |
return caption, photo_id
|
| 131 |
|
| 132 |
|
|
|
|
| 136 |
online_mem = c.get_chat_online_count(chat)
|
| 137 |
chat_id = chat.id
|
| 138 |
username = chat.username
|
| 139 |
+
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat)
|
| 140 |
title = chat.title
|
| 141 |
type_ = c_type(c, chat_id=chat)
|
| 142 |
is_scam = chat.is_scam
|
|
|
|
| 155 |
sticker_set = chat.sticker_set_name
|
| 156 |
linked_chat = chat.linked_chat
|
| 157 |
reactions = chat.available_reactions
|
| 158 |
+
|
| 159 |
caption = f"""
|
| 160 |
🔰 <b>CHAT INFO</b> 🔰
|
| 161 |
|
|
|
|
| 186 |
return caption, photo_id
|
| 187 |
|
| 188 |
|
| 189 |
+
@Gojo.on_message(command(["info", "whois"]))
|
| 190 |
async def info_func(c: Gojo, message: Message):
|
| 191 |
try:
|
| 192 |
+
user, _, _ = await extract_user(c, message)
|
| 193 |
except Exception as e:
|
| 194 |
+
return await message.reply_text(
|
| 195 |
+
f"Got an error while running extract_user function error is {e}.....Give this message in supoort group"
|
| 196 |
+
)
|
| 197 |
+
|
| 198 |
if not user:
|
| 199 |
message.reply_text("Can't find user to fetch info!")
|
| 200 |
+
|
| 201 |
+
m = await message.reply_text(
|
| 202 |
+
f"Fetching user info of user {message.from_user.id}..."
|
| 203 |
+
)
|
| 204 |
|
| 205 |
try:
|
| 206 |
+
info_caption, photo_id = await user_info(c, user=user)
|
| 207 |
+
LOGGER.info(
|
| 208 |
+
f"{message.from_user.id} tried to fetch user info of user {message.from_user.id} in {message.chat.id}"
|
| 209 |
+
)
|
| 210 |
except Exception as e:
|
| 211 |
LOGGER.error(e)
|
| 212 |
LOGGER.error(format_exc())
|
|
|
|
| 219 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 220 |
await m.delete()
|
| 221 |
os.remove(photo)
|
| 222 |
+
LOGGER.info(
|
| 223 |
+
f"{message.from_user.id} fetched user info of user {user.username} in {m.chat.id}"
|
| 224 |
+
)
|
| 225 |
|
| 226 |
|
| 227 |
+
@Gojo.on_message(command(["chinfo", "chatinfo", "chat_info"]))
|
|
|
|
| 228 |
async def chat_info_func(c: Gojo, message: Message):
|
| 229 |
+
splited = message.text.split()
|
| 230 |
try:
|
| 231 |
if len(splited) == 1:
|
| 232 |
chat = message.chat.id
|
| 233 |
|
| 234 |
else:
|
| 235 |
chat = splited[1]
|
| 236 |
+
|
| 237 |
try:
|
| 238 |
chat = int(chat)
|
| 239 |
except ValueError:
|
| 240 |
return await message.reply_text("**Usage:**/chinfo [USERNAME|ID]")
|
|
|
|
| 241 |
|
| 242 |
+
m = await message.reply_text(
|
| 243 |
+
f"Fetching chat info of chat **{message.chat.title}**....."
|
| 244 |
+
)
|
| 245 |
|
| 246 |
info_caption, photo_id = await chat_info(c, chat=chat)
|
| 247 |
if not photo_id:
|
|
|
|
| 249 |
|
| 250 |
photo = await Gojo.download_media(photo_id)
|
| 251 |
await message.reply_photo(photo, caption=info_caption, quote=False)
|
| 252 |
+
LOGGER.info(
|
| 253 |
+
f"{message.from_user.id} fetched chat info of chat {chat} in {message.chat.id}"
|
| 254 |
+
)
|
| 255 |
|
| 256 |
await m.delete()
|
| 257 |
os.remove(photo)
|
|
|
|
| 260 |
LOGGER.error(e)
|
| 261 |
LOGGER.error(format_exc())
|
| 262 |
|
| 263 |
+
|
| 264 |
__PLUGIN__ = "info"
|
| 265 |
__alt_name__ = [
|
| 266 |
"info",
|
| 267 |
"chinfo",
|
| 268 |
+
]
|
| 269 |
|
| 270 |
__HELP__ = """
|
| 271 |
***Information***
|
Powers/plugins/initial.py
CHANGED
|
@@ -1,20 +1,19 @@
|
|
| 1 |
-
from pyrogram import filters
|
| 2 |
-
from pyrogram.errors import RPCError
|
| 3 |
-
from pyrogram.types import Message
|
| 4 |
-
|
| 5 |
from Powers import LOGGER
|
|
|
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
-
from
|
| 8 |
-
from
|
|
|
|
| 9 |
from Powers.database.chats_db import Chats
|
| 10 |
-
from Powers.database.
|
|
|
|
|
|
|
| 11 |
from Powers.database.filters_db import Filters
|
|
|
|
|
|
|
| 12 |
from Powers.database.greetings_db import Greetings
|
| 13 |
-
from Powers.database.notes_db import Notes, NotesSettings
|
| 14 |
-
from Powers.database.pins_db import Pins
|
| 15 |
from Powers.database.reporting_db import Reporting
|
| 16 |
-
from Powers.database.
|
| 17 |
-
from Powers.database.users_db import Users
|
| 18 |
|
| 19 |
|
| 20 |
@Gojo.on_message(filters.group, group=4)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
Powers/plugins/locks.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
-
from asyncio import sleep
|
| 2 |
-
|
| 3 |
-
from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
|
| 4 |
-
from pyrogram.types import ChatPermissions, Message
|
| 5 |
-
|
| 6 |
from Powers import LOGGER
|
|
|
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
from Powers.database.approve_db import Approve
|
|
|
|
| 9 |
from Powers.utils.custom_filters import command, restrict_filter
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
@Gojo.on_message(command("locktypes"))
|
|
@@ -111,9 +109,11 @@ async def lock_perm(c: Gojo, m: Message):
|
|
| 111 |
perm = "pin"
|
| 112 |
|
| 113 |
else:
|
| 114 |
-
await m.reply_text(
|
|
|
|
| 115 |
|
| 116 |
-
Use /locktypes to get the lock types"""
|
|
|
|
| 117 |
return
|
| 118 |
|
| 119 |
try:
|
|
@@ -277,9 +277,11 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
| 277 |
uperm = "pin"
|
| 278 |
|
| 279 |
else:
|
| 280 |
-
await m.reply_text(
|
|
|
|
| 281 |
|
| 282 |
-
Use /locktypes to get the lock types"""
|
|
|
|
| 283 |
return
|
| 284 |
|
| 285 |
try:
|
|
@@ -327,7 +329,7 @@ __PLUGIN__ = "locks"
|
|
| 327 |
|
| 328 |
__alt_name__ = ["grouplock", "lock", "grouplocks"]
|
| 329 |
|
| 330 |
-
__HELP__ = """
|
| 331 |
***Locks***
|
| 332 |
|
| 333 |
Use this to lock group permissions.
|
|
@@ -340,4 +342,4 @@ Allows you to lock and unlock permission types in the chat.
|
|
| 340 |
* /locktypes: Check available lock types!
|
| 341 |
|
| 342 |
**Example:**
|
| 343 |
-
`/lock media`: this locks all the media messages in the chat."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"))
|
|
|
|
| 109 |
perm = "pin"
|
| 110 |
|
| 111 |
else:
|
| 112 |
+
await m.reply_text(
|
| 113 |
+
text=""" Invalid Lock Type!
|
| 114 |
|
| 115 |
+
Use /locktypes to get the lock types"""
|
| 116 |
+
)
|
| 117 |
return
|
| 118 |
|
| 119 |
try:
|
|
|
|
| 277 |
uperm = "pin"
|
| 278 |
|
| 279 |
else:
|
| 280 |
+
await m.reply_text(
|
| 281 |
+
text="""Invalid Lock Type!
|
| 282 |
|
| 283 |
+
Use /locktypes to get the lock types"""
|
| 284 |
+
)
|
| 285 |
return
|
| 286 |
|
| 287 |
try:
|
|
|
|
| 329 |
|
| 330 |
__alt_name__ = ["grouplock", "lock", "grouplocks"]
|
| 331 |
|
| 332 |
+
__HELP__ = """
|
| 333 |
***Locks***
|
| 334 |
|
| 335 |
Use this to lock group permissions.
|
|
|
|
| 342 |
* /locktypes: Check available lock types!
|
| 343 |
|
| 344 |
**Example:**
|
| 345 |
+
`/lock media`: this locks all the media messages in the chat."""
|
Powers/plugins/muting.py
CHANGED
|
@@ -1,32 +1,24 @@
|
|
| 1 |
from random import choice
|
| 2 |
-
from
|
| 3 |
-
ChatAdminRequired,
|
| 4 |
-
RightForbidden,
|
| 5 |
-
RPCError,
|
| 6 |
-
UserNotParticipant,
|
| 7 |
-
)
|
| 8 |
-
from pyrogram.filters import regex
|
| 9 |
-
from pyrogram.types import (
|
| 10 |
-
CallbackQuery,
|
| 11 |
-
ChatPermissions,
|
| 12 |
-
InlineKeyboardButton,
|
| 13 |
-
InlineKeyboardMarkup,
|
| 14 |
-
Message,
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
-
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
| 18 |
from Powers.bot_class import Gojo
|
| 19 |
-
from
|
| 20 |
-
from Powers.utils.
|
| 21 |
-
from Powers.utils.extract_user import extract_user
|
| 22 |
from Powers.utils.parser import mention_html
|
| 23 |
from Powers.utils.string import extract_time
|
| 24 |
-
from Powers.
|
| 25 |
-
from Powers.utils.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
MUTE_MEDIA = choice(MUTE_GIFS)
|
| 29 |
|
|
|
|
| 30 |
@Gojo.on_message(command("tmute") & restrict_filter)
|
| 31 |
async def tmute_usr(c: Gojo, m: Message):
|
| 32 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
|
@@ -49,7 +41,9 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
| 49 |
LOGGER.info(
|
| 50 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 51 |
)
|
| 52 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 53 |
return
|
| 54 |
|
| 55 |
try:
|
|
@@ -92,9 +86,9 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
| 92 |
mutetime,
|
| 93 |
)
|
| 94 |
LOGGER.info(f"{m.from_user.id} tmuted {user_id} in {m.chat.id}")
|
| 95 |
-
admin=
|
| 96 |
-
muted=
|
| 97 |
-
txt =f"Admin {admin} muted {muted}!"
|
| 98 |
if reason:
|
| 99 |
txt += f"\n<b>Reason</b>: {reason}"
|
| 100 |
keyboard = InlineKeyboardMarkup(
|
|
@@ -107,7 +101,12 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
| 107 |
],
|
| 108 |
],
|
| 109 |
)
|
| 110 |
-
await m.reply_animation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
except ChatAdminRequired:
|
| 112 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 113 |
except RightForbidden:
|
|
@@ -149,7 +148,9 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
| 149 |
LOGGER.info(
|
| 150 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 151 |
)
|
| 152 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 153 |
return
|
| 154 |
|
| 155 |
try:
|
|
@@ -158,7 +159,7 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
| 158 |
admins_group = await admin_cache_reload(m, "mute")
|
| 159 |
|
| 160 |
if user_id in admins_group:
|
| 161 |
-
await m.reply_text(text
|
| 162 |
return
|
| 163 |
|
| 164 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
@@ -190,8 +191,8 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
| 190 |
)
|
| 191 |
LOGGER.info(f"{m.from_user.id} dtmuted {user_id} in {m.chat.id}")
|
| 192 |
await m.reply_to_message.delete()
|
| 193 |
-
admin=
|
| 194 |
-
muted=
|
| 195 |
txt = f"Admin {admin} muted {muted}!"
|
| 196 |
if reason:
|
| 197 |
txt += f"\n<b>Reason</b>: {reason}"
|
|
@@ -205,16 +206,22 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
| 205 |
],
|
| 206 |
],
|
| 207 |
)
|
| 208 |
-
await c.send_animation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 209 |
except ChatAdminRequired:
|
| 210 |
-
await m.reply_text(text
|
| 211 |
except RightForbidden:
|
| 212 |
-
await m.reply_text(text
|
| 213 |
except UserNotParticipant:
|
| 214 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 215 |
except RPCError as ef:
|
| 216 |
await m.reply_text(
|
| 217 |
-
text
|
| 218 |
|
| 219 |
<b>Error:</b> <code>{ef}</code>"""
|
| 220 |
)
|
|
@@ -245,7 +252,9 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
| 245 |
LOGGER.info(
|
| 246 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 247 |
)
|
| 248 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 249 |
return
|
| 250 |
|
| 251 |
try:
|
|
@@ -254,7 +263,7 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
| 254 |
admins_group = await admin_cache_reload(m, "mute")
|
| 255 |
|
| 256 |
if user_id in admins_group:
|
| 257 |
-
await m.reply_text(text
|
| 258 |
return
|
| 259 |
|
| 260 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
@@ -289,14 +298,14 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
| 289 |
if m.reply_to_message:
|
| 290 |
await m.reply_to_message.delete()
|
| 291 |
except ChatAdminRequired:
|
| 292 |
-
await m.reply_text(text
|
| 293 |
except RightForbidden:
|
| 294 |
-
await m.reply_text(text
|
| 295 |
except UserNotParticipant:
|
| 296 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 297 |
except RPCError as ef:
|
| 298 |
await m.reply_text(
|
| 299 |
-
text
|
| 300 |
|
| 301 |
<b>Error:</b> <code>{ef}</code>"""
|
| 302 |
)
|
|
@@ -336,7 +345,9 @@ async def mute_usr(c: Gojo, m: Message):
|
|
| 336 |
LOGGER.info(
|
| 337 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 338 |
)
|
| 339 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 340 |
return
|
| 341 |
|
| 342 |
try:
|
|
@@ -345,7 +356,7 @@ async def mute_usr(c: Gojo, m: Message):
|
|
| 345 |
admins_group = await admin_cache_reload(m, "mute")
|
| 346 |
|
| 347 |
if user_id in admins_group:
|
| 348 |
-
await m.reply_text(text
|
| 349 |
return
|
| 350 |
|
| 351 |
try:
|
|
@@ -354,8 +365,8 @@ async def mute_usr(c: Gojo, m: Message):
|
|
| 354 |
ChatPermissions(),
|
| 355 |
)
|
| 356 |
LOGGER.info(f"{m.from_user.id} muted {user_id} in {m.chat.id}")
|
| 357 |
-
admin=
|
| 358 |
-
muted=
|
| 359 |
txt = f"Admin {admin} muted {muted}!"
|
| 360 |
if reason:
|
| 361 |
txt += f"\n<b>Reason</b>: {reason}"
|
|
@@ -369,16 +380,21 @@ async def mute_usr(c: Gojo, m: Message):
|
|
| 369 |
],
|
| 370 |
],
|
| 371 |
)
|
| 372 |
-
await m.reply_animation(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
except ChatAdminRequired:
|
| 374 |
-
await m.reply_text(text
|
| 375 |
except RightForbidden:
|
| 376 |
-
await m.reply_text(text
|
| 377 |
except UserNotParticipant:
|
| 378 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 379 |
except RPCError as ef:
|
| 380 |
await m.reply_text(
|
| 381 |
-
text
|
| 382 |
|
| 383 |
<b>Error:</b> <code>{ef}</code>"""
|
| 384 |
)
|
|
@@ -409,7 +425,9 @@ async def smute_usr(c: Gojo, m: Message):
|
|
| 409 |
LOGGER.info(
|
| 410 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 411 |
)
|
| 412 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 413 |
return
|
| 414 |
|
| 415 |
try:
|
|
@@ -418,7 +436,7 @@ async def smute_usr(c: Gojo, m: Message):
|
|
| 418 |
admins_group = await admin_cache_reload(m, "mute")
|
| 419 |
|
| 420 |
if user_id in admins_group:
|
| 421 |
-
await m.reply_text(text
|
| 422 |
return
|
| 423 |
|
| 424 |
try:
|
|
@@ -433,14 +451,14 @@ async def smute_usr(c: Gojo, m: Message):
|
|
| 433 |
return
|
| 434 |
return
|
| 435 |
except ChatAdminRequired:
|
| 436 |
-
await m.reply_text(text
|
| 437 |
except RightForbidden:
|
| 438 |
-
await m.reply_text(text
|
| 439 |
except UserNotParticipant:
|
| 440 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 441 |
except RPCError as ef:
|
| 442 |
await m.reply_text(
|
| 443 |
-
text
|
| 444 |
|
| 445 |
<b>Error:</b> <code>{ef}</code>"""
|
| 446 |
)
|
|
@@ -478,7 +496,9 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
| 478 |
LOGGER.info(
|
| 479 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 480 |
)
|
| 481 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 482 |
return
|
| 483 |
|
| 484 |
try:
|
|
@@ -487,7 +507,7 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
| 487 |
admins_group = await admin_cache_reload(m, "mute")
|
| 488 |
|
| 489 |
if user_id in admins_group:
|
| 490 |
-
await m.reply_text(text
|
| 491 |
return
|
| 492 |
|
| 493 |
try:
|
|
@@ -497,8 +517,8 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
| 497 |
)
|
| 498 |
LOGGER.info(f"{m.from_user.id} dmuted {user_id} in {m.chat.id}")
|
| 499 |
await m.reply_to_message.delete()
|
| 500 |
-
admin=
|
| 501 |
-
muted=
|
| 502 |
txt = f"Admin {admin} muted {muted}!"
|
| 503 |
if reason:
|
| 504 |
txt += f"\n<b>Reason</b>: {reason}"
|
|
@@ -512,16 +532,18 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
| 512 |
],
|
| 513 |
],
|
| 514 |
)
|
| 515 |
-
await c.send_animation(
|
|
|
|
|
|
|
| 516 |
except ChatAdminRequired:
|
| 517 |
-
await m.reply_text(text
|
| 518 |
except RightForbidden:
|
| 519 |
-
await m.reply_text(text
|
| 520 |
except UserNotParticipant:
|
| 521 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 522 |
except RPCError as ef:
|
| 523 |
await m.reply_text(
|
| 524 |
-
text
|
| 525 |
|
| 526 |
<b>Error:</b> <code>{ef}</code>"""
|
| 527 |
)
|
|
@@ -548,20 +570,18 @@ async def unmute_usr(c: Gojo, m: Message):
|
|
| 548 |
try:
|
| 549 |
await m.chat.unban_member(user_id)
|
| 550 |
LOGGER.info(f"{m.from_user.id} unmuted {user_id} in {m.chat.id}")
|
| 551 |
-
admin=
|
| 552 |
-
unmuted=
|
| 553 |
-
await m.reply_text(
|
| 554 |
-
text=f"Admin {admin} unmuted {unmuted}!"
|
| 555 |
-
)
|
| 556 |
except ChatAdminRequired:
|
| 557 |
-
await m.reply_text(text
|
| 558 |
except UserNotParticipant:
|
| 559 |
await m.reply_text("How can I unmute a user who is not a part of this chat?")
|
| 560 |
except RightForbidden:
|
| 561 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 562 |
except RPCError as ef:
|
| 563 |
await m.reply_text(
|
| 564 |
-
text
|
| 565 |
|
| 566 |
<b>Error:</b> <code>{ef}</code>"""
|
| 567 |
)
|
|
|
|
| 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 |
MUTE_MEDIA = choice(MUTE_GIFS)
|
| 20 |
|
| 21 |
+
|
| 22 |
@Gojo.on_message(command("tmute") & restrict_filter)
|
| 23 |
async def tmute_usr(c: Gojo, m: Message):
|
| 24 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
|
|
|
| 41 |
LOGGER.info(
|
| 42 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 43 |
)
|
| 44 |
+
await m.reply_text(
|
| 45 |
+
text="This user is in my support staff, cannot restrict them."
|
| 46 |
+
)
|
| 47 |
return
|
| 48 |
|
| 49 |
try:
|
|
|
|
| 86 |
mutetime,
|
| 87 |
)
|
| 88 |
LOGGER.info(f"{m.from_user.id} tmuted {user_id} in {m.chat.id}")
|
| 89 |
+
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
| 90 |
+
muted = await mention_html(user_first_name, user_id)
|
| 91 |
+
txt = f"Admin {admin} muted {muted}!"
|
| 92 |
if reason:
|
| 93 |
txt += f"\n<b>Reason</b>: {reason}"
|
| 94 |
keyboard = InlineKeyboardMarkup(
|
|
|
|
| 101 |
],
|
| 102 |
],
|
| 103 |
)
|
| 104 |
+
await m.reply_animation(
|
| 105 |
+
animation=MUTE_MEDIA,
|
| 106 |
+
caption=txt,
|
| 107 |
+
reply_markup=keyboard,
|
| 108 |
+
reply_to_message_id=r_id,
|
| 109 |
+
)
|
| 110 |
except ChatAdminRequired:
|
| 111 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 112 |
except RightForbidden:
|
|
|
|
| 148 |
LOGGER.info(
|
| 149 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 150 |
)
|
| 151 |
+
await m.reply_text(
|
| 152 |
+
text="This user is in my support staff, cannot restrict them."
|
| 153 |
+
)
|
| 154 |
return
|
| 155 |
|
| 156 |
try:
|
|
|
|
| 159 |
admins_group = await admin_cache_reload(m, "mute")
|
| 160 |
|
| 161 |
if user_id in admins_group:
|
| 162 |
+
await m.reply_text(text="This user is an admin, I cannot mute them!")
|
| 163 |
return
|
| 164 |
|
| 165 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
|
| 191 |
)
|
| 192 |
LOGGER.info(f"{m.from_user.id} dtmuted {user_id} in {m.chat.id}")
|
| 193 |
await m.reply_to_message.delete()
|
| 194 |
+
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
| 195 |
+
muted = await mention_html(user_first_name, user_id)
|
| 196 |
txt = f"Admin {admin} muted {muted}!"
|
| 197 |
if reason:
|
| 198 |
txt += f"\n<b>Reason</b>: {reason}"
|
|
|
|
| 206 |
],
|
| 207 |
],
|
| 208 |
)
|
| 209 |
+
await c.send_animation(
|
| 210 |
+
animation=MUTE_MEDIA,
|
| 211 |
+
chat_id=m.chat.id,
|
| 212 |
+
caption=txt,
|
| 213 |
+
reply_markup=keyboard,
|
| 214 |
+
unsave=True,
|
| 215 |
+
)
|
| 216 |
except ChatAdminRequired:
|
| 217 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 218 |
except RightForbidden:
|
| 219 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 220 |
except UserNotParticipant:
|
| 221 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 222 |
except RPCError as ef:
|
| 223 |
await m.reply_text(
|
| 224 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 225 |
|
| 226 |
<b>Error:</b> <code>{ef}</code>"""
|
| 227 |
)
|
|
|
|
| 252 |
LOGGER.info(
|
| 253 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 254 |
)
|
| 255 |
+
await m.reply_text(
|
| 256 |
+
text="This user is in my support staff, cannot restrict them."
|
| 257 |
+
)
|
| 258 |
return
|
| 259 |
|
| 260 |
try:
|
|
|
|
| 263 |
admins_group = await admin_cache_reload(m, "mute")
|
| 264 |
|
| 265 |
if user_id in admins_group:
|
| 266 |
+
await m.reply_text(text="This user is an admin, I cannot mute them!")
|
| 267 |
return
|
| 268 |
|
| 269 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
|
| 298 |
if m.reply_to_message:
|
| 299 |
await m.reply_to_message.delete()
|
| 300 |
except ChatAdminRequired:
|
| 301 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 302 |
except RightForbidden:
|
| 303 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 304 |
except UserNotParticipant:
|
| 305 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 306 |
except RPCError as ef:
|
| 307 |
await m.reply_text(
|
| 308 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 309 |
|
| 310 |
<b>Error:</b> <code>{ef}</code>"""
|
| 311 |
)
|
|
|
|
| 345 |
LOGGER.info(
|
| 346 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 347 |
)
|
| 348 |
+
await m.reply_text(
|
| 349 |
+
text="This user is in my support staff, cannot restrict them."
|
| 350 |
+
)
|
| 351 |
return
|
| 352 |
|
| 353 |
try:
|
|
|
|
| 356 |
admins_group = await admin_cache_reload(m, "mute")
|
| 357 |
|
| 358 |
if user_id in admins_group:
|
| 359 |
+
await m.reply_text(text="This user is an admin, I cannot mute them!")
|
| 360 |
return
|
| 361 |
|
| 362 |
try:
|
|
|
|
| 365 |
ChatPermissions(),
|
| 366 |
)
|
| 367 |
LOGGER.info(f"{m.from_user.id} muted {user_id} in {m.chat.id}")
|
| 368 |
+
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
| 369 |
+
muted = await mention_html(user_first_name, user_id)
|
| 370 |
txt = f"Admin {admin} muted {muted}!"
|
| 371 |
if reason:
|
| 372 |
txt += f"\n<b>Reason</b>: {reason}"
|
|
|
|
| 380 |
],
|
| 381 |
],
|
| 382 |
)
|
| 383 |
+
await m.reply_animation(
|
| 384 |
+
animation=MUTE_MEDIA,
|
| 385 |
+
caption=txt,
|
| 386 |
+
reply_markup=keyboard,
|
| 387 |
+
reply_to_message_id=r_id,
|
| 388 |
+
)
|
| 389 |
except ChatAdminRequired:
|
| 390 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 391 |
except RightForbidden:
|
| 392 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 393 |
except UserNotParticipant:
|
| 394 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 395 |
except RPCError as ef:
|
| 396 |
await m.reply_text(
|
| 397 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 398 |
|
| 399 |
<b>Error:</b> <code>{ef}</code>"""
|
| 400 |
)
|
|
|
|
| 425 |
LOGGER.info(
|
| 426 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 427 |
)
|
| 428 |
+
await m.reply_text(
|
| 429 |
+
text="This user is in my support staff, cannot restrict them."
|
| 430 |
+
)
|
| 431 |
return
|
| 432 |
|
| 433 |
try:
|
|
|
|
| 436 |
admins_group = await admin_cache_reload(m, "mute")
|
| 437 |
|
| 438 |
if user_id in admins_group:
|
| 439 |
+
await m.reply_text(text="This user is an admin, I cannot mute them!")
|
| 440 |
return
|
| 441 |
|
| 442 |
try:
|
|
|
|
| 451 |
return
|
| 452 |
return
|
| 453 |
except ChatAdminRequired:
|
| 454 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 455 |
except RightForbidden:
|
| 456 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 457 |
except UserNotParticipant:
|
| 458 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 459 |
except RPCError as ef:
|
| 460 |
await m.reply_text(
|
| 461 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 462 |
|
| 463 |
<b>Error:</b> <code>{ef}</code>"""
|
| 464 |
)
|
|
|
|
| 496 |
LOGGER.info(
|
| 497 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 498 |
)
|
| 499 |
+
await m.reply_text(
|
| 500 |
+
text="This user is in my support staff, cannot restrict them."
|
| 501 |
+
)
|
| 502 |
return
|
| 503 |
|
| 504 |
try:
|
|
|
|
| 507 |
admins_group = await admin_cache_reload(m, "mute")
|
| 508 |
|
| 509 |
if user_id in admins_group:
|
| 510 |
+
await m.reply_text(text="This user is an admin, I cannot mute them!")
|
| 511 |
return
|
| 512 |
|
| 513 |
try:
|
|
|
|
| 517 |
)
|
| 518 |
LOGGER.info(f"{m.from_user.id} dmuted {user_id} in {m.chat.id}")
|
| 519 |
await m.reply_to_message.delete()
|
| 520 |
+
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
| 521 |
+
muted = await mention_html(user_first_name, user_id)
|
| 522 |
txt = f"Admin {admin} muted {muted}!"
|
| 523 |
if reason:
|
| 524 |
txt += f"\n<b>Reason</b>: {reason}"
|
|
|
|
| 532 |
],
|
| 533 |
],
|
| 534 |
)
|
| 535 |
+
await c.send_animation(
|
| 536 |
+
animation=MUTE_MEDIA, chat_id=m.chat.id, caption=txt, reply_markup=keyboard
|
| 537 |
+
)
|
| 538 |
except ChatAdminRequired:
|
| 539 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 540 |
except RightForbidden:
|
| 541 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 542 |
except UserNotParticipant:
|
| 543 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
| 544 |
except RPCError as ef:
|
| 545 |
await m.reply_text(
|
| 546 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 547 |
|
| 548 |
<b>Error:</b> <code>{ef}</code>"""
|
| 549 |
)
|
|
|
|
| 570 |
try:
|
| 571 |
await m.chat.unban_member(user_id)
|
| 572 |
LOGGER.info(f"{m.from_user.id} unmuted {user_id} in {m.chat.id}")
|
| 573 |
+
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
| 574 |
+
unmuted = await mention_html(user_first_name, user_id)
|
| 575 |
+
await m.reply_text(text=f"Admin {admin} unmuted {unmuted}!")
|
|
|
|
|
|
|
| 576 |
except ChatAdminRequired:
|
| 577 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
| 578 |
except UserNotParticipant:
|
| 579 |
await m.reply_text("How can I unmute a user who is not a part of this chat?")
|
| 580 |
except RightForbidden:
|
| 581 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
| 582 |
except RPCError as ef:
|
| 583 |
await m.reply_text(
|
| 584 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 585 |
|
| 586 |
<b>Error:</b> <code>{ef}</code>"""
|
| 587 |
)
|
Powers/plugins/notes.py
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
|
|
| 1 |
from secrets import choice
|
| 2 |
-
from traceback import format_exc
|
| 3 |
-
|
| 4 |
from pyrogram import filters
|
| 5 |
-
from
|
| 6 |
-
from
|
| 7 |
-
|
| 8 |
-
from Powers import LOGGER
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
-
from
|
| 11 |
-
from Powers.utils.cmd_senders import send_cmd
|
| 12 |
-
from Powers.utils.custom_filters import admin_filter, command, owner_filter
|
| 13 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
| 14 |
from Powers.utils.msg_types import Types, get_note_type
|
|
|
|
|
|
|
|
|
|
| 15 |
from Powers.utils.string import (
|
| 16 |
-
build_keyboard,
|
| 17 |
-
|
| 18 |
-
parse_button,
|
| 19 |
-
)
|
| 20 |
-
from Powers.vars import Config
|
| 21 |
|
| 22 |
# Initialise
|
| 23 |
db = Notes()
|
|
@@ -454,4 +450,4 @@ Only admins can save and deletenotes, anyone can get them.
|
|
| 454 |
* /privatenotes `<on/yes/no/off>`: Whether to turn private rules on or off, prevents spam in chat when people use notes command.
|
| 455 |
|
| 456 |
── **Note Format** ──
|
| 457 |
-
Check /markdownhelp for help related to formatting!"""
|
|
|
|
| 1 |
+
from Powers import LOGGER
|
| 2 |
from secrets import choice
|
|
|
|
|
|
|
| 3 |
from pyrogram import filters
|
| 4 |
+
from Powers.vars import Config
|
| 5 |
+
from traceback import format_exc
|
|
|
|
|
|
|
| 6 |
from Powers.bot_class import Gojo
|
| 7 |
+
from pyrogram.errors import RPCError
|
|
|
|
|
|
|
| 8 |
from Powers.utils.kbhelpers import ikb
|
| 9 |
+
from Powers.utils.cmd_senders import send_cmd
|
| 10 |
from Powers.utils.msg_types import Types, get_note_type
|
| 11 |
+
from Powers.database.notes_db import Notes, NotesSettings
|
| 12 |
+
from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
|
| 13 |
+
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
| 14 |
from Powers.utils.string import (
|
| 15 |
+
parse_button, build_keyboard, escape_mentions_using_curly_brackets)
|
| 16 |
+
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# Initialise
|
| 19 |
db = Notes()
|
|
|
|
| 450 |
* /privatenotes `<on/yes/no/off>`: Whether to turn private rules on or off, prevents spam in chat when people use notes command.
|
| 451 |
|
| 452 |
── **Note Format** ──
|
| 453 |
+
Check /markdownhelp for help related to formatting!"""
|
Powers/plugins/pin.py
CHANGED
|
@@ -1,15 +1,13 @@
|
|
| 1 |
-
from
|
| 2 |
-
|
| 3 |
-
from pyrogram.errors import ChatAdminRequired, RightForbidden, RPCError
|
| 4 |
from pyrogram.filters import regex
|
| 5 |
-
from
|
| 6 |
-
|
| 7 |
from Powers import LOGGER, SUPPORT_GROUP
|
| 8 |
-
from Powers.bot_class import Gojo
|
| 9 |
from Powers.database.pins_db import Pins
|
| 10 |
-
from
|
| 11 |
-
from Powers.utils.
|
| 12 |
-
from Powers.utils.
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
@Gojo.on_message(command("pin") & admin_filter)
|
|
@@ -125,7 +123,7 @@ async def unpinall_calllback(c: Gojo, q: CallbackQuery):
|
|
| 125 |
await q.message.edit_text(text="I don't have enough rights to unpin messages.")
|
| 126 |
except RPCError as ef:
|
| 127 |
await q.message.edit_text(
|
| 128 |
-
|
| 129 |
|
| 130 |
<b>Error:</b> <code>{ef}</code>"""
|
| 131 |
)
|
|
@@ -139,9 +137,7 @@ async def anti_channel_pin(_, m: Message):
|
|
| 139 |
|
| 140 |
if len(m.text.split()) == 1:
|
| 141 |
status = pinsdb.get_settings()["antichannelpin"]
|
| 142 |
-
await m.reply_text(
|
| 143 |
-
text=f"Current AntiChannelPin status: {status}"
|
| 144 |
-
)
|
| 145 |
return
|
| 146 |
|
| 147 |
if len(m.text.split()) == 2:
|
|
@@ -154,7 +150,9 @@ async def anti_channel_pin(_, m: Message):
|
|
| 154 |
LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
|
| 155 |
msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
|
| 156 |
else:
|
| 157 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 158 |
return
|
| 159 |
|
| 160 |
await m.reply_text(msg)
|
|
@@ -191,9 +189,7 @@ async def clean_linked(_, m: Message):
|
|
| 191 |
|
| 192 |
if len(m.text.split()) == 1:
|
| 193 |
status = pinsdb.get_settings()["cleanlinked"]
|
| 194 |
-
await m.reply_text(
|
| 195 |
-
text=f"Current AntiChannelPin status: {status}"
|
| 196 |
-
)
|
| 197 |
return
|
| 198 |
|
| 199 |
if len(m.text.split()) == 2:
|
|
@@ -206,7 +202,9 @@ async def clean_linked(_, m: Message):
|
|
| 206 |
LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
|
| 207 |
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
|
| 208 |
else:
|
| 209 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 210 |
return
|
| 211 |
|
| 212 |
await m.reply_text(msg)
|
|
@@ -248,4 +246,4 @@ Here you find find all help related to groups pins and how to manage them via me
|
|
| 248 |
* /unpinall: Unpins all the pinned message in the current chat.
|
| 249 |
* /antichannelpin `<on/off/yes/no>`: Toggle antichannelpin status. All the messages from linked channel will be unpinned if enabled!
|
| 250 |
* /cleanlinked `<on/off/yes/no>`: Toggle cleanlinked status. All the messages from linked channel will be deleted if enabled!
|
| 251 |
-
* /permapin `<text>`: Pin a custom messages via bot. This message can contain markdown, and can be used in replies to the media include additional buttons and text."""
|
|
|
|
| 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 Powers.utils.string import parse_button, build_keyboard
|
| 9 |
+
from Powers.utils.custom_filters import command, admin_filter
|
| 10 |
+
from pyrogram.errors import RPCError, RightForbidden, ChatAdminRequired
|
| 11 |
|
| 12 |
|
| 13 |
@Gojo.on_message(command("pin") & admin_filter)
|
|
|
|
| 123 |
await q.message.edit_text(text="I don't have enough rights to unpin messages.")
|
| 124 |
except RPCError as ef:
|
| 125 |
await q.message.edit_text(
|
| 126 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
| 127 |
|
| 128 |
<b>Error:</b> <code>{ef}</code>"""
|
| 129 |
)
|
|
|
|
| 137 |
|
| 138 |
if len(m.text.split()) == 1:
|
| 139 |
status = pinsdb.get_settings()["antichannelpin"]
|
| 140 |
+
await m.reply_text(text=f"Current AntiChannelPin status: {status}")
|
|
|
|
|
|
|
| 141 |
return
|
| 142 |
|
| 143 |
if len(m.text.split()) == 2:
|
|
|
|
| 150 |
LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
|
| 151 |
msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
|
| 152 |
else:
|
| 153 |
+
await m.reply_text(
|
| 154 |
+
text="Please check help on how to use this this command."
|
| 155 |
+
)
|
| 156 |
return
|
| 157 |
|
| 158 |
await m.reply_text(msg)
|
|
|
|
| 189 |
|
| 190 |
if len(m.text.split()) == 1:
|
| 191 |
status = pinsdb.get_settings()["cleanlinked"]
|
| 192 |
+
await m.reply_text(text=f"Current AntiChannelPin status: {status}")
|
|
|
|
|
|
|
| 193 |
return
|
| 194 |
|
| 195 |
if len(m.text.split()) == 2:
|
|
|
|
| 202 |
LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
|
| 203 |
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
|
| 204 |
else:
|
| 205 |
+
await m.reply_text(
|
| 206 |
+
text="Please check help on how to use this this command."
|
| 207 |
+
)
|
| 208 |
return
|
| 209 |
|
| 210 |
await m.reply_text(msg)
|
|
|
|
| 246 |
* /unpinall: Unpins all the pinned message in the current chat.
|
| 247 |
* /antichannelpin `<on/off/yes/no>`: Toggle antichannelpin status. All the messages from linked channel will be unpinned if enabled!
|
| 248 |
* /cleanlinked `<on/off/yes/no>`: Toggle cleanlinked status. All the messages from linked channel will be deleted if enabled!
|
| 249 |
+
* /permapin `<text>`: Pin a custom messages via bot. This message can contain markdown, and can be used in replies to the media include additional buttons and text."""
|
Powers/plugins/purge.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
from asyncio import sleep
|
| 2 |
-
|
| 3 |
-
from pyrogram.errors import MessageDeleteForbidden, RPCError
|
| 4 |
-
from pyrogram.types import Message
|
| 5 |
-
|
| 6 |
from Powers import SUPPORT_GROUP
|
| 7 |
from Powers.bot_class import Gojo
|
|
|
|
| 8 |
from Powers.utils.chat_type import chattype
|
| 9 |
-
from
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
@Gojo.on_message(command("purge") & admin_filter)
|
|
@@ -35,7 +33,9 @@ async def purge(c: Gojo, m: Message):
|
|
| 35 |
)
|
| 36 |
await m.delete()
|
| 37 |
except MessageDeleteForbidden:
|
| 38 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 39 |
return
|
| 40 |
except RPCError as ef:
|
| 41 |
await m.reply_text(
|
|
@@ -46,10 +46,7 @@ async def purge(c: Gojo, m: Message):
|
|
| 46 |
|
| 47 |
count_del_msg = len(message_ids)
|
| 48 |
|
| 49 |
-
z = await m.reply_text(
|
| 50 |
-
text=f"Deleted <i>{count_del_msg}</i> messages"
|
| 51 |
-
|
| 52 |
-
)
|
| 53 |
await sleep(3)
|
| 54 |
await z.delete()
|
| 55 |
return
|
|
@@ -83,7 +80,9 @@ async def spurge(c: Gojo, m: Message):
|
|
| 83 |
)
|
| 84 |
await m.delete()
|
| 85 |
except MessageDeleteForbidden:
|
| 86 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 87 |
return
|
| 88 |
except RPCError as ef:
|
| 89 |
await m.reply_text(
|
|
@@ -125,4 +124,4 @@ __HELP__ = """
|
|
| 125 |
|
| 126 |
* /purge: Deletes messages upto replied message.
|
| 127 |
* /spurge: Deletes messages upto replied message without a success message.
|
| 128 |
-
* /del: Deletes a single message, used as a reply to message."""
|
|
|
|
| 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 Powers.utils.chat_type 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)
|
|
|
|
| 33 |
)
|
| 34 |
await m.delete()
|
| 35 |
except MessageDeleteForbidden:
|
| 36 |
+
await m.reply_text(
|
| 37 |
+
text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup."
|
| 38 |
+
)
|
| 39 |
return
|
| 40 |
except RPCError as ef:
|
| 41 |
await m.reply_text(
|
|
|
|
| 46 |
|
| 47 |
count_del_msg = len(message_ids)
|
| 48 |
|
| 49 |
+
z = await m.reply_text(text=f"Deleted <i>{count_del_msg}</i> messages")
|
|
|
|
|
|
|
|
|
|
| 50 |
await sleep(3)
|
| 51 |
await z.delete()
|
| 52 |
return
|
|
|
|
| 80 |
)
|
| 81 |
await m.delete()
|
| 82 |
except MessageDeleteForbidden:
|
| 83 |
+
await m.reply_text(
|
| 84 |
+
text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup."
|
| 85 |
+
)
|
| 86 |
return
|
| 87 |
except RPCError as ef:
|
| 88 |
await m.reply_text(
|
|
|
|
| 124 |
|
| 125 |
* /purge: Deletes messages upto replied message.
|
| 126 |
* /spurge: Deletes messages upto replied message without a success message.
|
| 127 |
+
* /del: Deletes a single message, used as a reply to message."""
|
Powers/plugins/report.py
CHANGED
|
@@ -1,17 +1,15 @@
|
|
| 1 |
-
from traceback import format_exc
|
| 2 |
-
|
| 3 |
from pyrogram import filters
|
| 4 |
-
from
|
| 5 |
-
from pyrogram.errors import RPCError
|
| 6 |
-
from pyrogram.types import CallbackQuery, Message
|
| 7 |
-
|
| 8 |
-
from Powers import LOGGER, SUPPORT_STAFF
|
| 9 |
from Powers.bot_class import Gojo
|
| 10 |
-
from
|
| 11 |
-
from Powers.utils.custom_filters import admin_filter, command
|
| 12 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
| 13 |
from Powers.utils.chat_type import chattype
|
| 14 |
from Powers.utils.parser import mention_html
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
@Gojo.on_message(
|
|
@@ -101,7 +99,8 @@ async def report_watcher(c: Gojo, m: Message):
|
|
| 101 |
msg = f"{(await mention_html(m.from_user.first_name, m.from_user.id))} is calling for admins in '{chat_name}'!\n"
|
| 102 |
|
| 103 |
link_chat_id = str(m.chat.id).replace("-100", "")
|
| 104 |
-
|
|
|
|
| 105 |
|
| 106 |
reply_markup = ikb(
|
| 107 |
[
|
|
@@ -215,4 +214,4 @@ __HELP__ = """
|
|
| 215 |
**Admins Only:**
|
| 216 |
* /reports `<on/off/yes/no>`: change report setting, or view current status.
|
| 217 |
- If done in PM, toggles your status.
|
| 218 |
-
- If in group, toggles that groups's status."""
|
|
|
|
|
|
|
|
|
|
| 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.chat_type import chattype
|
| 8 |
from Powers.utils.parser import mention_html
|
| 9 |
+
from pyrogram.types import Message, CallbackQuery
|
| 10 |
+
from Powers.database.reporting_db import Reporting
|
| 11 |
+
from pyrogram.enums import ChatMembersFilter as cmf
|
| 12 |
+
from Powers.utils.custom_filters import command, admin_filter
|
| 13 |
|
| 14 |
|
| 15 |
@Gojo.on_message(
|
|
|
|
| 99 |
msg = f"{(await mention_html(m.from_user.first_name, m.from_user.id))} is calling for admins in '{chat_name}'!\n"
|
| 100 |
|
| 101 |
link_chat_id = str(m.chat.id).replace("-100", "")
|
| 102 |
+
# message link
|
| 103 |
+
link = f"https://t.me/c/{link_chat_id}/{reported_msg_id}"
|
| 104 |
|
| 105 |
reply_markup = ikb(
|
| 106 |
[
|
|
|
|
| 214 |
**Admins Only:**
|
| 215 |
* /reports `<on/off/yes/no>`: change report setting, or view current status.
|
| 216 |
- If done in PM, toggles your status.
|
| 217 |
+
- If in group, toggles that groups's status."""
|
Powers/plugins/rules.py
CHANGED
|
@@ -1,12 +1,11 @@
|
|
| 1 |
-
from pyrogram import filters
|
| 2 |
-
from pyrogram.types import CallbackQuery, Message
|
| 3 |
-
|
| 4 |
from Powers import LOGGER
|
|
|
|
|
|
|
| 5 |
from Powers.bot_class import Gojo
|
| 6 |
-
from Powers.database.rules_db import Rules
|
| 7 |
-
from Powers.utils.custom_filters import admin_filter, command
|
| 8 |
from Powers.utils.kbhelpers import ikb
|
| 9 |
-
from Powers.
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
@Gojo.on_message(command("rules") & filters.group)
|
|
@@ -105,7 +104,9 @@ async def priv_rules(_, m: Message):
|
|
| 105 |
await m.reply_text(msg)
|
| 106 |
elif len(m.text.split()) == 1:
|
| 107 |
curr_pref = db.get_privrules()
|
| 108 |
-
msg =
|
|
|
|
|
|
|
| 109 |
LOGGER.info(f"{m.from_user.id} fetched privaterules preference in {m.chat.id}")
|
| 110 |
await m.reply_text(msg)
|
| 111 |
else:
|
|
@@ -122,7 +123,9 @@ async def clear_rules(_, m: Message):
|
|
| 122 |
|
| 123 |
rules = db.get_rules()
|
| 124 |
if not rules:
|
| 125 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 126 |
return
|
| 127 |
|
| 128 |
await m.reply_text(
|
|
@@ -157,4 +160,4 @@ Set rules for you chat so that members know what to do and what not to do in you
|
|
| 157 |
**Admin only:**
|
| 158 |
* /setrules `<rules>`: Set the rules for this chat, also works as a reply to a message.
|
| 159 |
* /clearrules: Clear the rules for this chat.
|
| 160 |
-
* /privrules `<on/yes/no/off>`: Turns on/off the option to send the rules to PM of user or group."""
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
|
|
|
| 104 |
await m.reply_text(msg)
|
| 105 |
elif len(m.text.split()) == 1:
|
| 106 |
curr_pref = db.get_privrules()
|
| 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:
|
|
|
|
| 123 |
|
| 124 |
rules = db.get_rules()
|
| 125 |
if not rules:
|
| 126 |
+
await m.reply_text(
|
| 127 |
+
text="The Admins for this group have not setup rules! That doesn't mean you can break the DECORUM of this group !"
|
| 128 |
+
)
|
| 129 |
return
|
| 130 |
|
| 131 |
await m.reply_text(
|
|
|
|
| 160 |
**Admin only:**
|
| 161 |
* /setrules `<rules>`: Set the rules for this chat, also works as a reply to a message.
|
| 162 |
* /clearrules: Clear the rules for this chat.
|
| 163 |
+
* /privrules `<on/yes/no/off>`: Turns on/off the option to send the rules to PM of user or group."""
|
Powers/plugins/start.py
CHANGED
|
@@ -1,32 +1,24 @@
|
|
| 1 |
from random import choice
|
| 2 |
-
|
| 3 |
from pyrogram import filters
|
| 4 |
-
from
|
| 5 |
-
from pyrogram.types import CallbackQuery, Message
|
| 6 |
-
|
| 7 |
-
from Powers import HELP_COMMANDS, LOGGER
|
| 8 |
from Powers.bot_class import Gojo
|
| 9 |
-
from Powers.utils.custom_filters import command
|
| 10 |
-
from Powers.utils.chat_type import chattype
|
| 11 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
| 12 |
from Powers.utils.extras import StartPic
|
| 13 |
from Powers.utils.chat_type import chattype
|
|
|
|
|
|
|
|
|
|
| 14 |
from Powers.utils.start_utils import (
|
| 15 |
-
gen_cmds_kb,
|
| 16 |
-
|
| 17 |
-
get_help_msg,
|
| 18 |
-
get_private_note,
|
| 19 |
-
get_private_rules,
|
| 20 |
-
)
|
| 21 |
-
from Powers.vars import Config
|
| 22 |
-
|
| 23 |
|
| 24 |
|
| 25 |
@Gojo.on_message(
|
| 26 |
command("donate") & (filters.group | filters.private),
|
| 27 |
)
|
| 28 |
async def donate(_, m: Message):
|
| 29 |
-
cpt="""
|
| 30 |
Hey Thanks for your thought of donating me!
|
| 31 |
When you donate, all the fund goes towards my development which makes on fast and responsive.
|
| 32 |
Your donation might also me get me a new feature or two, which I wasn't able to get due to server limitations.
|
|
@@ -35,11 +27,9 @@ All the fund would be put into my services such as database, storage and hosting
|
|
| 35 |
|
| 36 |
You can donate by contacting my owner: [Captain Ezio](http://t.me/iamgojoof6eyes)
|
| 37 |
"""
|
| 38 |
-
|
| 39 |
|
| 40 |
LOGGER.info(f"{m.from_user.id} fetched donation text in {m.chat.id}")
|
| 41 |
-
await m.reply_photo(photo=choice(StartPic),
|
| 42 |
-
caption=cpt)
|
| 43 |
return
|
| 44 |
|
| 45 |
|
|
@@ -67,7 +57,6 @@ async def close_admin_callback(_, q: CallbackQuery):
|
|
| 67 |
@Gojo.on_message(
|
| 68 |
command("start") & (filters.group | filters.private),
|
| 69 |
)
|
| 70 |
-
|
| 71 |
async def start(c: Gojo, m: Message):
|
| 72 |
chat_type = await chattype(m)
|
| 73 |
if chat_type == "private":
|
|
@@ -89,43 +78,42 @@ async def start(c: Gojo, m: Message):
|
|
| 89 |
if not help_msg:
|
| 90 |
return
|
| 91 |
|
| 92 |
-
|
| 93 |
-
|
| 94 |
await m.reply_photo(
|
| 95 |
photo=choice(StartPic),
|
| 96 |
caption=help_msg,
|
| 97 |
parse_mode="markdown",
|
| 98 |
reply_markup=ikb(help_kb),
|
| 99 |
quote=True,
|
| 100 |
-
|
| 101 |
)
|
| 102 |
return
|
| 103 |
try:
|
| 104 |
-
cpt=f"""
|
| 105 |
Hey [{m.from_user.first_name}](http://t.me/{m.from_user.username})! My self Gojo ✨.
|
| 106 |
I'm here to help you manage your groups!
|
| 107 |
Hit /help to find out more about how to use me in my full potential!
|
| 108 |
|
| 109 |
Join my [News Channel](https://t.me/gojo_updates) to get information on all the latest updates."""
|
| 110 |
-
|
| 111 |
-
|
| 112 |
|
| 113 |
await m.reply_photo(
|
| 114 |
photo=choice(StartPic),
|
| 115 |
caption=cpt,
|
| 116 |
reply_markup=(await gen_start_kb(m)),
|
| 117 |
quote=True,
|
| 118 |
-
|
| 119 |
)
|
| 120 |
except UserIsBlocked:
|
| 121 |
LOGGER.warning(f"Bot blocked by {m.from_user.id}")
|
| 122 |
else:
|
| 123 |
-
kb = ikb(
|
| 124 |
-
[
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
await m.reply_photo(
|
| 130 |
photo=choice(StartPic),
|
| 131 |
caption="I'm alive :3",
|
|
@@ -138,7 +126,7 @@ Join my [News Channel](https://t.me/gojo_updates) to get information on all the
|
|
| 138 |
@Gojo.on_callback_query(filters.regex("^start_back$"))
|
| 139 |
async def start_back(_, q: CallbackQuery):
|
| 140 |
try:
|
| 141 |
-
cpt=f"""
|
| 142 |
Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! My name is Gojo ✨.
|
| 143 |
I'm here to help you manage your groups!
|
| 144 |
Hit /help to find out more about how to use me in my full potential!
|
|
@@ -148,7 +136,6 @@ Join my [News Channel](http://t.me/gojo_updates) to get information on all the l
|
|
| 148 |
await q.edit_message_caption(
|
| 149 |
caption=cpt,
|
| 150 |
reply_markup=(await gen_start_kb(q.message)),
|
| 151 |
-
|
| 152 |
)
|
| 153 |
except MessageNotModified:
|
| 154 |
pass
|
|
@@ -165,7 +152,7 @@ async def commands_menu(_, q: CallbackQuery):
|
|
| 165 |
],
|
| 166 |
)
|
| 167 |
try:
|
| 168 |
-
cpt=f"""
|
| 169 |
Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! My name is Gojo✨.
|
| 170 |
I'm here to help you manage your groups!
|
| 171 |
Commands available:
|
|
@@ -174,16 +161,15 @@ Commands available:
|
|
| 174 |
|
| 175 |
await q.edit_message_caption(
|
| 176 |
caption=cpt,
|
| 177 |
-
|
| 178 |
)
|
| 179 |
except MessageNotModified:
|
| 180 |
pass
|
| 181 |
except QueryIdInvalid:
|
| 182 |
await q.message.reply_photo(
|
| 183 |
-
photo=choice(StartPic),
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
await q.answer()
|
| 188 |
return
|
| 189 |
|
|
@@ -203,17 +189,16 @@ async def help_menu(_, m: Message):
|
|
| 203 |
)
|
| 204 |
chat_type = await chattype(m)
|
| 205 |
if chat_type == "private":
|
| 206 |
-
|
| 207 |
await m.reply_photo(
|
| 208 |
photo=choice(StartPic),
|
| 209 |
caption=help_msg,
|
| 210 |
parse_mode="markdown",
|
| 211 |
reply_markup=ikb(help_kb),
|
| 212 |
quote=True,
|
| 213 |
-
|
| 214 |
)
|
| 215 |
else:
|
| 216 |
-
|
| 217 |
await m.reply_photo(
|
| 218 |
photo=choice(StartPic),
|
| 219 |
caption=f"Press the button below to get help for <i>{help_option}</i>",
|
|
@@ -238,7 +223,7 @@ async def help_menu(_, m: Message):
|
|
| 238 |
[("« Back", "start_back")],
|
| 239 |
],
|
| 240 |
)
|
| 241 |
-
msg =f"""
|
| 242 |
Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!My name is Gojo✨.
|
| 243 |
I'm here to help you manage your groups!
|
| 244 |
Commands available:
|
|
@@ -249,7 +234,7 @@ Commands available:
|
|
| 249 |
[[("Help", f"t.me/{Config.BOT_USERNAME}?start=help", "url")]],
|
| 250 |
)
|
| 251 |
msg = "Contact me in PM to get the list of possible commands."
|
| 252 |
-
|
| 253 |
await m.reply_photo(
|
| 254 |
photo=choice(StartPic),
|
| 255 |
caption=msg,
|
|
@@ -263,7 +248,7 @@ Commands available:
|
|
| 263 |
async def get_module_info(_, q: CallbackQuery):
|
| 264 |
module = q.data.split(".", 1)[1]
|
| 265 |
|
| 266 |
-
help_msg = f"**{str(module)}:**\n\n" + HELP_COMMANDS[module]["help_msg"],
|
| 267 |
|
| 268 |
help_kb = HELP_COMMANDS[module]["buttons"] + [
|
| 269 |
[("« " + "Back", "commands")],
|
|
|
|
| 1 |
from random import choice
|
|
|
|
| 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 import LOGGER, HELP_COMMANDS
|
| 7 |
from Powers.utils.extras import StartPic
|
| 8 |
from Powers.utils.chat_type import chattype
|
| 9 |
+
from Powers.utils.custom_filters import command
|
| 10 |
+
from pyrogram.types import Message, CallbackQuery
|
| 11 |
+
from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
|
| 12 |
from 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(
|
| 18 |
command("donate") & (filters.group | filters.private),
|
| 19 |
)
|
| 20 |
async def donate(_, m: Message):
|
| 21 |
+
cpt = """
|
| 22 |
Hey Thanks for your thought of donating me!
|
| 23 |
When you donate, all the fund goes towards my development which makes on fast and responsive.
|
| 24 |
Your donation might also me get me a new feature or two, which I wasn't able to get due to server limitations.
|
|
|
|
| 27 |
|
| 28 |
You can donate by contacting my owner: [Captain Ezio](http://t.me/iamgojoof6eyes)
|
| 29 |
"""
|
|
|
|
| 30 |
|
| 31 |
LOGGER.info(f"{m.from_user.id} fetched donation text in {m.chat.id}")
|
| 32 |
+
await m.reply_photo(photo=choice(StartPic), caption=cpt)
|
|
|
|
| 33 |
return
|
| 34 |
|
| 35 |
|
|
|
|
| 57 |
@Gojo.on_message(
|
| 58 |
command("start") & (filters.group | filters.private),
|
| 59 |
)
|
|
|
|
| 60 |
async def start(c: Gojo, m: Message):
|
| 61 |
chat_type = await chattype(m)
|
| 62 |
if chat_type == "private":
|
|
|
|
| 78 |
if not help_msg:
|
| 79 |
return
|
| 80 |
|
|
|
|
|
|
|
| 81 |
await m.reply_photo(
|
| 82 |
photo=choice(StartPic),
|
| 83 |
caption=help_msg,
|
| 84 |
parse_mode="markdown",
|
| 85 |
reply_markup=ikb(help_kb),
|
| 86 |
quote=True,
|
|
|
|
| 87 |
)
|
| 88 |
return
|
| 89 |
try:
|
| 90 |
+
cpt = f"""
|
| 91 |
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),
|
| 99 |
caption=cpt,
|
| 100 |
reply_markup=(await gen_start_kb(m)),
|
| 101 |
quote=True,
|
|
|
|
| 102 |
)
|
| 103 |
except UserIsBlocked:
|
| 104 |
LOGGER.warning(f"Bot blocked by {m.from_user.id}")
|
| 105 |
else:
|
| 106 |
+
kb = ikb(
|
| 107 |
+
[
|
| 108 |
+
[
|
| 109 |
+
(
|
| 110 |
+
"Connect me to pm",
|
| 111 |
+
f"https://t.me/{Config.BOT_USERNAME}?start=start",
|
| 112 |
+
"url",
|
| 113 |
+
)
|
| 114 |
+
]
|
| 115 |
+
]
|
| 116 |
+
)
|
| 117 |
await m.reply_photo(
|
| 118 |
photo=choice(StartPic),
|
| 119 |
caption="I'm alive :3",
|
|
|
|
| 126 |
@Gojo.on_callback_query(filters.regex("^start_back$"))
|
| 127 |
async def start_back(_, q: CallbackQuery):
|
| 128 |
try:
|
| 129 |
+
cpt = f"""
|
| 130 |
Hey [{q.from_user.first_name}](http://t.me/{q.from_user.username})! My name is Gojo ✨.
|
| 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!
|
|
|
|
| 136 |
await q.edit_message_caption(
|
| 137 |
caption=cpt,
|
| 138 |
reply_markup=(await gen_start_kb(q.message)),
|
|
|
|
| 139 |
)
|
| 140 |
except MessageNotModified:
|
| 141 |
pass
|
|
|
|
| 152 |
],
|
| 153 |
)
|
| 154 |
try:
|
| 155 |
+
cpt = f"""
|
| 156 |
Hey **[{q.from_user.first_name}](http://t.me/{q.from_user.username})**! My name is Gojo✨.
|
| 157 |
I'm here to help you manage your groups!
|
| 158 |
Commands available:
|
|
|
|
| 161 |
|
| 162 |
await q.edit_message_caption(
|
| 163 |
caption=cpt,
|
| 164 |
+
reply_markup=keyboard,
|
| 165 |
)
|
| 166 |
except MessageNotModified:
|
| 167 |
pass
|
| 168 |
except QueryIdInvalid:
|
| 169 |
await q.message.reply_photo(
|
| 170 |
+
photo=choice(StartPic), caption=cpt, reply_markup=keyboard
|
| 171 |
+
)
|
| 172 |
+
|
|
|
|
| 173 |
await q.answer()
|
| 174 |
return
|
| 175 |
|
|
|
|
| 189 |
)
|
| 190 |
chat_type = await chattype(m)
|
| 191 |
if chat_type == "private":
|
| 192 |
+
|
| 193 |
await m.reply_photo(
|
| 194 |
photo=choice(StartPic),
|
| 195 |
caption=help_msg,
|
| 196 |
parse_mode="markdown",
|
| 197 |
reply_markup=ikb(help_kb),
|
| 198 |
quote=True,
|
|
|
|
| 199 |
)
|
| 200 |
else:
|
| 201 |
+
|
| 202 |
await m.reply_photo(
|
| 203 |
photo=choice(StartPic),
|
| 204 |
caption=f"Press the button below to get help for <i>{help_option}</i>",
|
|
|
|
| 223 |
[("« Back", "start_back")],
|
| 224 |
],
|
| 225 |
)
|
| 226 |
+
msg = f"""
|
| 227 |
Hey **[{m.from_user.first_name}](http://t.me/{m.from_user.username})**!My name is Gojo✨.
|
| 228 |
I'm here to help you manage your groups!
|
| 229 |
Commands available:
|
|
|
|
| 234 |
[[("Help", f"t.me/{Config.BOT_USERNAME}?start=help", "url")]],
|
| 235 |
)
|
| 236 |
msg = "Contact me in PM to get the list of possible commands."
|
| 237 |
+
|
| 238 |
await m.reply_photo(
|
| 239 |
photo=choice(StartPic),
|
| 240 |
caption=msg,
|
|
|
|
| 248 |
async def get_module_info(_, q: CallbackQuery):
|
| 249 |
module = q.data.split(".", 1)[1]
|
| 250 |
|
| 251 |
+
help_msg = (f"**{str(module)}:**\n\n" + HELP_COMMANDS[module]["help_msg"],)
|
| 252 |
|
| 253 |
help_kb = HELP_COMMANDS[module]["buttons"] + [
|
| 254 |
[("« " + "Back", "commands")],
|
Powers/plugins/stats.py
CHANGED
|
@@ -1,19 +1,18 @@
|
|
| 1 |
-
from pyrogram.types import Message
|
| 2 |
-
|
| 3 |
from Powers.bot_class import Gojo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
from Powers.database.antispam_db import GBan
|
| 5 |
from Powers.database.approve_db import Approve
|
| 6 |
-
from Powers.database.blacklist_db import Blacklist
|
| 7 |
-
from Powers.database.chats_db import Chats
|
| 8 |
-
from Powers.database.disable_db import Disabling
|
| 9 |
from Powers.database.filters_db import Filters
|
|
|
|
|
|
|
|
|
|
| 10 |
from Powers.database.greetings_db import Greetings
|
| 11 |
-
from Powers.database.notes_db import Notes, NotesSettings
|
| 12 |
-
from Powers.database.pins_db import Pins
|
| 13 |
-
from Powers.database.rules_db import Rules
|
| 14 |
-
from Powers.database.users_db import Users
|
| 15 |
from Powers.database.warns_db import Warns, WarnSettings
|
| 16 |
-
from Powers.
|
| 17 |
|
| 18 |
|
| 19 |
@Gojo.on_message(command("stats", dev_cmd=True))
|
|
|
|
|
|
|
|
|
|
| 1 |
from Powers.bot_class import Gojo
|
| 2 |
+
from pyrogram.types import Message
|
| 3 |
+
from Powers.database.pins_db import Pins
|
| 4 |
+
from Powers.database.chats_db import Chats
|
| 5 |
+
from Powers.database.rules_db import Rules
|
| 6 |
+
from Powers.database.users_db import Users
|
| 7 |
from Powers.database.antispam_db import GBan
|
| 8 |
from Powers.database.approve_db import Approve
|
|
|
|
|
|
|
|
|
|
| 9 |
from Powers.database.filters_db import Filters
|
| 10 |
+
from Powers.utils.custom_filters import command
|
| 11 |
+
from Powers.database.disable_db import Disabling
|
| 12 |
+
from Powers.database.blacklist_db import Blacklist
|
| 13 |
from Powers.database.greetings_db import Greetings
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
from Powers.database.warns_db import Warns, WarnSettings
|
| 15 |
+
from Powers.database.notes_db import Notes, NotesSettings
|
| 16 |
|
| 17 |
|
| 18 |
@Gojo.on_message(command("stats", dev_cmd=True))
|
Powers/plugins/utils.py
CHANGED
|
@@ -1,41 +1,38 @@
|
|
| 1 |
-
from io import BytesIO
|
| 2 |
-
from os import remove
|
| 3 |
import re
|
| 4 |
import aiofiles
|
| 5 |
-
from
|
| 6 |
-
from
|
| 7 |
-
from
|
| 8 |
from tswift import Song
|
|
|
|
|
|
|
| 9 |
from wikipedia import summary
|
| 10 |
-
from
|
| 11 |
from traceback import format_exc
|
| 12 |
-
|
| 13 |
-
from gpytranslate import Translator
|
| 14 |
-
from pyrogram import filters
|
| 15 |
-
from pyrogram.errors import MessageTooLong, PeerIdInvalid, RPCError
|
| 16 |
-
from pyrogram.types import Message,InlineKeyboardButton, InlineKeyboardMarkup
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
from Powers import *
|
| 20 |
from Powers.bot_class import Gojo
|
| 21 |
-
from
|
| 22 |
-
from
|
| 23 |
-
from Powers.utils.custom_filters import command
|
| 24 |
-
from Powers.utils.chat_type import chattype
|
| 25 |
from Powers.utils.http_helper import *
|
| 26 |
from Powers.utils.kbhelpers import ikb
|
|
|
|
|
|
|
| 27 |
from Powers.utils.parser import mention_html
|
|
|
|
|
|
|
| 28 |
from Powers.utils.extract_user import extract_user
|
| 29 |
-
from Powers.
|
| 30 |
-
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
|
| 34 |
@Gojo.on_message(command("wiki"))
|
| 35 |
async def wiki(_, m: Message):
|
| 36 |
|
| 37 |
if len(m.text.split()) <= 1:
|
| 38 |
-
return await m.reply_text(
|
|
|
|
|
|
|
| 39 |
|
| 40 |
search = m.text.split(None, 1)[1]
|
| 41 |
try:
|
|
@@ -102,9 +99,8 @@ async def get_lyrics(_, m: Message):
|
|
| 102 |
if not query:
|
| 103 |
await m.edit_text(text="You haven't specified which song to look for!")
|
| 104 |
return
|
| 105 |
-
song_name=query
|
| 106 |
-
em = await m.reply_text(
|
| 107 |
-
text=f"Finding lyrics for <code>{song_name}<code>...")
|
| 108 |
song = Song.find_song(query)
|
| 109 |
if song:
|
| 110 |
if song.lyrics:
|
|
@@ -144,10 +140,10 @@ async def id_info(c: Gojo, m: Message):
|
|
| 144 |
if m.reply_to_message and m.reply_to_message.forward_from:
|
| 145 |
user1 = m.reply_to_message.from_user
|
| 146 |
user2 = m.reply_to_message.forward_from
|
| 147 |
-
orig_sender=(await mention_html(user2.first_name, user2.id)),
|
| 148 |
-
orig_id=f"<code>{user2.id}</code>",
|
| 149 |
-
fwd_sender=(await mention_html(user1.first_name, user1.id)),
|
| 150 |
-
fwd_id=f"<code>{user1.id}</code>",
|
| 151 |
await m.reply_text(
|
| 152 |
text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
|
| 153 |
Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
|
|
@@ -157,8 +153,10 @@ async def id_info(c: Gojo, m: Message):
|
|
| 157 |
try:
|
| 158 |
user = await c.get_users(user_id)
|
| 159 |
except PeerIdInvalid:
|
| 160 |
-
await m.reply_text(
|
| 161 |
-
|
|
|
|
|
|
|
| 162 |
return
|
| 163 |
|
| 164 |
await m.reply_text(
|
|
@@ -166,13 +164,9 @@ async def id_info(c: Gojo, m: Message):
|
|
| 166 |
parse_mode="HTML",
|
| 167 |
)
|
| 168 |
elif chat_type == "private":
|
| 169 |
-
await m.reply_text(
|
| 170 |
-
text=f"Your ID is <code>{m.chat.id}</code>."
|
| 171 |
-
)
|
| 172 |
else:
|
| 173 |
-
await m.reply_text(
|
| 174 |
-
text=f"This Group's ID is <code>{m.chat.id}</code>"
|
| 175 |
-
)
|
| 176 |
return
|
| 177 |
|
| 178 |
|
|
@@ -218,11 +212,13 @@ async def github(_, message):
|
|
| 218 |
LOGGER.error(e)
|
| 219 |
LOGGER.error(format_exc())
|
| 220 |
|
| 221 |
-
|
|
|
|
| 222 |
session = ClientSession()
|
| 223 |
pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
|
| 224 |
BASE = "https://batbin.me/"
|
| 225 |
|
|
|
|
| 226 |
async def post(url: str, *args, **kwargs):
|
| 227 |
async with session.post(url, *args, **kwargs) as resp:
|
| 228 |
try:
|
|
@@ -231,6 +227,7 @@ async def post(url: str, *args, **kwargs):
|
|
| 231 |
data = await resp.text()
|
| 232 |
return data
|
| 233 |
|
|
|
|
| 234 |
async def paste(content: str):
|
| 235 |
resp = await post(f"{BASE}api/v2/paste", data=content)
|
| 236 |
if not resp["success"]:
|
|
@@ -242,7 +239,7 @@ async def paste(content: str):
|
|
| 242 |
async def paste_func(_, message: Message):
|
| 243 |
if not message.reply_to_message:
|
| 244 |
return await message.reply_text("Reply To A Message With `/paste`")
|
| 245 |
-
|
| 246 |
r = message.reply_to_message
|
| 247 |
|
| 248 |
if not r.text and not r.document:
|
|
@@ -285,13 +282,18 @@ async def paste_func(_, message: Message):
|
|
| 285 |
)
|
| 286 |
await m.delete()
|
| 287 |
except Exception:
|
| 288 |
-
await m.edit(
|
|
|
|
|
|
|
|
|
|
| 289 |
|
| 290 |
|
| 291 |
@Gojo.on_message(command("tr"))
|
| 292 |
async def tr(_, message):
|
| 293 |
trl = Translator()
|
| 294 |
-
if message.reply_to_message and (
|
|
|
|
|
|
|
| 295 |
if len(message.text.split()) == 1:
|
| 296 |
target_lang = "en"
|
| 297 |
else:
|
|
@@ -319,8 +321,6 @@ async def tr(_, message):
|
|
| 319 |
)
|
| 320 |
|
| 321 |
|
| 322 |
-
|
| 323 |
-
|
| 324 |
__PLUGIN__ = "utils"
|
| 325 |
_DISABLE_CMDS_ = [
|
| 326 |
"paste",
|
|
|
|
|
|
|
|
|
|
| 1 |
import re
|
| 2 |
import aiofiles
|
| 3 |
+
from Powers import *
|
| 4 |
+
from os import remove
|
| 5 |
+
from io import BytesIO
|
| 6 |
from tswift import Song
|
| 7 |
+
from pyrogram import filters
|
| 8 |
+
from datetime import datetime
|
| 9 |
from wikipedia import summary
|
| 10 |
+
from Powers.vars import Config
|
| 11 |
from traceback import format_exc
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
from Powers.bot_class import Gojo
|
| 13 |
+
from aiohttp import ClientSession
|
| 14 |
+
from gpytranslate import Translator
|
|
|
|
|
|
|
| 15 |
from Powers.utils.http_helper import *
|
| 16 |
from Powers.utils.kbhelpers import ikb
|
| 17 |
+
from Powers.database.users_db import Users
|
| 18 |
+
from Powers.utils.chat_type import chattype
|
| 19 |
from Powers.utils.parser import mention_html
|
| 20 |
+
from search_engine_parser import GoogleSearch
|
| 21 |
+
from Powers.utils.custom_filters import command
|
| 22 |
from Powers.utils.extract_user import extract_user
|
| 23 |
+
from Powers.utils.clean_file import remove_markdown_and_html
|
| 24 |
+
from wikipedia.exceptions import PageError, DisambiguationError
|
| 25 |
+
from pyrogram.errors import RPCError, PeerIdInvalid, MessageTooLong
|
| 26 |
+
from pyrogram.types import Message, InlineKeyboardButton, InlineKeyboardMarkup
|
| 27 |
|
| 28 |
|
| 29 |
@Gojo.on_message(command("wiki"))
|
| 30 |
async def wiki(_, m: Message):
|
| 31 |
|
| 32 |
if len(m.text.split()) <= 1:
|
| 33 |
+
return await m.reply_text(
|
| 34 |
+
text="Please check help on how to use this this command."
|
| 35 |
+
)
|
| 36 |
|
| 37 |
search = m.text.split(None, 1)[1]
|
| 38 |
try:
|
|
|
|
| 99 |
if not query:
|
| 100 |
await m.edit_text(text="You haven't specified which song to look for!")
|
| 101 |
return
|
| 102 |
+
song_name = query
|
| 103 |
+
em = await m.reply_text(text=f"Finding lyrics for <code>{song_name}<code>...")
|
|
|
|
| 104 |
song = Song.find_song(query)
|
| 105 |
if song:
|
| 106 |
if song.lyrics:
|
|
|
|
| 140 |
if m.reply_to_message and m.reply_to_message.forward_from:
|
| 141 |
user1 = m.reply_to_message.from_user
|
| 142 |
user2 = m.reply_to_message.forward_from
|
| 143 |
+
orig_sender = ((await mention_html(user2.first_name, user2.id)),)
|
| 144 |
+
orig_id = (f"<code>{user2.id}</code>",)
|
| 145 |
+
fwd_sender = ((await mention_html(user1.first_name, user1.id)),)
|
| 146 |
+
fwd_id = (f"<code>{user1.id}</code>",)
|
| 147 |
await m.reply_text(
|
| 148 |
text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
|
| 149 |
Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
|
|
|
|
| 153 |
try:
|
| 154 |
user = await c.get_users(user_id)
|
| 155 |
except PeerIdInvalid:
|
| 156 |
+
await m.reply_text(
|
| 157 |
+
text="""Failed to get user
|
| 158 |
+
Peer ID invalid, I haven't seen this user anywhere earlier, maybe username would help to know them!"""
|
| 159 |
+
)
|
| 160 |
return
|
| 161 |
|
| 162 |
await m.reply_text(
|
|
|
|
| 164 |
parse_mode="HTML",
|
| 165 |
)
|
| 166 |
elif chat_type == "private":
|
| 167 |
+
await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
|
|
|
|
|
|
|
| 168 |
else:
|
| 169 |
+
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
|
|
|
|
|
|
| 170 |
return
|
| 171 |
|
| 172 |
|
|
|
|
| 212 |
LOGGER.error(e)
|
| 213 |
LOGGER.error(format_exc())
|
| 214 |
|
| 215 |
+
|
| 216 |
+
# paste here
|
| 217 |
session = ClientSession()
|
| 218 |
pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
|
| 219 |
BASE = "https://batbin.me/"
|
| 220 |
|
| 221 |
+
|
| 222 |
async def post(url: str, *args, **kwargs):
|
| 223 |
async with session.post(url, *args, **kwargs) as resp:
|
| 224 |
try:
|
|
|
|
| 227 |
data = await resp.text()
|
| 228 |
return data
|
| 229 |
|
| 230 |
+
|
| 231 |
async def paste(content: str):
|
| 232 |
resp = await post(f"{BASE}api/v2/paste", data=content)
|
| 233 |
if not resp["success"]:
|
|
|
|
| 239 |
async def paste_func(_, message: Message):
|
| 240 |
if not message.reply_to_message:
|
| 241 |
return await message.reply_text("Reply To A Message With `/paste`")
|
| 242 |
+
|
| 243 |
r = message.reply_to_message
|
| 244 |
|
| 245 |
if not r.text and not r.document:
|
|
|
|
| 282 |
)
|
| 283 |
await m.delete()
|
| 284 |
except Exception:
|
| 285 |
+
await m.edit(
|
| 286 |
+
"Here is the link of the document....",
|
| 287 |
+
reply_markup=InlineKeyboardMarkup(kb),
|
| 288 |
+
)
|
| 289 |
|
| 290 |
|
| 291 |
@Gojo.on_message(command("tr"))
|
| 292 |
async def tr(_, message):
|
| 293 |
trl = Translator()
|
| 294 |
+
if message.reply_to_message and (
|
| 295 |
+
message.reply_to_message.text or message.reply_to_message.caption
|
| 296 |
+
):
|
| 297 |
if len(message.text.split()) == 1:
|
| 298 |
target_lang = "en"
|
| 299 |
else:
|
|
|
|
| 321 |
)
|
| 322 |
|
| 323 |
|
|
|
|
|
|
|
| 324 |
__PLUGIN__ = "utils"
|
| 325 |
_DISABLE_CMDS_ = [
|
| 326 |
"paste",
|
Powers/plugins/warns.py
CHANGED
|
@@ -1,25 +1,19 @@
|
|
| 1 |
from time import time
|
| 2 |
-
|
| 3 |
from pyrogram import filters
|
|
|
|
|
|
|
| 4 |
from pyrogram.errors import RPCError
|
| 5 |
-
from pyrogram.types import (
|
| 6 |
-
CallbackQuery,
|
| 7 |
-
ChatPermissions,
|
| 8 |
-
InlineKeyboardButton,
|
| 9 |
-
InlineKeyboardMarkup,
|
| 10 |
-
Message,
|
| 11 |
-
)
|
| 12 |
-
|
| 13 |
from Powers import LOGGER, SUPPORT_STAFF
|
| 14 |
-
from Powers.bot_class import Gojo
|
| 15 |
from Powers.database.rules_db import Rules
|
| 16 |
from Powers.database.users_db import Users
|
|
|
|
|
|
|
| 17 |
from Powers.database.warns_db import Warns, WarnSettings
|
| 18 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 19 |
-
from Powers.utils.custom_filters import
|
| 20 |
-
from
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
|
| 25 |
@Gojo.on_message(
|
|
@@ -52,7 +46,9 @@ async def warn(c: Gojo, m: Message):
|
|
| 52 |
return
|
| 53 |
|
| 54 |
if user_id in SUPPORT_STAFF:
|
| 55 |
-
await m.reply_text(
|
|
|
|
|
|
|
| 56 |
LOGGER.info(
|
| 57 |
f"{m.from_user.id} trying to warn {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 58 |
)
|
|
@@ -384,4 +380,4 @@ Admin commands:
|
|
| 384 |
- /warnlimit `<number>`: Set the number of warnings before users are punished.
|
| 385 |
|
| 386 |
Examples:
|
| 387 |
-
`/warn @user`: this warns a user in the chat."""
|
|
|
|
| 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(
|
|
|
|
| 46 |
return
|
| 47 |
|
| 48 |
if user_id in SUPPORT_STAFF:
|
| 49 |
+
await m.reply_text(
|
| 50 |
+
text="This user is in my support staff, cannot restrict them."
|
| 51 |
+
)
|
| 52 |
LOGGER.info(
|
| 53 |
f"{m.from_user.id} trying to warn {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
| 54 |
)
|
|
|
|
| 380 |
- /warnlimit `<number>`: Set the number of warnings before users are punished.
|
| 381 |
|
| 382 |
Examples:
|
| 383 |
+
`/warn @user`: this warns a user in the chat."""
|
Powers/plugins/watchers.py
CHANGED
|
@@ -1,22 +1,21 @@
|
|
| 1 |
-
from re import escape as re_escape
|
| 2 |
from time import time
|
| 3 |
-
from traceback import format_exc
|
| 4 |
-
|
| 5 |
from pyrogram import filters
|
| 6 |
-
from
|
| 7 |
-
from pyrogram.types import ChatPermissions, Message
|
| 8 |
-
|
| 9 |
-
from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_STAFF
|
| 10 |
from Powers.bot_class import Gojo
|
| 11 |
-
from
|
|
|
|
|
|
|
| 12 |
from Powers.database.approve_db import Approve
|
| 13 |
from Powers.database.blacklist_db import Blacklist
|
| 14 |
-
from Powers.
|
| 15 |
-
from
|
|
|
|
| 16 |
from Powers.database.warns_db import Warns, WarnSettings
|
|
|
|
|
|
|
| 17 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 18 |
-
from
|
| 19 |
-
|
| 20 |
|
| 21 |
# Initialise
|
| 22 |
gban_db = GBan()
|
|
@@ -184,7 +183,7 @@ async def gban_watcher(c: Gojo, m: Message):
|
|
| 184 |
try:
|
| 185 |
await m.chat.ban_member(m.from_user.id)
|
| 186 |
await m.delete(m.message_id) # Delete users message!
|
| 187 |
-
user_gbanned=
|
| 188 |
await m.reply_text(
|
| 189 |
text=f"""This user ({user_gbanned}) has been banned globally!
|
| 190 |
|
|
@@ -203,7 +202,7 @@ async def gban_watcher(c: Gojo, m: Message):
|
|
| 203 |
MESSAGE_DUMP,
|
| 204 |
text=f"""<b>Gban Watcher Error!</b>
|
| 205 |
<b>Chat:</b> <code>{m.chat.id}</code>
|
| 206 |
-
<b>Error:</b> <code>{ef}</code>"""
|
| 207 |
)
|
| 208 |
return
|
| 209 |
|
|
|
|
|
|
|
| 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()
|
|
|
|
| 183 |
try:
|
| 184 |
await m.chat.ban_member(m.from_user.id)
|
| 185 |
await m.delete(m.message_id) # Delete users message!
|
| 186 |
+
user_gbanned = await mention_html(m.from_user.first_name, m.from_user.id)
|
| 187 |
await m.reply_text(
|
| 188 |
text=f"""This user ({user_gbanned}) has been banned globally!
|
| 189 |
|
|
|
|
| 202 |
MESSAGE_DUMP,
|
| 203 |
text=f"""<b>Gban Watcher Error!</b>
|
| 204 |
<b>Chat:</b> <code>{m.chat.id}</code>
|
| 205 |
+
<b>Error:</b> <code>{ef}</code>""",
|
| 206 |
)
|
| 207 |
return
|
| 208 |
|
Powers/utils/admin_check.py
CHANGED
|
@@ -1,8 +1,7 @@
|
|
| 1 |
from traceback import format_exc
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
from pyrogram.types import CallbackQuery, Message
|
| 4 |
-
|
| 5 |
-
from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS
|
| 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 |
+
from pyrogram.types import Message, CallbackQuery
|
| 3 |
+
from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
SUDO_LEVEL = SUDO_USERS + DEV_USERS + [int(OWNER_ID)]
|
| 7 |
DEV_LEVEL = DEV_USERS + [int(OWNER_ID)]
|
Powers/utils/caching.py
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 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 pyrogram.types import CallbackQuery
|
| 7 |
-
from pyrogram import enums
|
| 8 |
from pyrogram.types.messages_and_media.message import Message
|
| 9 |
|
| 10 |
-
from Powers import LOGGER
|
| 11 |
|
| 12 |
THREAD_LOCK = RLock()
|
| 13 |
|
|
@@ -34,16 +33,16 @@ async def admin_cache_reload(m: Message or CallbackQuery, status=None) -> List[i
|
|
| 34 |
except KeyError:
|
| 35 |
# Because it might be first time when admn_list is being reloaded
|
| 36 |
pass
|
| 37 |
-
|
| 38 |
-
|
| 39 |
admin_list = [
|
| 40 |
(
|
| 41 |
z.user.id,
|
| 42 |
(("@" + z.user.username) if z.user.username else z.user.first_name),
|
| 43 |
z.is_anonymous,
|
| 44 |
)
|
| 45 |
-
|
| 46 |
-
|
|
|
|
| 47 |
if not z.user.is_deleted
|
| 48 |
]
|
| 49 |
ADMIN_CACHE[m.chat.id] = admin_list
|
|
|
|
|
|
|
|
|
|
| 1 |
from typing import List
|
| 2 |
+
from Powers import LOGGER
|
| 3 |
+
from pyrogram import enums
|
| 4 |
+
from threading import RLock
|
| 5 |
from cachetools import TTLCache
|
| 6 |
+
from time import time, perf_counter
|
| 7 |
from pyrogram.types import CallbackQuery
|
|
|
|
| 8 |
from pyrogram.types.messages_and_media.message import Message
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
THREAD_LOCK = RLock()
|
| 12 |
|
|
|
|
| 33 |
except KeyError:
|
| 34 |
# Because it might be first time when admn_list is being reloaded
|
| 35 |
pass
|
| 36 |
+
|
|
|
|
| 37 |
admin_list = [
|
| 38 |
(
|
| 39 |
z.user.id,
|
| 40 |
(("@" + z.user.username) if z.user.username else z.user.first_name),
|
| 41 |
z.is_anonymous,
|
| 42 |
)
|
| 43 |
+
async for z in m.chat.get_members(
|
| 44 |
+
filter=enums.ChatMembersFilter.ADMINISTRATORS
|
| 45 |
+
)
|
| 46 |
if not z.user.is_deleted
|
| 47 |
]
|
| 48 |
ADMIN_CACHE[m.chat.id] = admin_list
|
Powers/utils/chat_type.py
CHANGED
|
@@ -1,40 +1,37 @@
|
|
| 1 |
from Powers.bot_class import Gojo
|
| 2 |
-
|
| 3 |
-
from pyrogram.enums import ChatType
|
| 4 |
from pyrogram.types import Message
|
| 5 |
-
|
| 6 |
|
| 7 |
|
| 8 |
async def chattype(m: Message):
|
| 9 |
-
# To get chat type with message
|
| 10 |
|
| 11 |
if m.chat.type == ChatType.CHANNEL:
|
| 12 |
ct = "channel"
|
| 13 |
-
|
| 14 |
if m.chat.type == ChatType.PRIVATE:
|
| 15 |
ct = "private"
|
| 16 |
|
| 17 |
if m.chat.type == ChatType.GROUP:
|
| 18 |
-
ct="group"
|
| 19 |
|
| 20 |
if m.chat.type == ChatType.SUPERGROUP:
|
| 21 |
ct = "supergroup"
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
return ct
|
| 26 |
|
|
|
|
| 27 |
async def c_type(c: Gojo, chat_id):
|
| 28 |
# To get chat type with chat id
|
| 29 |
-
|
| 30 |
c = await Gojo.get_chat(chat_id)
|
| 31 |
-
|
| 32 |
if c.type == ChatType.CHANNEL:
|
| 33 |
ct = "channel"
|
| 34 |
-
|
| 35 |
if c.type == ChatType.GROUP:
|
| 36 |
ct = "group"
|
| 37 |
-
|
| 38 |
if c.type == ChatType.SUPERGROUP:
|
| 39 |
ct = "supergroup"
|
| 40 |
|
|
|
|
| 1 |
from Powers.bot_class import Gojo
|
|
|
|
|
|
|
| 2 |
from pyrogram.types import Message
|
| 3 |
+
from pyrogram.enums import ChatType
|
| 4 |
|
| 5 |
|
| 6 |
async def chattype(m: Message):
|
| 7 |
+
# To get chat type with message
|
| 8 |
|
| 9 |
if m.chat.type == ChatType.CHANNEL:
|
| 10 |
ct = "channel"
|
| 11 |
+
|
| 12 |
if m.chat.type == ChatType.PRIVATE:
|
| 13 |
ct = "private"
|
| 14 |
|
| 15 |
if m.chat.type == ChatType.GROUP:
|
| 16 |
+
ct = "group"
|
| 17 |
|
| 18 |
if m.chat.type == ChatType.SUPERGROUP:
|
| 19 |
ct = "supergroup"
|
| 20 |
|
|
|
|
|
|
|
| 21 |
return ct
|
| 22 |
|
| 23 |
+
|
| 24 |
async def c_type(c: Gojo, chat_id):
|
| 25 |
# To get chat type with chat id
|
| 26 |
+
|
| 27 |
c = await Gojo.get_chat(chat_id)
|
| 28 |
+
|
| 29 |
if c.type == ChatType.CHANNEL:
|
| 30 |
ct = "channel"
|
| 31 |
+
|
| 32 |
if c.type == ChatType.GROUP:
|
| 33 |
ct = "group"
|
| 34 |
+
|
| 35 |
if c.type == ChatType.SUPERGROUP:
|
| 36 |
ct = "supergroup"
|
| 37 |
|
Powers/utils/custom_filters.py
CHANGED
|
@@ -1,19 +1,16 @@
|
|
| 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 pyrogram.errors import RPCError, UserNotParticipant
|
| 7 |
from pyrogram.filters import create
|
| 8 |
-
from
|
| 9 |
-
from
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
from Powers import DEV_USERS, OWNER_ID, SUDO_USERS
|
| 13 |
from Powers.database.disable_db import Disabling
|
|
|
|
|
|
|
|
|
|
| 14 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 15 |
-
|
| 16 |
-
from Powers.vars import Config
|
| 17 |
|
| 18 |
SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
|
| 19 |
DEV_LEVEL = set(DEV_USERS + [int(OWNER_ID)])
|
|
@@ -32,7 +29,7 @@ def command(
|
|
| 32 |
|
| 33 |
date = m.edit_date
|
| 34 |
if date:
|
| 35 |
-
return
|
| 36 |
|
| 37 |
chattype = bool(m.chat and m.chat.type in {enums.ChatType.CHANNEL})
|
| 38 |
if chattype:
|
|
@@ -101,7 +98,7 @@ def command(
|
|
| 101 |
return True
|
| 102 |
return False
|
| 103 |
|
| 104 |
-
commands = commands if
|
| 105 |
commands = {c if case_sensitive else c.lower() for c in commands}
|
| 106 |
|
| 107 |
return create(
|
|
|
|
|
|
|
|
|
|
| 1 |
from shlex import split
|
| 2 |
+
from pyrogram import enums
|
| 3 |
+
from Powers.vars import Config
|
| 4 |
from typing import List, Union
|
|
|
|
|
|
|
| 5 |
from pyrogram.filters import create
|
| 6 |
+
from Powers.utils.chat_type import chattype
|
| 7 |
+
from re import escape, compile as compile_re
|
|
|
|
|
|
|
|
|
|
| 8 |
from Powers.database.disable_db import Disabling
|
| 9 |
+
from pyrogram.types import Message, CallbackQuery
|
| 10 |
+
from Powers import OWNER_ID, DEV_USERS, SUDO_USERS
|
| 11 |
+
from pyrogram.errors import RPCError, UserNotParticipant
|
| 12 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
| 13 |
+
|
|
|
|
| 14 |
|
| 15 |
SUDO_LEVEL = set(SUDO_USERS + DEV_USERS + [int(OWNER_ID)])
|
| 16 |
DEV_LEVEL = set(DEV_USERS + [int(OWNER_ID)])
|
|
|
|
| 29 |
|
| 30 |
date = m.edit_date
|
| 31 |
if date:
|
| 32 |
+
return # reaction
|
| 33 |
|
| 34 |
chattype = bool(m.chat and m.chat.type in {enums.ChatType.CHANNEL})
|
| 35 |
if chattype:
|
|
|
|
| 98 |
return True
|
| 99 |
return False
|
| 100 |
|
| 101 |
+
commands = commands if isinstance(commands, list) else [commands]
|
| 102 |
commands = {c if case_sensitive else c.lower() for c in commands}
|
| 103 |
|
| 104 |
return create(
|