Spaces:
Sleeping
Sleeping
Merge branch 'main' into dependabot/pip/pymongo-4.6.3
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .github/workflows/pre-commit-autoupdate.yml +1 -1
- .gitignore +2 -3
- .pre-commit-config.yaml +3 -3
- Powers/__init__.py +41 -30
- Powers/__main__.py +2 -4
- Powers/bot_class.py +16 -16
- Powers/database/afk_db.py +18 -16
- Powers/database/antispam_db.py +2 -1
- Powers/database/approve_db.py +17 -3
- Powers/database/autojoin_db.py +13 -13
- Powers/database/blacklist_db.py +1 -2
- Powers/database/captcha_db.py +35 -23
- Powers/database/chats_db.py +0 -1
- Powers/database/disable_db.py +3 -3
- Powers/database/filters_db.py +11 -2
- Powers/database/flood_db.py +11 -10
- Powers/database/greetings_db.py +14 -14
- Powers/database/locks_db.py +68 -26
- Powers/database/notes_db.py +4 -3
- Powers/database/pins_db.py +1 -2
- Powers/database/reporting_db.py +3 -3
- Powers/database/rules_db.py +0 -1
- Powers/database/support_db.py +15 -15
- Powers/database/users_db.py +2 -2
- Powers/database/warns_db.py +8 -7
- Powers/plugins/__init__.py +1 -0
- Powers/plugins/admin.py +32 -32
- Powers/plugins/afk.py +158 -0
- Powers/plugins/antispam.py +29 -11
- Powers/plugins/approve.py +0 -6
- Powers/plugins/auto_join.py +185 -0
- Powers/plugins/bans.py +54 -53
- Powers/plugins/birthday.py +14 -12
- Powers/plugins/blacklist.py +0 -9
- Powers/plugins/botstaff.py +0 -57
- Powers/plugins/captcha.py +269 -0
- Powers/plugins/chat_blacklist.py +32 -3
- Powers/plugins/clean_db.py +0 -75
- Powers/plugins/dev.py +77 -28
- Powers/plugins/disable.py +20 -7
- Powers/plugins/filters.py +4 -10
- Powers/plugins/flood.py +188 -45
- Powers/plugins/formatting.py +63 -14
- Powers/plugins/fun.py +1 -19
- Powers/plugins/greetings.py +113 -130
- Powers/plugins/info.py +24 -17
- Powers/plugins/locks.py +133 -91
- Powers/plugins/muting.py +22 -38
- Powers/plugins/notes.py +6 -18
- Powers/plugins/pin.py +2 -12
.github/workflows/pre-commit-autoupdate.yml
CHANGED
@@ -15,7 +15,7 @@ jobs:
|
|
15 |
- name: Run pre-commit autoupdate
|
16 |
run: pre-commit autoupdate
|
17 |
- name: Create Pull Request
|
18 |
-
uses: peter-evans/create-pull-request@
|
19 |
with:
|
20 |
token: ${{ secrets.GITHUB_TOKEN }}
|
21 |
branch: update/pre-commit-autoupdate
|
|
|
15 |
- name: Run pre-commit autoupdate
|
16 |
run: pre-commit autoupdate
|
17 |
- name: Create Pull Request
|
18 |
+
uses: peter-evans/create-pull-request@v6
|
19 |
with:
|
20 |
token: ${{ secrets.GITHUB_TOKEN }}
|
21 |
branch: update/pre-commit-autoupdate
|
.gitignore
CHANGED
@@ -1,18 +1,17 @@
|
|
1 |
*.session
|
2 |
*.session-journal
|
3 |
-
Powers/config.py
|
4 |
-
Powers/vars.py
|
5 |
.vscode/
|
6 |
postgres-data/
|
7 |
*.env
|
8 |
!sample.env
|
9 |
logs/
|
10 |
Powers/local_vars.py
|
11 |
-
Powers/vars.py
|
12 |
.idea/
|
|
|
13 |
|
14 |
# Byte-compiled / optimized / DLL files
|
15 |
__pycache__/
|
|
|
16 |
*.py[cod]
|
17 |
*$py.class
|
18 |
|
|
|
1 |
*.session
|
2 |
*.session-journal
|
|
|
|
|
3 |
.vscode/
|
4 |
postgres-data/
|
5 |
*.env
|
6 |
!sample.env
|
7 |
logs/
|
8 |
Powers/local_vars.py
|
|
|
9 |
.idea/
|
10 |
+
scrapped/
|
11 |
|
12 |
# Byte-compiled / optimized / DLL files
|
13 |
__pycache__/
|
14 |
+
Youtube/
|
15 |
*.py[cod]
|
16 |
*$py.class
|
17 |
|
.pre-commit-config.yaml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
-
rev:
|
4 |
hooks:
|
5 |
- id: trailing-whitespace
|
6 |
- id: end-of-file-fixer
|
@@ -12,7 +12,7 @@ repos:
|
|
12 |
- id: check-merge-conflict
|
13 |
|
14 |
- repo: https://github.com/psf/black
|
15 |
-
rev:
|
16 |
hooks:
|
17 |
- id: black
|
18 |
language_version: python3
|
@@ -24,7 +24,7 @@ repos:
|
|
24 |
args: [--py36-plus]
|
25 |
|
26 |
- repo: https://github.com/asottile/pyupgrade
|
27 |
-
rev: v3.
|
28 |
hooks:
|
29 |
- id: pyupgrade
|
30 |
args: [--py36-plus]
|
|
|
1 |
repos:
|
2 |
- repo: https://github.com/pre-commit/pre-commit-hooks
|
3 |
+
rev: v5.0.0
|
4 |
hooks:
|
5 |
- id: trailing-whitespace
|
6 |
- id: end-of-file-fixer
|
|
|
12 |
- id: check-merge-conflict
|
13 |
|
14 |
- repo: https://github.com/psf/black
|
15 |
+
rev: 24.10.0
|
16 |
hooks:
|
17 |
- id: black
|
18 |
language_version: python3
|
|
|
24 |
args: [--py36-plus]
|
25 |
|
26 |
- repo: https://github.com/asottile/pyupgrade
|
27 |
+
rev: v3.19.0
|
28 |
hooks:
|
29 |
- id: pyupgrade
|
30 |
args: [--py36-plus]
|
Powers/__init__.py
CHANGED
@@ -1,10 +1,10 @@
|
|
|
|
1 |
from datetime import datetime
|
2 |
from importlib import import_module as imp_mod
|
3 |
from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
|
4 |
getLogger)
|
5 |
from os import environ, listdir, mkdir, path
|
6 |
from platform import python_version
|
7 |
-
from random import choice
|
8 |
from sys import exit as sysexit
|
9 |
from sys import stdout, version_info
|
10 |
from time import time
|
@@ -13,6 +13,7 @@ from traceback import format_exc
|
|
13 |
import lyricsgenius
|
14 |
import pyrogram
|
15 |
import pytz
|
|
|
16 |
|
17 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
18 |
LOGDIR = f"{__name__}/logs"
|
@@ -20,6 +21,9 @@ LOGDIR = f"{__name__}/logs"
|
|
20 |
# Make Logs directory if it does not exixts
|
21 |
if not path.isdir(LOGDIR):
|
22 |
mkdir(LOGDIR)
|
|
|
|
|
|
|
23 |
|
24 |
LOGFILE = f"{LOGDIR}/{__name__}_{LOG_DATETIME}_log.txt"
|
25 |
|
@@ -47,7 +51,8 @@ if version_info[0] < 3 or version_info[1] < 7:
|
|
47 |
|
48 |
# the secret configuration specific things
|
49 |
try:
|
50 |
-
|
|
|
51 |
from Powers.vars import Config
|
52 |
else:
|
53 |
from Powers.vars import Development as Config
|
@@ -55,12 +60,12 @@ except Exception as ef:
|
|
55 |
LOGGER.error(ef) # Print Error
|
56 |
LOGGER.error(format_exc())
|
57 |
sysexit(1)
|
58 |
-
#time zone
|
59 |
TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
|
60 |
|
61 |
-
|
62 |
version = []
|
63 |
-
for i in listdir(
|
64 |
if i.startswith("version") and i.endswith("md"):
|
65 |
version.append(i)
|
66 |
else:
|
@@ -92,16 +97,16 @@ if Config.GENIUS_API_TOKEN:
|
|
92 |
genius_lyrics.verbose = False
|
93 |
LOGGER.info("Client setup complete")
|
94 |
elif not Config.GENIUS_API_TOKEN:
|
95 |
-
LOGGER.
|
96 |
is_genius_lyrics = False
|
97 |
genius_lyrics = False
|
98 |
|
99 |
-
is_audd = False
|
100 |
-
Audd = None
|
101 |
-
if Config.AuDD_API:
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
is_rmbg = False
|
107 |
RMBG = None
|
@@ -114,25 +119,15 @@ API_ID = Config.API_ID
|
|
114 |
API_HASH = Config.API_HASH
|
115 |
|
116 |
# General Config
|
117 |
-
MESSAGE_DUMP = Config.MESSAGE_DUMP
|
118 |
SUPPORT_GROUP = Config.SUPPORT_GROUP
|
119 |
SUPPORT_CHANNEL = Config.SUPPORT_CHANNEL
|
120 |
|
121 |
-
# Users Config
|
122 |
OWNER_ID = Config.OWNER_ID
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
WHITELIST_USERS = Config.WHITELIST_USERS
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
defult_dev = [1344569458, 1432756163, 5294360309] + [int(OWNER_ID)]
|
131 |
-
|
132 |
-
Defult_dev = set(defult_dev)
|
133 |
-
|
134 |
-
DEVS = DEVS_USER | Defult_dev
|
135 |
-
DEV_USERS = list(DEVS)
|
136 |
|
137 |
# Plugins, DB and Workers
|
138 |
DB_URI = Config.DB_URI
|
@@ -147,16 +142,31 @@ PREFIX_HANDLER = Config.PREFIX_HANDLER
|
|
147 |
HELP_COMMANDS = {} # For help menu
|
148 |
UPTIME = time() # Check bot uptime
|
149 |
|
150 |
-
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
scheduler = AsyncIOScheduler(timezone=TIME_ZONE)
|
153 |
|
|
|
154 |
async def load_cmds(all_plugins):
|
155 |
"""Loads all the plugins in bot."""
|
156 |
for single in all_plugins:
|
157 |
# If plugin in NO_LOAD, skip the plugin
|
158 |
if single.lower() in [i.lower() for i in Config.NO_LOAD]:
|
159 |
-
LOGGER.warning(
|
|
|
160 |
continue
|
161 |
|
162 |
imported_module = imp_mod(f"Powers.plugins.{single}")
|
@@ -197,6 +207,7 @@ async def load_cmds(all_plugins):
|
|
197 |
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
198 |
|
199 |
return (
|
200 |
-
", ".join((i.split(".")[1]).capitalize()
|
|
|
201 |
+ "\n"
|
202 |
)
|
|
|
1 |
+
import shutil
|
2 |
from datetime import datetime
|
3 |
from importlib import import_module as imp_mod
|
4 |
from logging import (INFO, WARNING, FileHandler, StreamHandler, basicConfig,
|
5 |
getLogger)
|
6 |
from os import environ, listdir, mkdir, path
|
7 |
from platform import python_version
|
|
|
8 |
from sys import exit as sysexit
|
9 |
from sys import stdout, version_info
|
10 |
from time import time
|
|
|
13 |
import lyricsgenius
|
14 |
import pyrogram
|
15 |
import pytz
|
16 |
+
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
17 |
|
18 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
19 |
LOGDIR = f"{__name__}/logs"
|
|
|
21 |
# Make Logs directory if it does not exixts
|
22 |
if not path.isdir(LOGDIR):
|
23 |
mkdir(LOGDIR)
|
24 |
+
else:
|
25 |
+
shutil.rmtree(LOGDIR)
|
26 |
+
mkdir(LOGDIR)
|
27 |
|
28 |
LOGFILE = f"{LOGDIR}/{__name__}_{LOG_DATETIME}_log.txt"
|
29 |
|
|
|
51 |
|
52 |
# the secret configuration specific things
|
53 |
try:
|
54 |
+
from Powers.vars import is_env
|
55 |
+
if is_env or environ.get("ENV"):
|
56 |
from Powers.vars import Config
|
57 |
else:
|
58 |
from Powers.vars import Development as Config
|
|
|
60 |
LOGGER.error(ef) # Print Error
|
61 |
LOGGER.error(format_exc())
|
62 |
sysexit(1)
|
63 |
+
# time zone
|
64 |
TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
|
65 |
|
66 |
+
Vpath = "./Version"
|
67 |
version = []
|
68 |
+
for i in listdir(Vpath):
|
69 |
if i.startswith("version") and i.endswith("md"):
|
70 |
version.append(i)
|
71 |
else:
|
|
|
97 |
genius_lyrics.verbose = False
|
98 |
LOGGER.info("Client setup complete")
|
99 |
elif not Config.GENIUS_API_TOKEN:
|
100 |
+
LOGGER.info("Genius api not found lyrics command will not work")
|
101 |
is_genius_lyrics = False
|
102 |
genius_lyrics = False
|
103 |
|
104 |
+
# is_audd = False
|
105 |
+
# Audd = None
|
106 |
+
# if Config.AuDD_API:
|
107 |
+
# is_audd = True
|
108 |
+
# Audd = Config.AuDD_API
|
109 |
+
# LOGGER.info("Found Audd api")
|
110 |
|
111 |
is_rmbg = False
|
112 |
RMBG = None
|
|
|
119 |
API_HASH = Config.API_HASH
|
120 |
|
121 |
# General Config
|
122 |
+
MESSAGE_DUMP = Config.MESSAGE_DUMP if Config.MESSAGE_DUMP else Config.OWNER_ID
|
123 |
SUPPORT_GROUP = Config.SUPPORT_GROUP
|
124 |
SUPPORT_CHANNEL = Config.SUPPORT_CHANNEL
|
125 |
|
126 |
+
# Users Config
|
127 |
OWNER_ID = Config.OWNER_ID
|
128 |
+
DEV_USERS = set(Config.DEV_USERS)
|
129 |
+
SUDO_USERS = set(Config.SUDO_USERS)
|
130 |
+
WHITELIST_USERS = set(Config.WHITELIST_USERS)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
|
132 |
# Plugins, DB and Workers
|
133 |
DB_URI = Config.DB_URI
|
|
|
142 |
HELP_COMMANDS = {} # For help menu
|
143 |
UPTIME = time() # Check bot uptime
|
144 |
|
|
|
145 |
|
146 |
+
#Make dir
|
147 |
+
youtube_dir = "./Youtube/"
|
148 |
+
if not path.isdir(youtube_dir):
|
149 |
+
mkdir(youtube_dir)
|
150 |
+
else:
|
151 |
+
shutil.rmtree(youtube_dir)
|
152 |
+
mkdir(youtube_dir)
|
153 |
+
|
154 |
+
scrap_dir = "./scrapped/"
|
155 |
+
if not path.isdir(scrap_dir):
|
156 |
+
mkdir(scrap_dir)
|
157 |
+
else:
|
158 |
+
shutil.rmtree(scrap_dir)
|
159 |
+
mkdir(scrap_dir)
|
160 |
scheduler = AsyncIOScheduler(timezone=TIME_ZONE)
|
161 |
|
162 |
+
|
163 |
async def load_cmds(all_plugins):
|
164 |
"""Loads all the plugins in bot."""
|
165 |
for single in all_plugins:
|
166 |
# If plugin in NO_LOAD, skip the plugin
|
167 |
if single.lower() in [i.lower() for i in Config.NO_LOAD]:
|
168 |
+
LOGGER.warning(
|
169 |
+
f"Not loading '{single}' s it's added in NO_LOAD list")
|
170 |
continue
|
171 |
|
172 |
imported_module = imp_mod(f"Powers.plugins.{single}")
|
|
|
207 |
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
208 |
|
209 |
return (
|
210 |
+
", ".join((i.split(".")[1]).capitalize()
|
211 |
+
for i in list(HELP_COMMANDS.keys()))
|
212 |
+ "\n"
|
213 |
)
|
Powers/__main__.py
CHANGED
@@ -1,8 +1,6 @@
|
|
1 |
-
import uvloop # Comment it out if using on windows
|
2 |
from Powers.bot_class import Gojo
|
3 |
|
4 |
if __name__ == "__main__":
|
5 |
-
uvloop.install()
|
6 |
Gojo().run()
|
7 |
-
|
8 |
-
|
|
|
1 |
+
# import uvloop # Comment it out if using on windows
|
2 |
from Powers.bot_class import Gojo
|
3 |
|
4 |
if __name__ == "__main__":
|
5 |
+
# uvloop.install() # Comment it out if using on windows
|
6 |
Gojo().run()
|
|
|
|
Powers/bot_class.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
from platform import python_version
|
2 |
from threading import RLock
|
3 |
-
from time import gmtime, strftime
|
|
|
4 |
|
5 |
from pyrogram import Client, __version__
|
6 |
from pyrogram.raw.all import layer
|
@@ -24,7 +25,6 @@ if MESSAGE_DUMP == -100 or not str(MESSAGE_DUMP).startswith("-100"):
|
|
24 |
)
|
25 |
|
26 |
|
27 |
-
|
28 |
class Gojo(Client):
|
29 |
"""Starts the Pyrogram Client on the Bot Token when we do 'python3 -m Powers'"""
|
30 |
|
@@ -45,10 +45,11 @@ class Gojo(Client):
|
|
45 |
await super().start()
|
46 |
await self.set_bot_commands(
|
47 |
[
|
48 |
-
BotCommand(
|
|
|
49 |
BotCommand("help", "To get help menu"),
|
50 |
BotCommand("donate", "To buy me a coffee"),
|
51 |
-
BotCommand("bug","To report bugs")
|
52 |
]
|
53 |
)
|
54 |
meh = await self.get_me() # Get bot info from pyrogram client
|
@@ -67,10 +68,11 @@ class Gojo(Client):
|
|
67 |
# Get cmds and keys
|
68 |
cmd_list = await load_cmds(await all_plugins())
|
69 |
await load_support_users()
|
|
|
70 |
LOGGER.info(f"Plugins Loaded: {cmd_list}")
|
71 |
-
scheduler.add_job(clean_my_db,'cron',[self],hour=3,minute=0,second=0)
|
72 |
if BDB_URI:
|
73 |
-
scheduler.add_job(send_wishish,'cron',[
|
|
|
74 |
scheduler.start()
|
75 |
# Send a message to MESSAGE_DUMP telling that the
|
76 |
# bot has started and has loaded all plugins!
|
@@ -87,24 +89,22 @@ class Gojo(Client):
|
|
87 |
|
88 |
async def stop(self):
|
89 |
"""Stop the bot and send a message to MESSAGE_DUMP telling that the bot has stopped."""
|
90 |
-
runtime = strftime("%Hh %Mm %Ss", gmtime(
|
91 |
LOGGER.info("Uploading logs before stopping...!\n")
|
92 |
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
await self.send_document(
|
94 |
-
|
95 |
document=LOGFILE,
|
96 |
caption=(
|
97 |
"Bot Stopped!\n\n" f"Uptime: {runtime}\n" f"<code>{LOG_DATETIME}</code>"
|
98 |
),
|
99 |
)
|
100 |
-
scheduler.remove_all_jobs()
|
101 |
-
if MESSAGE_DUMP:
|
102 |
-
# LOG_CHANNEL is not necessary
|
103 |
-
await self.send_document(
|
104 |
-
MESSAGE_DUMP,
|
105 |
-
document=LOGFILE,
|
106 |
-
caption=f"Uptime: {runtime}",
|
107 |
-
)
|
108 |
await super().stop()
|
109 |
MongoDB.close()
|
110 |
LOGGER.info(
|
|
|
1 |
from platform import python_version
|
2 |
from threading import RLock
|
3 |
+
from time import gmtime, strftime
|
4 |
+
from time import time as t
|
5 |
|
6 |
from pyrogram import Client, __version__
|
7 |
from pyrogram.raw.all import layer
|
|
|
25 |
)
|
26 |
|
27 |
|
|
|
28 |
class Gojo(Client):
|
29 |
"""Starts the Pyrogram Client on the Bot Token when we do 'python3 -m Powers'"""
|
30 |
|
|
|
45 |
await super().start()
|
46 |
await self.set_bot_commands(
|
47 |
[
|
48 |
+
BotCommand(
|
49 |
+
"start", "To check weather the bot is alive or not"),
|
50 |
BotCommand("help", "To get help menu"),
|
51 |
BotCommand("donate", "To buy me a coffee"),
|
52 |
+
BotCommand("bug", "To report bugs")
|
53 |
]
|
54 |
)
|
55 |
meh = await self.get_me() # Get bot info from pyrogram client
|
|
|
68 |
# Get cmds and keys
|
69 |
cmd_list = await load_cmds(await all_plugins())
|
70 |
await load_support_users()
|
71 |
+
await cache_support()
|
72 |
LOGGER.info(f"Plugins Loaded: {cmd_list}")
|
|
|
73 |
if BDB_URI:
|
74 |
+
scheduler.add_job(send_wishish, 'cron', [
|
75 |
+
self], hour=0, minute=0, second=0)
|
76 |
scheduler.start()
|
77 |
# Send a message to MESSAGE_DUMP telling that the
|
78 |
# bot has started and has loaded all plugins!
|
|
|
89 |
|
90 |
async def stop(self):
|
91 |
"""Stop the bot and send a message to MESSAGE_DUMP telling that the bot has stopped."""
|
92 |
+
runtime = strftime("%Hh %Mm %Ss", gmtime(t() - UPTIME))
|
93 |
LOGGER.info("Uploading logs before stopping...!\n")
|
94 |
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
95 |
+
scheduler.remove_all_jobs()
|
96 |
+
if MESSAGE_DUMP:
|
97 |
+
# LOG_CHANNEL is not necessary
|
98 |
+
target = MESSAGE_DUMP
|
99 |
+
else:
|
100 |
+
target = OWNER_ID
|
101 |
await self.send_document(
|
102 |
+
target,
|
103 |
document=LOGFILE,
|
104 |
caption=(
|
105 |
"Bot Stopped!\n\n" f"Uptime: {runtime}\n" f"<code>{LOG_DATETIME}</code>"
|
106 |
),
|
107 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
await super().stop()
|
109 |
MongoDB.close()
|
110 |
LOGGER.info(
|
Powers/database/afk_db.py
CHANGED
@@ -13,43 +13,45 @@ class AFK(MongoDB):
|
|
13 |
def __init__(self) -> None:
|
14 |
super().__init__(self.db_name)
|
15 |
|
16 |
-
def insert_afk(self, chat_id, user_id, time, reason, media_type,media=None):
|
17 |
with INSERTION_LOCK:
|
18 |
curr = self.check_afk(chat_id=chat_id, user_id=user_id)
|
19 |
if curr:
|
20 |
if reason:
|
21 |
-
self.update({"chat_id":chat_id,"user_id":user_id},{
|
|
|
22 |
if media:
|
23 |
-
self.update({"chat_id":chat_id,"user_id":user_id},{
|
|
|
24 |
return True
|
25 |
else:
|
26 |
self.insert_one(
|
27 |
{
|
28 |
-
"chat_id":chat_id,
|
29 |
-
"user_id":user_id,
|
30 |
-
"reason":reason,
|
31 |
-
"time":time,
|
32 |
-
"media":media,
|
33 |
-
"media_type":media_type
|
34 |
}
|
35 |
)
|
36 |
return True
|
37 |
|
38 |
def check_afk(self, chat_id, user_id):
|
39 |
-
curr = self.find_one({"chat_id":chat_id,"user_id":user_id})
|
40 |
if curr:
|
41 |
return True
|
42 |
return False
|
43 |
-
|
44 |
def get_afk(self, chat_id, user_id):
|
45 |
-
curr = self.find_one({"chat_id":chat_id,"user_id":user_id})
|
46 |
if curr:
|
47 |
return curr
|
48 |
return
|
49 |
-
|
50 |
def delete_afk(self, chat_id, user_id):
|
51 |
with INSERTION_LOCK:
|
52 |
-
curr = self.check_afk(chat_id,user_id)
|
53 |
if curr:
|
54 |
-
self.delete_one({"chat_id":chat_id,"user_id":user_id})
|
55 |
-
return
|
|
|
13 |
def __init__(self) -> None:
|
14 |
super().__init__(self.db_name)
|
15 |
|
16 |
+
def insert_afk(self, chat_id, user_id, time, reason, media_type, media=None):
|
17 |
with INSERTION_LOCK:
|
18 |
curr = self.check_afk(chat_id=chat_id, user_id=user_id)
|
19 |
if curr:
|
20 |
if reason:
|
21 |
+
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
22 |
+
"reason": reason, "time": time})
|
23 |
if media:
|
24 |
+
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
25 |
+
'media': media, 'media_type': media_type, "time": time})
|
26 |
return True
|
27 |
else:
|
28 |
self.insert_one(
|
29 |
{
|
30 |
+
"chat_id": chat_id,
|
31 |
+
"user_id": user_id,
|
32 |
+
"reason": reason,
|
33 |
+
"time": time,
|
34 |
+
"media": media,
|
35 |
+
"media_type": media_type
|
36 |
}
|
37 |
)
|
38 |
return True
|
39 |
|
40 |
def check_afk(self, chat_id, user_id):
|
41 |
+
curr = self.find_one({"chat_id": chat_id, "user_id": user_id})
|
42 |
if curr:
|
43 |
return True
|
44 |
return False
|
45 |
+
|
46 |
def get_afk(self, chat_id, user_id):
|
47 |
+
curr = self.find_one({"chat_id": chat_id, "user_id": user_id})
|
48 |
if curr:
|
49 |
return curr
|
50 |
return
|
51 |
+
|
52 |
def delete_afk(self, chat_id, user_id):
|
53 |
with INSERTION_LOCK:
|
54 |
+
curr = self.check_afk(chat_id, user_id)
|
55 |
if curr:
|
56 |
+
self.delete_one({"chat_id": chat_id, "user_id": user_id})
|
57 |
+
return
|
Powers/database/antispam_db.py
CHANGED
@@ -28,6 +28,7 @@ class GBan(MongoDB):
|
|
28 |
return self.update_gban_reason(user_id, reason)
|
29 |
|
30 |
# If not already gbanned, then add to gban
|
|
|
31 |
time_rn = datetime.now(TZ)
|
32 |
return self.insert_one(
|
33 |
{
|
@@ -43,8 +44,8 @@ class GBan(MongoDB):
|
|
43 |
with INSERTION_LOCK:
|
44 |
# Check if user is already gbanned or not
|
45 |
if self.find_one({"_id": user_id}):
|
|
|
46 |
return self.delete_one({"_id": user_id})
|
47 |
-
|
48 |
return "User not gbanned!"
|
49 |
|
50 |
def get_gban(self, user_id: int):
|
|
|
28 |
return self.update_gban_reason(user_id, reason)
|
29 |
|
30 |
# If not already gbanned, then add to gban
|
31 |
+
ANTISPAM_BANNED.add(user_id)
|
32 |
time_rn = datetime.now(TZ)
|
33 |
return self.insert_one(
|
34 |
{
|
|
|
44 |
with INSERTION_LOCK:
|
45 |
# Check if user is already gbanned or not
|
46 |
if self.find_one({"_id": user_id}):
|
47 |
+
ANTISPAM_BANNED.remove(user_id)
|
48 |
return self.delete_one({"_id": user_id})
|
|
|
49 |
return "User not gbanned!"
|
50 |
|
51 |
def get_gban(self, user_id: int):
|
Powers/database/approve_db.py
CHANGED
@@ -1,11 +1,16 @@
|
|
1 |
from threading import RLock
|
|
|
2 |
from Powers import LOGGER
|
3 |
from Powers.database import MongoDB
|
|
|
4 |
INSERTION_LOCK = RLock()
|
|
|
|
|
5 |
class Approve(MongoDB):
|
6 |
"""Class for managing Approves in Chats in Bot."""
|
7 |
# Database name to connect to to preform operations
|
8 |
db_name = "approve"
|
|
|
9 |
def __init__(self, chat_id: int) -> None:
|
10 |
super().__init__(self.db_name)
|
11 |
self.chat_id = chat_id
|
@@ -22,7 +27,6 @@ class Approve(MongoDB):
|
|
22 |
else:
|
23 |
j = False
|
24 |
return j
|
25 |
-
|
26 |
|
27 |
def add_approve(self, user_id: int, user_name: str):
|
28 |
with INSERTION_LOCK:
|
@@ -33,6 +37,7 @@ class Approve(MongoDB):
|
|
33 |
{"users": self.chat_info["users"]},
|
34 |
)
|
35 |
return True
|
|
|
36 |
def remove_approve(self, user_id: int):
|
37 |
with INSERTION_LOCK:
|
38 |
if self.check_approve(user_id):
|
@@ -47,50 +52,59 @@ class Approve(MongoDB):
|
|
47 |
{"users": self.chat_info["users"]},
|
48 |
)
|
49 |
return True
|
|
|
50 |
def unapprove_all(self):
|
51 |
with INSERTION_LOCK:
|
52 |
return self.delete_one(
|
53 |
{"_id": self.chat_id},
|
54 |
)
|
|
|
55 |
def clean_approve(self):
|
56 |
with INSERTION_LOCK:
|
57 |
return self.delete_one(
|
58 |
-
{"_id":self.chat_id}
|
59 |
)
|
|
|
60 |
def list_approved(self):
|
61 |
with INSERTION_LOCK:
|
62 |
return self.chat_info["users"]
|
|
|
63 |
def count_approved(self):
|
64 |
with INSERTION_LOCK:
|
65 |
return len(self.chat_info["users"])
|
|
|
66 |
def load_from_db(self):
|
67 |
return self.find_all()
|
|
|
68 |
def __ensure_in_db(self):
|
69 |
chat_data = self.find_one({"_id": self.chat_id})
|
70 |
if not chat_data:
|
71 |
new_data = {"_id": self.chat_id, "users": []}
|
72 |
self.insert_one(new_data)
|
73 |
-
LOGGER.info(f"Initialized Approve Document for chat {self.chat_id}")
|
74 |
return new_data
|
75 |
return chat_data
|
76 |
# Migrate if chat id changes!
|
|
|
77 |
def migrate_chat(self, new_chat_id: int):
|
78 |
old_chat_db = self.find_one({"_id": self.chat_id})
|
79 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
80 |
self.insert_one(new_data)
|
81 |
self.delete_one({"_id": self.chat_id})
|
|
|
82 |
@staticmethod
|
83 |
def count_all_approved():
|
84 |
with INSERTION_LOCK:
|
85 |
collection = MongoDB(Approve.db_name)
|
86 |
all_data = collection.find_all()
|
87 |
return sum(len(i["users"]) for i in all_data if len(i["users"]) >= 1)
|
|
|
88 |
@staticmethod
|
89 |
def count_approved_chats():
|
90 |
with INSERTION_LOCK:
|
91 |
collection = MongoDB(Approve.db_name)
|
92 |
all_data = collection.find_all()
|
93 |
return sum(len(i["users"]) >= 1 for i in all_data)
|
|
|
94 |
@staticmethod
|
95 |
def repair_db(collection):
|
96 |
all_data = collection.find_all()
|
|
|
1 |
from threading import RLock
|
2 |
+
|
3 |
from Powers import LOGGER
|
4 |
from Powers.database import MongoDB
|
5 |
+
|
6 |
INSERTION_LOCK = RLock()
|
7 |
+
|
8 |
+
|
9 |
class Approve(MongoDB):
|
10 |
"""Class for managing Approves in Chats in Bot."""
|
11 |
# Database name to connect to to preform operations
|
12 |
db_name = "approve"
|
13 |
+
|
14 |
def __init__(self, chat_id: int) -> None:
|
15 |
super().__init__(self.db_name)
|
16 |
self.chat_id = chat_id
|
|
|
27 |
else:
|
28 |
j = False
|
29 |
return j
|
|
|
30 |
|
31 |
def add_approve(self, user_id: int, user_name: str):
|
32 |
with INSERTION_LOCK:
|
|
|
37 |
{"users": self.chat_info["users"]},
|
38 |
)
|
39 |
return True
|
40 |
+
|
41 |
def remove_approve(self, user_id: int):
|
42 |
with INSERTION_LOCK:
|
43 |
if self.check_approve(user_id):
|
|
|
52 |
{"users": self.chat_info["users"]},
|
53 |
)
|
54 |
return True
|
55 |
+
|
56 |
def unapprove_all(self):
|
57 |
with INSERTION_LOCK:
|
58 |
return self.delete_one(
|
59 |
{"_id": self.chat_id},
|
60 |
)
|
61 |
+
|
62 |
def clean_approve(self):
|
63 |
with INSERTION_LOCK:
|
64 |
return self.delete_one(
|
65 |
+
{"_id": self.chat_id}
|
66 |
)
|
67 |
+
|
68 |
def list_approved(self):
|
69 |
with INSERTION_LOCK:
|
70 |
return self.chat_info["users"]
|
71 |
+
|
72 |
def count_approved(self):
|
73 |
with INSERTION_LOCK:
|
74 |
return len(self.chat_info["users"])
|
75 |
+
|
76 |
def load_from_db(self):
|
77 |
return self.find_all()
|
78 |
+
|
79 |
def __ensure_in_db(self):
|
80 |
chat_data = self.find_one({"_id": self.chat_id})
|
81 |
if not chat_data:
|
82 |
new_data = {"_id": self.chat_id, "users": []}
|
83 |
self.insert_one(new_data)
|
|
|
84 |
return new_data
|
85 |
return chat_data
|
86 |
# Migrate if chat id changes!
|
87 |
+
|
88 |
def migrate_chat(self, new_chat_id: int):
|
89 |
old_chat_db = self.find_one({"_id": self.chat_id})
|
90 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
91 |
self.insert_one(new_data)
|
92 |
self.delete_one({"_id": self.chat_id})
|
93 |
+
|
94 |
@staticmethod
|
95 |
def count_all_approved():
|
96 |
with INSERTION_LOCK:
|
97 |
collection = MongoDB(Approve.db_name)
|
98 |
all_data = collection.find_all()
|
99 |
return sum(len(i["users"]) for i in all_data if len(i["users"]) >= 1)
|
100 |
+
|
101 |
@staticmethod
|
102 |
def count_approved_chats():
|
103 |
with INSERTION_LOCK:
|
104 |
collection = MongoDB(Approve.db_name)
|
105 |
all_data = collection.find_all()
|
106 |
return sum(len(i["users"]) >= 1 for i in all_data)
|
107 |
+
|
108 |
@staticmethod
|
109 |
def repair_db(collection):
|
110 |
all_data = collection.find_all()
|
Powers/database/autojoin_db.py
CHANGED
@@ -15,36 +15,36 @@ class AUTOJOIN(MongoDB):
|
|
15 |
def __init__(self) -> None:
|
16 |
super().__init__(self.db_name)
|
17 |
|
18 |
-
def load_autojoin(self, chat,mode="auto"):
|
19 |
"""
|
20 |
type = auto or notify
|
21 |
auto to auto accept join requests
|
22 |
notify to notify the admins about the join requests
|
23 |
"""
|
24 |
-
curr = self.find_one({"chat_id":chat,})
|
25 |
if not curr:
|
26 |
with INSERTION_LOCK:
|
27 |
-
self.insert_one({"chat_id":chat,"type":mode})
|
28 |
return True
|
29 |
return False
|
30 |
|
31 |
-
def get_autojoin(self,chat):
|
32 |
-
curr = self.find_one({"chat_id":chat})
|
33 |
if not curr:
|
34 |
return False
|
35 |
else:
|
36 |
return curr["type"]
|
37 |
|
38 |
-
def update_join_type(self,chat,mode):
|
39 |
-
curr = self.find_one({"chat_id":chat})
|
40 |
if curr:
|
41 |
-
self.update({"chat_id":chat},{"type":mode})
|
42 |
-
return
|
43 |
else:
|
44 |
return
|
45 |
|
46 |
-
def remove_autojoin(self,chat):
|
47 |
-
curr = self.find_one({"chat_id":chat})
|
48 |
if curr:
|
49 |
-
self.delete_one({"chat_id":chat})
|
50 |
-
return
|
|
|
15 |
def __init__(self) -> None:
|
16 |
super().__init__(self.db_name)
|
17 |
|
18 |
+
def load_autojoin(self, chat, mode="auto"):
|
19 |
"""
|
20 |
type = auto or notify
|
21 |
auto to auto accept join requests
|
22 |
notify to notify the admins about the join requests
|
23 |
"""
|
24 |
+
curr = self.find_one({"chat_id": chat, })
|
25 |
if not curr:
|
26 |
with INSERTION_LOCK:
|
27 |
+
self.insert_one({"chat_id": chat, "type": mode})
|
28 |
return True
|
29 |
return False
|
30 |
|
31 |
+
def get_autojoin(self, chat):
|
32 |
+
curr = self.find_one({"chat_id": chat})
|
33 |
if not curr:
|
34 |
return False
|
35 |
else:
|
36 |
return curr["type"]
|
37 |
|
38 |
+
def update_join_type(self, chat, mode):
|
39 |
+
curr = self.find_one({"chat_id": chat})
|
40 |
if curr:
|
41 |
+
self.update({"chat_id": chat}, {"type": mode})
|
42 |
+
return
|
43 |
else:
|
44 |
return
|
45 |
|
46 |
+
def remove_autojoin(self, chat):
|
47 |
+
curr = self.find_one({"chat_id": chat})
|
48 |
if curr:
|
49 |
+
self.delete_one({"chat_id": chat})
|
50 |
+
return
|
Powers/database/blacklist_db.py
CHANGED
@@ -110,13 +110,12 @@ class Blacklist(MongoDB):
|
|
110 |
"reason": "Automated blacklisted word: {{}}",
|
111 |
}
|
112 |
self.insert_one(new_data)
|
113 |
-
LOGGER.info(f"Initialized Blacklist Document for chat {self.chat_id}")
|
114 |
return new_data
|
115 |
return chat_data
|
116 |
|
117 |
def clean_blacklist(self):
|
118 |
with INSERTION_LOCK:
|
119 |
-
return self.delete_one({"_id":self.chat_id})
|
120 |
|
121 |
# Migrate if chat id changes!
|
122 |
def migrate_chat(self, new_chat_id: int):
|
|
|
110 |
"reason": "Automated blacklisted word: {{}}",
|
111 |
}
|
112 |
self.insert_one(new_data)
|
|
|
113 |
return new_data
|
114 |
return chat_data
|
115 |
|
116 |
def clean_blacklist(self):
|
117 |
with INSERTION_LOCK:
|
118 |
+
return self.delete_one({"_id": self.chat_id})
|
119 |
|
120 |
# Migrate if chat id changes!
|
121 |
def migrate_chat(self, new_chat_id: int):
|
Powers/database/captcha_db.py
CHANGED
@@ -13,15 +13,15 @@ class CAPTCHA(MongoDB):
|
|
13 |
def __init__(self) -> None:
|
14 |
super().__init__(self.db_name)
|
15 |
|
16 |
-
def insert_captcha(self, chat, captcha_type:str="qr", captcha_action:str = "mute"):
|
17 |
with INSERTION_LOCK:
|
18 |
curr = self.is_captcha(chat)
|
19 |
if not curr:
|
20 |
self.insert_one(
|
21 |
{
|
22 |
-
"chat_id":chat,
|
23 |
-
"captcha_type":captcha_type,
|
24 |
-
"captcha_action":captcha_action
|
25 |
}
|
26 |
)
|
27 |
return
|
@@ -36,29 +36,31 @@ class CAPTCHA(MongoDB):
|
|
36 |
with INSERTION_LOCK:
|
37 |
curr = self.is_captcha(chat)
|
38 |
if curr:
|
39 |
-
self.update({"chat_id":chat},{"captcha_type":captcha_type})
|
40 |
return
|
41 |
|
42 |
def update_action(self, chat, captcha_action):
|
43 |
with INSERTION_LOCK:
|
44 |
curr = self.is_captcha(chat)
|
45 |
if curr:
|
46 |
-
self.update({"chat_id":chat},{
|
|
|
47 |
return
|
48 |
-
|
49 |
def remove_captcha(self, chat):
|
50 |
with INSERTION_LOCK:
|
51 |
curr = self.is_captcha(chat)
|
52 |
if curr:
|
53 |
-
self.delete_one({"chat_id":chat})
|
54 |
return
|
55 |
|
56 |
def get_captcha(self, chat):
|
57 |
-
curr = self.find_one({"chat_id":chat})
|
58 |
if curr:
|
59 |
return curr
|
60 |
return False
|
61 |
|
|
|
62 |
class CAPTCHA_DATA(MongoDB):
|
63 |
"""class to store captcha data"""
|
64 |
db_name = "captcha_data"
|
@@ -67,47 +69,57 @@ class CAPTCHA_DATA(MongoDB):
|
|
67 |
super().__init__(self.db_name)
|
68 |
|
69 |
def load_cap_data(self, chat, user, data):
|
70 |
-
curr = self.find_one({"chat_id":chat,"user_id":user})
|
71 |
if not curr:
|
72 |
with INSERTION_LOCK:
|
73 |
-
self.insert_one(
|
|
|
74 |
return True
|
75 |
else:
|
76 |
return
|
77 |
|
78 |
def get_cap_data(self, chat, user):
|
79 |
-
curr = self.find_one({"chat_id":chat,"user_id":user})
|
80 |
if curr:
|
81 |
return curr["data"]
|
82 |
else:
|
83 |
return False
|
84 |
|
85 |
def remove_cap_data(self, chat, user):
|
86 |
-
curr = self.find_one({"chat_id":chat,"user_id":user})
|
87 |
if curr:
|
88 |
with INSERTION_LOCK:
|
89 |
-
self.delete_one({"chat_id":chat,"user_id":user})
|
90 |
return
|
91 |
|
92 |
def store_message_id(self, chat, user, message):
|
93 |
-
curr = self.find_one({"chat_id":chat,"user_id":user})
|
94 |
if not curr:
|
95 |
with INSERTION_LOCK:
|
96 |
-
self.insert_one(
|
|
|
97 |
return
|
98 |
else:
|
99 |
-
return
|
100 |
-
|
101 |
-
def
|
102 |
-
curr = self.find_one({"chat_id":chat,"user_id":user})
|
103 |
if curr:
|
104 |
return curr["message_id"]
|
105 |
else:
|
106 |
return False
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
def del_message_id(self, chat, user):
|
109 |
-
curr = self.find_one({"chat_id":chat,"user_id":user})
|
110 |
if curr:
|
111 |
with INSERTION_LOCK:
|
112 |
-
self.delete_one({"chat_id":chat,"user_id":user})
|
113 |
-
|
|
|
|
13 |
def __init__(self) -> None:
|
14 |
super().__init__(self.db_name)
|
15 |
|
16 |
+
def insert_captcha(self, chat, captcha_type: str = "qr", captcha_action: str = "mute"):
|
17 |
with INSERTION_LOCK:
|
18 |
curr = self.is_captcha(chat)
|
19 |
if not curr:
|
20 |
self.insert_one(
|
21 |
{
|
22 |
+
"chat_id": chat,
|
23 |
+
"captcha_type": captcha_type,
|
24 |
+
"captcha_action": captcha_action
|
25 |
}
|
26 |
)
|
27 |
return
|
|
|
36 |
with INSERTION_LOCK:
|
37 |
curr = self.is_captcha(chat)
|
38 |
if curr:
|
39 |
+
self.update({"chat_id": chat}, {"captcha_type": captcha_type})
|
40 |
return
|
41 |
|
42 |
def update_action(self, chat, captcha_action):
|
43 |
with INSERTION_LOCK:
|
44 |
curr = self.is_captcha(chat)
|
45 |
if curr:
|
46 |
+
self.update({"chat_id": chat}, {
|
47 |
+
"captcha_action": captcha_action})
|
48 |
return
|
49 |
+
|
50 |
def remove_captcha(self, chat):
|
51 |
with INSERTION_LOCK:
|
52 |
curr = self.is_captcha(chat)
|
53 |
if curr:
|
54 |
+
self.delete_one({"chat_id": chat})
|
55 |
return
|
56 |
|
57 |
def get_captcha(self, chat):
|
58 |
+
curr = self.find_one({"chat_id": chat})
|
59 |
if curr:
|
60 |
return curr
|
61 |
return False
|
62 |
|
63 |
+
|
64 |
class CAPTCHA_DATA(MongoDB):
|
65 |
"""class to store captcha data"""
|
66 |
db_name = "captcha_data"
|
|
|
69 |
super().__init__(self.db_name)
|
70 |
|
71 |
def load_cap_data(self, chat, user, data):
|
72 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
73 |
if not curr:
|
74 |
with INSERTION_LOCK:
|
75 |
+
self.insert_one(
|
76 |
+
{"chat_id": chat, "user_id": user, "data": data})
|
77 |
return True
|
78 |
else:
|
79 |
return
|
80 |
|
81 |
def get_cap_data(self, chat, user):
|
82 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
83 |
if curr:
|
84 |
return curr["data"]
|
85 |
else:
|
86 |
return False
|
87 |
|
88 |
def remove_cap_data(self, chat, user):
|
89 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
90 |
if curr:
|
91 |
with INSERTION_LOCK:
|
92 |
+
self.delete_one({"chat_id": chat, "user_id": user})
|
93 |
return
|
94 |
|
95 |
def store_message_id(self, chat, user, message):
|
96 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
97 |
if not curr:
|
98 |
with INSERTION_LOCK:
|
99 |
+
self.insert_one(
|
100 |
+
{"chat_id": chat, "user_id": user, "message_id": message})
|
101 |
return
|
102 |
else:
|
103 |
+
return
|
104 |
+
|
105 |
+
def get_message_id(self, chat, user):
|
106 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
107 |
if curr:
|
108 |
return curr["message_id"]
|
109 |
else:
|
110 |
return False
|
111 |
|
112 |
+
def is_already_data(self, chat, user):
|
113 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
114 |
+
if curr:
|
115 |
+
return curr.get("message_id", False)
|
116 |
+
else:
|
117 |
+
return False
|
118 |
+
|
119 |
def del_message_id(self, chat, user):
|
120 |
+
curr = self.find_one({"chat_id": chat, "user_id": user})
|
121 |
if curr:
|
122 |
with INSERTION_LOCK:
|
123 |
+
self.delete_one({"chat_id": chat, "user_id": user})
|
124 |
+
|
125 |
+
return curr["message_id"]
|
Powers/database/chats_db.py
CHANGED
@@ -107,7 +107,6 @@ class Chats(MongoDB):
|
|
107 |
if not chat_data:
|
108 |
new_data = {"_id": self.chat_id, "chat_name": "", "users": []}
|
109 |
self.insert_one(new_data)
|
110 |
-
LOGGER.info(f"Initialized Chats Document for chat {self.chat_id}")
|
111 |
return new_data
|
112 |
return chat_data
|
113 |
|
|
|
107 |
if not chat_data:
|
108 |
new_data = {"_id": self.chat_id, "chat_name": "", "users": []}
|
109 |
self.insert_one(new_data)
|
|
|
110 |
return new_data
|
111 |
return chat_data
|
112 |
|
Powers/database/disable_db.py
CHANGED
@@ -146,9 +146,9 @@ class Disabling(MongoDB):
|
|
146 |
"commands": [],
|
147 |
"action": "none",
|
148 |
}
|
149 |
-
DISABLED_CMDS[self.chat_id] = {
|
|
|
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
|
@@ -163,7 +163,7 @@ class Disabling(MongoDB):
|
|
163 |
|
164 |
def clean_disable(self):
|
165 |
with INSERTION_LOCK:
|
166 |
-
return self.delete_one({"_id":self.chat_id})
|
167 |
|
168 |
@staticmethod
|
169 |
def repair_db(collection):
|
|
|
146 |
"commands": [],
|
147 |
"action": "none",
|
148 |
}
|
149 |
+
DISABLED_CMDS[self.chat_id] = {
|
150 |
+
"commands": [], "action": "none"}
|
151 |
self.insert_one(new_data)
|
|
|
152 |
return new_data
|
153 |
DISABLED_CMDS[self.chat_id] = chat_data
|
154 |
return chat_data
|
|
|
163 |
|
164 |
def clean_disable(self):
|
165 |
with INSERTION_LOCK:
|
166 |
+
return self.delete_one({"_id": self.chat_id})
|
167 |
|
168 |
@staticmethod
|
169 |
def repair_db(collection):
|
Powers/database/filters_db.py
CHANGED
@@ -24,7 +24,15 @@ class Filters(MongoDB):
|
|
24 |
# Database update
|
25 |
curr = self.find_one({"chat_id": chat_id, "keyword": keyword})
|
26 |
if curr:
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
return self.insert_one(
|
29 |
{
|
30 |
"chat_id": chat_id,
|
@@ -71,7 +79,8 @@ class Filters(MongoDB):
|
|
71 |
curr = self.find_all()
|
72 |
if curr:
|
73 |
return len(
|
74 |
-
[z for z in (i["keyword"].split("|")
|
|
|
75 |
)
|
76 |
return 0
|
77 |
|
|
|
24 |
# Database update
|
25 |
curr = self.find_one({"chat_id": chat_id, "keyword": keyword})
|
26 |
if curr:
|
27 |
+
self.update(
|
28 |
+
{"chat_id": chat_id, "keyword": keyword},
|
29 |
+
{
|
30 |
+
"filter_reply": filter_reply,
|
31 |
+
"msgtype": msgtype,
|
32 |
+
"fileid": fileid
|
33 |
+
}
|
34 |
+
)
|
35 |
+
return
|
36 |
return self.insert_one(
|
37 |
{
|
38 |
"chat_id": chat_id,
|
|
|
79 |
curr = self.find_all()
|
80 |
if curr:
|
81 |
return len(
|
82 |
+
[z for z in (i["keyword"].split("|")
|
83 |
+
for i in curr) if len(z) >= 2],
|
84 |
)
|
85 |
return 0
|
86 |
|
Powers/database/flood_db.py
CHANGED
@@ -7,6 +7,7 @@ from Powers.utils.msg_types import Types
|
|
7 |
|
8 |
INSERTION_LOCK = RLock()
|
9 |
|
|
|
10 |
class Floods(MongoDB):
|
11 |
"""Class to store flood limit and action of a chat"""
|
12 |
db_name = "flood"
|
@@ -24,7 +25,7 @@ class Floods(MongoDB):
|
|
24 |
with INSERTION_LOCK:
|
25 |
curr = self.find_one({"chat_id": chat_id})
|
26 |
if curr:
|
27 |
-
if not(limit == int(curr['limit']) and within == int(curr['within']) and action == str(curr['action'])):
|
28 |
return self.update(
|
29 |
{
|
30 |
"chat_id": chat_id
|
@@ -36,37 +37,37 @@ class Floods(MongoDB):
|
|
36 |
}
|
37 |
)
|
38 |
else:
|
39 |
-
return
|
40 |
else:
|
41 |
return self.insert_one(
|
42 |
{
|
43 |
-
"chat_id"
|
44 |
"limit": limit,
|
45 |
"within": within,
|
46 |
-
"action"
|
47 |
},
|
48 |
)
|
49 |
-
|
50 |
def is_chat(self, chat_id: int):
|
51 |
with INSERTION_LOCK:
|
52 |
curr = self.find_one({"chat_id": chat_id})
|
53 |
if curr:
|
54 |
-
action = [str(curr['limit']), str(
|
|
|
55 |
return action
|
56 |
return False
|
57 |
-
|
58 |
def get_action(self, chat_id: int):
|
59 |
with INSERTION_LOCK:
|
60 |
curr = self.find_one({"chat_id": chat_id})
|
61 |
if curr:
|
62 |
return curr['action']
|
63 |
return "Flood haven't set"
|
64 |
-
|
65 |
def rm_flood(self, chat_id: int):
|
66 |
with INSERTION_LOCK:
|
67 |
curr = self.find_one({"chat_id": chat_id})
|
68 |
if curr:
|
69 |
-
self.delete_one({"chat_id":chat_id})
|
70 |
return True
|
71 |
return False
|
72 |
-
|
|
|
7 |
|
8 |
INSERTION_LOCK = RLock()
|
9 |
|
10 |
+
|
11 |
class Floods(MongoDB):
|
12 |
"""Class to store flood limit and action of a chat"""
|
13 |
db_name = "flood"
|
|
|
25 |
with INSERTION_LOCK:
|
26 |
curr = self.find_one({"chat_id": chat_id})
|
27 |
if curr:
|
28 |
+
if not (limit == int(curr['limit']) and within == int(curr['within']) and action == str(curr['action'])):
|
29 |
return self.update(
|
30 |
{
|
31 |
"chat_id": chat_id
|
|
|
37 |
}
|
38 |
)
|
39 |
else:
|
40 |
+
return
|
41 |
else:
|
42 |
return self.insert_one(
|
43 |
{
|
44 |
+
"chat_id": chat_id,
|
45 |
"limit": limit,
|
46 |
"within": within,
|
47 |
+
"action": action
|
48 |
},
|
49 |
)
|
50 |
+
|
51 |
def is_chat(self, chat_id: int):
|
52 |
with INSERTION_LOCK:
|
53 |
curr = self.find_one({"chat_id": chat_id})
|
54 |
if curr:
|
55 |
+
action = [str(curr['limit']), str(
|
56 |
+
curr['within']), str(curr['action'])]
|
57 |
return action
|
58 |
return False
|
59 |
+
|
60 |
def get_action(self, chat_id: int):
|
61 |
with INSERTION_LOCK:
|
62 |
curr = self.find_one({"chat_id": chat_id})
|
63 |
if curr:
|
64 |
return curr['action']
|
65 |
return "Flood haven't set"
|
66 |
+
|
67 |
def rm_flood(self, chat_id: int):
|
68 |
with INSERTION_LOCK:
|
69 |
curr = self.find_one({"chat_id": chat_id})
|
70 |
if curr:
|
71 |
+
self.delete_one({"chat_id": chat_id})
|
72 |
return True
|
73 |
return False
|
|
Powers/database/greetings_db.py
CHANGED
@@ -45,6 +45,7 @@ class Greetings(MongoDB):
|
|
45 |
def get_welcome_media(self):
|
46 |
with INSERTION_LOCK:
|
47 |
return self.chat_info["welcome_media"]
|
|
|
48 |
def get_welcome_msgtype(self):
|
49 |
with INSERTION_LOCK:
|
50 |
return self.chat_info["welcome_mtype"]
|
@@ -78,32 +79,32 @@ class Greetings(MongoDB):
|
|
78 |
with INSERTION_LOCK:
|
79 |
return self.update({"_id": self.chat_id}, {"goodbye": status})
|
80 |
|
81 |
-
def set_welcome_text(self, welcome_text: str, mtype,media=None):
|
82 |
with INSERTION_LOCK:
|
83 |
self.update(
|
84 |
{"_id": self.chat_id},
|
85 |
-
{"welcome_text": welcome_text,"welcome_mtype":mtype},
|
86 |
)
|
87 |
if media:
|
88 |
self.update(
|
89 |
{"_id": self.chat_id},
|
90 |
-
{"welcome_media": media,"welcome_mtype":mtype}
|
91 |
)
|
92 |
|
93 |
-
return
|
94 |
|
95 |
-
def set_goodbye_text(self, goodbye_text: str,mtype,media=None):
|
96 |
with INSERTION_LOCK:
|
97 |
self.update(
|
98 |
{"_id": self.chat_id},
|
99 |
-
{"goodbye_text": goodbye_text,"goodbye_mtype":mtype},
|
100 |
)
|
101 |
if media:
|
102 |
self.update(
|
103 |
{"_id": self.chat_id},
|
104 |
-
{"goodbye_media": media,"goodbye_mtype":mtype}
|
105 |
)
|
106 |
-
return
|
107 |
|
108 |
def set_current_cleanservice_settings(self, status: bool):
|
109 |
with INSERTION_LOCK:
|
@@ -154,13 +155,12 @@ class Greetings(MongoDB):
|
|
154 |
"welcome_text": "Hey {first}, welcome to {chatname}!",
|
155 |
"welcome": True,
|
156 |
"goodbye": True,
|
157 |
-
"welcome_media":False,
|
158 |
-
"welcome_mtype":False,
|
159 |
-
"goodbye_media":False,
|
160 |
-
"goodbye_mtype":False
|
161 |
}
|
162 |
self.insert_one(new_data)
|
163 |
-
LOGGER.info(f"Initialized Greetings Document for chat {self.chat_id}")
|
164 |
return new_data
|
165 |
return chat_data
|
166 |
|
@@ -173,7 +173,7 @@ class Greetings(MongoDB):
|
|
173 |
|
174 |
def clean_greetings(self):
|
175 |
with INSERTION_LOCK:
|
176 |
-
return self.delete_one({"_id":self.chat_id})
|
177 |
|
178 |
@staticmethod
|
179 |
def count_chats(query: str):
|
|
|
45 |
def get_welcome_media(self):
|
46 |
with INSERTION_LOCK:
|
47 |
return self.chat_info["welcome_media"]
|
48 |
+
|
49 |
def get_welcome_msgtype(self):
|
50 |
with INSERTION_LOCK:
|
51 |
return self.chat_info["welcome_mtype"]
|
|
|
79 |
with INSERTION_LOCK:
|
80 |
return self.update({"_id": self.chat_id}, {"goodbye": status})
|
81 |
|
82 |
+
def set_welcome_text(self, welcome_text: str, mtype, media=None):
|
83 |
with INSERTION_LOCK:
|
84 |
self.update(
|
85 |
{"_id": self.chat_id},
|
86 |
+
{"welcome_text": welcome_text, "welcome_mtype": mtype},
|
87 |
)
|
88 |
if media:
|
89 |
self.update(
|
90 |
{"_id": self.chat_id},
|
91 |
+
{"welcome_media": media, "welcome_mtype": mtype}
|
92 |
)
|
93 |
|
94 |
+
return
|
95 |
|
96 |
+
def set_goodbye_text(self, goodbye_text: str, mtype, media=None):
|
97 |
with INSERTION_LOCK:
|
98 |
self.update(
|
99 |
{"_id": self.chat_id},
|
100 |
+
{"goodbye_text": goodbye_text, "goodbye_mtype": mtype},
|
101 |
)
|
102 |
if media:
|
103 |
self.update(
|
104 |
{"_id": self.chat_id},
|
105 |
+
{"goodbye_media": media, "goodbye_mtype": mtype}
|
106 |
)
|
107 |
+
return
|
108 |
|
109 |
def set_current_cleanservice_settings(self, status: bool):
|
110 |
with INSERTION_LOCK:
|
|
|
155 |
"welcome_text": "Hey {first}, welcome to {chatname}!",
|
156 |
"welcome": True,
|
157 |
"goodbye": True,
|
158 |
+
"welcome_media": False,
|
159 |
+
"welcome_mtype": False,
|
160 |
+
"goodbye_media": False,
|
161 |
+
"goodbye_mtype": False
|
162 |
}
|
163 |
self.insert_one(new_data)
|
|
|
164 |
return new_data
|
165 |
return chat_data
|
166 |
|
|
|
173 |
|
174 |
def clean_greetings(self):
|
175 |
with INSERTION_LOCK:
|
176 |
+
return self.delete_one({"_id": self.chat_id})
|
177 |
|
178 |
@staticmethod
|
179 |
def count_chats(query: str):
|
Powers/database/locks_db.py
CHANGED
@@ -5,9 +5,13 @@ from Powers.database import MongoDB
|
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
7 |
|
|
|
|
|
|
|
|
|
8 |
class LOCKS(MongoDB):
|
9 |
"""Class to store locks"""
|
10 |
-
|
11 |
db_name = "locks"
|
12 |
|
13 |
def __init__(self) -> None:
|
@@ -15,59 +19,98 @@ class LOCKS(MongoDB):
|
|
15 |
|
16 |
def insert_lock_channel(self, chat: int, locktype: str):
|
17 |
"""
|
18 |
-
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
19 |
"""
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
if curr:
|
22 |
return False
|
23 |
else:
|
24 |
with INSERTION_LOCK:
|
25 |
-
hmm = self.merge_u_and_c(chat,locktype)
|
26 |
if not hmm:
|
27 |
-
self.insert_one({"chat_id":chat,"locktype":locktype})
|
28 |
return True
|
29 |
|
30 |
def remove_lock_channel(self, chat: int, locktype: str):
|
31 |
"""
|
32 |
-
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
33 |
"""
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
if curr:
|
36 |
with INSERTION_LOCK:
|
37 |
-
self.delete_one({"chat_id":chat,"locktype":locktype})
|
38 |
return True
|
39 |
else:
|
40 |
return False
|
41 |
|
42 |
-
def get_lock_channel(self, locktype: str="all"):
|
43 |
"""
|
44 |
-
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
45 |
"""
|
46 |
-
if locktype not in ["anti_c_send","anti_fwd","anti_fwd_u","anti_fwd_c","anti_links", "all"]:
|
47 |
return False
|
48 |
else:
|
49 |
-
if locktype
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
curr = self.find_all(find)
|
54 |
-
if not curr:
|
55 |
-
list_ = []
|
56 |
else:
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
60 |
def merge_u_and_c(self, chat: int, locktype: str):
|
61 |
if locktype == "anti_fwd_u":
|
62 |
-
curr = self.find_one({"chat_id":chat,"locktype":"anti_fwd_c"})
|
63 |
elif locktype == "anti_fwd_c":
|
64 |
-
curr = self.find_one({"chat_id":chat,"locktype":"anti_fwd_u"})
|
65 |
else:
|
66 |
return False
|
67 |
|
68 |
if curr:
|
69 |
-
self.delete_one({"chat_id":chat,"locktype":locktype})
|
70 |
-
self.insert_one({"chat_id":chat,"locktype":"anti_fwd"})
|
71 |
return True
|
72 |
else:
|
73 |
return False
|
@@ -76,9 +119,8 @@ class LOCKS(MongoDB):
|
|
76 |
"""
|
77 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
78 |
"""
|
79 |
-
curr = self.find_one({"chat_id":chat,"locktype":locktype})
|
80 |
if curr:
|
81 |
return True
|
82 |
else:
|
83 |
return False
|
84 |
-
|
|
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
7 |
|
8 |
+
lock_t = ["bot", "anti_c_send", "anti_fwd",
|
9 |
+
"anti_fwd_u", "anti_fwd_c", "anti_links"]
|
10 |
+
|
11 |
+
|
12 |
class LOCKS(MongoDB):
|
13 |
"""Class to store locks"""
|
14 |
+
|
15 |
db_name = "locks"
|
16 |
|
17 |
def __init__(self) -> None:
|
|
|
19 |
|
20 |
def insert_lock_channel(self, chat: int, locktype: str):
|
21 |
"""
|
22 |
+
locktypes: all, bot, anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
23 |
"""
|
24 |
+
if locktype == "all":
|
25 |
+
for i in lock_t:
|
26 |
+
curr = self.find_one({"chat_id": chat, "locktype": i})
|
27 |
+
if curr:
|
28 |
+
continue
|
29 |
+
if i in ["anti_fwd_u", "anti_fwd_c"]:
|
30 |
+
continue
|
31 |
+
self.insert_one({"chat_id": chat, "locktype": i})
|
32 |
+
return True
|
33 |
+
curr = self.find_one({"chat_id": chat, "locktype": locktype})
|
34 |
if curr:
|
35 |
return False
|
36 |
else:
|
37 |
with INSERTION_LOCK:
|
38 |
+
hmm = self.merge_u_and_c(chat, locktype)
|
39 |
if not hmm:
|
40 |
+
self.insert_one({"chat_id": chat, "locktype": locktype})
|
41 |
return True
|
42 |
|
43 |
def remove_lock_channel(self, chat: int, locktype: str):
|
44 |
"""
|
45 |
+
locktypes: all, bot, anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
46 |
"""
|
47 |
+
if locktype == "all":
|
48 |
+
for i in lock_t:
|
49 |
+
curr = self.find_one({"chat_id": chat, "locktype": i})
|
50 |
+
if curr:
|
51 |
+
self.delete_one({"chat_id": chat, "locktype": i})
|
52 |
+
return True
|
53 |
+
curr = self.find_one({"chat_id": chat, "locktype": locktype})
|
54 |
if curr:
|
55 |
with INSERTION_LOCK:
|
56 |
+
self.delete_one({"chat_id": chat, "locktype": locktype})
|
57 |
return True
|
58 |
else:
|
59 |
return False
|
60 |
|
61 |
+
def get_lock_channel(self, chat: int, locktype: str = "all"):
|
62 |
"""
|
63 |
+
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links, bot
|
64 |
"""
|
65 |
+
if locktype not in ["anti_c_send", "anti_fwd", "anti_fwd_u", "anti_fwd_c", "anti_links", "bot", "all"]:
|
66 |
return False
|
67 |
else:
|
68 |
+
if locktype != "all":
|
69 |
+
curr = self.find_one(
|
70 |
+
{"chat_id": chat, "locktype": locktype})
|
71 |
+
return bool(curr)
|
|
|
|
|
|
|
72 |
else:
|
73 |
+
to_return = {
|
74 |
+
"anti_channel": False,
|
75 |
+
"anti_fwd": {
|
76 |
+
"user": False,
|
77 |
+
"chat": False
|
78 |
+
},
|
79 |
+
"anti_links": False,
|
80 |
+
"bot": False
|
81 |
+
}
|
82 |
+
curr = self.find_all({"chat_id": chat})
|
83 |
+
if not curr:
|
84 |
+
return None
|
85 |
+
else:
|
86 |
+
for i in list(curr):
|
87 |
+
if i["locktype"] == "anti_c_send":
|
88 |
+
to_return["anti_channel"] = True
|
89 |
+
elif i["locktype"] == "anti_fwd":
|
90 |
+
to_return["anti_fwd"]["user"] = to_return["anti_fwd"]["chat"] = True
|
91 |
+
elif i["locktype"] == "anti_fwd_u":
|
92 |
+
to_return["anti_fwd"]["user"] = True
|
93 |
+
elif i["locktype"] == "anti_fwd_c":
|
94 |
+
to_return["anti_fwd"]["chat"] = True
|
95 |
+
elif i["anti_links"] == "anti_links":
|
96 |
+
to_return["anti_links"] = True
|
97 |
+
elif i["locktype"] == "bot":
|
98 |
+
to_return["bot"] = True
|
99 |
+
else:
|
100 |
+
continue
|
101 |
+
return to_return
|
102 |
|
103 |
def merge_u_and_c(self, chat: int, locktype: str):
|
104 |
if locktype == "anti_fwd_u":
|
105 |
+
curr = self.find_one({"chat_id": chat, "locktype": "anti_fwd_c"})
|
106 |
elif locktype == "anti_fwd_c":
|
107 |
+
curr = self.find_one({"chat_id": chat, "locktype": "anti_fwd_u"})
|
108 |
else:
|
109 |
return False
|
110 |
|
111 |
if curr:
|
112 |
+
self.delete_one({"chat_id": chat, "locktype": locktype})
|
113 |
+
self.insert_one({"chat_id": chat, "locktype": "anti_fwd"})
|
114 |
return True
|
115 |
else:
|
116 |
return False
|
|
|
119 |
"""
|
120 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
121 |
"""
|
122 |
+
curr = self.find_one({"chat_id": chat, "locktype": locktype})
|
123 |
if curr:
|
124 |
return True
|
125 |
else:
|
126 |
return False
|
|
Powers/database/notes_db.py
CHANGED
@@ -57,7 +57,8 @@ class Notes(MongoDB):
|
|
57 |
def get_all_notes(self, chat_id: int):
|
58 |
with INSERTION_LOCK:
|
59 |
curr = self.find_all({"chat_id": chat_id})
|
60 |
-
note_list = sorted([(note["note_name"], note["hash"])
|
|
|
61 |
return note_list
|
62 |
|
63 |
def rm_note(self, chat_id: int, note_name: str):
|
@@ -124,9 +125,9 @@ class NotesSettings(MongoDB):
|
|
124 |
self.update({"_id": chat_id}, {"privatenotes": False})
|
125 |
return False
|
126 |
|
127 |
-
def clean_notes(self,chat_id):
|
128 |
with INSERTION_LOCK:
|
129 |
-
return self.delete_one({"_id":chat_id})
|
130 |
|
131 |
def list_chats(self):
|
132 |
return self.find_all({"privatenotes": True})
|
|
|
57 |
def get_all_notes(self, chat_id: int):
|
58 |
with INSERTION_LOCK:
|
59 |
curr = self.find_all({"chat_id": chat_id})
|
60 |
+
note_list = sorted([(note["note_name"], note["hash"])
|
61 |
+
for note in curr])
|
62 |
return note_list
|
63 |
|
64 |
def rm_note(self, chat_id: int, note_name: str):
|
|
|
125 |
self.update({"_id": chat_id}, {"privatenotes": False})
|
126 |
return False
|
127 |
|
128 |
+
def clean_notes(self, chat_id):
|
129 |
with INSERTION_LOCK:
|
130 |
+
return self.delete_one({"_id": chat_id})
|
131 |
|
132 |
def list_chats(self):
|
133 |
return self.find_all({"privatenotes": True})
|
Powers/database/pins_db.py
CHANGED
@@ -62,13 +62,12 @@ class Pins(MongoDB):
|
|
62 |
"cleanlinked": False,
|
63 |
}
|
64 |
self.insert_one(new_data)
|
65 |
-
LOGGER.info(f"Initialized Pins Document for chat {self.chat_id}")
|
66 |
return new_data
|
67 |
return chat_data
|
68 |
|
69 |
def clean_pins(self):
|
70 |
with INSERTION_LOCK:
|
71 |
-
return self.delete_one({"_id":self.chat_id})
|
72 |
|
73 |
# Migrate if chat id changes!
|
74 |
def migrate_chat(self, new_chat_id: int):
|
|
|
62 |
"cleanlinked": False,
|
63 |
}
|
64 |
self.insert_one(new_data)
|
|
|
65 |
return new_data
|
66 |
return chat_data
|
67 |
|
68 |
def clean_pins(self):
|
69 |
with INSERTION_LOCK:
|
70 |
+
return self.delete_one({"_id": self.chat_id})
|
71 |
|
72 |
# Migrate if chat id changes!
|
73 |
def migrate_chat(self, new_chat_id: int):
|
Powers/database/reporting_db.py
CHANGED
@@ -42,9 +42,9 @@ class Reporting(MongoDB):
|
|
42 |
chat_data = self.find_one({"_id": self.chat_id})
|
43 |
if not chat_data:
|
44 |
chat_type = self.get_chat_type()
|
45 |
-
new_data = {"_id": self.chat_id,
|
|
|
46 |
self.insert_one(new_data)
|
47 |
-
LOGGER.info(f"Initialized Language Document for chat {self.chat_id}")
|
48 |
return new_data
|
49 |
return chat_data
|
50 |
|
@@ -57,7 +57,7 @@ class Reporting(MongoDB):
|
|
57 |
|
58 |
def clean_reporting(self):
|
59 |
with INSERTION_LOCK:
|
60 |
-
return self.delete_one({"_id":self.chat_id})
|
61 |
|
62 |
@staticmethod
|
63 |
def repair_db(collection):
|
|
|
42 |
chat_data = self.find_one({"_id": self.chat_id})
|
43 |
if not chat_data:
|
44 |
chat_type = self.get_chat_type()
|
45 |
+
new_data = {"_id": self.chat_id,
|
46 |
+
"status": True, "chat_type": chat_type}
|
47 |
self.insert_one(new_data)
|
|
|
48 |
return new_data
|
49 |
return chat_data
|
50 |
|
|
|
57 |
|
58 |
def clean_reporting(self):
|
59 |
with INSERTION_LOCK:
|
60 |
+
return self.delete_one({"_id": self.chat_id})
|
61 |
|
62 |
@staticmethod
|
63 |
def repair_db(collection):
|
Powers/database/rules_db.py
CHANGED
@@ -68,7 +68,6 @@ class Rules(MongoDB):
|
|
68 |
if not chat_data:
|
69 |
new_data = {"_id": self.chat_id, "privrules": False, "rules": ""}
|
70 |
self.insert_one(new_data)
|
71 |
-
LOGGER.info(f"Initialized Language Document for chat {self.chat_id}")
|
72 |
return new_data
|
73 |
return chat_data
|
74 |
|
|
|
68 |
if not chat_data:
|
69 |
new_data = {"_id": self.chat_id, "privrules": False, "rules": ""}
|
70 |
self.insert_one(new_data)
|
|
|
71 |
return new_data
|
72 |
return chat_data
|
73 |
|
Powers/database/support_db.py
CHANGED
@@ -5,6 +5,7 @@ from Powers.database import MongoDB
|
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
7 |
|
|
|
8 |
class SUPPORTS(MongoDB):
|
9 |
"""
|
10 |
class to store support users in database
|
@@ -12,7 +13,7 @@ class SUPPORTS(MongoDB):
|
|
12 |
"""
|
13 |
|
14 |
db_name = "supports"
|
15 |
-
|
16 |
def __init__(self) -> None:
|
17 |
super().__init__(self.db_name)
|
18 |
|
@@ -22,49 +23,48 @@ class SUPPORTS(MongoDB):
|
|
22 |
with INSERTION_LOCK:
|
23 |
self.insert_one(
|
24 |
{
|
25 |
-
"user_id":user_id,
|
26 |
-
"support_type":support_type
|
27 |
}
|
28 |
)
|
29 |
return
|
30 |
|
31 |
-
def update_support_user_type(self,user,new_type):
|
32 |
curr = self.is_support_user(user)
|
33 |
if curr:
|
34 |
with INSERTION_LOCK:
|
35 |
self.update(
|
36 |
{
|
37 |
-
"user_id":user
|
38 |
},
|
39 |
{
|
40 |
-
"support_type":new_type
|
41 |
}
|
42 |
)
|
43 |
return
|
44 |
|
45 |
-
|
46 |
def is_support_user(self, user_id):
|
47 |
-
curr = self.find_one({"user_id":user_id})
|
48 |
if curr:
|
49 |
return True
|
50 |
return False
|
51 |
|
52 |
-
def delete_support_user(self,user):
|
53 |
curr = self.is_support_user(user)
|
54 |
if curr:
|
55 |
with INSERTION_LOCK:
|
56 |
-
self.delete_one({"user_id":user})
|
57 |
return
|
58 |
|
59 |
-
def get_particular_support(self,support_type):
|
60 |
-
curr = self.find_all({"support_type":support_type})
|
61 |
if curr:
|
62 |
return [i['user_id'] for i in curr]
|
63 |
else:
|
64 |
return []
|
65 |
|
66 |
-
def get_support_type(self,user):
|
67 |
-
curr = self.find_one({"user_id":user})
|
68 |
if curr:
|
69 |
return curr["support_type"]
|
70 |
-
return False
|
|
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
7 |
|
8 |
+
|
9 |
class SUPPORTS(MongoDB):
|
10 |
"""
|
11 |
class to store support users in database
|
|
|
13 |
"""
|
14 |
|
15 |
db_name = "supports"
|
16 |
+
|
17 |
def __init__(self) -> None:
|
18 |
super().__init__(self.db_name)
|
19 |
|
|
|
23 |
with INSERTION_LOCK:
|
24 |
self.insert_one(
|
25 |
{
|
26 |
+
"user_id": user_id,
|
27 |
+
"support_type": support_type
|
28 |
}
|
29 |
)
|
30 |
return
|
31 |
|
32 |
+
def update_support_user_type(self, user, new_type):
|
33 |
curr = self.is_support_user(user)
|
34 |
if curr:
|
35 |
with INSERTION_LOCK:
|
36 |
self.update(
|
37 |
{
|
38 |
+
"user_id": user
|
39 |
},
|
40 |
{
|
41 |
+
"support_type": new_type
|
42 |
}
|
43 |
)
|
44 |
return
|
45 |
|
|
|
46 |
def is_support_user(self, user_id):
|
47 |
+
curr = self.find_one({"user_id": user_id})
|
48 |
if curr:
|
49 |
return True
|
50 |
return False
|
51 |
|
52 |
+
def delete_support_user(self, user):
|
53 |
curr = self.is_support_user(user)
|
54 |
if curr:
|
55 |
with INSERTION_LOCK:
|
56 |
+
self.delete_one({"user_id": user})
|
57 |
return
|
58 |
|
59 |
+
def get_particular_support(self, support_type):
|
60 |
+
curr = self.find_all({"support_type": support_type})
|
61 |
if curr:
|
62 |
return [i['user_id'] for i in curr]
|
63 |
else:
|
64 |
return []
|
65 |
|
66 |
+
def get_support_type(self, user):
|
67 |
+
curr = self.find_one({"user_id": user})
|
68 |
if curr:
|
69 |
return curr["support_type"]
|
70 |
+
return False
|
Powers/database/users_db.py
CHANGED
@@ -67,9 +67,9 @@ class Users(MongoDB):
|
|
67 |
def __ensure_in_db(self):
|
68 |
chat_data = self.find_one({"_id": self.user_id})
|
69 |
if not chat_data:
|
70 |
-
new_data = {"_id": self.user_id,
|
|
|
71 |
self.insert_one(new_data)
|
72 |
-
LOGGER.info(f"Initialized User Document for {self.user_id}")
|
73 |
return new_data
|
74 |
return chat_data
|
75 |
|
|
|
67 |
def __ensure_in_db(self):
|
68 |
chat_data = self.find_one({"_id": self.user_id})
|
69 |
if not chat_data:
|
70 |
+
new_data = {"_id": self.user_id,
|
71 |
+
"username": "", "name": "unknown_till_now"}
|
72 |
self.insert_one(new_data)
|
|
|
73 |
return new_data
|
74 |
return chat_data
|
75 |
|
Powers/database/warns_db.py
CHANGED
@@ -49,7 +49,7 @@ class Warns(MongoDB):
|
|
49 |
|
50 |
def clean_warn(self):
|
51 |
with INSERTION_LOCK:
|
52 |
-
return self.delete_one({"chat_id":self.chat_id})
|
53 |
|
54 |
def get_warns(self, user_id: int):
|
55 |
with INSERTION_LOCK:
|
@@ -93,12 +93,14 @@ class Warns(MongoDB):
|
|
93 |
f"Repairing Approve Database - setting '{key}:{val}' for {data['user_id']} in {data['chat_id']}",
|
94 |
)
|
95 |
collection.update(
|
96 |
-
{"chat_id": data["chat_id"],
|
|
|
97 |
{key: val},
|
98 |
)
|
99 |
|
100 |
def __ensure_in_db(self, user_id: int):
|
101 |
-
chat_data = self.find_one(
|
|
|
102 |
if not chat_data:
|
103 |
new_data = {
|
104 |
"chat_id": self.chat_id,
|
@@ -107,7 +109,6 @@ class Warns(MongoDB):
|
|
107 |
"num_warns": 0,
|
108 |
}
|
109 |
self.insert_one(new_data)
|
110 |
-
LOGGER.info(f"Initialized Warn Document for {user_id} in {self.chat_id}")
|
111 |
return new_data
|
112 |
return chat_data
|
113 |
|
@@ -123,9 +124,9 @@ class WarnSettings(MongoDB):
|
|
123 |
def __ensure_in_db(self):
|
124 |
chat_data = self.find_one({"_id": self.chat_id})
|
125 |
if not chat_data:
|
126 |
-
new_data = {"_id": self.chat_id,
|
|
|
127 |
self.insert_one(new_data)
|
128 |
-
LOGGER.info(f"Initialized Warn Settings Document for {self.chat_id}")
|
129 |
return new_data
|
130 |
return chat_data
|
131 |
|
@@ -140,7 +141,7 @@ class WarnSettings(MongoDB):
|
|
140 |
|
141 |
def clean_warns(self):
|
142 |
with INSERTION_LOCK:
|
143 |
-
return self.delete_one({"_id":self.chat_id})
|
144 |
|
145 |
def get_warnmode(self):
|
146 |
with INSERTION_LOCK:
|
|
|
49 |
|
50 |
def clean_warn(self):
|
51 |
with INSERTION_LOCK:
|
52 |
+
return self.delete_one({"chat_id": self.chat_id})
|
53 |
|
54 |
def get_warns(self, user_id: int):
|
55 |
with INSERTION_LOCK:
|
|
|
93 |
f"Repairing Approve Database - setting '{key}:{val}' for {data['user_id']} in {data['chat_id']}",
|
94 |
)
|
95 |
collection.update(
|
96 |
+
{"chat_id": data["chat_id"],
|
97 |
+
"user_id": data["user_id"]},
|
98 |
{key: val},
|
99 |
)
|
100 |
|
101 |
def __ensure_in_db(self, user_id: int):
|
102 |
+
chat_data = self.find_one(
|
103 |
+
{"chat_id": self.chat_id, "user_id": user_id})
|
104 |
if not chat_data:
|
105 |
new_data = {
|
106 |
"chat_id": self.chat_id,
|
|
|
109 |
"num_warns": 0,
|
110 |
}
|
111 |
self.insert_one(new_data)
|
|
|
112 |
return new_data
|
113 |
return chat_data
|
114 |
|
|
|
124 |
def __ensure_in_db(self):
|
125 |
chat_data = self.find_one({"_id": self.chat_id})
|
126 |
if not chat_data:
|
127 |
+
new_data = {"_id": self.chat_id,
|
128 |
+
"warn_mode": "none", "warn_limit": 3}
|
129 |
self.insert_one(new_data)
|
|
|
130 |
return new_data
|
131 |
return chat_data
|
132 |
|
|
|
141 |
|
142 |
def clean_warns(self):
|
143 |
with INSERTION_LOCK:
|
144 |
+
return self.delete_one({"_id": self.chat_id})
|
145 |
|
146 |
def get_warnmode(self):
|
147 |
with INSERTION_LOCK:
|
Powers/plugins/__init__.py
CHANGED
@@ -38,3 +38,4 @@ def till_date(date):
|
|
38 |
form = "%Y-%m-%d %H:%M:%S"
|
39 |
z = datetime.strptime(date,form)
|
40 |
return z
|
|
|
|
38 |
form = "%Y-%m-%d %H:%M:%S"
|
39 |
z = datetime.strptime(date,form)
|
40 |
return z
|
41 |
+
|
Powers/plugins/admin.py
CHANGED
@@ -6,26 +6,21 @@ from traceback import format_exc
|
|
6 |
from pyrogram import filters
|
7 |
from pyrogram.enums import ChatMemberStatus as CMS
|
8 |
from pyrogram.enums import ChatType
|
9 |
-
from pyrogram.errors import (
|
10 |
-
FloodWait, RightForbidden,
|
11 |
-
UserAdminInvalid)
|
12 |
from pyrogram.types import ChatPrivileges, Message
|
13 |
|
14 |
-
from Powers import LOGGER, OWNER_ID
|
15 |
from Powers.bot_class import Gojo
|
16 |
from Powers.database.approve_db import Approve
|
17 |
from Powers.database.reporting_db import Reporting
|
18 |
-
from Powers.supports import get_support_staff
|
19 |
from Powers.utils.caching import (ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK,
|
20 |
admin_cache_reload)
|
21 |
-
from Powers.utils.custom_filters import
|
22 |
-
promote_filter)
|
23 |
from Powers.utils.extract_user import extract_user
|
24 |
from Powers.utils.parser import mention_html
|
25 |
-
from Powers.vars import Config
|
26 |
|
27 |
-
SUPPORT_STAFF = get_support_staff()
|
28 |
-
DEV_LEVEL = get_support_staff("dev_level")
|
29 |
|
30 |
@Gojo.on_message(command("adminlist"))
|
31 |
async def adminlist_show(_, m: Message):
|
@@ -69,7 +64,7 @@ async def adminlist_show(_, m: Message):
|
|
69 |
adminstr += "\n\n<b>Bots:</b>\n"
|
70 |
adminstr += "\n".join(f"- {i}" for i in mention_bots)
|
71 |
await m.reply_text(adminstr + "\n\n" + note)
|
72 |
-
|
73 |
except Exception as ef:
|
74 |
if str(ef) == str(m.chat.id):
|
75 |
await m.reply_text(text="Use /admincache to reload admins!")
|
@@ -83,25 +78,31 @@ async def adminlist_show(_, m: Message):
|
|
83 |
return
|
84 |
|
85 |
|
|
|
86 |
@Gojo.on_message(command("zombies") & admin_filter)
|
87 |
async def zombie_clean(c: Gojo, m: Message):
|
88 |
zombie = 0
|
89 |
wait = await m.reply_text("Searching ... and banning ...")
|
|
|
90 |
async for member in c.get_chat_members(m.chat.id):
|
91 |
if member.user.is_deleted:
|
92 |
zombie += 1
|
93 |
try:
|
94 |
await c.ban_chat_member(m.chat.id, member.user.id)
|
95 |
except UserAdminInvalid:
|
96 |
-
|
97 |
except FloodWait as e:
|
98 |
-
await sleep(e.
|
|
|
|
|
|
|
|
|
99 |
if zombie == 0:
|
100 |
return await wait.edit_text("Group is clean!")
|
101 |
-
|
102 |
-
|
103 |
-
)
|
104 |
-
|
105 |
|
106 |
@Gojo.on_message(command("admincache"))
|
107 |
async def reload_admins(_, m: Message):
|
@@ -110,6 +111,7 @@ async def reload_admins(_, m: Message):
|
|
110 |
return await m.reply_text(
|
111 |
"This command is made to be used in groups only!",
|
112 |
)
|
|
|
113 |
if (
|
114 |
(m.chat.id in set(TEMP_ADMIN_CACHE_BLOCK.keys()))
|
115 |
and (m.from_user.id not in SUPPORT_STAFF)
|
@@ -121,7 +123,6 @@ async def reload_admins(_, m: Message):
|
|
121 |
await admin_cache_reload(m, "admincache")
|
122 |
TEMP_ADMIN_CACHE_BLOCK[m.chat.id] = "manualblock"
|
123 |
await m.reply_text(text="Reloaded all admins in this chat!")
|
124 |
-
LOGGER.info(f"Admincache cmd use in {m.chat.id} by {m.from_user.id}")
|
125 |
except RPCError as ef:
|
126 |
await m.reply_text(
|
127 |
text=f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
@@ -164,8 +165,8 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
164 |
user_id, user_first_name, user_name = await extract_user(c, m)
|
165 |
except Exception:
|
166 |
return
|
167 |
-
bot = await c.get_chat_member(m.chat.id,
|
168 |
-
if user_id ==
|
169 |
await m.reply_text("Huh, how can I even promote myself?")
|
170 |
return
|
171 |
if not bot.privileges.can_promote_members:
|
@@ -205,9 +206,6 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
205 |
except Exception as e:
|
206 |
LOGGER.error(e)
|
207 |
LOGGER.error(format_exc())
|
208 |
-
LOGGER.info(
|
209 |
-
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
210 |
-
)
|
211 |
await m.reply_text(
|
212 |
(
|
213 |
"{promoter} promoted {promoted} in chat <b>{chat_title}</b> with full rights!"
|
@@ -260,8 +258,8 @@ async def promote_usr(c: Gojo, m: Message):
|
|
260 |
user_id, user_first_name, user_name = await extract_user(c, m)
|
261 |
except Exception:
|
262 |
return
|
263 |
-
bot = await c.get_chat_member(m.chat.id,
|
264 |
-
if user_id ==
|
265 |
await m.reply_text("Huh, how can I even promote myself?")
|
266 |
return
|
267 |
if not bot.privileges.can_promote_members:
|
@@ -291,6 +289,8 @@ async def promote_usr(c: Gojo, m: Message):
|
|
291 |
can_pin_messages=bot.privileges.can_pin_messages,
|
292 |
can_manage_chat=bot.privileges.can_manage_chat,
|
293 |
can_manage_video_chats=bot.privileges.can_manage_video_chats,
|
|
|
|
|
294 |
),
|
295 |
)
|
296 |
title = ""
|
@@ -308,9 +308,7 @@ async def promote_usr(c: Gojo, m: Message):
|
|
308 |
except Exception as e:
|
309 |
LOGGER.error(e)
|
310 |
LOGGER.error(format_exc())
|
311 |
-
|
312 |
-
f"{m.from_user.id} promoted {user_id} in {m.chat.id} with title '{title}'",
|
313 |
-
)
|
314 |
await m.reply_text(
|
315 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
316 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
@@ -359,7 +357,7 @@ async def demote_usr(c: Gojo, m: Message):
|
|
359 |
user_id, user_first_name, _ = await extract_user(c, m)
|
360 |
except Exception:
|
361 |
return
|
362 |
-
if user_id ==
|
363 |
await m.reply_text("Get an admin to demote me!")
|
364 |
return
|
365 |
# If user not already admin
|
@@ -379,7 +377,6 @@ async def demote_usr(c: Gojo, m: Message):
|
|
379 |
user_id=user_id,
|
380 |
privileges=ChatPrivileges(can_manage_chat=False),
|
381 |
)
|
382 |
-
LOGGER.info(f"{m.from_user.id} demoted {user_id} in {m.chat.id}")
|
383 |
# ----- Remove admin from cache -----
|
384 |
try:
|
385 |
admin_list = ADMIN_CACHE[m.chat.id]
|
@@ -408,6 +405,8 @@ async def demote_usr(c: Gojo, m: Message):
|
|
408 |
await m.reply_text(
|
409 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
410 |
)
|
|
|
|
|
411 |
except RPCError as ef:
|
412 |
await m.reply_text(
|
413 |
f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
@@ -420,6 +419,8 @@ async def demote_usr(c: Gojo, m: Message):
|
|
420 |
@Gojo.on_message(command("invitelink"))
|
421 |
async def get_invitelink(c: Gojo, m: Message):
|
422 |
# Bypass the bot devs, sudos and owner
|
|
|
|
|
423 |
if m.from_user.id not in DEV_LEVEL:
|
424 |
user = await m.chat.get_member(m.from_user.id)
|
425 |
if not user.privileges.can_invite_users and user.status != CMS.OWNER:
|
@@ -431,7 +432,6 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
431 |
text=f"Invite Link for Chat <b>{m.chat.id}</b>: {link}",
|
432 |
disable_web_page_preview=True,
|
433 |
)
|
434 |
-
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
|
435 |
except ChatAdminRequired:
|
436 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
437 |
except ChatAdminInviteRequired:
|
@@ -508,7 +508,7 @@ async def set_user_title(c: Gojo, m: Message):
|
|
508 |
return
|
509 |
if not user_id:
|
510 |
return await m.reply_text("Cannot find user!")
|
511 |
-
if user_id ==
|
512 |
return await m.reply_text("Huh, why ?")
|
513 |
if not reason:
|
514 |
return await m.reply_text("Read /help please!")
|
|
|
6 |
from pyrogram import filters
|
7 |
from pyrogram.enums import ChatMemberStatus as CMS
|
8 |
from pyrogram.enums import ChatType
|
9 |
+
from pyrogram.errors import (BotChannelsNa, ChatAdminInviteRequired,
|
10 |
+
ChatAdminRequired, FloodWait, RightForbidden,
|
11 |
+
RPCError, UserAdminInvalid)
|
12 |
from pyrogram.types import ChatPrivileges, Message
|
13 |
|
14 |
+
from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, WHITELIST_USERS
|
15 |
from Powers.bot_class import Gojo
|
16 |
from Powers.database.approve_db import Approve
|
17 |
from Powers.database.reporting_db import Reporting
|
|
|
18 |
from Powers.utils.caching import (ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK,
|
19 |
admin_cache_reload)
|
20 |
+
from Powers.utils.custom_filters import admin_filter, command, promote_filter
|
|
|
21 |
from Powers.utils.extract_user import extract_user
|
22 |
from Powers.utils.parser import mention_html
|
|
|
23 |
|
|
|
|
|
24 |
|
25 |
@Gojo.on_message(command("adminlist"))
|
26 |
async def adminlist_show(_, m: Message):
|
|
|
64 |
adminstr += "\n\n<b>Bots:</b>\n"
|
65 |
adminstr += "\n".join(f"- {i}" for i in mention_bots)
|
66 |
await m.reply_text(adminstr + "\n\n" + note)
|
67 |
+
|
68 |
except Exception as ef:
|
69 |
if str(ef) == str(m.chat.id):
|
70 |
await m.reply_text(text="Use /admincache to reload admins!")
|
|
|
78 |
return
|
79 |
|
80 |
|
81 |
+
|
82 |
@Gojo.on_message(command("zombies") & admin_filter)
|
83 |
async def zombie_clean(c: Gojo, m: Message):
|
84 |
zombie = 0
|
85 |
wait = await m.reply_text("Searching ... and banning ...")
|
86 |
+
failed = 0
|
87 |
async for member in c.get_chat_members(m.chat.id):
|
88 |
if member.user.is_deleted:
|
89 |
zombie += 1
|
90 |
try:
|
91 |
await c.ban_chat_member(m.chat.id, member.user.id)
|
92 |
except UserAdminInvalid:
|
93 |
+
failed += 1
|
94 |
except FloodWait as e:
|
95 |
+
await sleep(e.value)
|
96 |
+
try:
|
97 |
+
await c.ban_chat_member(m.chat.id, member.user.id)
|
98 |
+
except:
|
99 |
+
pass
|
100 |
if zombie == 0:
|
101 |
return await wait.edit_text("Group is clean!")
|
102 |
+
await wait.delete()
|
103 |
+
txt=f"<b>{zombie}</b> Zombies found and {zombie - failed} has been banned!\n{failed} zombies' are immune to me",
|
104 |
+
await m.reply_animation("https://graph.org/file/02a1dcf7788186ffb36cb.mp4", caption=txt)
|
105 |
+
return
|
106 |
|
107 |
@Gojo.on_message(command("admincache"))
|
108 |
async def reload_admins(_, m: Message):
|
|
|
111 |
return await m.reply_text(
|
112 |
"This command is made to be used in groups only!",
|
113 |
)
|
114 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
115 |
if (
|
116 |
(m.chat.id in set(TEMP_ADMIN_CACHE_BLOCK.keys()))
|
117 |
and (m.from_user.id not in SUPPORT_STAFF)
|
|
|
123 |
await admin_cache_reload(m, "admincache")
|
124 |
TEMP_ADMIN_CACHE_BLOCK[m.chat.id] = "manualblock"
|
125 |
await m.reply_text(text="Reloaded all admins in this chat!")
|
|
|
126 |
except RPCError as ef:
|
127 |
await m.reply_text(
|
128 |
text=f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
|
|
165 |
user_id, user_first_name, user_name = await extract_user(c, m)
|
166 |
except Exception:
|
167 |
return
|
168 |
+
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
169 |
+
if user_id == c.me.id:
|
170 |
await m.reply_text("Huh, how can I even promote myself?")
|
171 |
return
|
172 |
if not bot.privileges.can_promote_members:
|
|
|
206 |
except Exception as e:
|
207 |
LOGGER.error(e)
|
208 |
LOGGER.error(format_exc())
|
|
|
|
|
|
|
209 |
await m.reply_text(
|
210 |
(
|
211 |
"{promoter} promoted {promoted} in chat <b>{chat_title}</b> with full rights!"
|
|
|
258 |
user_id, user_first_name, user_name = await extract_user(c, m)
|
259 |
except Exception:
|
260 |
return
|
261 |
+
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
262 |
+
if user_id == c.me.id:
|
263 |
await m.reply_text("Huh, how can I even promote myself?")
|
264 |
return
|
265 |
if not bot.privileges.can_promote_members:
|
|
|
289 |
can_pin_messages=bot.privileges.can_pin_messages,
|
290 |
can_manage_chat=bot.privileges.can_manage_chat,
|
291 |
can_manage_video_chats=bot.privileges.can_manage_video_chats,
|
292 |
+
can_post_messages=bot.privileges.can_post_messages,
|
293 |
+
can_edit_messages=bot.privileges.can_edit_messages
|
294 |
),
|
295 |
)
|
296 |
title = ""
|
|
|
308 |
except Exception as e:
|
309 |
LOGGER.error(e)
|
310 |
LOGGER.error(format_exc())
|
311 |
+
|
|
|
|
|
312 |
await m.reply_text(
|
313 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
314 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
|
|
357 |
user_id, user_first_name, _ = await extract_user(c, m)
|
358 |
except Exception:
|
359 |
return
|
360 |
+
if user_id == c.me.id:
|
361 |
await m.reply_text("Get an admin to demote me!")
|
362 |
return
|
363 |
# If user not already admin
|
|
|
377 |
user_id=user_id,
|
378 |
privileges=ChatPrivileges(can_manage_chat=False),
|
379 |
)
|
|
|
380 |
# ----- Remove admin from cache -----
|
381 |
try:
|
382 |
admin_list = ADMIN_CACHE[m.chat.id]
|
|
|
405 |
await m.reply_text(
|
406 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
407 |
)
|
408 |
+
except BotChannelsNa:
|
409 |
+
await m.reply_text("May be the user is bot and due to telegram restrictions I can't demote them. Please do it manually")
|
410 |
except RPCError as ef:
|
411 |
await m.reply_text(
|
412 |
f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
|
|
419 |
@Gojo.on_message(command("invitelink"))
|
420 |
async def get_invitelink(c: Gojo, m: Message):
|
421 |
# Bypass the bot devs, sudos and owner
|
422 |
+
|
423 |
+
DEV_LEVEL = DEV_USERS
|
424 |
if m.from_user.id not in DEV_LEVEL:
|
425 |
user = await m.chat.get_member(m.from_user.id)
|
426 |
if not user.privileges.can_invite_users and user.status != CMS.OWNER:
|
|
|
432 |
text=f"Invite Link for Chat <b>{m.chat.id}</b>: {link}",
|
433 |
disable_web_page_preview=True,
|
434 |
)
|
|
|
435 |
except ChatAdminRequired:
|
436 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
437 |
except ChatAdminInviteRequired:
|
|
|
508 |
return
|
509 |
if not user_id:
|
510 |
return await m.reply_text("Cannot find user!")
|
511 |
+
if user_id == c.me.id:
|
512 |
return await m.reply_text("Huh, why ?")
|
513 |
if not reason:
|
514 |
return await m.reply_text("Read /help please!")
|
Powers/plugins/afk.py
ADDED
@@ -0,0 +1,158 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datetime import datetime
|
2 |
+
from random import choice
|
3 |
+
|
4 |
+
from pyrogram import ContinuePropagation, filters
|
5 |
+
from pyrogram.enums import ParseMode as PM
|
6 |
+
from pyrogram.types import Message
|
7 |
+
|
8 |
+
from Powers.bot_class import Gojo
|
9 |
+
from Powers.database.afk_db import AFK
|
10 |
+
from Powers.plugins import till_date
|
11 |
+
from Powers.utils.cmd_senders import send_cmd
|
12 |
+
from Powers.utils.custom_filters import afk_filter, command
|
13 |
+
from Powers.utils.msg_types import Types, get_afk_type
|
14 |
+
|
15 |
+
res = [
|
16 |
+
"{first} is resting for a while...",
|
17 |
+
"{first} living his real life, go and live yours.",
|
18 |
+
"{first} is quite busy now-a-days.",
|
19 |
+
"I am looking for {first} too...tell me if you see him/her around",
|
20 |
+
"{first} ran away from the chat...",
|
21 |
+
"{first} is busy in his/her work ||simping||",
|
22 |
+
"{first} is busy saving the world",
|
23 |
+
"{first} is now tired fighting all the curses"
|
24 |
+
]
|
25 |
+
|
26 |
+
back = [
|
27 |
+
"{first} is finally back to life",
|
28 |
+
"{first} welcome back",
|
29 |
+
"{first} the spy is back watch what you talk about"
|
30 |
+
"{first} is now finally back from the dead"
|
31 |
+
]
|
32 |
+
|
33 |
+
@Gojo.on_message(command(["afk","brb"]) & ~filters.private)
|
34 |
+
async def going_afk(c: Gojo, m: Message):
|
35 |
+
user = m.from_user.id
|
36 |
+
chat = m.chat.id
|
37 |
+
afk = AFK()
|
38 |
+
text, data_type, content = await get_afk_type(m)
|
39 |
+
|
40 |
+
time = str(datetime.now()).rsplit(".",1)[0]
|
41 |
+
|
42 |
+
if len(m.command) == 1:
|
43 |
+
text = choice(res)
|
44 |
+
|
45 |
+
elif len(m.command) > 1:
|
46 |
+
text = m.text.markdown.split(None,1)[1]
|
47 |
+
|
48 |
+
if not data_type:
|
49 |
+
data_type = Types.TEXT
|
50 |
+
|
51 |
+
afk.insert_afk(chat,user,str(time),text,data_type,content)
|
52 |
+
|
53 |
+
await m.reply_text(f"{m.from_user.mention} is now AFK")
|
54 |
+
|
55 |
+
return
|
56 |
+
|
57 |
+
async def get_hours(hour:str):
|
58 |
+
tim = hour.strip().split(":")
|
59 |
+
txt = ""
|
60 |
+
if int(tim[0]):
|
61 |
+
txt += tim[0] + " hours "
|
62 |
+
if int(tim[1]):
|
63 |
+
txt += tim[1] + " minutes "
|
64 |
+
if int(round(float(tim[2]))):
|
65 |
+
txt += str(round(float(tim[2]))) + " seconds"
|
66 |
+
|
67 |
+
return txt
|
68 |
+
|
69 |
+
|
70 |
+
@Gojo.on_message(afk_filter & filters.group, 10000)
|
71 |
+
async def afk_checker(c: Gojo, m: Message):
|
72 |
+
afk = AFK()
|
73 |
+
back_ = choice(back)
|
74 |
+
user = m.from_user.id
|
75 |
+
chat = m.chat.id
|
76 |
+
repl = m.reply_to_message
|
77 |
+
|
78 |
+
if repl and repl.from_user:
|
79 |
+
rep_user = repl.from_user.id
|
80 |
+
else:
|
81 |
+
rep_user = False
|
82 |
+
|
83 |
+
is_afk = afk.check_afk(chat,user)
|
84 |
+
is_rep_afk = False
|
85 |
+
if rep_user:
|
86 |
+
is_rep_afk = afk.check_afk(chat,rep_user)
|
87 |
+
|
88 |
+
if is_rep_afk and rep_user != user:
|
89 |
+
con = afk.get_afk(chat,rep_user)
|
90 |
+
time = till_date(con["time"])
|
91 |
+
media = con["media"]
|
92 |
+
media_type = con["media_type"]
|
93 |
+
tim_ = datetime.now() - time
|
94 |
+
tim_ = str(tim_).split(",")
|
95 |
+
tim = await get_hours(tim_[-1])
|
96 |
+
if len(tim_) == 1:
|
97 |
+
tims = tim
|
98 |
+
elif len(tim_) == 2:
|
99 |
+
tims = tim_[0] + " " + tim
|
100 |
+
reason = f"{repl.from_user.first_name} is afk since {tims}\n"
|
101 |
+
if con['reason'] not in res:
|
102 |
+
reason += f"\nDue to: {con['reason'].format(first=repl.from_user.first_name)}"
|
103 |
+
else:
|
104 |
+
reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
|
105 |
+
txt = reason
|
106 |
+
|
107 |
+
if media_type == Types.TEXT:
|
108 |
+
await (await send_cmd(c,media_type))(
|
109 |
+
chat,
|
110 |
+
txt,
|
111 |
+
parse_mode=PM.MARKDOWN,
|
112 |
+
reply_to_message_id=m.id,
|
113 |
+
)
|
114 |
+
else:
|
115 |
+
await (await send_cmd(c,media_type))(
|
116 |
+
chat,
|
117 |
+
media,
|
118 |
+
txt,
|
119 |
+
parse_mode=PM.MARKDOWN,
|
120 |
+
reply_to_message_id=repl.id
|
121 |
+
)
|
122 |
+
|
123 |
+
if is_afk:
|
124 |
+
txt = False
|
125 |
+
try:
|
126 |
+
txt = m.command[0]
|
127 |
+
except Exception:
|
128 |
+
pass
|
129 |
+
|
130 |
+
if txt and txt in ["afk","brb"]:
|
131 |
+
raise ContinuePropagation
|
132 |
+
else:
|
133 |
+
con = afk.get_afk(chat,user)
|
134 |
+
time = till_date(con["time"])
|
135 |
+
tim_ = datetime.now() - time
|
136 |
+
tim_ = str(tim_).split(",")
|
137 |
+
tim = await get_hours(tim_[-1])
|
138 |
+
if len(tim_) == 1:
|
139 |
+
tims = tim
|
140 |
+
elif len(tim_) == 2:
|
141 |
+
tims = tim_[0] + " " + tim
|
142 |
+
txt = back_.format(first=m.from_user.mention) + f"\n\nAfk for: {tims}"
|
143 |
+
await m.reply_text(txt)
|
144 |
+
afk.delete_afk(chat,user)
|
145 |
+
raise ContinuePropagation
|
146 |
+
|
147 |
+
__PLUGIN__ = "afk"
|
148 |
+
|
149 |
+
_DISABLE_CMDS_ = ["afk","brb"]
|
150 |
+
|
151 |
+
__alt_name__ = ["brb"]
|
152 |
+
|
153 |
+
__HELP__ = """
|
154 |
+
**AFK**
|
155 |
+
• /afk (/brb) [reason | reply to a message]
|
156 |
+
|
157 |
+
`reply to a message` can be any media or text
|
158 |
+
"""
|
Powers/plugins/antispam.py
CHANGED
@@ -5,20 +5,18 @@ from traceback import format_exc
|
|
5 |
from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
|
6 |
from pyrogram.types import Message
|
7 |
|
8 |
-
from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP,
|
|
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.antispam_db import GBan
|
11 |
from Powers.database.users_db import Users
|
12 |
-
from Powers.supports import get_support_staff
|
13 |
from Powers.utils.clean_file import remove_markdown_and_html
|
14 |
from Powers.utils.custom_filters import command
|
15 |
from Powers.utils.extract_user import extract_user
|
16 |
from Powers.utils.parser import mention_html
|
17 |
-
from Powers.vars import Config
|
18 |
|
19 |
# Initialize
|
20 |
db = GBan()
|
21 |
-
SUPPORT_STAFF = get_support_staff()
|
22 |
|
23 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
24 |
async def gban(c: Gojo, m: Message):
|
@@ -39,11 +37,13 @@ async def gban(c: Gojo, m: Message):
|
|
39 |
else:
|
40 |
gban_reason = m.text.split(None, 2)[2]
|
41 |
|
|
|
|
|
42 |
if user_id in SUPPORT_STAFF:
|
43 |
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
|
44 |
return
|
45 |
|
46 |
-
if user_id ==
|
47 |
await m.reply_text(
|
48 |
text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......"
|
49 |
)
|
@@ -60,7 +60,6 @@ async def gban(c: Gojo, m: Message):
|
|
60 |
f"Added {user_first_name} to GBan List. \n They will now be banned in all groups where I'm admin!"
|
61 |
)
|
62 |
)
|
63 |
-
LOGGER.info(f"{m.from_user.id} gbanned {user_id} from {m.chat.id}")
|
64 |
date = datetime.utcnow().strftime("%H:%M - %d-%m-%Y")
|
65 |
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}"
|
66 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
@@ -70,6 +69,10 @@ async def gban(c: Gojo, m: Message):
|
|
70 |
user_id,
|
71 |
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}",
|
72 |
)
|
|
|
|
|
|
|
|
|
73 |
except UserIsBlocked:
|
74 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
75 |
except PeerIdInvalid:
|
@@ -92,11 +95,13 @@ async def ungban(c: Gojo, m: Message):
|
|
92 |
|
93 |
user_id, user_first_name, _ = await extract_user(c, m)
|
94 |
|
|
|
|
|
95 |
if user_id in SUPPORT_STAFF:
|
96 |
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
|
97 |
return
|
98 |
|
99 |
-
if user_id ==
|
100 |
await m.reply_text(
|
101 |
text="""You can't gban me nigga!
|
102 |
Fuck yourself.......!"""
|
@@ -107,7 +112,6 @@ async def ungban(c: Gojo, m: Message):
|
|
107 |
db.remove_gban(user_id)
|
108 |
await m.reply_text(text=f"Removed {user_first_name} from Global Ban List.")
|
109 |
time = ((datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),)
|
110 |
-
LOGGER.info(f"{m.from_user.id} ungbanned {user_id} from {m.chat.id}")
|
111 |
log_msg = f"""#UNGBAN
|
112 |
<b>Originated from:</b> {m.chat.id}
|
113 |
<b>Admin:</b> {(await mention_html(m.from_user.first_name, m.from_user.id))}
|
@@ -137,7 +141,6 @@ async def gban_count(_, m: Message):
|
|
137 |
await m.reply_text(
|
138 |
text=f"Number of people gbanned: <code>{(db.count_gbans())}</code>"
|
139 |
)
|
140 |
-
LOGGER.info(f"{m.from_user.id} counting gbans in {m.chat.id}")
|
141 |
return
|
142 |
|
143 |
|
@@ -153,7 +156,8 @@ async def gban_list(_, m: Message):
|
|
153 |
|
154 |
banfile = "Here are all the globally banned geys!\n\n"
|
155 |
for user in banned_users:
|
156 |
-
|
|
|
157 |
if user["reason"]:
|
158 |
banfile += f"<b>Reason:</b> {user['reason']}\n"
|
159 |
|
@@ -166,6 +170,20 @@ async def gban_list(_, m: Message):
|
|
166 |
document=f, caption="Here are all the globally banned geys!\n\n"
|
167 |
)
|
168 |
|
169 |
-
LOGGER.info(f"{m.from_user.id} exported gbanlist in {m.chat.id}")
|
170 |
|
171 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from pyrogram.errors import MessageTooLong, PeerIdInvalid, UserIsBlocked
|
6 |
from pyrogram.types import Message
|
7 |
|
8 |
+
from Powers import (DEV_USERS, LOGGER, MESSAGE_DUMP, SUDO_USERS, SUPPORT_GROUP,
|
9 |
+
WHITELIST_USERS)
|
10 |
from Powers.bot_class import Gojo
|
11 |
from Powers.database.antispam_db import GBan
|
12 |
from Powers.database.users_db import Users
|
|
|
13 |
from Powers.utils.clean_file import remove_markdown_and_html
|
14 |
from Powers.utils.custom_filters import command
|
15 |
from Powers.utils.extract_user import extract_user
|
16 |
from Powers.utils.parser import mention_html
|
|
|
17 |
|
18 |
# Initialize
|
19 |
db = GBan()
|
|
|
20 |
|
21 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
22 |
async def gban(c: Gojo, m: Message):
|
|
|
37 |
else:
|
38 |
gban_reason = m.text.split(None, 2)[2]
|
39 |
|
40 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
41 |
+
|
42 |
if user_id in SUPPORT_STAFF:
|
43 |
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
|
44 |
return
|
45 |
|
46 |
+
if user_id == c.me.id:
|
47 |
await m.reply_text(
|
48 |
text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......"
|
49 |
)
|
|
|
60 |
f"Added {user_first_name} to GBan List. \n They will now be banned in all groups where I'm admin!"
|
61 |
)
|
62 |
)
|
|
|
63 |
date = datetime.utcnow().strftime("%H:%M - %d-%m-%Y")
|
64 |
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}"
|
65 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
|
|
69 |
user_id,
|
70 |
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}",
|
71 |
)
|
72 |
+
try:
|
73 |
+
await c.ban_chat_member(m.chat.id, user_id)
|
74 |
+
except Exception as e:
|
75 |
+
await m.reply_text(f"Failed to ban this user\n{e}")
|
76 |
except UserIsBlocked:
|
77 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
78 |
except PeerIdInvalid:
|
|
|
95 |
|
96 |
user_id, user_first_name, _ = await extract_user(c, m)
|
97 |
|
98 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
99 |
+
|
100 |
if user_id in SUPPORT_STAFF:
|
101 |
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
|
102 |
return
|
103 |
|
104 |
+
if user_id == c.me.id:
|
105 |
await m.reply_text(
|
106 |
text="""You can't gban me nigga!
|
107 |
Fuck yourself.......!"""
|
|
|
112 |
db.remove_gban(user_id)
|
113 |
await m.reply_text(text=f"Removed {user_first_name} from Global Ban List.")
|
114 |
time = ((datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),)
|
|
|
115 |
log_msg = f"""#UNGBAN
|
116 |
<b>Originated from:</b> {m.chat.id}
|
117 |
<b>Admin:</b> {(await mention_html(m.from_user.first_name, m.from_user.id))}
|
|
|
141 |
await m.reply_text(
|
142 |
text=f"Number of people gbanned: <code>{(db.count_gbans())}</code>"
|
143 |
)
|
|
|
144 |
return
|
145 |
|
146 |
|
|
|
156 |
|
157 |
banfile = "Here are all the globally banned geys!\n\n"
|
158 |
for user in banned_users:
|
159 |
+
USER = Users.get_user_info(user['_id'])
|
160 |
+
banfile += f"[x] <b>{USER['name'] if USER else 'Name NA'}</b> - <code>{user['_id']}</code>\n"
|
161 |
if user["reason"]:
|
162 |
banfile += f"<b>Reason:</b> {user['reason']}\n"
|
163 |
|
|
|
170 |
document=f, caption="Here are all the globally banned geys!\n\n"
|
171 |
)
|
172 |
|
|
|
173 |
|
174 |
return
|
175 |
+
|
176 |
+
__PLUGIN__ = "global"
|
177 |
+
|
178 |
+
__alt_name__ = ["antispam", "global"]
|
179 |
+
|
180 |
+
|
181 |
+
__HELP__ = """
|
182 |
+
**Global**
|
183 |
+
|
184 |
+
**Sudo commands:**
|
185 |
+
• /gban [reply to user | user id | username]: Add the user in the global ban watchlist.
|
186 |
+
• /ungban [reply to user | user id | username]: Remove the user from the global ban watchlist.
|
187 |
+
• /numgbans : Give number of users who are banned globally.
|
188 |
+
• /gbanlist : Give list of globally banned users.
|
189 |
+
"""
|
Powers/plugins/approve.py
CHANGED
@@ -51,7 +51,6 @@ async def approve_user(c: Gojo, m: Message):
|
|
51 |
)
|
52 |
return
|
53 |
db.add_approve(user_id, user_first_name)
|
54 |
-
LOGGER.info(f"{user_id} approved by {m.from_user.id} in {m.chat.id}")
|
55 |
|
56 |
# Allow all permissions
|
57 |
try:
|
@@ -90,7 +89,6 @@ async def disapprove_user(c: Gojo, m: Message):
|
|
90 |
except UserNotParticipant:
|
91 |
if already_approved: # If user is approved and not in chat, unapprove them.
|
92 |
db.remove_approve(user_id)
|
93 |
-
LOGGER.info(f"{user_id} disapproved in {m.chat.id} as UserNotParticipant")
|
94 |
await m.reply_text("This user is not in this chat, unapproved them.")
|
95 |
return
|
96 |
except RPCError as ef:
|
@@ -110,7 +108,6 @@ async def disapprove_user(c: Gojo, m: Message):
|
|
110 |
return
|
111 |
|
112 |
db.remove_approve(user_id)
|
113 |
-
LOGGER.info(f"{user_id} disapproved by {m.from_user.id} in {m.chat.id}")
|
114 |
|
115 |
# Set permission same as of current user by fetching them from chat!
|
116 |
await m.chat.restrict_member(
|
@@ -147,7 +144,6 @@ async def check_approved(_, m: Message):
|
|
147 |
pass
|
148 |
msg += f"- `{user_id}`: {user_name}\n"
|
149 |
await m.reply_text(msg)
|
150 |
-
LOGGER.info(f"{m.from_user.id} checking approved users in {m.chat.id}")
|
151 |
return
|
152 |
|
153 |
|
@@ -160,7 +156,6 @@ async def check_approval(c: Gojo, m: Message):
|
|
160 |
except Exception:
|
161 |
return
|
162 |
check_approve = db.check_approve(user_id)
|
163 |
-
LOGGER.info(f"{m.from_user.id} checking approval of {user_id} in {m.chat.id}")
|
164 |
|
165 |
if not user_id:
|
166 |
await m.reply_text(
|
@@ -218,7 +213,6 @@ async def unapproveall_callback(_, q: CallbackQuery):
|
|
218 |
permissions=q.message.chat.permissions,
|
219 |
)
|
220 |
await q.message.delete()
|
221 |
-
LOGGER.info(f"{user_id} disapproved all users in {q.message.chat.id}")
|
222 |
await q.answer("Disapproved all users!", show_alert=True)
|
223 |
return
|
224 |
|
|
|
51 |
)
|
52 |
return
|
53 |
db.add_approve(user_id, user_first_name)
|
|
|
54 |
|
55 |
# Allow all permissions
|
56 |
try:
|
|
|
89 |
except UserNotParticipant:
|
90 |
if already_approved: # If user is approved and not in chat, unapprove them.
|
91 |
db.remove_approve(user_id)
|
|
|
92 |
await m.reply_text("This user is not in this chat, unapproved them.")
|
93 |
return
|
94 |
except RPCError as ef:
|
|
|
108 |
return
|
109 |
|
110 |
db.remove_approve(user_id)
|
|
|
111 |
|
112 |
# Set permission same as of current user by fetching them from chat!
|
113 |
await m.chat.restrict_member(
|
|
|
144 |
pass
|
145 |
msg += f"- `{user_id}`: {user_name}\n"
|
146 |
await m.reply_text(msg)
|
|
|
147 |
return
|
148 |
|
149 |
|
|
|
156 |
except Exception:
|
157 |
return
|
158 |
check_approve = db.check_approve(user_id)
|
|
|
159 |
|
160 |
if not user_id:
|
161 |
await m.reply_text(
|
|
|
213 |
permissions=q.message.chat.permissions,
|
214 |
)
|
215 |
await q.message.delete()
|
|
|
216 |
await q.answer("Disapproved all users!", show_alert=True)
|
217 |
return
|
218 |
|
Powers/plugins/auto_join.py
ADDED
@@ -0,0 +1,185 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from traceback import format_exc
|
2 |
+
|
3 |
+
from pyrogram import filters
|
4 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
5 |
+
from pyrogram.types import CallbackQuery, ChatJoinRequest
|
6 |
+
from pyrogram.types import InlineKeyboardButton as ikb
|
7 |
+
from pyrogram.types import InlineKeyboardMarkup as ikm
|
8 |
+
from pyrogram.types import Message
|
9 |
+
|
10 |
+
from Powers import DEV_USERS, LOGGER, SUDO_USERS, WHITELIST_USERS
|
11 |
+
from Powers.bot_class import Gojo
|
12 |
+
from Powers.database.autojoin_db import AUTOJOIN
|
13 |
+
from Powers.utils.custom_filters import admin_filter, auto_join_filter, command
|
14 |
+
|
15 |
+
|
16 |
+
@Gojo.on_message(command(["joinreq"]) & admin_filter)
|
17 |
+
async def accept_join_requests(c: Gojo, m: Message):
|
18 |
+
if m.chat.id == m.from_user.id:
|
19 |
+
await m.reply_text("Use it in groups")
|
20 |
+
return
|
21 |
+
|
22 |
+
split = m.command
|
23 |
+
a_j = AUTOJOIN()
|
24 |
+
|
25 |
+
try:
|
26 |
+
status = (await m.chat.get_member(c.me.id)).status
|
27 |
+
if status != CMS.ADMINISTRATOR:
|
28 |
+
await m.reply_text("I should be admin to accept and reject join requests")
|
29 |
+
return
|
30 |
+
except Exception as ef:
|
31 |
+
await m.reply_text(f"Some error occured, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
32 |
+
LOGGER.error(ef)
|
33 |
+
LOGGER.error(format_exc())
|
34 |
+
return
|
35 |
+
if len(split) == 1:
|
36 |
+
txt = "**USAGE**\n/joinreq [on | off]"
|
37 |
+
await m.reply_text(txt)
|
38 |
+
return
|
39 |
+
else:
|
40 |
+
yes_no = split[1].lower()
|
41 |
+
if yes_no not in ["on","off"]:
|
42 |
+
txt = "**USAGE**\n/joinreq [on | off]"
|
43 |
+
await m.reply_text(txt)
|
44 |
+
return
|
45 |
+
|
46 |
+
else:
|
47 |
+
if yes_no == "on":
|
48 |
+
is_al = a_j.load_autojoin(m.chat.id)
|
49 |
+
|
50 |
+
if is_al:
|
51 |
+
txt = "Now I will approve all the join request of the chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
|
52 |
+
await m.reply_text(txt)
|
53 |
+
return
|
54 |
+
else:
|
55 |
+
txt = "Auto approve join request is already on for this chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
|
56 |
+
await m.reply_text(txt)
|
57 |
+
return
|
58 |
+
|
59 |
+
elif yes_no == "off":
|
60 |
+
a_j.remove_autojoin(m.chat.id)
|
61 |
+
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
62 |
+
await m.reply_text(txt)
|
63 |
+
return
|
64 |
+
|
65 |
+
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
66 |
+
async def join_request_mode(c: Gojo, m: Message):
|
67 |
+
if m.chat.id == m.from_user.id:
|
68 |
+
await m.reply_text("Use it in groups")
|
69 |
+
return
|
70 |
+
u_text = "**USAGE**\n/joinreqmode [auto | manual]\nauto: auto approve joins\nmanual: will notify admin about the join request"
|
71 |
+
|
72 |
+
split = m.command
|
73 |
+
a_j = AUTOJOIN()
|
74 |
+
|
75 |
+
if len(split) == 1:
|
76 |
+
await m.reply_text(u_text)
|
77 |
+
return
|
78 |
+
|
79 |
+
else:
|
80 |
+
auto_manual = split[1]
|
81 |
+
if auto_manual not in ["auto","manual"]:
|
82 |
+
await m.reply_text(u_text)
|
83 |
+
return
|
84 |
+
else:
|
85 |
+
a_j.update_join_type(m.chat.id,auto_manual)
|
86 |
+
txt = "Changed join request type"
|
87 |
+
await m.reply_text(txt)
|
88 |
+
return
|
89 |
+
|
90 |
+
|
91 |
+
@Gojo.on_chat_join_request(auto_join_filter)
|
92 |
+
async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
93 |
+
user = j.from_user.id
|
94 |
+
userr = j.from_user
|
95 |
+
chat = j.chat.id
|
96 |
+
aj = AUTOJOIN()
|
97 |
+
join_type = aj.get_autojoin(chat)
|
98 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
99 |
+
|
100 |
+
if not join_type:
|
101 |
+
return
|
102 |
+
if join_type == "auto" or user in SUPPORT_STAFF:
|
103 |
+
try:
|
104 |
+
await c.approve_chat_join_request(chat,user)
|
105 |
+
await c.send_message(chat, f"Accepted join request of the {userr.mention}")
|
106 |
+
return
|
107 |
+
except Exception as ef:
|
108 |
+
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
109 |
+
LOGGER.error(ef)
|
110 |
+
LOGGER.error(format_exc())
|
111 |
+
return
|
112 |
+
elif join_type == "manual":
|
113 |
+
txt = "New join request is available\n**USER's INFO**\n"
|
114 |
+
txt += f"Name: {userr.full_name}"
|
115 |
+
txt += f"Mention: {userr.mention}"
|
116 |
+
txt += f"Id: {user}"
|
117 |
+
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
118 |
+
if userr.username:
|
119 |
+
txt+= f"Username: @{userr.username}"
|
120 |
+
kb = [
|
121 |
+
[
|
122 |
+
ikb("Accept",f"accept_joinreq_uest_{user}"),
|
123 |
+
ikb("Decline",f"decline_joinreq_uest_{user}")
|
124 |
+
]
|
125 |
+
]
|
126 |
+
await c.send_message(chat,txt,reply_markup=ikm(kb))
|
127 |
+
return
|
128 |
+
|
129 |
+
@Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
|
130 |
+
async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
131 |
+
user_id = q.from_user.id
|
132 |
+
chat = q.message.chat.id
|
133 |
+
try:
|
134 |
+
user_status = (await q.message.chat.get_member(user_id)).status
|
135 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
136 |
+
await q.answer(
|
137 |
+
"You're not even an admin, don't try this explosive shit!",
|
138 |
+
show_alert=True,
|
139 |
+
)
|
140 |
+
return
|
141 |
+
except:
|
142 |
+
await q.answer("Unknow error occured. You are not admin or owner")
|
143 |
+
return
|
144 |
+
split = q.data.split("_")
|
145 |
+
chat = q.message.chat.id
|
146 |
+
user = int(split[-1])
|
147 |
+
data = split[0]
|
148 |
+
try:
|
149 |
+
userr = await c.get_users(user)
|
150 |
+
except:
|
151 |
+
userr = None
|
152 |
+
if data == "accept":
|
153 |
+
try:
|
154 |
+
await c.approve_chat_join_request(chat,user)
|
155 |
+
await q.answer(f"Accepted join request of the {userr.mention if userr else user}",True)
|
156 |
+
await q.edit_message_text(f"Accepted join request of the {userr.mention if userr else user}")
|
157 |
+
except Exception as ef:
|
158 |
+
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
159 |
+
LOGGER.error(ef)
|
160 |
+
LOGGER.error(format_exc())
|
161 |
+
|
162 |
+
elif data == "decline":
|
163 |
+
try:
|
164 |
+
await c.decline_chat_join_request(chat,user)
|
165 |
+
await q.answer(f"DECLINED: {user}")
|
166 |
+
await q.edit_message_text()
|
167 |
+
except Exception as ef:
|
168 |
+
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
169 |
+
LOGGER.error(ef)
|
170 |
+
LOGGER.error(format_exc())
|
171 |
+
|
172 |
+
return
|
173 |
+
|
174 |
+
__PLUGIN__ = "auto join"
|
175 |
+
|
176 |
+
__alt_name__ = ["join_request"]
|
177 |
+
|
178 |
+
|
179 |
+
__HELP__ = """
|
180 |
+
**Auto join request**
|
181 |
+
|
182 |
+
**Admin commands:**
|
183 |
+
• /joinreq [on | off]: To switch on auto accept join request
|
184 |
+
• /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
|
185 |
+
"""
|
Powers/plugins/bans.py
CHANGED
@@ -3,24 +3,22 @@ from traceback import format_exc
|
|
3 |
|
4 |
from pyrogram import enums
|
5 |
from pyrogram.errors import (ChatAdminRequired, PeerIdInvalid, RightForbidden,
|
6 |
-
RPCError, UserAdminInvalid)
|
7 |
from pyrogram.filters import regex
|
8 |
from pyrogram.types import (CallbackQuery, ChatPrivileges,
|
9 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
10 |
Message)
|
11 |
|
12 |
-
from Powers import LOGGER, MESSAGE_DUMP, OWNER_ID
|
|
|
13 |
from Powers.bot_class import Gojo
|
14 |
-
from Powers.supports import get_support_staff
|
15 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
16 |
from Powers.utils.custom_filters import command, restrict_filter
|
17 |
from Powers.utils.extract_user import extract_user
|
18 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS
|
19 |
from Powers.utils.parser import mention_html
|
20 |
from Powers.utils.string import extract_time
|
21 |
-
from Powers.vars import Config
|
22 |
|
23 |
-
SUPPORT_STAFF = get_support_staff()
|
24 |
|
25 |
@Gojo.on_message(command("tban") & restrict_filter)
|
26 |
async def tban_usr(c: Gojo, m: Message):
|
@@ -36,17 +34,17 @@ async def tban_usr(c: Gojo, m: Message):
|
|
36 |
if not user_id:
|
37 |
await m.reply_text("Cannot find user to ban")
|
38 |
return
|
39 |
-
if user_id ==
|
40 |
await m.reply_text("WTF?? Why would I ban myself?")
|
41 |
await m.stop_propagation()
|
42 |
|
|
|
|
|
43 |
if user_id in SUPPORT_STAFF:
|
44 |
await m.reply_text(
|
45 |
text="This user is in my support staff, cannot restrict them."
|
46 |
)
|
47 |
-
|
48 |
-
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
49 |
-
)
|
50 |
await m.stop_propagation()
|
51 |
|
52 |
r_id = m.reply_to_message.id if m.reply_to_message else m.id
|
@@ -85,7 +83,6 @@ async def tban_usr(c: Gojo, m: Message):
|
|
85 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
86 |
banned = await mention_html(user_first_name, user_id)
|
87 |
chat_title = m.chat.title
|
88 |
-
LOGGER.info(f"{m.from_user.id} tbanned {user_id} in {m.chat.id}")
|
89 |
await m.chat.ban_member(
|
90 |
user_id,
|
91 |
until_date=bantime)
|
@@ -137,6 +134,8 @@ async def tban_usr(c: Gojo, m: Message):
|
|
137 |
await m.reply_text(
|
138 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
139 |
)
|
|
|
|
|
140 |
except RightForbidden:
|
141 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
142 |
except RPCError as ef:
|
@@ -158,6 +157,8 @@ async def stban_usr(c: Gojo, m: Message):
|
|
158 |
await m.reply_text(text="I can't ban nothing!")
|
159 |
await m.stop_propagation()
|
160 |
|
|
|
|
|
161 |
try:
|
162 |
user_id, _, _ = await extract_user(c, m)
|
163 |
except Exception:
|
@@ -166,7 +167,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
166 |
if not user_id:
|
167 |
await m.reply_text("Cannot find user to ban")
|
168 |
return
|
169 |
-
if user_id ==
|
170 |
await m.reply_text("What the heck? Why would I ban myself?")
|
171 |
await m.stop_propagation()
|
172 |
|
@@ -174,9 +175,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
174 |
await m.reply_text(
|
175 |
text="This user is in my support staff, cannot restrict them."
|
176 |
)
|
177 |
-
|
178 |
-
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
179 |
-
)
|
180 |
await m.stop_propagation()
|
181 |
|
182 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
@@ -210,7 +209,6 @@ async def stban_usr(c: Gojo, m: Message):
|
|
210 |
await m.stop_propagation()
|
211 |
|
212 |
try:
|
213 |
-
LOGGER.info(f"{m.from_user.id} stbanned {user_id} in {m.chat.id}")
|
214 |
await m.chat.ban_member(user_id, until_date=bantime)
|
215 |
await m.delete()
|
216 |
if m.reply_to_message:
|
@@ -227,6 +225,8 @@ async def stban_usr(c: Gojo, m: Message):
|
|
227 |
await m.reply_text(
|
228 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
229 |
)
|
|
|
|
|
230 |
except RightForbidden:
|
231 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
232 |
except RPCError as ef:
|
@@ -258,15 +258,15 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
258 |
if not user_id:
|
259 |
await m.reply_text("Cannot find user to ban")
|
260 |
return
|
261 |
-
if user_id ==
|
262 |
await m.reply_text("Huh, why would I ban myself?")
|
263 |
await m.stop_propagation()
|
264 |
|
|
|
|
|
265 |
if user_id in SUPPORT_STAFF:
|
266 |
await m.reply_text(text="I am not going to ban one of my support staff")
|
267 |
-
|
268 |
-
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
269 |
-
)
|
270 |
await m.stop_propagation()
|
271 |
|
272 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
@@ -303,7 +303,6 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
303 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
304 |
banned = await mention_html(user_first_name, user_id)
|
305 |
chat_title = m.chat.title
|
306 |
-
LOGGER.info(f"{m.from_user.id} dtbanned {user_id} in {m.chat.id}")
|
307 |
await m.chat.ban_member(user_id, until_date=bantime)
|
308 |
await m.reply_to_message.delete()
|
309 |
txt = f"{admin} banned {banned} in <b>{chat_title}</b>!"
|
@@ -386,17 +385,17 @@ async def kick_usr(c: Gojo, m: Message):
|
|
386 |
await m.reply_text("Cannot find user to kick")
|
387 |
return
|
388 |
|
389 |
-
if user_id ==
|
390 |
await m.reply_text("Huh, why would I kick myself?")
|
391 |
await m.stop_propagation()
|
392 |
|
|
|
|
|
393 |
if user_id in SUPPORT_STAFF:
|
394 |
await m.reply_text(
|
395 |
text="This user is in my support staff, cannot restrict them."
|
396 |
)
|
397 |
-
|
398 |
-
f"{m.from_user.id} trying to kick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
399 |
-
)
|
400 |
await m.stop_propagation()
|
401 |
|
402 |
try:
|
@@ -412,7 +411,6 @@ async def kick_usr(c: Gojo, m: Message):
|
|
412 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
413 |
kicked = await mention_html(user_first_name, user_id)
|
414 |
chat_title = m.chat.title
|
415 |
-
LOGGER.info(f"{m.from_user.id} kicked {user_id} in {m.chat.id}")
|
416 |
await m.chat.ban_member(user_id)
|
417 |
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
418 |
if reason:
|
@@ -444,6 +442,8 @@ async def kick_usr(c: Gojo, m: Message):
|
|
444 |
await m.reply_text(
|
445 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
446 |
)
|
|
|
|
|
447 |
except RightForbidden:
|
448 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
449 |
except RPCError as ef:
|
@@ -473,17 +473,17 @@ async def skick_usr(c: Gojo, m: Message):
|
|
473 |
await m.reply_text("Cannot find user to kick")
|
474 |
return
|
475 |
|
476 |
-
if user_id ==
|
477 |
-
await m.reply_text("
|
478 |
await m.stop_propagation()
|
479 |
|
|
|
|
|
480 |
if user_id in SUPPORT_STAFF:
|
481 |
await m.reply_text(
|
482 |
text="This user is in my support staff, cannot restrict them."
|
483 |
)
|
484 |
-
|
485 |
-
f"{m.from_user.id} trying to skick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
486 |
-
)
|
487 |
await m.stop_propagation()
|
488 |
|
489 |
try:
|
@@ -496,7 +496,6 @@ async def skick_usr(c: Gojo, m: Message):
|
|
496 |
await m.stop_propagation()
|
497 |
|
498 |
try:
|
499 |
-
LOGGER.info(f"{m.from_user.id} skicked {user_id} in {m.chat.id}")
|
500 |
await m.chat.ban_member(user_id)
|
501 |
await m.delete()
|
502 |
if m.reply_to_message:
|
@@ -512,6 +511,8 @@ async def skick_usr(c: Gojo, m: Message):
|
|
512 |
await m.reply_text(
|
513 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
514 |
)
|
|
|
|
|
515 |
except RightForbidden:
|
516 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
517 |
except RPCError as ef:
|
@@ -543,17 +544,17 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
543 |
await m.reply_text("Cannot find user to kick")
|
544 |
return
|
545 |
|
546 |
-
if user_id ==
|
547 |
await m.reply_text("Huh, why would I kick myself?")
|
548 |
await m.stop_propagation()
|
549 |
|
|
|
|
|
550 |
if user_id in SUPPORT_STAFF:
|
551 |
await m.reply_text(
|
552 |
text="This user is in my support staff, cannot restrict them."
|
553 |
)
|
554 |
-
|
555 |
-
f"{m.from_user.id} trying to dkick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
556 |
-
)
|
557 |
await m.stop_propagation()
|
558 |
|
559 |
try:
|
@@ -566,7 +567,6 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
566 |
await m.stop_propagation()
|
567 |
|
568 |
try:
|
569 |
-
LOGGER.info(f"{m.from_user.id} dkicked {user_id} in {m.chat.id}")
|
570 |
await m.reply_to_message.delete()
|
571 |
await m.chat.ban_member(user_id)
|
572 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
@@ -601,6 +601,8 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
601 |
)
|
602 |
except RightForbidden:
|
603 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
|
|
|
|
604 |
except RPCError as ef:
|
605 |
await m.reply_text(
|
606 |
text=f"""Some error occured, report it using `/bug`
|
@@ -690,17 +692,16 @@ async def sban_usr(c: Gojo, m: Message):
|
|
690 |
if user_id == m.chat.id:
|
691 |
await m.reply_text("That's an admin!")
|
692 |
await m.stop_propagation()
|
693 |
-
if user_id ==
|
694 |
await m.reply_text("Huh, why would I ban myself?")
|
695 |
await m.stop_propagation()
|
696 |
|
|
|
|
|
697 |
if user_id in SUPPORT_STAFF:
|
698 |
await m.reply_text(
|
699 |
text="This user is in my support staff, cannot restrict them."
|
700 |
)
|
701 |
-
LOGGER.info(
|
702 |
-
f"{m.from_user.id} trying to sban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
703 |
-
)
|
704 |
await m.stop_propagation()
|
705 |
|
706 |
try:
|
@@ -713,7 +714,6 @@ async def sban_usr(c: Gojo, m: Message):
|
|
713 |
await m.stop_propagation()
|
714 |
|
715 |
try:
|
716 |
-
LOGGER.info(f"{m.from_user.id} sbanned {user_id} in {m.chat.id}")
|
717 |
await m.chat.ban_member(user_id)
|
718 |
await m.delete()
|
719 |
if m.reply_to_message:
|
@@ -730,6 +730,8 @@ async def sban_usr(c: Gojo, m: Message):
|
|
730 |
)
|
731 |
except RightForbidden:
|
732 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
|
|
|
|
733 |
except RPCError as ef:
|
734 |
await m.reply_text(
|
735 |
text=f"""Some error occured, report it using `/bug`
|
@@ -767,17 +769,16 @@ async def dban_usr(c: Gojo, m: Message):
|
|
767 |
if user_id == m.chat.id:
|
768 |
await m.reply_text("That's an admin!")
|
769 |
await m.stop_propagation()
|
770 |
-
if user_id ==
|
771 |
await m.reply_text("Huh, why would I ban myself?")
|
772 |
await m.stop_propagation()
|
773 |
|
|
|
|
|
774 |
if user_id in SUPPORT_STAFF:
|
775 |
await m.reply_text(
|
776 |
text="This user is in my support staff, cannot restrict them."
|
777 |
)
|
778 |
-
LOGGER.info(
|
779 |
-
f"{m.from_user.id} trying to dban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
780 |
-
)
|
781 |
await m.stop_propagation()
|
782 |
|
783 |
try:
|
@@ -794,7 +795,6 @@ async def dban_usr(c: Gojo, m: Message):
|
|
794 |
reason = m.text.split(None, 1)[1]
|
795 |
|
796 |
try:
|
797 |
-
LOGGER.info(f"{m.from_user.id} dbanned {user_id} in {m.chat.id}")
|
798 |
await m.reply_to_message.delete()
|
799 |
await m.chat.ban_member(user_id)
|
800 |
txt = f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in <b>{m.chat.title}</b>!"
|
@@ -830,6 +830,8 @@ async def dban_usr(c: Gojo, m: Message):
|
|
830 |
)
|
831 |
except RightForbidden:
|
832 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
|
|
|
|
833 |
except RPCError as ef:
|
834 |
await m.reply_text(
|
835 |
text=f"""Some error occured, report it using `/bug`
|
@@ -864,17 +866,16 @@ async def ban_usr(c: Gojo, m: Message):
|
|
864 |
if user_id == m.chat.id:
|
865 |
await m.reply_text("That's an admin!")
|
866 |
await m.stop_propagation()
|
867 |
-
if user_id ==
|
868 |
await m.reply_text("Huh, why would I ban myself?")
|
869 |
await m.stop_propagation()
|
870 |
|
|
|
|
|
871 |
if user_id in SUPPORT_STAFF:
|
872 |
await m.reply_text(
|
873 |
text="This user is in my support staff, cannot restrict them."
|
874 |
)
|
875 |
-
LOGGER.info(
|
876 |
-
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
877 |
-
)
|
878 |
await m.stop_propagation()
|
879 |
|
880 |
try:
|
@@ -897,7 +898,6 @@ async def ban_usr(c: Gojo, m: Message):
|
|
897 |
reason = m.text.split(None, 2)[2]
|
898 |
|
899 |
try:
|
900 |
-
LOGGER.info(f"{m.from_user.id} banned {user_id} in {m.chat.id}")
|
901 |
await m.chat.ban_member(user_id)
|
902 |
banned = await mention_html(user_first_name, user_id)
|
903 |
txt = f"{m.from_user.mention} banned {banned} in <b>{m.chat.title}</b>!"
|
@@ -938,6 +938,8 @@ async def ban_usr(c: Gojo, m: Message):
|
|
938 |
await m.reply_text(
|
939 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
940 |
)
|
|
|
|
|
941 |
except UserAdminInvalid:
|
942 |
await m.reply_text(
|
943 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
@@ -968,7 +970,7 @@ async def unbanbutton(c: Gojo, q: CallbackQuery):
|
|
968 |
)
|
969 |
return
|
970 |
|
971 |
-
|
972 |
await q.answer(
|
973 |
"You don't have enough permission to do this!\nStay in your limits!",
|
974 |
show_alert=True,
|
@@ -991,7 +993,6 @@ async def kickme(c: Gojo, m: Message):
|
|
991 |
if len(m.text.split()) >= 2:
|
992 |
reason = m.text.split(None, 1)[1]
|
993 |
try:
|
994 |
-
LOGGER.info(f"{m.from_user.id} kickme used by {m.from_user.id} in {m.chat.id}")
|
995 |
mem = await c.get_chat_member(m.chat.id,m.from_user.id)
|
996 |
if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
|
997 |
try:
|
|
|
3 |
|
4 |
from pyrogram import enums
|
5 |
from pyrogram.errors import (ChatAdminRequired, PeerIdInvalid, RightForbidden,
|
6 |
+
RPCError, UserAdminInvalid, UserNotParticipant)
|
7 |
from pyrogram.filters import regex
|
8 |
from pyrogram.types import (CallbackQuery, ChatPrivileges,
|
9 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
10 |
Message)
|
11 |
|
12 |
+
from Powers import (DEV_USERS, LOGGER, MESSAGE_DUMP, OWNER_ID, SUDO_USERS,
|
13 |
+
WHITELIST_USERS)
|
14 |
from Powers.bot_class import Gojo
|
|
|
15 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
16 |
from Powers.utils.custom_filters import command, restrict_filter
|
17 |
from Powers.utils.extract_user import extract_user
|
18 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS
|
19 |
from Powers.utils.parser import mention_html
|
20 |
from Powers.utils.string import extract_time
|
|
|
21 |
|
|
|
22 |
|
23 |
@Gojo.on_message(command("tban") & restrict_filter)
|
24 |
async def tban_usr(c: Gojo, m: Message):
|
|
|
34 |
if not user_id:
|
35 |
await m.reply_text("Cannot find user to ban")
|
36 |
return
|
37 |
+
if user_id == c.me.id:
|
38 |
await m.reply_text("WTF?? Why would I ban myself?")
|
39 |
await m.stop_propagation()
|
40 |
|
41 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
42 |
+
|
43 |
if user_id in SUPPORT_STAFF:
|
44 |
await m.reply_text(
|
45 |
text="This user is in my support staff, cannot restrict them."
|
46 |
)
|
47 |
+
|
|
|
|
|
48 |
await m.stop_propagation()
|
49 |
|
50 |
r_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
|
83 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
84 |
banned = await mention_html(user_first_name, user_id)
|
85 |
chat_title = m.chat.title
|
|
|
86 |
await m.chat.ban_member(
|
87 |
user_id,
|
88 |
until_date=bantime)
|
|
|
134 |
await m.reply_text(
|
135 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
136 |
)
|
137 |
+
except UserNotParticipant:
|
138 |
+
await m.reply_text("User is not part of the group")
|
139 |
except RightForbidden:
|
140 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
141 |
except RPCError as ef:
|
|
|
157 |
await m.reply_text(text="I can't ban nothing!")
|
158 |
await m.stop_propagation()
|
159 |
|
160 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
161 |
+
|
162 |
try:
|
163 |
user_id, _, _ = await extract_user(c, m)
|
164 |
except Exception:
|
|
|
167 |
if not user_id:
|
168 |
await m.reply_text("Cannot find user to ban")
|
169 |
return
|
170 |
+
if user_id == c.me.id:
|
171 |
await m.reply_text("What the heck? Why would I ban myself?")
|
172 |
await m.stop_propagation()
|
173 |
|
|
|
175 |
await m.reply_text(
|
176 |
text="This user is in my support staff, cannot restrict them."
|
177 |
)
|
178 |
+
|
|
|
|
|
179 |
await m.stop_propagation()
|
180 |
|
181 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
209 |
await m.stop_propagation()
|
210 |
|
211 |
try:
|
|
|
212 |
await m.chat.ban_member(user_id, until_date=bantime)
|
213 |
await m.delete()
|
214 |
if m.reply_to_message:
|
|
|
225 |
await m.reply_text(
|
226 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
227 |
)
|
228 |
+
except UserNotParticipant:
|
229 |
+
await m.reply_text("User is not part of the group")
|
230 |
except RightForbidden:
|
231 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
232 |
except RPCError as ef:
|
|
|
258 |
if not user_id:
|
259 |
await m.reply_text("Cannot find user to ban")
|
260 |
return
|
261 |
+
if user_id == c.me.id:
|
262 |
await m.reply_text("Huh, why would I ban myself?")
|
263 |
await m.stop_propagation()
|
264 |
|
265 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
266 |
+
|
267 |
if user_id in SUPPORT_STAFF:
|
268 |
await m.reply_text(text="I am not going to ban one of my support staff")
|
269 |
+
|
|
|
|
|
270 |
await m.stop_propagation()
|
271 |
|
272 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
303 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
304 |
banned = await mention_html(user_first_name, user_id)
|
305 |
chat_title = m.chat.title
|
|
|
306 |
await m.chat.ban_member(user_id, until_date=bantime)
|
307 |
await m.reply_to_message.delete()
|
308 |
txt = f"{admin} banned {banned} in <b>{chat_title}</b>!"
|
|
|
385 |
await m.reply_text("Cannot find user to kick")
|
386 |
return
|
387 |
|
388 |
+
if user_id == c.me.id:
|
389 |
await m.reply_text("Huh, why would I kick myself?")
|
390 |
await m.stop_propagation()
|
391 |
|
392 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
393 |
+
|
394 |
if user_id in SUPPORT_STAFF:
|
395 |
await m.reply_text(
|
396 |
text="This user is in my support staff, cannot restrict them."
|
397 |
)
|
398 |
+
|
|
|
|
|
399 |
await m.stop_propagation()
|
400 |
|
401 |
try:
|
|
|
411 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
412 |
kicked = await mention_html(user_first_name, user_id)
|
413 |
chat_title = m.chat.title
|
|
|
414 |
await m.chat.ban_member(user_id)
|
415 |
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
416 |
if reason:
|
|
|
442 |
await m.reply_text(
|
443 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
444 |
)
|
445 |
+
except UserNotParticipant:
|
446 |
+
await m.reply_text("User is not part of the group")
|
447 |
except RightForbidden:
|
448 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
449 |
except RPCError as ef:
|
|
|
473 |
await m.reply_text("Cannot find user to kick")
|
474 |
return
|
475 |
|
476 |
+
if user_id == c.me.id:
|
477 |
+
await m.reply_text("Nuh Hu, why would I kick myself?")
|
478 |
await m.stop_propagation()
|
479 |
|
480 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
481 |
+
|
482 |
if user_id in SUPPORT_STAFF:
|
483 |
await m.reply_text(
|
484 |
text="This user is in my support staff, cannot restrict them."
|
485 |
)
|
486 |
+
|
|
|
|
|
487 |
await m.stop_propagation()
|
488 |
|
489 |
try:
|
|
|
496 |
await m.stop_propagation()
|
497 |
|
498 |
try:
|
|
|
499 |
await m.chat.ban_member(user_id)
|
500 |
await m.delete()
|
501 |
if m.reply_to_message:
|
|
|
511 |
await m.reply_text(
|
512 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
513 |
)
|
514 |
+
except UserNotParticipant:
|
515 |
+
await m.reply_text("User is not part of the group")
|
516 |
except RightForbidden:
|
517 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
518 |
except RPCError as ef:
|
|
|
544 |
await m.reply_text("Cannot find user to kick")
|
545 |
return
|
546 |
|
547 |
+
if user_id == c.me.id:
|
548 |
await m.reply_text("Huh, why would I kick myself?")
|
549 |
await m.stop_propagation()
|
550 |
|
551 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
552 |
+
|
553 |
if user_id in SUPPORT_STAFF:
|
554 |
await m.reply_text(
|
555 |
text="This user is in my support staff, cannot restrict them."
|
556 |
)
|
557 |
+
|
|
|
|
|
558 |
await m.stop_propagation()
|
559 |
|
560 |
try:
|
|
|
567 |
await m.stop_propagation()
|
568 |
|
569 |
try:
|
|
|
570 |
await m.reply_to_message.delete()
|
571 |
await m.chat.ban_member(user_id)
|
572 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
|
|
601 |
)
|
602 |
except RightForbidden:
|
603 |
await m.reply_text(text="I don't have enough rights to kick this user.")
|
604 |
+
except UserNotParticipant:
|
605 |
+
await m.reply_text("User is not part of the group")
|
606 |
except RPCError as ef:
|
607 |
await m.reply_text(
|
608 |
text=f"""Some error occured, report it using `/bug`
|
|
|
692 |
if user_id == m.chat.id:
|
693 |
await m.reply_text("That's an admin!")
|
694 |
await m.stop_propagation()
|
695 |
+
if user_id == c.me.id:
|
696 |
await m.reply_text("Huh, why would I ban myself?")
|
697 |
await m.stop_propagation()
|
698 |
|
699 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
700 |
+
|
701 |
if user_id in SUPPORT_STAFF:
|
702 |
await m.reply_text(
|
703 |
text="This user is in my support staff, cannot restrict them."
|
704 |
)
|
|
|
|
|
|
|
705 |
await m.stop_propagation()
|
706 |
|
707 |
try:
|
|
|
714 |
await m.stop_propagation()
|
715 |
|
716 |
try:
|
|
|
717 |
await m.chat.ban_member(user_id)
|
718 |
await m.delete()
|
719 |
if m.reply_to_message:
|
|
|
730 |
)
|
731 |
except RightForbidden:
|
732 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
733 |
+
except UserNotParticipant:
|
734 |
+
await m.reply_text("User is not part of the group")
|
735 |
except RPCError as ef:
|
736 |
await m.reply_text(
|
737 |
text=f"""Some error occured, report it using `/bug`
|
|
|
769 |
if user_id == m.chat.id:
|
770 |
await m.reply_text("That's an admin!")
|
771 |
await m.stop_propagation()
|
772 |
+
if user_id == c.me.id:
|
773 |
await m.reply_text("Huh, why would I ban myself?")
|
774 |
await m.stop_propagation()
|
775 |
|
776 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
777 |
+
|
778 |
if user_id in SUPPORT_STAFF:
|
779 |
await m.reply_text(
|
780 |
text="This user is in my support staff, cannot restrict them."
|
781 |
)
|
|
|
|
|
|
|
782 |
await m.stop_propagation()
|
783 |
|
784 |
try:
|
|
|
795 |
reason = m.text.split(None, 1)[1]
|
796 |
|
797 |
try:
|
|
|
798 |
await m.reply_to_message.delete()
|
799 |
await m.chat.ban_member(user_id)
|
800 |
txt = f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in <b>{m.chat.title}</b>!"
|
|
|
830 |
)
|
831 |
except RightForbidden:
|
832 |
await m.reply_text(text="I don't have enough rights to ban this user.")
|
833 |
+
except UserNotParticipant:
|
834 |
+
await m.reply_text("User is not part of the group")
|
835 |
except RPCError as ef:
|
836 |
await m.reply_text(
|
837 |
text=f"""Some error occured, report it using `/bug`
|
|
|
866 |
if user_id == m.chat.id:
|
867 |
await m.reply_text("That's an admin!")
|
868 |
await m.stop_propagation()
|
869 |
+
if user_id == c.me.id:
|
870 |
await m.reply_text("Huh, why would I ban myself?")
|
871 |
await m.stop_propagation()
|
872 |
|
873 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
874 |
+
|
875 |
if user_id in SUPPORT_STAFF:
|
876 |
await m.reply_text(
|
877 |
text="This user is in my support staff, cannot restrict them."
|
878 |
)
|
|
|
|
|
|
|
879 |
await m.stop_propagation()
|
880 |
|
881 |
try:
|
|
|
898 |
reason = m.text.split(None, 2)[2]
|
899 |
|
900 |
try:
|
|
|
901 |
await m.chat.ban_member(user_id)
|
902 |
banned = await mention_html(user_first_name, user_id)
|
903 |
txt = f"{m.from_user.mention} banned {banned} in <b>{m.chat.title}</b>!"
|
|
|
938 |
await m.reply_text(
|
939 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
940 |
)
|
941 |
+
except UserNotParticipant:
|
942 |
+
await m.reply_text("User is not part of the group")
|
943 |
except UserAdminInvalid:
|
944 |
await m.reply_text(
|
945 |
text="Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
|
|
970 |
)
|
971 |
return
|
972 |
|
973 |
+
elif user and not user.privileges.can_restrict_members and q.from_user.id != OWNER_ID:
|
974 |
await q.answer(
|
975 |
"You don't have enough permission to do this!\nStay in your limits!",
|
976 |
show_alert=True,
|
|
|
993 |
if len(m.text.split()) >= 2:
|
994 |
reason = m.text.split(None, 1)[1]
|
995 |
try:
|
|
|
996 |
mem = await c.get_chat_member(m.chat.id,m.from_user.id)
|
997 |
if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
|
998 |
try:
|
Powers/plugins/birthday.py
CHANGED
@@ -125,7 +125,7 @@ async def who_is_next(c: Gojo, m: Message):
|
|
125 |
if m.chat.type == ChatType.PRIVATE:
|
126 |
await m.reply_text("Use it in group")
|
127 |
return
|
128 |
-
curr = datetime.now(
|
129 |
xx = await m.reply_text("📆")
|
130 |
users = []
|
131 |
if blist:
|
@@ -147,8 +147,8 @@ async def who_is_next(c: Gojo, m: Message):
|
|
147 |
for i in users:
|
148 |
DOB = give_date(i["dob"])
|
149 |
dete = date(curr.year, DOB.month, DOB.day)
|
150 |
-
leff = (dete - curr).days
|
151 |
-
txt += f"`{i['user_id']}` : {leff} days left"
|
152 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
153 |
await xx.delete()
|
154 |
await m.reply_text(txt)
|
@@ -173,22 +173,24 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
173 |
await m.reply_text(f"Got an error\n{e}")
|
174 |
return
|
175 |
|
176 |
-
curr = datetime.now(
|
177 |
u_dob = give_date(result["dob"])
|
178 |
formatted = str(u_dob.strftime('%d' + '%B %Y'))[2:-5]
|
179 |
day = int(result["dob"].split('/')[0])
|
180 |
-
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day
|
181 |
bday_on = f"{day}{suffix} {formatted}"
|
182 |
-
if u_dob.month < curr.month:
|
183 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
184 |
days_left = (next_b - curr).days
|
185 |
-
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {days_left}"
|
186 |
txt += f"\nBirthday on: {bday_on}"
|
187 |
txt += f"\n\nDate of birth: {result['dob']}"
|
|
|
|
|
188 |
else:
|
189 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
190 |
days_left = (u_dobm - curr).days
|
191 |
-
txt = f"User's birthday is coming🥳\nDays left
|
192 |
txt += f"\nBirthday on: {bday_on}"
|
193 |
txt += f"\n\nDate of birth: {result['dob']}"
|
194 |
txt+= "\n\n**NOTE**:\nDOB may be wrong if user haven't entered his/her birth year"
|
@@ -216,7 +218,7 @@ async def chat_birthday_settings(c: Gojo, m: Message):
|
|
216 |
await m.reply_text("Do you want to wish members for their birthday in the group?",reply_markup=kb)
|
217 |
return
|
218 |
|
219 |
-
@Gojo.on_callback_query(filters.regex("^switchh_"))
|
220 |
async def switch_on_off(c:Gojo, q: CallbackQuery):
|
221 |
user = (await q.message.chat.get_member(q.from_user.id)).status
|
222 |
await q.message.chat.get_member(q.from_user.id)
|
@@ -225,11 +227,11 @@ async def switch_on_off(c:Gojo, q: CallbackQuery):
|
|
225 |
return
|
226 |
data = q.data.split("_")[1]
|
227 |
chats = q.message.chat.id
|
228 |
-
|
229 |
if data == "yes":
|
230 |
-
bday_cinfo.delete_one(
|
231 |
elif data == "no":
|
232 |
-
bday_cinfo.insert_one(
|
233 |
await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",reply_markup=IKM([[IKB("Close", "f_close")]]))
|
234 |
return
|
235 |
|
|
|
125 |
if m.chat.type == ChatType.PRIVATE:
|
126 |
await m.reply_text("Use it in group")
|
127 |
return
|
128 |
+
curr = datetime.now().date()
|
129 |
xx = await m.reply_text("📆")
|
130 |
users = []
|
131 |
if blist:
|
|
|
147 |
for i in users:
|
148 |
DOB = give_date(i["dob"])
|
149 |
dete = date(curr.year, DOB.month, DOB.day)
|
150 |
+
leff = (dete - curr).days
|
151 |
+
txt += f"`{i['user_id']}` : {leff} days left\n"
|
152 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
153 |
await xx.delete()
|
154 |
await m.reply_text(txt)
|
|
|
173 |
await m.reply_text(f"Got an error\n{e}")
|
174 |
return
|
175 |
|
176 |
+
curr = datetime.now().date()
|
177 |
u_dob = give_date(result["dob"])
|
178 |
formatted = str(u_dob.strftime('%d' + '%B %Y'))[2:-5]
|
179 |
day = int(result["dob"].split('/')[0])
|
180 |
+
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
|
181 |
bday_on = f"{day}{suffix} {formatted}"
|
182 |
+
if (u_dob.day,u_dob.month) < (curr.day,curr.month):
|
183 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
184 |
days_left = (next_b - curr).days
|
185 |
+
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {abs(days_left)}"
|
186 |
txt += f"\nBirthday on: {bday_on}"
|
187 |
txt += f"\n\nDate of birth: {result['dob']}"
|
188 |
+
elif (u_dob.day,u_dob.month) == (curr.day,curr.month):
|
189 |
+
txt = f"Today is {men}'s birthday."
|
190 |
else:
|
191 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
192 |
days_left = (u_dobm - curr).days
|
193 |
+
txt = f"User's birthday is coming🥳\nDays left: {abs(days_left)}"
|
194 |
txt += f"\nBirthday on: {bday_on}"
|
195 |
txt += f"\n\nDate of birth: {result['dob']}"
|
196 |
txt+= "\n\n**NOTE**:\nDOB may be wrong if user haven't entered his/her birth year"
|
|
|
218 |
await m.reply_text("Do you want to wish members for their birthday in the group?",reply_markup=kb)
|
219 |
return
|
220 |
|
221 |
+
@Gojo.on_callback_query(filters.regex(r"^switchh_(yes|no)$"))
|
222 |
async def switch_on_off(c:Gojo, q: CallbackQuery):
|
223 |
user = (await q.message.chat.get_member(q.from_user.id)).status
|
224 |
await q.message.chat.get_member(q.from_user.id)
|
|
|
227 |
return
|
228 |
data = q.data.split("_")[1]
|
229 |
chats = q.message.chat.id
|
230 |
+
query = {"chat_id":chats}
|
231 |
if data == "yes":
|
232 |
+
bday_cinfo.delete_one(query)
|
233 |
elif data == "no":
|
234 |
+
bday_cinfo.insert_one(query)
|
235 |
await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",reply_markup=IKM([[IKB("Close", "f_close")]]))
|
236 |
return
|
237 |
|
Powers/plugins/blacklist.py
CHANGED
@@ -15,8 +15,6 @@ from Powers.utils.kbhelpers import ikb
|
|
15 |
async def view_blacklist(_, m: Message):
|
16 |
db = Blacklist(m.chat.id)
|
17 |
|
18 |
-
LOGGER.info(f"{m.from_user.id} checking blacklists in {m.chat.id}")
|
19 |
-
|
20 |
chat_title = m.chat.title
|
21 |
blacklists_chat = f"Current Blacklisted words in <b>{chat_title}</b>:\n\n"
|
22 |
all_blacklisted = db.get_blacklists()
|
@@ -58,7 +56,6 @@ async def add_blacklist(_, m: Message):
|
|
58 |
", ".join([f"<code>{i}</code>" for i in bl_words])
|
59 |
+ " already added in blacklist, skipped them!"
|
60 |
)
|
61 |
-
LOGGER.info(f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
|
62 |
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
63 |
await m.reply_text(
|
64 |
text=f"Added <code>{trigger}</code> in blacklist words!"
|
@@ -116,7 +113,6 @@ async def rm_blacklist(_, m: Message):
|
|
116 |
"Could not find " + ", ".join(f"<code>{i}</code>" for i in non_found_words)
|
117 |
) + " in blcklisted words, skipped them."
|
118 |
|
119 |
-
LOGGER.info(f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
|
120 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
121 |
await m.reply_text(
|
122 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
@@ -145,13 +141,9 @@ async def set_bl_action(_, m: Message):
|
|
145 |
|
146 |
return
|
147 |
db.set_action(action)
|
148 |
-
LOGGER.info(
|
149 |
-
f"{m.from_user.id} set blacklist action to '{action}' in {m.chat.id}",
|
150 |
-
)
|
151 |
await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
|
152 |
elif len(m.text.split()) == 1:
|
153 |
action = db.get_action()
|
154 |
-
LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
|
155 |
await m.reply_text(
|
156 |
text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
|
157 |
All blacklist modes delete the message containing blacklist word."""
|
@@ -201,7 +193,6 @@ async def rm_allbl_callback(_, q: CallbackQuery):
|
|
201 |
return
|
202 |
db.rm_all_blacklist()
|
203 |
await q.message.delete()
|
204 |
-
LOGGER.info(f"{user_id} removed all blacklists in {q.message.chat.id}")
|
205 |
await q.answer("Cleared all Blacklists!", show_alert=True)
|
206 |
return
|
207 |
|
|
|
15 |
async def view_blacklist(_, m: Message):
|
16 |
db = Blacklist(m.chat.id)
|
17 |
|
|
|
|
|
18 |
chat_title = m.chat.title
|
19 |
blacklists_chat = f"Current Blacklisted words in <b>{chat_title}</b>:\n\n"
|
20 |
all_blacklisted = db.get_blacklists()
|
|
|
56 |
", ".join([f"<code>{i}</code>" for i in bl_words])
|
57 |
+ " already added in blacklist, skipped them!"
|
58 |
)
|
|
|
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!"
|
|
|
113 |
"Could not find " + ", ".join(f"<code>{i}</code>" for i in non_found_words)
|
114 |
) + " in blcklisted words, skipped them."
|
115 |
|
|
|
116 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
117 |
await m.reply_text(
|
118 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
|
|
141 |
|
142 |
return
|
143 |
db.set_action(action)
|
|
|
|
|
|
|
144 |
await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
|
145 |
elif len(m.text.split()) == 1:
|
146 |
action = db.get_action()
|
|
|
147 |
await m.reply_text(
|
148 |
text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
|
149 |
All blacklist modes delete the message containing blacklist word."""
|
|
|
193 |
return
|
194 |
db.rm_all_blacklist()
|
195 |
await q.message.delete()
|
|
|
196 |
await q.answer("Cleared all Blacklists!", show_alert=True)
|
197 |
return
|
198 |
|
Powers/plugins/botstaff.py
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
from pyrogram.errors import RPCError
|
2 |
-
from pyrogram.types import Message
|
3 |
-
|
4 |
-
from Powers import LOGGER, OWNER_ID, WHITELIST_USERS
|
5 |
-
from Powers.bot_class import Gojo
|
6 |
-
from Powers.supports import get_support_staff
|
7 |
-
from Powers.utils.custom_filters import command
|
8 |
-
from Powers.utils.parser import mention_html
|
9 |
-
|
10 |
-
DEV_USERS = get_support_staff("dev")
|
11 |
-
SUDO_USERS = get_support_staff("sudo")
|
12 |
-
|
13 |
-
@Gojo.on_message(command("botstaff", dev_cmd=True))
|
14 |
-
async def botstaff(c: Gojo, m: Message):
|
15 |
-
try:
|
16 |
-
owner = await c.get_users(OWNER_ID)
|
17 |
-
reply = f"<b>🌟 Owner:</b> {(await mention_html(owner.first_name, OWNER_ID))} (<code>{OWNER_ID}</code>)\n"
|
18 |
-
except RPCError:
|
19 |
-
pass
|
20 |
-
true_dev = list(set(DEV_USERS) - {OWNER_ID})
|
21 |
-
reply += "\n<b>Developers ⚡️:</b>\n"
|
22 |
-
if not true_dev:
|
23 |
-
reply += "No Dev Users\n"
|
24 |
-
else:
|
25 |
-
for each_user in true_dev:
|
26 |
-
user_id = int(each_user)
|
27 |
-
try:
|
28 |
-
user = await c.get_users(user_id)
|
29 |
-
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
30 |
-
except RPCError:
|
31 |
-
pass
|
32 |
-
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
33 |
-
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
34 |
-
if true_sudo == []:
|
35 |
-
reply += "No Sudo Users\n"
|
36 |
-
else:
|
37 |
-
for each_user in true_sudo:
|
38 |
-
user_id = int(each_user)
|
39 |
-
try:
|
40 |
-
user = await c.get_users(user_id)
|
41 |
-
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
42 |
-
except RPCError:
|
43 |
-
pass
|
44 |
-
reply += "\n<b>Whitelisted Users 🐺:</b>\n"
|
45 |
-
if WHITELIST_USERS == []:
|
46 |
-
reply += "No additional whitelisted users\n"
|
47 |
-
else:
|
48 |
-
for each_user in WHITELIST_USERS:
|
49 |
-
user_id = int(each_user)
|
50 |
-
try:
|
51 |
-
user = await c.get_users(user_id)
|
52 |
-
reply += f"• {(await mention_html(user.first_name, user_id))} (<code>{user_id}</code>)\n"
|
53 |
-
except RPCError:
|
54 |
-
pass
|
55 |
-
await m.reply_text(reply)
|
56 |
-
LOGGER.info(f"{m.from_user.id} fetched botstaff in {m.chat.id}")
|
57 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powers/plugins/captcha.py
ADDED
@@ -0,0 +1,269 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from random import choice, shuffle
|
3 |
+
from traceback import format_exc
|
4 |
+
from typing import List
|
5 |
+
|
6 |
+
import pyrogram
|
7 |
+
from pyrogram import filters
|
8 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
9 |
+
from pyrogram.enums import ParseMode as PM
|
10 |
+
from pyrogram.types import CallbackQuery, ChatPermissions
|
11 |
+
from pyrogram.types import InlineKeyboardButton as IKB
|
12 |
+
from pyrogram.types import InlineKeyboardMarkup as ikm
|
13 |
+
from pyrogram.types import Message, User
|
14 |
+
|
15 |
+
from Powers import DEV_USERS, LOGGER, MESSAGE_DUMP, SUDO_USERS, WHITELIST_USERS
|
16 |
+
from Powers.bot_class import Gojo
|
17 |
+
from Powers.database.captcha_db import CAPTCHA, CAPTCHA_DATA
|
18 |
+
from Powers.utils.captcha_helper import (genrator, get_image_captcha,
|
19 |
+
get_qr_captcha)
|
20 |
+
from Powers.utils.custom_filters import admin_filter, captcha_filter, command
|
21 |
+
from Powers.utils.extras import BAN_GIFS
|
22 |
+
|
23 |
+
|
24 |
+
@Gojo.on_message(command("captcha") & admin_filter & ~filters.private)
|
25 |
+
async def start_captcha(_, m: Message):
|
26 |
+
captcha = CAPTCHA()
|
27 |
+
split = m.command
|
28 |
+
if len(split) == 1:
|
29 |
+
is_cap = captcha.is_captcha(m.chat.id)
|
30 |
+
if is_cap:
|
31 |
+
txt = "Captcha verification is currently **on** for this chat"
|
32 |
+
else:
|
33 |
+
txt = "Captcha verification is currently **off** for this chat"
|
34 |
+
await m.reply_text(txt)
|
35 |
+
return
|
36 |
+
else:
|
37 |
+
on_off = split[1].lower()
|
38 |
+
if on_off in ["on", "yes", "enable"]:
|
39 |
+
captcha.insert_captcha(m.chat.id)
|
40 |
+
await m.reply_text("Captcha verification is now **on** for this chat")
|
41 |
+
return
|
42 |
+
elif on_off in ["off", "no", "disable"]:
|
43 |
+
captcha.remove_captcha(m.chat.id)
|
44 |
+
await m.reply_text("Captcha verification is now **off** for this chat")
|
45 |
+
return
|
46 |
+
else:
|
47 |
+
await m.reply_text("**USAGE**\n/captcha [on | yes | enable | off | no | disable]")
|
48 |
+
return
|
49 |
+
|
50 |
+
|
51 |
+
@Gojo.on_message(command("captchamode") & admin_filter & ~filters.private)
|
52 |
+
async def set_captcha_mode(c: Gojo, m: Message):
|
53 |
+
split = m.command
|
54 |
+
captcha = CAPTCHA()
|
55 |
+
if len(split) == 1:
|
56 |
+
curr = captcha.get_captcha(m.chat.id)
|
57 |
+
if curr:
|
58 |
+
capatcha_type = curr["captcha_type"]
|
59 |
+
await m.reply_text(f"Current captcha verification methode is {capatcha_type}\nAvailable methodes:\n■ qr\n■ image")
|
60 |
+
return
|
61 |
+
else:
|
62 |
+
await m.reply_text("Captcha verification is off for the current chat")
|
63 |
+
return
|
64 |
+
else:
|
65 |
+
type_ = split[1].lower()
|
66 |
+
if type_ == "qr":
|
67 |
+
await m.reply_text("This feature is not implemented yet\nUse /captchamode image")
|
68 |
+
# captcha.update_type(m.chat.id, "qr")
|
69 |
+
# await m.reply_text("Captcha verification is now changed to qr code")
|
70 |
+
return
|
71 |
+
elif type_ == "image":
|
72 |
+
captcha.update_type(m.chat.id, "image")
|
73 |
+
await m.reply_text("Captcha verication is now changed to image")
|
74 |
+
return
|
75 |
+
else:
|
76 |
+
await m.reply_text("**USAGE**\n/captchamode [qr | image]")
|
77 |
+
return
|
78 |
+
|
79 |
+
|
80 |
+
@Gojo.on_callback_query(filters.regex("^captcha_"))
|
81 |
+
async def captcha_codes_check(c: Gojo, q: CallbackQuery):
|
82 |
+
split = q.data.split("_")
|
83 |
+
chat = int(split[1])
|
84 |
+
user = int(split[2])
|
85 |
+
code = split[3]
|
86 |
+
|
87 |
+
if q.from_user.id != user:
|
88 |
+
await q.answer("Not for you BAKA!")
|
89 |
+
return
|
90 |
+
|
91 |
+
c_data = CAPTCHA_DATA()
|
92 |
+
code_ = c_data.get_cap_data(chat, user)
|
93 |
+
|
94 |
+
if code_ == code:
|
95 |
+
cap = "You guessed the captcha right...Now you can talk in the chat with no restrictions"
|
96 |
+
c_data.remove_cap_data(chat, user)
|
97 |
+
await q.answer(cap, True)
|
98 |
+
try:
|
99 |
+
await q.message.chat.unban_member(user)
|
100 |
+
except Exception as e:
|
101 |
+
await q.message.reply_text(f"Unable to unmute {q.from_user.mention} this user")
|
102 |
+
await q.message.reply_text(e)
|
103 |
+
return
|
104 |
+
await c.send_message(chat, f"{q.from_user.mention} now you are free to talk")
|
105 |
+
await q.message.delete()
|
106 |
+
return
|
107 |
+
else:
|
108 |
+
caps = q.message.caption.split(":")
|
109 |
+
tries = int(caps[1].strip()) - 1
|
110 |
+
caps.pop(-1)
|
111 |
+
caps.append(f" {tries}")
|
112 |
+
new_cap = ":".join(caps)
|
113 |
+
await q.answer(f"Wrong\nTries left: {tries}", True)
|
114 |
+
if not tries:
|
115 |
+
txt = f"{q.from_user.mention} was not able to pass captcha verification thus banned from the group"
|
116 |
+
try:
|
117 |
+
await q.message.chat.ban_member(user)
|
118 |
+
except Exception as e:
|
119 |
+
await q.message.reply_text("Failed to ban member")
|
120 |
+
return
|
121 |
+
await q.message.delete()
|
122 |
+
keyboard = ikm(
|
123 |
+
[
|
124 |
+
[
|
125 |
+
IKB(
|
126 |
+
"Unban",
|
127 |
+
callback_data=f"unban_={user}",
|
128 |
+
),
|
129 |
+
],
|
130 |
+
],
|
131 |
+
)
|
132 |
+
anim = choice(BAN_GIFS)
|
133 |
+
try:
|
134 |
+
await c.send_animation(
|
135 |
+
chat_id=q.message.chat.id,
|
136 |
+
animation=str(anim),
|
137 |
+
caption=txt,
|
138 |
+
reply_markup=keyboard,
|
139 |
+
parse_mode=PM.HTML,
|
140 |
+
)
|
141 |
+
except Exception:
|
142 |
+
|
143 |
+
await c.send_animation(
|
144 |
+
chat_id=q.message.chat.id,
|
145 |
+
text=txt,
|
146 |
+
reply_markup=keyboard,
|
147 |
+
parse_mode=PM.HTML,
|
148 |
+
)
|
149 |
+
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
150 |
+
c_data.remove_cap_data(chat, user)
|
151 |
+
c_data.del_message_id(q.message.chat.id, user)
|
152 |
+
return
|
153 |
+
else:
|
154 |
+
await q.edit_message_caption(new_cap, reply_markup=q.message.reply_markup)
|
155 |
+
return
|
156 |
+
|
157 |
+
|
158 |
+
@Gojo.on_message(filters.group & captcha_filter & filters.new_chat_members, group=3)
|
159 |
+
async def on_chat_members_updatess(c: Gojo, m: Message):
|
160 |
+
chat = m.chat.id
|
161 |
+
|
162 |
+
users: List[User] = m.new_chat_members
|
163 |
+
for user in users:
|
164 |
+
captcha = CAPTCHA()
|
165 |
+
cap_data = CAPTCHA_DATA()
|
166 |
+
|
167 |
+
if user.is_bot:
|
168 |
+
continue
|
169 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
170 |
+
|
171 |
+
try:
|
172 |
+
status = (await m.chat.get_member(user)).status
|
173 |
+
if status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
174 |
+
continue
|
175 |
+
except:
|
176 |
+
pass
|
177 |
+
if user.id in SUPPORT_STAFF:
|
178 |
+
continue
|
179 |
+
captcha_info = captcha.get_captcha(chat)
|
180 |
+
captcha_type = captcha_info["captcha_type"]
|
181 |
+
is_already = cap_data.is_already_data(chat, user.id)
|
182 |
+
|
183 |
+
mess = False
|
184 |
+
try:
|
185 |
+
if is_already:
|
186 |
+
mess = await c.get_messages(chat, int(is_already))
|
187 |
+
except Exception:
|
188 |
+
cap_data.del_message_id(chat, is_already)
|
189 |
+
mess = False
|
190 |
+
is_already = False
|
191 |
+
|
192 |
+
if is_already and mess.empty:
|
193 |
+
cap_data.del_message_id(chat, is_already)
|
194 |
+
continue
|
195 |
+
|
196 |
+
try:
|
197 |
+
await c.restrict_chat_member(chat, user.id, ChatPermissions())
|
198 |
+
except Exception as e:
|
199 |
+
LOGGER.error(e)
|
200 |
+
LOGGER.error(format_exc())
|
201 |
+
continue
|
202 |
+
|
203 |
+
if not is_already:
|
204 |
+
captcha_type = "image" # I am not going to apply qr captcha in this update
|
205 |
+
if captcha_type == "qr":
|
206 |
+
pic = await get_qr_captcha(chat, user.id, c.me.username)
|
207 |
+
cap = f"Please {user.mention} scan this qr code with your phone to verify that you are human"
|
208 |
+
ms = await c.send_photo(chat, pic, caption=cap)
|
209 |
+
os.remove(pic)
|
210 |
+
cap_data.store_message_id(chat, user.id, ms.id)
|
211 |
+
continue
|
212 |
+
elif captcha_type == "image":
|
213 |
+
img, code = await get_image_captcha(chat, user.id)
|
214 |
+
cap = f"Please {user.mention} please choose the correct code from the one given bellow\nYou have three tries if you get all three wrong u will be banned from the chat.\nTries left: 3"
|
215 |
+
cap_data.load_cap_data(chat, user.id, code)
|
216 |
+
rand = [code]
|
217 |
+
while len(rand) != 5:
|
218 |
+
hehe = genrator()
|
219 |
+
if hehe == code:
|
220 |
+
continue
|
221 |
+
rand.append(hehe)
|
222 |
+
|
223 |
+
shuffle(rand)
|
224 |
+
|
225 |
+
ini = f"captcha_{chat}_{user.id}_"
|
226 |
+
|
227 |
+
kb = ikm(
|
228 |
+
[
|
229 |
+
[
|
230 |
+
IKB(rand[0], ini+rand[0])
|
231 |
+
],
|
232 |
+
[
|
233 |
+
IKB(rand[1], ini+rand[1])
|
234 |
+
],
|
235 |
+
[
|
236 |
+
IKB(rand[2], ini+rand[2])
|
237 |
+
],
|
238 |
+
[
|
239 |
+
IKB(rand[3], ini+rand[3])
|
240 |
+
],
|
241 |
+
[
|
242 |
+
IKB(rand[4], ini+rand[4])
|
243 |
+
]
|
244 |
+
]
|
245 |
+
)
|
246 |
+
await c.send_photo(chat, img, caption=cap, reply_markup=kb)
|
247 |
+
os.remove(img)
|
248 |
+
continue
|
249 |
+
elif is_already and mess:
|
250 |
+
kb = ikm(
|
251 |
+
[
|
252 |
+
[
|
253 |
+
IKB("Click here to verify", url=mess.link)
|
254 |
+
]
|
255 |
+
]
|
256 |
+
)
|
257 |
+
await c.send_message(f"{user.mention} your verification is already pending", reply_markup=kb)
|
258 |
+
continue
|
259 |
+
else:
|
260 |
+
await c.unban_chat_member(chat, user.id)
|
261 |
+
continue
|
262 |
+
|
263 |
+
|
264 |
+
__PLUGIN__ = "captcha"
|
265 |
+
|
266 |
+
__HELP__ = """
|
267 |
+
• /captcha [on|yes|enable|off|no|disable] : To enable or disable captcha verification
|
268 |
+
• /captchamode [qr|image] : To change captcha mode
|
269 |
+
"""
|
Powers/plugins/chat_blacklist.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from traceback import format_exc
|
2 |
|
|
|
3 |
from pyrogram.errors import PeerIdInvalid, RPCError
|
4 |
from pyrogram.types import Message
|
5 |
|
@@ -17,7 +18,6 @@ async def blacklist_chat(c: Gojo, m: Message):
|
|
17 |
if len(m.text.split()) >= 2:
|
18 |
chat_ids = m.text.split()[1:]
|
19 |
replymsg = await m.reply_text(f"Adding {len(chat_ids)} chats to blacklist")
|
20 |
-
LOGGER.info(f"{m.from_user.id} blacklisted {chat_ids} groups for bot")
|
21 |
for chat in chat_ids:
|
22 |
try:
|
23 |
get_chat = await c.get_chat(chat)
|
@@ -33,6 +33,13 @@ async def blacklist_chat(c: Gojo, m: Message):
|
|
33 |
await replymsg.edit_text(
|
34 |
f"Added the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
35 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
return
|
37 |
|
38 |
|
@@ -43,7 +50,6 @@ async def unblacklist_chat(c: Gojo, m: Message):
|
|
43 |
if len(m.text.split()) >= 2:
|
44 |
chat_ids = m.text.split()[1:]
|
45 |
replymsg = await m.reply_text(f"Removing {len(chat_ids)} chats from blacklist")
|
46 |
-
LOGGER.info(f"{m.from_user.id} removed blacklisted {chat_ids} groups for bot")
|
47 |
bl_chats = db.list_all_chats()
|
48 |
for chat in chat_ids:
|
49 |
try:
|
@@ -63,6 +69,16 @@ async def unblacklist_chat(c: Gojo, m: Message):
|
|
63 |
await replymsg.edit_text(
|
64 |
f"Removed the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
65 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return
|
67 |
|
68 |
|
@@ -71,7 +87,6 @@ async def unblacklist_chat(c: Gojo, m: Message):
|
|
71 |
)
|
72 |
async def list_blacklist_chats(_, m: Message):
|
73 |
bl_chats = db.list_all_chats()
|
74 |
-
LOGGER.info(f"{m.from_user.id} checking group blacklists in {m.chat.id}")
|
75 |
if bl_chats:
|
76 |
txt = (
|
77 |
(
|
@@ -84,3 +99,17 @@ async def list_blacklist_chats(_, m: Message):
|
|
84 |
txt = "No chats are currently blacklisted!"
|
85 |
await m.reply_text(txt)
|
86 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from traceback import format_exc
|
2 |
|
3 |
+
from pyrogram.enums import ChatType as CT
|
4 |
from pyrogram.errors import PeerIdInvalid, RPCError
|
5 |
from pyrogram.types import Message
|
6 |
|
|
|
18 |
if len(m.text.split()) >= 2:
|
19 |
chat_ids = m.text.split()[1:]
|
20 |
replymsg = await m.reply_text(f"Adding {len(chat_ids)} chats to blacklist")
|
|
|
21 |
for chat in chat_ids:
|
22 |
try:
|
23 |
get_chat = await c.get_chat(chat)
|
|
|
33 |
await replymsg.edit_text(
|
34 |
f"Added the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
35 |
)
|
36 |
+
else:
|
37 |
+
if m.chat.type == CT.PRIVATE:
|
38 |
+
await m.reply_text("Use in groups")
|
39 |
+
else:
|
40 |
+
chat_id = m.chat.id
|
41 |
+
db.add_chat(chat_id)
|
42 |
+
await m.reply_text("Added this chat to blacklist chats")
|
43 |
return
|
44 |
|
45 |
|
|
|
50 |
if len(m.text.split()) >= 2:
|
51 |
chat_ids = m.text.split()[1:]
|
52 |
replymsg = await m.reply_text(f"Removing {len(chat_ids)} chats from blacklist")
|
|
|
53 |
bl_chats = db.list_all_chats()
|
54 |
for chat in chat_ids:
|
55 |
try:
|
|
|
69 |
await replymsg.edit_text(
|
70 |
f"Removed the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
71 |
)
|
72 |
+
else:
|
73 |
+
if m.chat.type == CT.PRIVATE:
|
74 |
+
await m.reply_text("Use in groups")
|
75 |
+
else:
|
76 |
+
chat_id = m.chat.id
|
77 |
+
bl_chats = bl_chats = db.list_all_chats()
|
78 |
+
if chat_id not in bl_chats:
|
79 |
+
await m.reply_text("This chat is not in my list of blacklisted chats")
|
80 |
+
else:
|
81 |
+
await m.reply_text("Removed this chat from blacklist chats")
|
82 |
return
|
83 |
|
84 |
|
|
|
87 |
)
|
88 |
async def list_blacklist_chats(_, m: Message):
|
89 |
bl_chats = db.list_all_chats()
|
|
|
90 |
if bl_chats:
|
91 |
txt = (
|
92 |
(
|
|
|
99 |
txt = "No chats are currently blacklisted!"
|
100 |
await m.reply_text(txt)
|
101 |
return
|
102 |
+
|
103 |
+
|
104 |
+
__PLUGIN__ = "Chat blacklist"
|
105 |
+
|
106 |
+
|
107 |
+
|
108 |
+
__HELP__ = """
|
109 |
+
**Chat blacklist**
|
110 |
+
|
111 |
+
**Dev commands:**
|
112 |
+
• /blchat [space separated id or username of chats]: Add chats to black list if given or the current chat.
|
113 |
+
• /rmblchat [space separated id or username of chats]: Remove chats from black list if given or the current chat.
|
114 |
+
• /blchats: Give the list of blacklisted chats
|
115 |
+
"""
|
Powers/plugins/clean_db.py
DELETED
@@ -1,75 +0,0 @@
|
|
1 |
-
import time
|
2 |
-
from asyncio import sleep
|
3 |
-
from traceback import format_exc
|
4 |
-
|
5 |
-
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
6 |
-
from pyrogram.enums import ChatMemberStatus as CMS
|
7 |
-
from pyrogram.errors import PeerIdInvalid, UserNotParticipant
|
8 |
-
|
9 |
-
from Powers import LOGGER, MESSAGE_DUMP, TIME_ZONE
|
10 |
-
from Powers.bot_class import Gojo
|
11 |
-
from Powers.database.approve_db import Approve
|
12 |
-
from Powers.database.blacklist_db import Blacklist
|
13 |
-
from Powers.database.chats_db import Chats
|
14 |
-
from Powers.database.disable_db import Disabling
|
15 |
-
from Powers.database.filters_db import Filters
|
16 |
-
from Powers.database.flood_db import Floods
|
17 |
-
from Powers.database.greetings_db import Greetings
|
18 |
-
from Powers.database.notes_db import Notes, NotesSettings
|
19 |
-
from Powers.database.pins_db import Pins
|
20 |
-
from Powers.database.reporting_db import Reporting
|
21 |
-
# from Powers.database.users_db import Users
|
22 |
-
from Powers.database.warns_db import Warns, WarnSettings
|
23 |
-
from Powers.utils.custom_filters import command
|
24 |
-
from Powers.vars import Config
|
25 |
-
|
26 |
-
|
27 |
-
async def clean_my_db(c:Gojo,is_cmd=False, id=None):
|
28 |
-
to_clean = list()
|
29 |
-
chats_list = Chats.list_chats_by_id()
|
30 |
-
to_clean.clear()
|
31 |
-
start = time.time()
|
32 |
-
for chats in chats_list:
|
33 |
-
try:
|
34 |
-
stat = await c.get_chat_member(chat_id=chats,user_id=Config.BOT_ID)
|
35 |
-
if stat.status not in [CMS.MEMBER, CMS.ADMINISTRATOR, CMS.OWNER]:
|
36 |
-
to_clean.append(chats)
|
37 |
-
except UserNotParticipant:
|
38 |
-
to_clean.append(chats)
|
39 |
-
except Exception as e:
|
40 |
-
LOGGER.error(e)
|
41 |
-
LOGGER.error(format_exc())
|
42 |
-
if not is_cmd:
|
43 |
-
return e
|
44 |
-
else:
|
45 |
-
to_clean.append(chats)
|
46 |
-
for i in to_clean:
|
47 |
-
Approve(i).clean_approve()
|
48 |
-
Blacklist(i).clean_blacklist()
|
49 |
-
Chats.remove_chat(i)
|
50 |
-
Disabling(i).clean_disable()
|
51 |
-
Filters().rm_all_filters(i)
|
52 |
-
Floods().rm_flood(i)
|
53 |
-
Greetings(i).clean_greetings()
|
54 |
-
Notes().rm_all_notes(i)
|
55 |
-
NotesSettings().clean_notes(i)
|
56 |
-
Pins(i).clean_pins()
|
57 |
-
Reporting(i).clean_reporting()
|
58 |
-
Warns(i).clean_warn()
|
59 |
-
WarnSettings(i).clean_warns()
|
60 |
-
x = len(to_clean)
|
61 |
-
txt = f"#INFO\n\nCleaned db:\nTotal chats removed: {x}"
|
62 |
-
to_clean.clear()
|
63 |
-
nums = time.time()-start
|
64 |
-
if is_cmd:
|
65 |
-
txt += f"\nClean type: Forced\nInitiated by: {(await c.get_users(user_ids=id)).mention}"
|
66 |
-
txt += f"\nClean type: Manual\n\tTook {round(nums,2)} seconds to complete the process"
|
67 |
-
await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
|
68 |
-
return txt
|
69 |
-
else:
|
70 |
-
txt += f"\nClean type: Auto\n\tTook {round(nums,2)} seconds to complete the process"
|
71 |
-
await c.send_message(chat_id=MESSAGE_DUMP,text=txt)
|
72 |
-
return txt
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powers/plugins/dev.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import subprocess as subp
|
2 |
import sys
|
3 |
from asyncio import create_subprocess_shell, sleep, subprocess
|
|
|
4 |
from io import BytesIO, StringIO
|
5 |
from os import execvp
|
6 |
from sys import executable
|
@@ -15,15 +16,14 @@ from pyrogram.types import InlineKeyboardButton as IKB
|
|
15 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
16 |
from pyrogram.types import Message
|
17 |
|
18 |
-
from Powers import (BOT_TOKEN, LOG_DATETIME, LOGFILE, LOGGER,
|
19 |
-
OWNER_ID, UPTIME
|
|
|
20 |
from Powers.bot_class import Gojo
|
21 |
from Powers.database import MongoDB
|
22 |
from Powers.database.chats_db import Chats
|
23 |
from Powers.database.support_db import SUPPORTS
|
24 |
from Powers.database.users_db import Users
|
25 |
-
from Powers.plugins.scheduled_jobs import clean_my_db
|
26 |
-
from Powers.supports import get_support_staff
|
27 |
from Powers.utils.clean_file import remove_markdown_and_html
|
28 |
from Powers.utils.custom_filters import command
|
29 |
from Powers.utils.extract_user import extract_user
|
@@ -79,6 +79,12 @@ async def add_support(c: Gojo, m:Message):
|
|
79 |
return
|
80 |
else:
|
81 |
support.insert_support_user(userr,to)
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
await m.reply_text(f"This user is now a {to} user")
|
83 |
return
|
84 |
can_do = can_change_type(curr_user,to)
|
@@ -181,10 +187,13 @@ async def rm_support(c: Gojo, m: Message):
|
|
181 |
return
|
182 |
elif len(split) >= 2:
|
183 |
try:
|
184 |
-
curr
|
185 |
except Exception:
|
186 |
-
|
187 |
-
|
|
|
|
|
|
|
188 |
else:
|
189 |
await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
|
190 |
return
|
@@ -192,6 +201,9 @@ async def rm_support(c: Gojo, m: Message):
|
|
192 |
can_user = can_change_type(curr_user,to_user)
|
193 |
if m.from_user.id == int(OWNER_ID) or can_user:
|
194 |
support.delete_support_user(curr)
|
|
|
|
|
|
|
195 |
await m.reply_text("Done! User now no longer belongs to the support staff")
|
196 |
else:
|
197 |
await m.reply_text("Sorry you can't do that...")
|
@@ -199,13 +211,58 @@ async def rm_support(c: Gojo, m: Message):
|
|
199 |
|
200 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
201 |
async def ping(_, m: Message):
|
202 |
-
LOGGER.info(f"{m.from_user.id} used ping cmd in {m.chat.id}")
|
203 |
start = time()
|
204 |
replymsg = await m.reply_text(text="Pinging...", quote=True)
|
205 |
delta_ping = time() - start
|
206 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
207 |
return
|
208 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
209 |
|
210 |
@Gojo.on_message(command("logs", dev_cmd=True))
|
211 |
async def send_log(c: Gojo, m: Message):
|
@@ -336,6 +393,10 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
336 |
MESSAGE_DUMP,
|
337 |
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}",
|
338 |
)
|
|
|
|
|
|
|
|
|
339 |
for j in HARMFUL:
|
340 |
if j in evaluation.split() or j in cmd:
|
341 |
if m.from_user.id != OWNER_ID:
|
@@ -343,6 +404,9 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
343 |
await c.send_message(
|
344 |
MESSAGE_DUMP,
|
345 |
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}")
|
|
|
|
|
|
|
346 |
for i in evaluation.split():
|
347 |
for j in i.split("="):
|
348 |
if j and j[0] in HARMFUL:
|
@@ -352,10 +416,12 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
352 |
MESSAGE_DUMP,
|
353 |
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}"
|
354 |
)
|
355 |
-
|
|
|
|
|
356 |
|
357 |
try:
|
358 |
-
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```
|
359 |
await sm.edit(final_output)
|
360 |
except MessageTooLong:
|
361 |
final_output = f"<b>EVAL</b>: <code>{cmd}</code>\n\n<b>OUTPUT</b>:\n<code>{evaluation}</code> \n"
|
@@ -486,7 +552,7 @@ async def stop_and_send_logger(c:Gojo,is_update=False):
|
|
486 |
)
|
487 |
return
|
488 |
|
489 |
-
@Gojo.on_message(command(["restart", "update"], owner_cmd=True)
|
490 |
async def restart_the_bot(c:Gojo,m:Message):
|
491 |
try:
|
492 |
cmds = m.command
|
@@ -671,23 +737,6 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
671 |
return
|
672 |
|
673 |
|
674 |
-
@Gojo.on_message(command(["cleandb","cleandatabase"],sudo_cmd=True))
|
675 |
-
async def cleeeen(c:Gojo,m:Message):
|
676 |
-
x = await m.reply_text("Cleaning the database...")
|
677 |
-
try:
|
678 |
-
z = await clean_my_db(c,True,m.from_user.id)
|
679 |
-
try:
|
680 |
-
await x.delete()
|
681 |
-
except Exception:
|
682 |
-
pass
|
683 |
-
await m.reply_text(z)
|
684 |
-
return
|
685 |
-
except Exception as e:
|
686 |
-
await m.reply_text(e)
|
687 |
-
await x.delete()
|
688 |
-
LOGGER.error(e)
|
689 |
-
LOGGER.error(format_exc())
|
690 |
-
return
|
691 |
|
692 |
__PLUGIN__ = "devs"
|
693 |
|
|
|
1 |
import subprocess as subp
|
2 |
import sys
|
3 |
from asyncio import create_subprocess_shell, sleep, subprocess
|
4 |
+
from importlib.metadata import PackageNotFoundError, metadata
|
5 |
from io import BytesIO, StringIO
|
6 |
from os import execvp
|
7 |
from sys import executable
|
|
|
16 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
17 |
from pyrogram.types import Message
|
18 |
|
19 |
+
from Powers import (BOT_TOKEN, DEV_USERS, LOG_DATETIME, LOGFILE, LOGGER,
|
20 |
+
MESSAGE_DUMP, OWNER_ID, SUDO_USERS, UPTIME,
|
21 |
+
WHITELIST_USERS)
|
22 |
from Powers.bot_class import Gojo
|
23 |
from Powers.database import MongoDB
|
24 |
from Powers.database.chats_db import Chats
|
25 |
from Powers.database.support_db import SUPPORTS
|
26 |
from Powers.database.users_db import Users
|
|
|
|
|
27 |
from Powers.utils.clean_file import remove_markdown_and_html
|
28 |
from Powers.utils.custom_filters import command
|
29 |
from Powers.utils.extract_user import extract_user
|
|
|
79 |
return
|
80 |
else:
|
81 |
support.insert_support_user(userr,to)
|
82 |
+
if to == "dev":
|
83 |
+
DEV_USERS.add(userr)
|
84 |
+
elif to == "sudo":
|
85 |
+
SUDO_USERS.add(userr)
|
86 |
+
else:
|
87 |
+
WHITELIST_USERS.add(userr)
|
88 |
await m.reply_text(f"This user is now a {to} user")
|
89 |
return
|
90 |
can_do = can_change_type(curr_user,to)
|
|
|
187 |
return
|
188 |
elif len(split) >= 2:
|
189 |
try:
|
190 |
+
curr = int(split[1])
|
191 |
except Exception:
|
192 |
+
try:
|
193 |
+
curr,_,_ = extract_user(m)
|
194 |
+
except Exception:
|
195 |
+
await m.reply_text("Dunno who u r talking abt")
|
196 |
+
return
|
197 |
else:
|
198 |
await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
|
199 |
return
|
|
|
201 |
can_user = can_change_type(curr_user,to_user)
|
202 |
if m.from_user.id == int(OWNER_ID) or can_user:
|
203 |
support.delete_support_user(curr)
|
204 |
+
DEV_USERS.discard(curr)
|
205 |
+
SUDO_USERS.discard(curr)
|
206 |
+
WHITELIST_USERS.discard(curr)
|
207 |
await m.reply_text("Done! User now no longer belongs to the support staff")
|
208 |
else:
|
209 |
await m.reply_text("Sorry you can't do that...")
|
|
|
211 |
|
212 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
213 |
async def ping(_, m: Message):
|
|
|
214 |
start = time()
|
215 |
replymsg = await m.reply_text(text="Pinging...", quote=True)
|
216 |
delta_ping = time() - start
|
217 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
218 |
return
|
219 |
|
220 |
+
"""
|
221 |
+
|
222 |
+
['Metadata-Version', 'Name', 'Version', 'Summary', 'Home-page', 'Author', 'Author-email', 'License', 'Download-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Project-URL', 'Keywords', 'Platform', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Classifier', 'Requires-Python', 'Description-Content-Type', 'License-File', 'License-File', 'License-File', 'Requires-Dist', 'Requires-Dist', 'Description']
|
223 |
+
|
224 |
+
"""
|
225 |
+
|
226 |
+
@Gojo.on_message(command(["minfo", "moduleinfo"], dev_cmd=True))
|
227 |
+
async def check_module_info(_, m: Message):
|
228 |
+
if len(m.command) != 2:
|
229 |
+
await m.reply_text("**USAGE**\n/minfo [module name]")
|
230 |
+
return
|
231 |
+
|
232 |
+
module = m.command[-1]
|
233 |
+
|
234 |
+
try:
|
235 |
+
minfo = metadata(module)
|
236 |
+
except PackageNotFoundError:
|
237 |
+
await m.reply_text(f"No module found with name {module}")
|
238 |
+
return
|
239 |
+
|
240 |
+
name = minfo["Name"]
|
241 |
+
version = minfo["Version"]
|
242 |
+
summary = minfo["Summary"]
|
243 |
+
home_page = minfo["Home-Page"]
|
244 |
+
author = minfo["Author"]
|
245 |
+
license = minfo["License"]
|
246 |
+
download = minfo["Download-URL"]
|
247 |
+
|
248 |
+
txt = f"""
|
249 |
+
Here are the info about the module **{name}**
|
250 |
+
• Version: {version}
|
251 |
+
|
252 |
+
• Summary: {summary}
|
253 |
+
|
254 |
+
• Home page: {home_page}
|
255 |
+
|
256 |
+
• Author: {author}
|
257 |
+
|
258 |
+
• License: {license}
|
259 |
+
|
260 |
+
• Download: {download}
|
261 |
+
"""
|
262 |
+
await m.reply_text(txt, disable_web_page_preview=True)
|
263 |
+
return
|
264 |
+
|
265 |
+
|
266 |
|
267 |
@Gojo.on_message(command("logs", dev_cmd=True))
|
268 |
async def send_log(c: Gojo, m: Message):
|
|
|
393 |
MESSAGE_DUMP,
|
394 |
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}",
|
395 |
)
|
396 |
+
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
397 |
+
await sm.edit(final_output)
|
398 |
+
return
|
399 |
+
|
400 |
for j in HARMFUL:
|
401 |
if j in evaluation.split() or j in cmd:
|
402 |
if m.from_user.id != OWNER_ID:
|
|
|
404 |
await c.send_message(
|
405 |
MESSAGE_DUMP,
|
406 |
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}")
|
407 |
+
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
408 |
+
await sm.edit(final_output)
|
409 |
+
return
|
410 |
for i in evaluation.split():
|
411 |
for j in i.split("="):
|
412 |
if j and j[0] in HARMFUL:
|
|
|
416 |
MESSAGE_DUMP,
|
417 |
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}"
|
418 |
)
|
419 |
+
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
420 |
+
await sm.edit(final_output)
|
421 |
+
return
|
422 |
|
423 |
try:
|
424 |
+
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
425 |
await sm.edit(final_output)
|
426 |
except MessageTooLong:
|
427 |
final_output = f"<b>EVAL</b>: <code>{cmd}</code>\n\n<b>OUTPUT</b>:\n<code>{evaluation}</code> \n"
|
|
|
552 |
)
|
553 |
return
|
554 |
|
555 |
+
@Gojo.on_message(command(["restart", "update"], owner_cmd=True))
|
556 |
async def restart_the_bot(c:Gojo,m:Message):
|
557 |
try:
|
558 |
cmds = m.command
|
|
|
737 |
return
|
738 |
|
739 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
740 |
|
741 |
__PLUGIN__ = "devs"
|
742 |
|
Powers/plugins/disable.py
CHANGED
@@ -24,7 +24,6 @@ async def disableit(_, m: Message):
|
|
24 |
|
25 |
db = Disabling(m.chat.id)
|
26 |
disable_list = db.get_disabled()
|
27 |
-
LOGGER.info(f"{m.from_user.id} used disabled cmd in {m.chat.id}")
|
28 |
|
29 |
if str(m.text.split(None, 1)[1]) in disable_list:
|
30 |
return await m.reply_text("It's already disabled!")
|
@@ -48,8 +47,6 @@ async def set_dsbl_action(_, m: Message):
|
|
48 |
cur = True
|
49 |
args = m.text.split(" ", 1)
|
50 |
|
51 |
-
LOGGER.info(f"{m.from_user.id} disabledel used in {m.chat.id}")
|
52 |
-
|
53 |
if len(args) >= 2:
|
54 |
if args[1].lower() == "on":
|
55 |
db.set_action("del")
|
@@ -73,7 +70,6 @@ async def enableit(_, m: Message):
|
|
73 |
if str(m.text.split(None, 1)[1]) not in disable_list:
|
74 |
return await m.reply_text("It's not disabled!")
|
75 |
db.remove_disabled((str(m.text.split(None, 1)[1])).lower())
|
76 |
-
LOGGER.info(f"{m.from_user.id} enabled something in {m.chat.id}")
|
77 |
return await m.reply_text(f"Enabled {m.text.split(None, 1)[1]}!")
|
78 |
|
79 |
|
@@ -86,7 +82,6 @@ async def disabling(_, m: Message):
|
|
86 |
)
|
87 |
tes = "List of commnds that can be disabled:\n"
|
88 |
tes += "\n".join(f" • <code>{escape(i)}</code>" for i in disable_cmd_keys)
|
89 |
-
LOGGER.info(f"{m.from_user.id} checked disableable {m.chat.id}")
|
90 |
return await m.reply_text(tes)
|
91 |
|
92 |
|
@@ -99,7 +94,6 @@ async def disabled(_, m: Message):
|
|
99 |
return
|
100 |
tex = "Disabled commands:\n"
|
101 |
tex += "\n".join(f" • <code>{escape(i)}</code>" for i in disable_list)
|
102 |
-
LOGGER.info(f"{m.from_user.id} checked disabled {m.chat.id}")
|
103 |
return await m.reply_text(tex)
|
104 |
|
105 |
|
@@ -145,6 +139,25 @@ async def enablealll(_, q: CallbackQuery):
|
|
145 |
return
|
146 |
db = Disabling(q.message.chat.id)
|
147 |
db.rm_all_disabled()
|
148 |
-
LOGGER.info(f"{user_id} enabled all in {q.message.chat.id}")
|
149 |
await q.message.edit_text("Enabled all!", show_alert=True)
|
150 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
db = Disabling(m.chat.id)
|
26 |
disable_list = db.get_disabled()
|
|
|
27 |
|
28 |
if str(m.text.split(None, 1)[1]) in disable_list:
|
29 |
return await m.reply_text("It's already disabled!")
|
|
|
47 |
cur = True
|
48 |
args = m.text.split(" ", 1)
|
49 |
|
|
|
|
|
50 |
if len(args) >= 2:
|
51 |
if args[1].lower() == "on":
|
52 |
db.set_action("del")
|
|
|
70 |
if str(m.text.split(None, 1)[1]) not in disable_list:
|
71 |
return await m.reply_text("It's not disabled!")
|
72 |
db.remove_disabled((str(m.text.split(None, 1)[1])).lower())
|
|
|
73 |
return await m.reply_text(f"Enabled {m.text.split(None, 1)[1]}!")
|
74 |
|
75 |
|
|
|
82 |
)
|
83 |
tes = "List of commnds that can be disabled:\n"
|
84 |
tes += "\n".join(f" • <code>{escape(i)}</code>" for i in disable_cmd_keys)
|
|
|
85 |
return await m.reply_text(tes)
|
86 |
|
87 |
|
|
|
94 |
return
|
95 |
tex = "Disabled commands:\n"
|
96 |
tex += "\n".join(f" • <code>{escape(i)}</code>" for i in disable_list)
|
|
|
97 |
return await m.reply_text(tex)
|
98 |
|
99 |
|
|
|
139 |
return
|
140 |
db = Disabling(q.message.chat.id)
|
141 |
db.rm_all_disabled()
|
|
|
142 |
await q.message.edit_text("Enabled all!", show_alert=True)
|
143 |
return
|
144 |
+
|
145 |
+
|
146 |
+
__PLUGIN__ = "disable able"
|
147 |
+
|
148 |
+
__alt_name__ = ["disable commands", "disable"]
|
149 |
+
|
150 |
+
|
151 |
+
__HELP__ = """
|
152 |
+
**Disable commands**
|
153 |
+
|
154 |
+
**Admin commands:**
|
155 |
+
• /disable [command]: To disable the given command.
|
156 |
+
• /disabledel [on | off]: Will delete the command which is disabled.
|
157 |
+
• /enable [command]: To enable the given command.
|
158 |
+
• /disableable : Give all disableable commands.
|
159 |
+
• /disabled : Give all disabled commands.
|
160 |
+
|
161 |
+
**Owner command:**
|
162 |
+
• /enableall : Enable all the disabled commands.
|
163 |
+
"""
|
Powers/plugins/filters.py
CHANGED
@@ -25,8 +25,6 @@ db = Filters()
|
|
25 |
|
26 |
@Gojo.on_message(command("filters") & filters.group & ~filters.bot)
|
27 |
async def view_filters(_, m: Message):
|
28 |
-
LOGGER.info(f"{m.from_user.id} checking filters in {m.chat.id}")
|
29 |
-
|
30 |
filters_chat = f"Filters in <b>{m.chat.title}</b>:\n"
|
31 |
all_filters = db.get_all_filters(m.chat.id)
|
32 |
actual_filters = [j for i in all_filters for j in i.split("|")]
|
@@ -66,9 +64,9 @@ async def add_filter(_, m: Message):
|
|
66 |
extracted = await split_quotes(args[1])
|
67 |
keyword = extracted[0].lower()
|
68 |
|
69 |
-
for k in keyword.split("|"):
|
70 |
-
|
71 |
-
|
72 |
|
73 |
if not keyword:
|
74 |
return await m.reply_text(
|
@@ -98,7 +96,6 @@ async def add_filter(_, m: Message):
|
|
98 |
)
|
99 |
|
100 |
add = db.save_filter(m.chat.id, keyword, teks, msgtype, file_id)
|
101 |
-
LOGGER.info(f"{m.from_user.id} added new filter ({keyword}) in {m.chat.id}")
|
102 |
if add:
|
103 |
await m.reply_text(
|
104 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
@@ -110,7 +107,7 @@ async def add_filter(_, m: Message):
|
|
110 |
async def stop_filter(_, m: Message):
|
111 |
args = m.command
|
112 |
|
113 |
-
if len(args)
|
114 |
return await m.reply_text("What should I stop replying to?")
|
115 |
|
116 |
chat_filters = db.get_all_filters(m.chat.id)
|
@@ -122,7 +119,6 @@ async def stop_filter(_, m: Message):
|
|
122 |
for keyword in act_filters:
|
123 |
if keyword == m.text.split(None, 1)[1].lower():
|
124 |
db.rm_filter(m.chat.id, m.text.split(None, 1)[1].lower())
|
125 |
-
LOGGER.info(f"{m.from_user.id} removed filter ({keyword}) in {m.chat.id}")
|
126 |
await m.reply_text(
|
127 |
f"Okay, I'll stop replying to that filter and it's aliases in <b>{m.chat.title}</b>.",
|
128 |
)
|
@@ -171,7 +167,6 @@ async def rm_allfilters_callback(_, q: CallbackQuery):
|
|
171 |
return
|
172 |
db.rm_all_filters(q.message.chat.id)
|
173 |
await q.message.edit_text(f"Cleared all filters for {q.message.chat.title}")
|
174 |
-
LOGGER.info(f"{user_id} removed all filter from {q.message.chat.id}")
|
175 |
await q.answer("Cleared all Filters!", show_alert=True)
|
176 |
return
|
177 |
|
@@ -283,7 +278,6 @@ async def filters_watcher(c: Gojo, m: Message):
|
|
283 |
if match:
|
284 |
try:
|
285 |
msgtype = await send_filter_reply(c, m, trigger)
|
286 |
-
LOGGER.info(f"Replied with {msgtype} to {trigger} in {m.chat.id}")
|
287 |
except Exception as ef:
|
288 |
await m.reply_text(f"Error: {ef}")
|
289 |
LOGGER.error(ef)
|
|
|
25 |
|
26 |
@Gojo.on_message(command("filters") & filters.group & ~filters.bot)
|
27 |
async def view_filters(_, m: Message):
|
|
|
|
|
28 |
filters_chat = f"Filters in <b>{m.chat.title}</b>:\n"
|
29 |
all_filters = db.get_all_filters(m.chat.id)
|
30 |
actual_filters = [j for i in all_filters for j in i.split("|")]
|
|
|
64 |
extracted = await split_quotes(args[1])
|
65 |
keyword = extracted[0].lower()
|
66 |
|
67 |
+
# for k in keyword.split("|"):
|
68 |
+
# if k in actual_filters:
|
69 |
+
# return await m.reply_text(f"Filter <code>{k}</code> already exists!")
|
70 |
|
71 |
if not keyword:
|
72 |
return await m.reply_text(
|
|
|
96 |
)
|
97 |
|
98 |
add = db.save_filter(m.chat.id, keyword, teks, msgtype, file_id)
|
|
|
99 |
if add:
|
100 |
await m.reply_text(
|
101 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
|
|
107 |
async def stop_filter(_, m: Message):
|
108 |
args = m.command
|
109 |
|
110 |
+
if len(args) <= 1:
|
111 |
return await m.reply_text("What should I stop replying to?")
|
112 |
|
113 |
chat_filters = db.get_all_filters(m.chat.id)
|
|
|
119 |
for keyword in act_filters:
|
120 |
if keyword == m.text.split(None, 1)[1].lower():
|
121 |
db.rm_filter(m.chat.id, m.text.split(None, 1)[1].lower())
|
|
|
122 |
await m.reply_text(
|
123 |
f"Okay, I'll stop replying to that filter and it's aliases in <b>{m.chat.title}</b>.",
|
124 |
)
|
|
|
167 |
return
|
168 |
db.rm_all_filters(q.message.chat.id)
|
169 |
await q.message.edit_text(f"Cleared all filters for {q.message.chat.title}")
|
|
|
170 |
await q.answer("Cleared all Filters!", show_alert=True)
|
171 |
return
|
172 |
|
|
|
278 |
if match:
|
279 |
try:
|
280 |
msgtype = await send_filter_reply(c, m, trigger)
|
|
|
281 |
except Exception as ef:
|
282 |
await m.reply_text(f"Error: {ef}")
|
283 |
LOGGER.error(ef)
|
Powers/plugins/flood.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import time
|
|
|
2 |
from random import choice
|
3 |
from traceback import format_exc
|
4 |
|
@@ -10,21 +11,46 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
|
|
10 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
11 |
Message)
|
12 |
|
13 |
-
from Powers import LOGGER,
|
14 |
from Powers.bot_class import Gojo
|
15 |
-
from Powers.database.approve_db import Approve
|
16 |
from Powers.database.flood_db import Floods
|
17 |
-
from Powers.
|
18 |
-
from Powers.utils.custom_filters import admin_filter, command
|
19 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
20 |
-
from Powers.utils.kbhelpers import ikb
|
21 |
-
from Powers.vars import Config
|
22 |
-
|
23 |
-
SUPPORT_STAFF = get_support_staff()
|
24 |
|
25 |
on_key = ["on", "start", "disable"]
|
26 |
off_key = ["off", "end", "enable", "stop"]
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
close_kb =InlineKeyboardMarkup(
|
29 |
[
|
30 |
[
|
@@ -52,6 +78,16 @@ action_kb = InlineKeyboardMarkup(
|
|
52 |
callback_data="f_kick"
|
53 |
)
|
54 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
[
|
56 |
InlineKeyboardButton(
|
57 |
"➡️ Skip",
|
@@ -114,7 +150,7 @@ limit_kb = InlineKeyboardMarkup(
|
|
114 |
@Gojo.on_message(command(['floodaction','actionflood']) & admin_filter)
|
115 |
async def flood_action(c: Gojo, m: Message):
|
116 |
Flood = Floods()
|
117 |
-
bot = await c.get_chat_member(m.chat.id,
|
118 |
status = bot.status
|
119 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
120 |
if not bot.privileges.can_restrict_members:
|
@@ -151,7 +187,7 @@ async def flood_on_off(c: Gojo, m: Message):
|
|
151 |
|
152 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
153 |
async def flood_set(c: Gojo, m: Message):
|
154 |
-
bot = await c.get_chat_member(m.chat.id,
|
155 |
Flood = Floods()
|
156 |
status = bot.status
|
157 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
@@ -176,12 +212,17 @@ async def flood_set(c: Gojo, m: Message):
|
|
176 |
c_id = m.chat.id
|
177 |
if split[1].lower() in on_key:
|
178 |
if is_flood:
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
return
|
183 |
if split[1].lower() in off_key:
|
184 |
x = Flood.rm_flood(c_id)
|
|
|
|
|
|
|
185 |
if x:
|
186 |
await m.reply_text("Flood protection has been stopped for this chat")
|
187 |
return
|
@@ -192,6 +233,7 @@ async def flood_set(c: Gojo, m: Message):
|
|
192 |
|
193 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
194 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
|
|
195 |
data = q.data
|
196 |
if data == "f_close":
|
197 |
await q.answer("Closed")
|
@@ -229,6 +271,28 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
229 |
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
230 |
reply_markup=limit_kb
|
231 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
elif data in ["f_5", "f_10", "f_15", "f_f_f_skip"]:
|
233 |
try:
|
234 |
change = int(data.split("_")[-1])
|
@@ -263,8 +327,8 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
263 |
"Flood protection setting has been updated",
|
264 |
reply_markup=close_kb
|
265 |
)
|
266 |
-
return
|
267 |
await q.answer("skip")
|
|
|
268 |
if not change == swithin:
|
269 |
Flood.save_flood(c_id, slimit, change, saction)
|
270 |
await q.answer("Updated", show_alert=True)
|
@@ -291,6 +355,7 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
291 |
data = q.data.split("_")
|
292 |
action = data[1]
|
293 |
user_id = int(q.data.split("=")[1])
|
|
|
294 |
if not q.from_user:
|
295 |
return q.answer("Looks like you are not an user 👀")
|
296 |
if action == "ban":
|
@@ -330,41 +395,17 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
330 |
return
|
331 |
|
332 |
dic = {}
|
333 |
-
@Gojo.on_message(
|
334 |
async def flood_watcher(c: Gojo, m: Message):
|
335 |
c_id = m.chat.id
|
336 |
|
337 |
-
if not m.chat:
|
338 |
-
return
|
339 |
-
|
340 |
Flood = Floods()
|
341 |
|
342 |
-
|
343 |
-
u_id = m.from_user.id
|
344 |
-
except AttributeError:
|
345 |
-
return # Get this error when the message received is not by an user and return
|
346 |
|
347 |
is_flood = Flood.is_chat(c_id)
|
348 |
|
349 |
-
|
350 |
-
return # return of chat is not in anti flood protection
|
351 |
-
|
352 |
-
app_users = Approve(m.chat.id).list_approved()
|
353 |
-
|
354 |
-
if u_id in {i[0] for i in app_users}:
|
355 |
-
return #return if the user is approved
|
356 |
-
|
357 |
-
if not is_flood or u_id in SUPPORT_STAFF:
|
358 |
-
return #return if the user is in support_staff
|
359 |
-
|
360 |
-
try:
|
361 |
-
user_status = (await m.chat.get_member(m.from_user.id)).status
|
362 |
-
except Exception:
|
363 |
-
return
|
364 |
-
|
365 |
-
if user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
366 |
-
return #return if the user is owner or admin
|
367 |
-
|
368 |
action = is_flood[2]
|
369 |
limit = int(is_flood[0])
|
370 |
within = int(is_flood[1])
|
@@ -398,6 +439,101 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
398 |
|
399 |
if len(dic[c_id][u_id][1]) == limit:
|
400 |
if y-x <= within:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
if action == "ban":
|
402 |
try:
|
403 |
await m.chat.ban_member(u_id)
|
@@ -442,13 +578,14 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
442 |
|
443 |
elif action == "kick":
|
444 |
try:
|
445 |
-
|
446 |
-
|
|
|
|
|
447 |
await m.reply_animation(
|
448 |
animation=str(choice(KICK_GIFS)),
|
449 |
-
caption=txt
|
450 |
)
|
451 |
-
await m.chat.unban_member(u_id)
|
452 |
dic[c_id][u_id][1].clear()
|
453 |
dic[c_id][u_id][0].clear()
|
454 |
return
|
@@ -470,6 +607,12 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
470 |
dic[c_id][u_id][1].clear()
|
471 |
dic[c_id][u_id][0].clear()
|
472 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
elif action == "mute":
|
474 |
try:
|
475 |
await m.chat.restrict_member(
|
|
|
1 |
import time
|
2 |
+
from datetime import datetime, timedelta
|
3 |
from random import choice
|
4 |
from traceback import format_exc
|
5 |
|
|
|
11 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
12 |
Message)
|
13 |
|
14 |
+
from Powers import DEV_USERS, LOGGER, SUDO_USERS, WHITELIST_USERS
|
15 |
from Powers.bot_class import Gojo
|
|
|
16 |
from Powers.database.flood_db import Floods
|
17 |
+
from Powers.utils.custom_filters import admin_filter, command, flood_filter
|
|
|
18 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
|
|
|
|
|
|
|
|
19 |
|
20 |
on_key = ["on", "start", "disable"]
|
21 |
off_key = ["off", "end", "enable", "stop"]
|
22 |
|
23 |
+
async def get_what_temp(what):
|
24 |
+
temp_duration = InlineKeyboardMarkup(
|
25 |
+
[
|
26 |
+
[
|
27 |
+
InlineKeyboardButton(
|
28 |
+
"5 minutes",
|
29 |
+
f"f_temp_{what}_5min"
|
30 |
+
),
|
31 |
+
InlineKeyboardButton(
|
32 |
+
"10 minute",
|
33 |
+
f"f_temp_{what}_10min",
|
34 |
+
),
|
35 |
+
InlineKeyboardButton(
|
36 |
+
"30 minute",
|
37 |
+
f"f_temp_{what}_30min"
|
38 |
+
),
|
39 |
+
InlineKeyboardButton(
|
40 |
+
"1 hour",
|
41 |
+
f"f_temp_{what}_60min"
|
42 |
+
)
|
43 |
+
],
|
44 |
+
[
|
45 |
+
InlineKeyboardButton(
|
46 |
+
"« Back",
|
47 |
+
"f_temp_back"
|
48 |
+
)
|
49 |
+
]
|
50 |
+
]
|
51 |
+
)
|
52 |
+
return temp_duration
|
53 |
+
|
54 |
close_kb =InlineKeyboardMarkup(
|
55 |
[
|
56 |
[
|
|
|
78 |
callback_data="f_kick"
|
79 |
)
|
80 |
],
|
81 |
+
[
|
82 |
+
InlineKeyboardButton(
|
83 |
+
"Temp Mute 🔇",
|
84 |
+
"f_temp_mute"
|
85 |
+
),
|
86 |
+
InlineKeyboardButton(
|
87 |
+
"Temp Ban 🚷",
|
88 |
+
"f_temp_ban"
|
89 |
+
)
|
90 |
+
],
|
91 |
[
|
92 |
InlineKeyboardButton(
|
93 |
"➡️ Skip",
|
|
|
150 |
@Gojo.on_message(command(['floodaction','actionflood']) & admin_filter)
|
151 |
async def flood_action(c: Gojo, m: Message):
|
152 |
Flood = Floods()
|
153 |
+
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
154 |
status = bot.status
|
155 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
156 |
if not bot.privileges.can_restrict_members:
|
|
|
187 |
|
188 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
189 |
async def flood_set(c: Gojo, m: Message):
|
190 |
+
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
191 |
Flood = Floods()
|
192 |
status = bot.status
|
193 |
if not status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
|
|
212 |
c_id = m.chat.id
|
213 |
if split[1].lower() in on_key:
|
214 |
if is_flood:
|
215 |
+
saction = is_flood[2]
|
216 |
+
slimit = is_flood[0]
|
217 |
+
swithin = is_flood[1]
|
218 |
+
|
219 |
+
await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
220 |
return
|
221 |
if split[1].lower() in off_key:
|
222 |
x = Flood.rm_flood(c_id)
|
223 |
+
if not is_flood:
|
224 |
+
await m.reply_text("Flood protection is already off for this chat")
|
225 |
+
return
|
226 |
if x:
|
227 |
await m.reply_text("Flood protection has been stopped for this chat")
|
228 |
return
|
|
|
233 |
|
234 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
235 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
236 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
237 |
data = q.data
|
238 |
if data == "f_close":
|
239 |
await q.answer("Closed")
|
|
|
271 |
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
272 |
reply_markup=limit_kb
|
273 |
)
|
274 |
+
elif data.startswith("f_temp_"):
|
275 |
+
splited = data.split("_")
|
276 |
+
if len(splited) == 3:
|
277 |
+
to_do = splited[-1]
|
278 |
+
if to_do == "back":
|
279 |
+
kb = action_kb
|
280 |
+
await q.edit_message_text(
|
281 |
+
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
282 |
+
reply_markup=action_kb
|
283 |
+
)
|
284 |
+
return
|
285 |
+
kb = await get_what_temp(to_do)
|
286 |
+
await q.answer(f"Choose temp {to_do} time", True)
|
287 |
+
await q.edit_message_text(f"What shoud be temp {to_do} time?", reply_markup=kb)
|
288 |
+
else:
|
289 |
+
change = f"{splited[-2]}_{splited[-1]}"
|
290 |
+
Flood.save_flood(c_id, slimit, swithin, change)
|
291 |
+
await q.edit_message_text(
|
292 |
+
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
293 |
+
reply_markup=limit_kb
|
294 |
+
)
|
295 |
+
return
|
296 |
elif data in ["f_5", "f_10", "f_15", "f_f_f_skip"]:
|
297 |
try:
|
298 |
change = int(data.split("_")[-1])
|
|
|
327 |
"Flood protection setting has been updated",
|
328 |
reply_markup=close_kb
|
329 |
)
|
|
|
330 |
await q.answer("skip")
|
331 |
+
return
|
332 |
if not change == swithin:
|
333 |
Flood.save_flood(c_id, slimit, change, saction)
|
334 |
await q.answer("Updated", show_alert=True)
|
|
|
355 |
data = q.data.split("_")
|
356 |
action = data[1]
|
357 |
user_id = int(q.data.split("=")[1])
|
358 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
359 |
if not q.from_user:
|
360 |
return q.answer("Looks like you are not an user 👀")
|
361 |
if action == "ban":
|
|
|
395 |
return
|
396 |
|
397 |
dic = {}
|
398 |
+
@Gojo.on_message(flood_filter, 18)
|
399 |
async def flood_watcher(c: Gojo, m: Message):
|
400 |
c_id = m.chat.id
|
401 |
|
|
|
|
|
|
|
402 |
Flood = Floods()
|
403 |
|
404 |
+
u_id = m.from_user.id
|
|
|
|
|
|
|
405 |
|
406 |
is_flood = Flood.is_chat(c_id)
|
407 |
|
408 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
409 |
action = is_flood[2]
|
410 |
limit = int(is_flood[0])
|
411 |
within = int(is_flood[1])
|
|
|
439 |
|
440 |
if len(dic[c_id][u_id][1]) == limit:
|
441 |
if y-x <= within:
|
442 |
+
action = action.split("_")
|
443 |
+
if len(action) == 2:
|
444 |
+
try:
|
445 |
+
to_do = action[0]
|
446 |
+
for_tim = int(action[1].replace("min",""))
|
447 |
+
except:
|
448 |
+
for_tim = 30
|
449 |
+
for_how_much = datetime.now() + timedelta(minutes=for_tim)
|
450 |
+
if to_do == "ban":
|
451 |
+
try:
|
452 |
+
await m.chat.ban_member(u_id, until_date=for_how_much)
|
453 |
+
keyboard = InlineKeyboardMarkup(
|
454 |
+
[
|
455 |
+
[
|
456 |
+
InlineKeyboardButton(
|
457 |
+
"Unban",
|
458 |
+
callback_data=f"un_ban_={u_id}",
|
459 |
+
),
|
460 |
+
],
|
461 |
+
],
|
462 |
+
)
|
463 |
+
txt = f"Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: Baned\nReason: Spaming\nUntril: {for_how_much}"
|
464 |
+
await m.reply_animation(
|
465 |
+
animation=str(choice(BAN_GIFS)),
|
466 |
+
caption=txt,
|
467 |
+
reply_markup=keyboard,
|
468 |
+
)
|
469 |
+
dic[c_id][u_id][1].clear()
|
470 |
+
dic[c_id][u_id][0].clear()
|
471 |
+
return
|
472 |
+
|
473 |
+
except UserAdminInvalid:
|
474 |
+
await m.reply_text(
|
475 |
+
"I can't protect this chat from this user",
|
476 |
+
)
|
477 |
+
dic[c_id][u_id][1].clear()
|
478 |
+
dic[c_id][u_id][0].clear()
|
479 |
+
return
|
480 |
+
except RPCError as ef:
|
481 |
+
await m.reply_text(
|
482 |
+
text=f"""Some error occured, report it using `/bug`
|
483 |
+
|
484 |
+
<b>Error:</b> <code>{ef}</code>"""
|
485 |
+
)
|
486 |
+
LOGGER.error(ef)
|
487 |
+
LOGGER.error(format_exc())
|
488 |
+
dic[c_id][u_id][1].clear()
|
489 |
+
dic[c_id][u_id][0].clear()
|
490 |
+
return
|
491 |
+
else:
|
492 |
+
try:
|
493 |
+
await m.chat.restrict_member(
|
494 |
+
u_id,
|
495 |
+
ChatPermissions(),
|
496 |
+
until_date=for_how_much
|
497 |
+
)
|
498 |
+
keyboard = InlineKeyboardMarkup(
|
499 |
+
[
|
500 |
+
[
|
501 |
+
InlineKeyboardButton(
|
502 |
+
"Unmute",
|
503 |
+
callback_data=f"un_mute_={u_id}",
|
504 |
+
),
|
505 |
+
],
|
506 |
+
],
|
507 |
+
)
|
508 |
+
txt = f"Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: Muted\nReason: Spaming\nUntil: {for_how_much}"
|
509 |
+
await m.reply_animation(
|
510 |
+
animation=str(choice(MUTE_GIFS)),
|
511 |
+
caption=txt,
|
512 |
+
reply_markup=keyboard,
|
513 |
+
)
|
514 |
+
dic[c_id][u_id][1].clear()
|
515 |
+
dic[c_id][u_id][0].clear()
|
516 |
+
return
|
517 |
+
except UserAdminInvalid:
|
518 |
+
await m.reply_text(
|
519 |
+
"I can't protect this chat from this user",
|
520 |
+
)
|
521 |
+
dic[c_id][u_id][1].clear()
|
522 |
+
dic[c_id][u_id][0].clear()
|
523 |
+
return
|
524 |
+
except RPCError as ef:
|
525 |
+
await m.reply_text(
|
526 |
+
text=f"""Some error occured, report it using `/bug`
|
527 |
+
|
528 |
+
<b>Error:</b> <code>{ef}</code>"""
|
529 |
+
)
|
530 |
+
LOGGER.error(ef)
|
531 |
+
LOGGER.error(format_exc())
|
532 |
+
dic[c_id][u_id][1].clear()
|
533 |
+
dic[c_id][u_id][0].clear()
|
534 |
+
return
|
535 |
+
else:
|
536 |
+
action = action[0]
|
537 |
if action == "ban":
|
538 |
try:
|
539 |
await m.chat.ban_member(u_id)
|
|
|
578 |
|
579 |
elif action == "kick":
|
580 |
try:
|
581 |
+
d = datetime.now()+timedelta(seconds=31) #will automatically unban user after 31 seconds kind of fail safe if unban members doesn't work properly
|
582 |
+
await m.chat.ban_member(u_id, until_date=d)
|
583 |
+
success = await c.unban_chat_member(m.chat.id, u_id)
|
584 |
+
txt = f"Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: {'kicked' if success else 'banned for 30 seconds'}\nReason: Spaming"
|
585 |
await m.reply_animation(
|
586 |
animation=str(choice(KICK_GIFS)),
|
587 |
+
caption=txt
|
588 |
)
|
|
|
589 |
dic[c_id][u_id][1].clear()
|
590 |
dic[c_id][u_id][0].clear()
|
591 |
return
|
|
|
607 |
dic[c_id][u_id][1].clear()
|
608 |
dic[c_id][u_id][0].clear()
|
609 |
return
|
610 |
+
except Exception as e:
|
611 |
+
LOGGER.error(e)
|
612 |
+
LOGGER.error(format_exc())
|
613 |
+
dic[c_id][u_id][1].clear()
|
614 |
+
dic[c_id][u_id][0].clear()
|
615 |
+
return
|
616 |
elif action == "mute":
|
617 |
try:
|
618 |
await m.chat.restrict_member(
|
Powers/plugins/formatting.py
CHANGED
@@ -35,18 +35,10 @@ async def markdownhelp(_, m: Message):
|
|
35 |
quote=True,
|
36 |
reply_markup=(await gen_formatting_kb(m)),
|
37 |
)
|
38 |
-
LOGGER.info(f"{m.from_user.id} used cmd '{m.command}' in {m.chat.id}")
|
39 |
return
|
40 |
|
41 |
|
42 |
-
|
43 |
-
async def get_formatting_info(c: Gojo, q: CallbackQuery):
|
44 |
-
cmd = q.data.split(".")[1]
|
45 |
-
kb = ikb([[("Back", "back.formatting")]])
|
46 |
-
|
47 |
-
if cmd == "md_formatting":
|
48 |
-
|
49 |
-
txt = """<b>Markdown Formatting</b>
|
50 |
You can format your message using <b>bold</b>, <i>italic</i>, <u>underline</u>, <strike>strike</strike> and much more. Go ahead and experiment!
|
51 |
|
52 |
**Note**: It supports telegram user based formatting as well as html and markdown formattings.
|
@@ -66,17 +58,74 @@ If you would like to send buttons on the same row, use the <code>:same</code> fo
|
|
66 |
<code>[button 2](buttonurl://example.com:same)</code>
|
67 |
<code>[button 3](buttonurl://example.com)</code>
|
68 |
This will show button 1 and 2 on the same line, while 3 will be underneath."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
try:
|
70 |
await q.edit_message_caption(
|
71 |
-
caption=
|
72 |
reply_markup=kb,
|
73 |
parse_mode=enums.ParseMode.HTML,
|
74 |
)
|
75 |
except MediaCaptionTooLong:
|
76 |
-
await
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
80 |
elif cmd == "fillings":
|
81 |
await q.edit_message_caption(
|
82 |
caption="""<b>Fillings</b>
|
|
|
35 |
quote=True,
|
36 |
reply_markup=(await gen_formatting_kb(m)),
|
37 |
)
|
|
|
38 |
return
|
39 |
|
40 |
|
41 |
+
md_txt = """<b>Markdown Formatting</b>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
You can format your message using <b>bold</b>, <i>italic</i>, <u>underline</u>, <strike>strike</strike> and much more. Go ahead and experiment!
|
43 |
|
44 |
**Note**: It supports telegram user based formatting as well as html and markdown formattings.
|
|
|
58 |
<code>[button 2](buttonurl://example.com:same)</code>
|
59 |
<code>[button 3](buttonurl://example.com)</code>
|
60 |
This will show button 1 and 2 on the same line, while 3 will be underneath."""
|
61 |
+
|
62 |
+
async def get_splited_formatting(msg, page=1):
|
63 |
+
msg = msg.split("\n")
|
64 |
+
l = len(msg)
|
65 |
+
new_msg = ""
|
66 |
+
total = l // 10
|
67 |
+
first = 10 * (page - 1)
|
68 |
+
last = 10 * page
|
69 |
+
if not first:
|
70 |
+
for i in msg[first:last]:
|
71 |
+
new_msg += f"{i}\n"
|
72 |
+
kb = [
|
73 |
+
[
|
74 |
+
("Next page ▶️", f"next_format_{page+1}")
|
75 |
+
]
|
76 |
+
]
|
77 |
+
else:
|
78 |
+
first += 1
|
79 |
+
if page == total:
|
80 |
+
for i in msg[first:]:
|
81 |
+
new_msg += f"{i}\n"
|
82 |
+
kb = [
|
83 |
+
[
|
84 |
+
("◀️ Previous page", f"next_format_{page-1}")
|
85 |
+
]
|
86 |
+
]
|
87 |
+
else:
|
88 |
+
for i in msg[first:last]:
|
89 |
+
new_msg += f"{i}\n"
|
90 |
+
kb = [
|
91 |
+
[
|
92 |
+
("◀️ Previous page", f"next_format_{page-1}"),
|
93 |
+
("Next page ▶️", f"next_format_{page+1}")
|
94 |
+
]
|
95 |
+
]
|
96 |
+
|
97 |
+
|
98 |
+
kb = ikb(kb, True, "back.formatting")
|
99 |
+
|
100 |
+
return new_msg, kb
|
101 |
+
|
102 |
+
@Gojo.on_callback_query(filters.regex(r"^next_format_.*[0-9]$"))
|
103 |
+
async def change_formatting_page(c: Gojo, q: CallbackQuery):
|
104 |
+
page = q.data.split("_")[-1]
|
105 |
+
txt, kb = await get_splited_formatting(md_txt, int(page))
|
106 |
+
await q.edit_message_caption(txt, reply_markup=kb,parse_mode=enums.ParseMode.HTML,)
|
107 |
+
return
|
108 |
+
|
109 |
+
@Gojo.on_callback_query(filters.regex("^formatting."))
|
110 |
+
async def get_formatting_info(c: Gojo, q: CallbackQuery):
|
111 |
+
cmd = q.data.split(".")[1]
|
112 |
+
kb = ikb([[("Back", "back.formatting")]])
|
113 |
+
|
114 |
+
if cmd == "md_formatting":
|
115 |
+
|
116 |
try:
|
117 |
await q.edit_message_caption(
|
118 |
+
caption=md_txt,
|
119 |
reply_markup=kb,
|
120 |
parse_mode=enums.ParseMode.HTML,
|
121 |
)
|
122 |
except MediaCaptionTooLong:
|
123 |
+
txt, kb = await get_splited_formatting(md_txt)
|
124 |
+
await q.edit_message_caption(
|
125 |
+
caption=txt,
|
126 |
+
reply_markup=kb,
|
127 |
+
parse_mode=enums.ParseMode.HTML,
|
128 |
+
)
|
129 |
elif cmd == "fillings":
|
130 |
await q.edit_message_caption(
|
131 |
caption="""<b>Fillings</b>
|
Powers/plugins/fun.py
CHANGED
@@ -5,15 +5,13 @@ from pyrogram import enums
|
|
5 |
from pyrogram.errors import MessageTooLong
|
6 |
from pyrogram.types import Message
|
7 |
|
8 |
-
from Powers import
|
9 |
from Powers.bot_class import Gojo
|
10 |
-
from Powers.supports import get_support_staff
|
11 |
from Powers.utils import extras
|
12 |
from Powers.utils.custom_filters import command
|
13 |
from Powers.utils.extras import NOWYES as NO
|
14 |
from Powers.utils.extras import YESWNO as YES
|
15 |
|
16 |
-
DEV_USERS = get_support_staff("dev")
|
17 |
|
18 |
@Gojo.on_message(command("shout"))
|
19 |
async def fun_shout(_, m: Message):
|
@@ -33,7 +31,6 @@ async def fun_shout(_, m: Message):
|
|
33 |
result = "".join(result)
|
34 |
msg = "```\n" + result + "```"
|
35 |
await m.reply_text(msg, parse_mode=enums.ParseMode.MARKDOWN)
|
36 |
-
LOGGER.info(f"{m.from_user.id} shouted in {m.chat.id}")
|
37 |
return
|
38 |
except MessageTooLong as e:
|
39 |
await m.reply_text(f"Error: {e}")
|
@@ -43,7 +40,6 @@ async def fun_shout(_, m: Message):
|
|
43 |
@Gojo.on_message(command("runs"))
|
44 |
async def fun_run(_, m: Message):
|
45 |
await m.reply_text(choice(extras.RUN_STRINGS))
|
46 |
-
LOGGER.info(f"{m.from_user.id} runed in {m.chat.id}")
|
47 |
return
|
48 |
|
49 |
|
@@ -79,7 +75,6 @@ async def fun_slap(c: Gojo, m: Message):
|
|
79 |
|
80 |
reply = temp.format(user1=user1, user2=user2, item=item, hits=hit, throws=throw)
|
81 |
await reply_text(reply)
|
82 |
-
LOGGER.info(f"{m.from_user.id} slaped in {m.chat.id}")
|
83 |
return
|
84 |
|
85 |
|
@@ -87,7 +82,6 @@ async def fun_slap(c: Gojo, m: Message):
|
|
87 |
async def fun_roll(_, m: Message):
|
88 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
89 |
await reply_text(choice(range(1, 7)))
|
90 |
-
LOGGER.info(f"{m.from_user.id} roll in {m.chat.id}")
|
91 |
return
|
92 |
|
93 |
|
@@ -95,7 +89,6 @@ async def fun_roll(_, m: Message):
|
|
95 |
async def fun_toss(_, m: Message):
|
96 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
97 |
await reply_text(choice(extras.TOSS))
|
98 |
-
LOGGER.info(f"{m.from_user.id} tossed in {m.chat.id}")
|
99 |
return
|
100 |
|
101 |
|
@@ -108,13 +101,9 @@ async def insult(c: Gojo, m: Message):
|
|
108 |
user_first_name = m.reply_to_message.from_user.first_name
|
109 |
if user_id in DEV_USERS:
|
110 |
await m.reply_text("Sorry! I can't insult my devs....")
|
111 |
-
return LOGGER.info(
|
112 |
-
f"{m.from_user.id} tried to insult {user_first_name} in {m.chat.id}"
|
113 |
-
)
|
114 |
else:
|
115 |
Insult_omp = choice(extras.INSULT_STRINGS)
|
116 |
await m.reply_to_message.reply_text(Insult_omp)
|
117 |
-
LOGGER.info(f"{m.from_user.id} insulted {user_first_name} in {m.chat.id}")
|
118 |
|
119 |
|
120 |
@Gojo.on_message(command("yes"))
|
@@ -122,7 +111,6 @@ async def yesw(c: Gojo, m: Message):
|
|
122 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
123 |
rtext = YES[0]
|
124 |
await reply_text(rtext)
|
125 |
-
LOGGER.info(f"{m.from_user.id} said YES or may be NO in {m.chat.id}")
|
126 |
return
|
127 |
|
128 |
|
@@ -131,7 +119,6 @@ async def now(c: Gojo, m: Message):
|
|
131 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
132 |
rtext = NO[0]
|
133 |
await reply_text(rtext)
|
134 |
-
LOGGER.info(f"{m.from_user.id} said NO or may be YES in {m.chat.id}")
|
135 |
return
|
136 |
|
137 |
|
@@ -139,7 +126,6 @@ async def now(c: Gojo, m: Message):
|
|
139 |
async def fun_shrug(_, m: Message):
|
140 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
141 |
await reply_text(r"¯\_(ツ)_/¯")
|
142 |
-
LOGGER.info(f"{m.from_user.id} shruged in {m.chat.id}")
|
143 |
return
|
144 |
|
145 |
|
@@ -149,7 +135,6 @@ async def fun_bluetext(_, m: Message):
|
|
149 |
await reply_text(
|
150 |
"|| /BLUE /TEXT\n/MUST /CLICK\n/I /AM /A /STUPID /ANIMAL /THAT /IS /ATTRACTED /TO /COLORS ||",
|
151 |
)
|
152 |
-
LOGGER.info(f"{m.from_user.id} bluetexted in {m.chat.id}")
|
153 |
return
|
154 |
|
155 |
|
@@ -157,7 +142,6 @@ async def fun_bluetext(_, m: Message):
|
|
157 |
async def fun_decide(_, m: Message):
|
158 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
159 |
await reply_text(choice(extras.DECIDE))
|
160 |
-
LOGGER.info(f"{m.from_user.id} decided in {m.chat.id}")
|
161 |
return
|
162 |
|
163 |
|
@@ -165,7 +149,6 @@ async def fun_decide(_, m: Message):
|
|
165 |
async def fun_table(_, m: Message):
|
166 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
167 |
await reply_text(choice(extras.REACTIONS))
|
168 |
-
LOGGER.info(f"{m.from_user.id} reacted in {m.chat.id}")
|
169 |
return
|
170 |
|
171 |
|
@@ -199,7 +182,6 @@ async def weebify(_, m: Message):
|
|
199 |
text=f"""<b>Weebified String:</b>
|
200 |
<code>{string}</code>"""
|
201 |
)
|
202 |
-
LOGGER.info(f"{m.from_user.id} weebified '{args}' in {m.chat.id}")
|
203 |
return
|
204 |
|
205 |
|
|
|
5 |
from pyrogram.errors import MessageTooLong
|
6 |
from pyrogram.types import Message
|
7 |
|
8 |
+
from Powers import DEV_USERS
|
9 |
from Powers.bot_class import Gojo
|
|
|
10 |
from Powers.utils import extras
|
11 |
from Powers.utils.custom_filters import command
|
12 |
from Powers.utils.extras import NOWYES as NO
|
13 |
from Powers.utils.extras import YESWNO as YES
|
14 |
|
|
|
15 |
|
16 |
@Gojo.on_message(command("shout"))
|
17 |
async def fun_shout(_, m: Message):
|
|
|
31 |
result = "".join(result)
|
32 |
msg = "```\n" + result + "```"
|
33 |
await m.reply_text(msg, parse_mode=enums.ParseMode.MARKDOWN)
|
|
|
34 |
return
|
35 |
except MessageTooLong as e:
|
36 |
await m.reply_text(f"Error: {e}")
|
|
|
40 |
@Gojo.on_message(command("runs"))
|
41 |
async def fun_run(_, m: Message):
|
42 |
await m.reply_text(choice(extras.RUN_STRINGS))
|
|
|
43 |
return
|
44 |
|
45 |
|
|
|
75 |
|
76 |
reply = temp.format(user1=user1, user2=user2, item=item, hits=hit, throws=throw)
|
77 |
await reply_text(reply)
|
|
|
78 |
return
|
79 |
|
80 |
|
|
|
82 |
async def fun_roll(_, m: Message):
|
83 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
84 |
await reply_text(choice(range(1, 7)))
|
|
|
85 |
return
|
86 |
|
87 |
|
|
|
89 |
async def fun_toss(_, m: Message):
|
90 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
91 |
await reply_text(choice(extras.TOSS))
|
|
|
92 |
return
|
93 |
|
94 |
|
|
|
101 |
user_first_name = m.reply_to_message.from_user.first_name
|
102 |
if user_id in DEV_USERS:
|
103 |
await m.reply_text("Sorry! I can't insult my devs....")
|
|
|
|
|
|
|
104 |
else:
|
105 |
Insult_omp = choice(extras.INSULT_STRINGS)
|
106 |
await m.reply_to_message.reply_text(Insult_omp)
|
|
|
107 |
|
108 |
|
109 |
@Gojo.on_message(command("yes"))
|
|
|
111 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
112 |
rtext = YES[0]
|
113 |
await reply_text(rtext)
|
|
|
114 |
return
|
115 |
|
116 |
|
|
|
119 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
120 |
rtext = NO[0]
|
121 |
await reply_text(rtext)
|
|
|
122 |
return
|
123 |
|
124 |
|
|
|
126 |
async def fun_shrug(_, m: Message):
|
127 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
128 |
await reply_text(r"¯\_(ツ)_/¯")
|
|
|
129 |
return
|
130 |
|
131 |
|
|
|
135 |
await reply_text(
|
136 |
"|| /BLUE /TEXT\n/MUST /CLICK\n/I /AM /A /STUPID /ANIMAL /THAT /IS /ATTRACTED /TO /COLORS ||",
|
137 |
)
|
|
|
138 |
return
|
139 |
|
140 |
|
|
|
142 |
async def fun_decide(_, m: Message):
|
143 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
144 |
await reply_text(choice(extras.DECIDE))
|
|
|
145 |
return
|
146 |
|
147 |
|
|
|
149 |
async def fun_table(_, m: Message):
|
150 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
151 |
await reply_text(choice(extras.REACTIONS))
|
|
|
152 |
return
|
153 |
|
154 |
|
|
|
182 |
text=f"""<b>Weebified String:</b>
|
183 |
<code>{string}</code>"""
|
184 |
)
|
|
|
185 |
return
|
186 |
|
187 |
|
Powers/plugins/greetings.py
CHANGED
@@ -1,45 +1,38 @@
|
|
1 |
from html import escape
|
2 |
from secrets import choice
|
3 |
from traceback import format_exc
|
|
|
4 |
|
5 |
-
from pyrogram import enums, filters
|
6 |
-
from pyrogram.
|
7 |
-
from pyrogram.
|
8 |
-
from pyrogram.types import ChatMemberUpdated, Message
|
9 |
|
10 |
-
from Powers import LOGGER
|
11 |
from Powers.bot_class import Gojo
|
12 |
from Powers.database.antispam_db import GBan
|
13 |
from Powers.database.greetings_db import Greetings
|
14 |
-
from Powers.supports import get_support_staff
|
15 |
from Powers.utils.cmd_senders import send_cmd
|
16 |
-
from Powers.utils.custom_filters import admin_filter, bot_admin_filter,
|
|
|
17 |
from Powers.utils.kbhelpers import ikb
|
18 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
19 |
from Powers.utils.parser import escape_markdown, mention_html
|
20 |
from Powers.utils.string import (build_keyboard, escape_invalid_curly_brackets,
|
21 |
parse_button)
|
22 |
-
from Powers.vars import Config
|
23 |
|
24 |
# Initialize
|
25 |
gdb = GBan()
|
26 |
|
27 |
-
DEV_USERS = get_support_staff("dev")
|
28 |
-
|
29 |
ChatType = enums.ChatType
|
30 |
|
31 |
|
32 |
-
async def
|
33 |
-
|
34 |
-
|
35 |
text: str,
|
36 |
parse_words: list,
|
37 |
) -> str:
|
38 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
39 |
-
if n:
|
40 |
-
user = m.new_chat_member.user if m.new_chat_member else m.from_user
|
41 |
-
else:
|
42 |
-
user = m.old_chat_member.user if m.old_chat_member else m.from_user
|
43 |
if teks:
|
44 |
teks = teks.format(
|
45 |
first=escape(user.first_name),
|
@@ -239,115 +232,101 @@ async def cleannnnn(_, m: Message):
|
|
239 |
except Exception:
|
240 |
pass
|
241 |
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
and member.new_chat_member.status not in {CMS.BANNED, CMS.LEFT, CMS.RESTRICTED}
|
249 |
-
and not member.old_chat_member
|
250 |
-
):
|
251 |
-
pass
|
252 |
-
else:
|
253 |
-
return
|
254 |
-
|
255 |
-
user = member.new_chat_member.user if member.new_chat_member else member.from_user
|
256 |
-
|
257 |
-
db = Greetings(member.chat.id)
|
258 |
-
banned_users = gdb.check_gban(user.id)
|
259 |
-
try:
|
260 |
-
if user.id == Config.BOT_ID:
|
261 |
-
return
|
262 |
-
if user.id in DEV_USERS:
|
263 |
-
await c.send_animation(
|
264 |
-
chat_id=member.chat.id,
|
265 |
-
animation="./extras/william.gif",
|
266 |
-
caption="😳 My **DEV** has also joined the chat!",
|
267 |
-
)
|
268 |
-
return
|
269 |
-
if banned_users:
|
270 |
-
await member.chat.ban_member(user.id)
|
271 |
-
await c.send_message(
|
272 |
-
member.chat.id,
|
273 |
-
f"{user.mention} was globally banned so i banned!",
|
274 |
-
)
|
275 |
-
return
|
276 |
-
if user.is_bot:
|
277 |
-
return # ignore bots
|
278 |
-
except ChatAdminRequired:
|
279 |
-
return
|
280 |
-
status = db.get_welcome_status()
|
281 |
-
oo = db.get_welcome_text()
|
282 |
-
UwU = db.get_welcome_media()
|
283 |
-
mtype = db.get_welcome_msgtype()
|
284 |
-
parse_words = [
|
285 |
-
"first",
|
286 |
-
"last",
|
287 |
-
"fullname",
|
288 |
-
"username",
|
289 |
-
"mention",
|
290 |
-
"id",
|
291 |
-
"chatname",
|
292 |
-
]
|
293 |
-
hmm = await escape_mentions_using_curly_brackets_wl(member, True, oo, parse_words)
|
294 |
-
if status:
|
295 |
-
tek, button = await parse_button(hmm)
|
296 |
-
button = await build_keyboard(button)
|
297 |
-
button = ikb(button) if button else None
|
298 |
-
|
299 |
-
if "%%%" in tek:
|
300 |
-
filter_reply = tek.split("%%%")
|
301 |
-
teks = choice(filter_reply)
|
302 |
-
else:
|
303 |
-
teks = tek
|
304 |
-
ifff = db.get_current_cleanwelcome_id()
|
305 |
-
gg = db.get_current_cleanwelcome_settings()
|
306 |
-
if ifff and gg:
|
307 |
-
try:
|
308 |
-
await c.delete_messages(member.chat.id, int(ifff))
|
309 |
-
except RPCError:
|
310 |
-
pass
|
311 |
-
if not teks:
|
312 |
-
teks = "Hey {first}, welcome to {chatname}"
|
313 |
try:
|
314 |
-
if
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
|
|
320 |
)
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
-
if jj:
|
330 |
-
db.set_cleanwlcm_id(int(jj.id))
|
331 |
-
except RPCError as e:
|
332 |
-
LOGGER.error(e)
|
333 |
-
LOGGER.error(format_exc(e))
|
334 |
-
return
|
335 |
-
else:
|
336 |
-
return
|
337 |
-
|
338 |
-
|
339 |
-
@Gojo.on_chat_member_updated(filters.group, group=99)
|
340 |
-
async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
341 |
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
and member.old_chat_member
|
346 |
-
):
|
347 |
-
pass
|
348 |
-
else:
|
349 |
-
return
|
350 |
-
db = Greetings(member.chat.id)
|
351 |
status = db.get_goodbye_status()
|
352 |
oo = db.get_goodbye_text()
|
353 |
UwU = db.get_goodbye_media()
|
@@ -362,9 +341,9 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
362 |
"chatname",
|
363 |
]
|
364 |
|
365 |
-
user =
|
366 |
|
367 |
-
hmm = await escape_mentions_using_curly_brackets_wl(
|
368 |
if status:
|
369 |
tek, button = await parse_button(hmm)
|
370 |
button = await build_keyboard(button)
|
@@ -375,17 +354,21 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
375 |
teks = choice(filter_reply)
|
376 |
else:
|
377 |
teks = tek
|
|
|
|
|
|
|
|
|
378 |
ifff = db.get_current_cleangoodbye_id()
|
379 |
iii = db.get_current_cleangoodbye_settings()
|
380 |
if ifff and iii:
|
381 |
try:
|
382 |
-
await c.delete_messages(
|
383 |
except RPCError:
|
384 |
pass
|
385 |
if user.id in DEV_USERS:
|
386 |
await c.send_message(
|
387 |
-
|
388 |
-
"Will miss you master :(",
|
389 |
)
|
390 |
return
|
391 |
if not teks:
|
@@ -393,14 +376,14 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
393 |
try:
|
394 |
if not UwU:
|
395 |
ooo = await c.send_message(
|
396 |
-
|
397 |
text=teks,
|
398 |
reply_markup=button,
|
399 |
disable_web_page_preview=True,
|
400 |
)
|
401 |
elif UwU:
|
402 |
ooo = await (await send_cmd(c,mtype))(
|
403 |
-
|
404 |
UwU,
|
405 |
caption=teks,
|
406 |
reply_markup=button,
|
@@ -409,6 +392,8 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
409 |
if ooo:
|
410 |
db.set_cleangoodbye_id(int(ooo.id))
|
411 |
return
|
|
|
|
|
412 |
except RPCError as e:
|
413 |
LOGGER.error(e)
|
414 |
LOGGER.error(format_exc(e))
|
@@ -541,8 +526,6 @@ async def goodbye(c: Gojo, m: Message):
|
|
541 |
reply_markup=button,
|
542 |
)
|
543 |
return
|
544 |
-
return
|
545 |
-
|
546 |
|
547 |
__PLUGIN__ = "greetings"
|
548 |
__alt_name__ = ["welcome", "goodbye", "cleanservice"]
|
|
|
1 |
from html import escape
|
2 |
from secrets import choice
|
3 |
from traceback import format_exc
|
4 |
+
from typing import List
|
5 |
|
6 |
+
from pyrogram import emoji, enums, filters
|
7 |
+
from pyrogram.errors import ChannelPrivate, ChatAdminRequired, RPCError
|
8 |
+
from pyrogram.types import Message, User
|
|
|
9 |
|
10 |
+
from Powers import DEV_USERS, LOGGER
|
11 |
from Powers.bot_class import Gojo
|
12 |
from Powers.database.antispam_db import GBan
|
13 |
from Powers.database.greetings_db import Greetings
|
|
|
14 |
from Powers.utils.cmd_senders import send_cmd
|
15 |
+
from Powers.utils.custom_filters import (admin_filter, bot_admin_filter,
|
16 |
+
captcha_filter, command)
|
17 |
from Powers.utils.kbhelpers import ikb
|
18 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
19 |
from Powers.utils.parser import escape_markdown, mention_html
|
20 |
from Powers.utils.string import (build_keyboard, escape_invalid_curly_brackets,
|
21 |
parse_button)
|
|
|
22 |
|
23 |
# Initialize
|
24 |
gdb = GBan()
|
25 |
|
|
|
|
|
26 |
ChatType = enums.ChatType
|
27 |
|
28 |
|
29 |
+
async def escape_mentions_using_curly_brackets_wl(
|
30 |
+
user: User,
|
31 |
+
m: Message,
|
32 |
text: str,
|
33 |
parse_words: list,
|
34 |
) -> str:
|
35 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
|
|
|
|
|
|
|
|
36 |
if teks:
|
37 |
teks = teks.format(
|
38 |
first=escape(user.first_name),
|
|
|
232 |
except Exception:
|
233 |
pass
|
234 |
|
235 |
+
@Gojo.on_message(filters.group & filters.new_chat_members & ~captcha_filter, group=69)
|
236 |
+
async def member_has_joined(c: Gojo, m: Message):
|
237 |
+
users: List[User] = m.new_chat_members
|
238 |
+
db = Greetings(m.chat.id)
|
239 |
+
for user in users:
|
240 |
+
banned_users = gdb.check_gban(user.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
try:
|
242 |
+
if user.id == c.me.id:
|
243 |
+
continue
|
244 |
+
if user.id in DEV_USERS:
|
245 |
+
await c.send_animation(
|
246 |
+
chat_id=m.chat.id,
|
247 |
+
animation="./extras/william.gif",
|
248 |
+
caption=f"😳 My **DEV** {user.mention} has also joined the chat!",
|
249 |
)
|
250 |
+
continue
|
251 |
+
if banned_users:
|
252 |
+
await m.chat.ban_member(user.id)
|
253 |
+
await c.send_message(
|
254 |
+
m.chat.id,
|
255 |
+
f"{user.mention} was globally banned so i banned!",
|
256 |
)
|
257 |
+
continue
|
258 |
+
if user.is_bot:
|
259 |
+
continue # ignore bots
|
260 |
+
except ChatAdminRequired:
|
261 |
+
continue
|
262 |
+
status = db.get_welcome_status()
|
263 |
+
oo = db.get_welcome_text()
|
264 |
+
UwU = db.get_welcome_media()
|
265 |
+
mtype = db.get_welcome_msgtype()
|
266 |
+
parse_words = [
|
267 |
+
"first",
|
268 |
+
"last",
|
269 |
+
"fullname",
|
270 |
+
"username",
|
271 |
+
"mention",
|
272 |
+
"id",
|
273 |
+
"chatname",
|
274 |
+
]
|
275 |
+
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
276 |
+
if status:
|
277 |
+
tek, button = await parse_button(hmm)
|
278 |
+
button = await build_keyboard(button)
|
279 |
+
button = ikb(button) if button else None
|
280 |
+
|
281 |
+
if "%%%" in tek:
|
282 |
+
filter_reply = tek.split("%%%")
|
283 |
+
teks = choice(filter_reply)
|
284 |
+
else:
|
285 |
+
teks = tek
|
286 |
+
|
287 |
+
if not teks:
|
288 |
+
teks = f"A wild {user.mention} appeared in {m.chat.title}! Everyone be aware."
|
289 |
+
|
290 |
+
ifff = db.get_current_cleanwelcome_id()
|
291 |
+
gg = db.get_current_cleanwelcome_settings()
|
292 |
+
if ifff and gg:
|
293 |
+
try:
|
294 |
+
await c.delete_messages(m.chat.id, int(ifff))
|
295 |
+
except RPCError:
|
296 |
+
pass
|
297 |
+
if not teks:
|
298 |
+
teks = "Hey {first}, welcome to {chatname}"
|
299 |
+
try:
|
300 |
+
if not UwU:
|
301 |
+
jj = await c.send_message(
|
302 |
+
m.chat.id,
|
303 |
+
text=teks,
|
304 |
+
reply_markup=button,
|
305 |
+
disable_web_page_preview=True,
|
306 |
+
)
|
307 |
+
elif UwU:
|
308 |
+
jj = await (await send_cmd(c,mtype))(
|
309 |
+
m.chat.id,
|
310 |
+
UwU,
|
311 |
+
caption=teks,
|
312 |
+
reply_markup=button,
|
313 |
+
)
|
314 |
+
|
315 |
+
if jj:
|
316 |
+
db.set_cleanwlcm_id(int(jj.id))
|
317 |
+
except ChannelPrivate:
|
318 |
+
continue
|
319 |
+
except RPCError as e:
|
320 |
+
LOGGER.error(e)
|
321 |
+
LOGGER.error(format_exc(e))
|
322 |
+
continue
|
323 |
+
else:
|
324 |
+
continue
|
325 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
326 |
|
327 |
+
@Gojo.on_message(filters.group & filters.left_chat_member, group=99)
|
328 |
+
async def member_has_left(c: Gojo, m: Message):
|
329 |
+
db = Greetings(m.chat.id)
|
|
|
|
|
|
|
|
|
|
|
|
|
330 |
status = db.get_goodbye_status()
|
331 |
oo = db.get_goodbye_text()
|
332 |
UwU = db.get_goodbye_media()
|
|
|
341 |
"chatname",
|
342 |
]
|
343 |
|
344 |
+
user = m.left_chat_member if m.left_chat_member else m.from_user
|
345 |
|
346 |
+
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
347 |
if status:
|
348 |
tek, button = await parse_button(hmm)
|
349 |
button = await build_keyboard(button)
|
|
|
354 |
teks = choice(filter_reply)
|
355 |
else:
|
356 |
teks = tek
|
357 |
+
|
358 |
+
if not teks: #Just in case
|
359 |
+
teks = f"Thanks for being part of this group {user.mention}. But I don't like your arrogance and leaving the group {emoji.EYES}"
|
360 |
+
|
361 |
ifff = db.get_current_cleangoodbye_id()
|
362 |
iii = db.get_current_cleangoodbye_settings()
|
363 |
if ifff and iii:
|
364 |
try:
|
365 |
+
await c.delete_messages(m.chat.id, int(ifff))
|
366 |
except RPCError:
|
367 |
pass
|
368 |
if user.id in DEV_USERS:
|
369 |
await c.send_message(
|
370 |
+
m.chat.id,
|
371 |
+
f"Will miss you my master {user.mention} :(",
|
372 |
)
|
373 |
return
|
374 |
if not teks:
|
|
|
376 |
try:
|
377 |
if not UwU:
|
378 |
ooo = await c.send_message(
|
379 |
+
m.chat.id,
|
380 |
text=teks,
|
381 |
reply_markup=button,
|
382 |
disable_web_page_preview=True,
|
383 |
)
|
384 |
elif UwU:
|
385 |
ooo = await (await send_cmd(c,mtype))(
|
386 |
+
m.chat.id,
|
387 |
UwU,
|
388 |
caption=teks,
|
389 |
reply_markup=button,
|
|
|
392 |
if ooo:
|
393 |
db.set_cleangoodbye_id(int(ooo.id))
|
394 |
return
|
395 |
+
except ChannelPrivate:
|
396 |
+
pass
|
397 |
except RPCError as e:
|
398 |
LOGGER.error(e)
|
399 |
LOGGER.error(format_exc(e))
|
|
|
526 |
reply_markup=button,
|
527 |
)
|
528 |
return
|
|
|
|
|
529 |
|
530 |
__PLUGIN__ = "greetings"
|
531 |
__alt_name__ = ["welcome", "goodbye", "cleanservice"]
|
Powers/plugins/info.py
CHANGED
@@ -9,13 +9,11 @@ from pyrogram.raw.functions.channels import GetFullChannel
|
|
9 |
from pyrogram.raw.functions.users import GetFullUser
|
10 |
from pyrogram.types import Message
|
11 |
|
12 |
-
from Powers import LOGGER, OWNER_ID
|
13 |
from Powers.bot_class import Gojo
|
14 |
from Powers.database.antispam_db import GBan
|
15 |
-
from Powers.supports import get_support_staff
|
16 |
from Powers.utils.custom_filters import command
|
17 |
from Powers.utils.extract_user import extract_user
|
18 |
-
from Powers.vars import Config
|
19 |
|
20 |
gban_db = GBan()
|
21 |
|
@@ -83,10 +81,7 @@ async def user_info(c: Gojo, user, already=False):
|
|
83 |
about = ll.full_user.about
|
84 |
except Exception:
|
85 |
pass
|
86 |
-
SUPPORT_STAFF =
|
87 |
-
DEV_USERS = get_support_staff("dev")
|
88 |
-
SUDO_USERS = get_support_staff("sudo")
|
89 |
-
WHITELIST_USERS = get_support_staff("whitelist")
|
90 |
username = user.username
|
91 |
first_name = user.first_name
|
92 |
last_name = user.last_name
|
@@ -96,17 +91,17 @@ async def user_info(c: Gojo, user, already=False):
|
|
96 |
is_restricted = user.is_restricted
|
97 |
photo_id = user.photo.big_file_id if user.photo else None
|
98 |
is_support = True if user_id in SUPPORT_STAFF else False
|
99 |
-
if user_id ==
|
100 |
is_support = "A person is a great support to himself"
|
101 |
omp = "Hmmm.......Who is that again?"
|
102 |
-
if is_support or
|
103 |
if user_id in DEV_USERS:
|
104 |
omp = "Dev"
|
105 |
elif user_id in SUDO_USERS:
|
106 |
omp = "Sudoer"
|
107 |
elif user_id in WHITELIST_USERS:
|
108 |
omp = "Whitelist"
|
109 |
-
elif user_id ==
|
110 |
omp = "I am the targeted user"
|
111 |
elif user_id == OWNER_ID:
|
112 |
omp = "Owner of the bot"
|
@@ -146,10 +141,15 @@ async def user_info(c: Gojo, user, already=False):
|
|
146 |
<b>🔅 Second Name</b>: <code>{last_name}</code>
|
147 |
<b>🔍 Username</b>: {("@" + username) if username else "NA"}
|
148 |
<b>✍️ Bio</b>: `{about}`
|
149 |
-
<b>🧑💻 Support</b>: {is_support}
|
150 |
-
|
151 |
-
<b>💣 Gbanned</b>: {gban}
|
152 |
-
|
|
|
|
|
|
|
|
|
|
|
153 |
<b>🌐 DC ID</b>: {dc_id}
|
154 |
<b>✋ RESTRICTED</b>: {is_restricted}
|
155 |
<b>✅ VERIFIED</b>: {is_verified}
|
@@ -157,7 +157,6 @@ async def user_info(c: Gojo, user, already=False):
|
|
157 |
<b>⚠️ SCAM</b> : {is_scam}
|
158 |
<b>🤖 BOT</b>: {is_bot}
|
159 |
<b>👀 Last seen</b>: <code>{last_date}</code>
|
160 |
-
|
161 |
"""
|
162 |
|
163 |
return caption, photo_id
|
@@ -242,8 +241,12 @@ async def info_func(c: Gojo, message: Message):
|
|
242 |
if message.reply_to_message and message.reply_to_message.sender_chat:
|
243 |
await message.reply_text("This is not a user, but rather a channel. Use `/chinfo` to fetch its information.")
|
244 |
return
|
245 |
-
|
246 |
-
|
|
|
|
|
|
|
|
|
247 |
if not user:
|
248 |
await message.reply_text("Can't find user to fetch info!")
|
249 |
|
@@ -281,6 +284,10 @@ async def info_func(c: Gojo, message: Message):
|
|
281 |
LOGGER.error(rpc)
|
282 |
LOGGER.error(format_exc())
|
283 |
except Exception as e:
|
|
|
|
|
|
|
|
|
284 |
await message.reply_text(text=e)
|
285 |
LOGGER.error(e)
|
286 |
LOGGER.error(format_exc())
|
|
|
9 |
from pyrogram.raw.functions.users import GetFullUser
|
10 |
from pyrogram.types import Message
|
11 |
|
12 |
+
from Powers import DEV_USERS, LOGGER, OWNER_ID, SUDO_USERS, WHITELIST_USERS
|
13 |
from Powers.bot_class import Gojo
|
14 |
from Powers.database.antispam_db import GBan
|
|
|
15 |
from Powers.utils.custom_filters import command
|
16 |
from Powers.utils.extract_user import extract_user
|
|
|
17 |
|
18 |
gban_db = GBan()
|
19 |
|
|
|
81 |
about = ll.full_user.about
|
82 |
except Exception:
|
83 |
pass
|
84 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
|
|
|
|
|
|
85 |
username = user.username
|
86 |
first_name = user.first_name
|
87 |
last_name = user.last_name
|
|
|
91 |
is_restricted = user.is_restricted
|
92 |
photo_id = user.photo.big_file_id if user.photo else None
|
93 |
is_support = True if user_id in SUPPORT_STAFF else False
|
94 |
+
if user_id == c.me.id:
|
95 |
is_support = "A person is a great support to himself"
|
96 |
omp = "Hmmm.......Who is that again?"
|
97 |
+
if is_support or c.me.id:
|
98 |
if user_id in DEV_USERS:
|
99 |
omp = "Dev"
|
100 |
elif user_id in SUDO_USERS:
|
101 |
omp = "Sudoer"
|
102 |
elif user_id in WHITELIST_USERS:
|
103 |
omp = "Whitelist"
|
104 |
+
elif user_id == c.me.id:
|
105 |
omp = "I am the targeted user"
|
106 |
elif user_id == OWNER_ID:
|
107 |
omp = "Owner of the bot"
|
|
|
141 |
<b>🔅 Second Name</b>: <code>{last_name}</code>
|
142 |
<b>🔍 Username</b>: {("@" + username) if username else "NA"}
|
143 |
<b>✍️ Bio</b>: `{about}`
|
144 |
+
<b>🧑💻 Support</b>: {is_support}\n"""
|
145 |
+
if is_support:
|
146 |
+
caption += f"<b>🥷 Support user type</b>: <code>{omp}</code>\n<b>💣 Gbanned</b>: {gban}\n"
|
147 |
+
else:
|
148 |
+
caption += f"<b>💣 Gbanned</b>: {gban}\n"
|
149 |
+
|
150 |
+
if gban:
|
151 |
+
caption += f"<b>☠️ Gban reason</b>: <code>{reason}</code>\n"
|
152 |
+
caption += f"""
|
153 |
<b>🌐 DC ID</b>: {dc_id}
|
154 |
<b>✋ RESTRICTED</b>: {is_restricted}
|
155 |
<b>✅ VERIFIED</b>: {is_verified}
|
|
|
157 |
<b>⚠️ SCAM</b> : {is_scam}
|
158 |
<b>🤖 BOT</b>: {is_bot}
|
159 |
<b>👀 Last seen</b>: <code>{last_date}</code>
|
|
|
160 |
"""
|
161 |
|
162 |
return caption, photo_id
|
|
|
241 |
if message.reply_to_message and message.reply_to_message.sender_chat:
|
242 |
await message.reply_text("This is not a user, but rather a channel. Use `/chinfo` to fetch its information.")
|
243 |
return
|
244 |
+
try:
|
245 |
+
user, _, user_name = await extract_user(c, message)
|
246 |
+
except:
|
247 |
+
await message.reply_text("Got Some errors failed to fetch user info")
|
248 |
+
LOGGER.error(e)
|
249 |
+
LOGGER.error(format_exc)
|
250 |
if not user:
|
251 |
await message.reply_text("Can't find user to fetch info!")
|
252 |
|
|
|
284 |
LOGGER.error(rpc)
|
285 |
LOGGER.error(format_exc())
|
286 |
except Exception as e:
|
287 |
+
if e == "User not found ! Error: 'InputPeerChannel' object has no attribute 'user_id'":
|
288 |
+
await m.reply_text("Looks like you are trying to fetch info of a chat not an user. In that case please use /chinfo")
|
289 |
+
return
|
290 |
+
|
291 |
await message.reply_text(text=e)
|
292 |
LOGGER.error(e)
|
293 |
LOGGER.error(format_exc())
|
Powers/plugins/locks.py
CHANGED
@@ -1,21 +1,20 @@
|
|
1 |
from asyncio import sleep
|
|
|
2 |
from traceback import format_exc
|
3 |
|
4 |
from pyrogram import filters
|
5 |
from pyrogram.enums import MessageEntityType as MET
|
|
|
6 |
from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
|
7 |
-
from pyrogram.types import ChatPermissions, Message
|
8 |
|
9 |
-
from Powers import LOGGER
|
10 |
from Powers.bot_class import Gojo
|
11 |
from Powers.database.approve_db import Approve
|
12 |
from Powers.database.locks_db import LOCKS
|
13 |
-
from Powers.supports import get_support_staff
|
14 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
15 |
from Powers.utils.custom_filters import command, restrict_filter
|
16 |
-
from Powers.
|
17 |
-
|
18 |
-
SUDO_LEVEL = get_support_staff("sudo_level")
|
19 |
|
20 |
l_t = """
|
21 |
**Lock Types:**
|
@@ -35,7 +34,10 @@ l_t = """
|
|
35 |
- `forwardall` = Forwarding from channel and user
|
36 |
- `forwardu` = Forwarding from user
|
37 |
- `forwardc` = Forwarding from channel
|
38 |
-
- `links | url` = Lock links
|
|
|
|
|
|
|
39 |
|
40 |
@Gojo.on_message(command("locktypes"))
|
41 |
async def lock_types(_, m: Message):
|
@@ -67,11 +69,12 @@ async def lock_perm(c: Gojo, m: Message):
|
|
67 |
invite = get_perm.can_invite_users
|
68 |
pin = get_perm.can_pin_messages
|
69 |
stickers = animations = games = inlinebots = None
|
|
|
70 |
|
71 |
if lock_type == "all":
|
72 |
try:
|
73 |
await c.set_chat_permissions(chat_id, ChatPermissions())
|
74 |
-
|
75 |
except ChatNotModified:
|
76 |
pass
|
77 |
except ChatAdminRequired:
|
@@ -80,8 +83,6 @@ async def lock_perm(c: Gojo, m: Message):
|
|
80 |
await prevent_approved(m)
|
81 |
return
|
82 |
|
83 |
-
lock = LOCKS()
|
84 |
-
|
85 |
if lock_type == "msg":
|
86 |
msg = False
|
87 |
perm = "messages"
|
@@ -125,6 +126,13 @@ async def lock_perm(c: Gojo, m: Message):
|
|
125 |
elif lock_type == "pin":
|
126 |
pin = False
|
127 |
perm = "pin"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
elif lock_type in ["links", "url"]:
|
129 |
curr = lock.insert_lock_channel(m.chat.id, "anti_links")
|
130 |
if not curr:
|
@@ -133,28 +141,28 @@ async def lock_perm(c: Gojo, m: Message):
|
|
133 |
await m.reply_text("Locked links in the chat")
|
134 |
return
|
135 |
elif lock_type == "anonchannel":
|
136 |
-
curr = lock.insert_lock_channel(m.chat.id,"anti_c_send")
|
137 |
if not curr:
|
138 |
await m.reply_text("It is already on")
|
139 |
return
|
140 |
await m.reply_text("Locked Send As Chat")
|
141 |
return
|
142 |
elif lock_type == "forwardall":
|
143 |
-
curr = lock.insert_lock_channel(m.chat.id,"anti_fwd")
|
144 |
if not curr:
|
145 |
await m.reply_text("It is already on")
|
146 |
return
|
147 |
await m.reply_text("Locked Forward from user as well as channel")
|
148 |
return
|
149 |
elif lock_type == "forwardu":
|
150 |
-
curr = lock.insert_lock_channel(m.chat.id,"anti_fwd_u")
|
151 |
if not curr:
|
152 |
await m.reply_text("It is already on")
|
153 |
return
|
154 |
await m.reply_text("Locked Forward message from user")
|
155 |
return
|
156 |
elif lock_type == "forwardc":
|
157 |
-
curr = lock.insert_lock_channel(m.chat.id,"anti_fwd_c")
|
158 |
if not curr:
|
159 |
await m.reply_text("It is already on")
|
160 |
return
|
@@ -174,7 +182,8 @@ Use /locktypes to get the lock types"""
|
|
174 |
ChatPermissions(
|
175 |
can_send_messages=msg,
|
176 |
can_send_media_messages=media,
|
177 |
-
can_send_other_messages=any(
|
|
|
178 |
can_add_web_page_previews=webprev,
|
179 |
can_send_polls=polls,
|
180 |
can_change_info=info,
|
@@ -182,7 +191,6 @@ Use /locktypes to get the lock types"""
|
|
182 |
can_pin_messages=pin,
|
183 |
),
|
184 |
)
|
185 |
-
LOGGER.info(f"{m.from_user.id} locked selected permissions in {m.chat.id}")
|
186 |
except ChatNotModified:
|
187 |
pass
|
188 |
except ChatAdminRequired:
|
@@ -205,24 +213,13 @@ async def view_locks(_, m: Message):
|
|
205 |
return "❌"
|
206 |
|
207 |
lock = LOCKS()
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
anon = True
|
216 |
-
anti_f = anti_f_u = anti_f_c = False
|
217 |
-
if m.chat.id in anti_forward:
|
218 |
-
anti_f = True
|
219 |
-
if m.chat.id in anti_forward_u:
|
220 |
-
anti_f_u = True
|
221 |
-
if m.chat.id in anti_forward_c:
|
222 |
-
anti_f_c = True
|
223 |
-
antil = False
|
224 |
-
if m.chat.id in anti_links:
|
225 |
-
antil = True
|
226 |
vmsg = await convert_to_emoji(v_perm.can_send_messages)
|
227 |
vmedia = await convert_to_emoji(v_perm.can_send_media_messages)
|
228 |
vother = await convert_to_emoji(v_perm.can_send_other_messages)
|
@@ -236,6 +233,7 @@ async def view_locks(_, m: Message):
|
|
236 |
vantiu = await convert_to_emoji(anti_f_u)
|
237 |
vantic = await convert_to_emoji(anti_f_c)
|
238 |
vantil = await convert_to_emoji(antil)
|
|
|
239 |
|
240 |
if v_perm is not None:
|
241 |
try:
|
@@ -256,11 +254,9 @@ async def view_locks(_, m: Message):
|
|
256 |
<b>Can forward:</b> {vanti}
|
257 |
<b>Can forward from user:</b> {vantiu}
|
258 |
<b>Can forward from channel and chats:</b> {vantic}
|
259 |
-
<b>Can send links:</b> {
|
|
|
260 |
"""
|
261 |
-
LOGGER.info(f"{m.from_user.id} used locks cmd in {m.chat.id}")
|
262 |
-
await chkmsg.edit_text(permission_view_str)
|
263 |
-
|
264 |
except RPCError as e_f:
|
265 |
await chkmsg.edit_text(text="Something went wrong!")
|
266 |
await m.reply_text(e_f)
|
@@ -279,6 +275,7 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
279 |
await m.reply_text(text="Specify a permission to unlock!")
|
280 |
return
|
281 |
|
|
|
282 |
if unlock_type == "all":
|
283 |
try:
|
284 |
await c.set_chat_permissions(
|
@@ -294,7 +291,7 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
294 |
can_pin_messages=True,
|
295 |
),
|
296 |
)
|
297 |
-
|
298 |
except ChatNotModified:
|
299 |
pass
|
300 |
except ChatAdminRequired:
|
@@ -314,8 +311,6 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
314 |
upin = get_uperm.can_pin_messages
|
315 |
ustickers = uanimations = ugames = uinlinebots = None
|
316 |
|
317 |
-
lock = LOCKS()
|
318 |
-
|
319 |
if unlock_type == "msg":
|
320 |
umsg = True
|
321 |
uperm = "messages"
|
@@ -359,16 +354,22 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
359 |
elif unlock_type == "pin":
|
360 |
upin = True
|
361 |
uperm = "pin"
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
elif unlock_type == "anonchannel":
|
363 |
-
curr = lock.remove_lock_channel(m.chat.id,"anti_c_send")
|
364 |
-
|
365 |
if not curr:
|
366 |
await m.reply_text("Send as chat is not allowed in this chat")
|
367 |
return
|
368 |
await m.reply_text("Send as chat is now enabled for this chat")
|
369 |
return
|
370 |
elif unlock_type in ["links", "url"]:
|
371 |
-
curr = lock.remove_lock_channel(m.chat.id,"anti_links")
|
372 |
if curr:
|
373 |
await m.reply_text("Sending link is now allowed")
|
374 |
return
|
@@ -376,33 +377,33 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
376 |
await m.reply_text("Sending link is not allowed")
|
377 |
return
|
378 |
elif unlock_type == "forwardall":
|
379 |
-
curr = lock.remove_lock_channel(m.chat.id,"anti_fwd")
|
380 |
-
|
381 |
if not curr:
|
382 |
await m.reply_text("Forwarding content is not allowed in this chat")
|
383 |
return
|
384 |
await m.reply_text("Forwarding content is now enabled for this chat")
|
385 |
return
|
386 |
-
|
387 |
elif unlock_type == "forwardu":
|
388 |
-
curr = lock.remove_lock_channel(m.chat.id,"anti_fwd_u")
|
389 |
-
|
390 |
if not curr:
|
391 |
await m.reply_text("Forwarding content from users is not allowed in this chat")
|
392 |
return
|
393 |
-
|
394 |
await m.reply_text("Forwarding content from users is now enabled for this chat")
|
395 |
return
|
396 |
-
|
397 |
elif unlock_type == "forwardc":
|
398 |
-
curr = lock.remove_lock_channel(m.chat.id,"anti_fwd_c")
|
399 |
-
|
400 |
if not curr:
|
401 |
await m.reply_text("Forwarding content from channel is not allowed in this chat")
|
402 |
return
|
403 |
await m.reply_text("Forwarding content from channel is now enabled for this chat")
|
404 |
return
|
405 |
-
|
406 |
else:
|
407 |
await m.reply_text(
|
408 |
text="""Invalid Lock Type!
|
@@ -412,7 +413,6 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
412 |
return
|
413 |
|
414 |
try:
|
415 |
-
LOGGER.info(f"{m.from_user.id} unlocked selected permissions in {m.chat.id}")
|
416 |
await c.set_chat_permissions(
|
417 |
chat_id,
|
418 |
ChatPermissions(
|
@@ -438,7 +438,8 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
438 |
await prevent_approved(m)
|
439 |
return
|
440 |
|
441 |
-
|
|
|
442 |
try:
|
443 |
await m.delete()
|
444 |
return
|
@@ -447,63 +448,87 @@ async def delete_messages(c:Gojo, m: Message):
|
|
447 |
LOGGER.error(format_exc())
|
448 |
return
|
449 |
|
450 |
-
|
|
|
451 |
approved_users = Approve(m.chat.id).list_approved()
|
452 |
ul = [user[0] for user in approved_users]
|
453 |
try:
|
454 |
admins_group = {i[0] for i in ADMIN_CACHE[m.chat.id]}
|
455 |
except KeyError:
|
456 |
admins_group = await admin_cache_reload(m, "lock")
|
457 |
-
|
|
|
|
|
458 |
if m.forward_from:
|
459 |
-
if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id ==
|
460 |
return True
|
461 |
return False
|
462 |
elif m.forward_from_chat:
|
463 |
-
|
464 |
-
if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == Config.BOT_ID:
|
465 |
return True
|
466 |
-
|
467 |
-
return False
|
468 |
-
elif x_chat and x_chat.id == m.chat.id:
|
469 |
return True
|
|
|
|
|
470 |
elif m.from_user:
|
471 |
-
if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id ==
|
472 |
return True
|
473 |
return False
|
|
|
|
|
474 |
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
if not all_chats:
|
480 |
return
|
481 |
-
|
|
|
482 |
return
|
483 |
-
|
484 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
485 |
return
|
486 |
-
await delete_messages(c,m)
|
|
|
|
|
|
|
487 |
return
|
488 |
-
is_approved = await is_approved_user(c,m)
|
489 |
entity = m.entities if m.text else m.caption_entities
|
490 |
-
if entity:
|
491 |
for i in entity:
|
492 |
if i.type in [MET.URL or MET.TEXT_LINK]:
|
493 |
-
|
494 |
-
await delete_messages(c,m)
|
495 |
-
return
|
496 |
-
elif m.forward_from or m.forward_from_chat:
|
497 |
-
if not is_approved:
|
498 |
-
if lock.is_particular_lock(m.chat.id,"anti_fwd"):
|
499 |
-
await delete_messages(c,m)
|
500 |
-
return
|
501 |
-
elif lock.is_particular_lock(m.chat.id,"anti_fwd_u") and not m.forward_from_chat:
|
502 |
-
await delete_messages(c,m)
|
503 |
-
return
|
504 |
-
elif lock.is_particular_lock(m.chat.id,"anti_fwd_c") and m.forward_from_chat:
|
505 |
-
await delete_messages(c,m)
|
506 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
|
508 |
async def prevent_approved(m: Message):
|
509 |
approved_users = Approve(m.chat.id).list_approved()
|
@@ -513,7 +538,6 @@ async def prevent_approved(m: Message):
|
|
513 |
await m.chat.unban_member(user_id=i)
|
514 |
except (ChatAdminRequired, ChatNotModified, RPCError):
|
515 |
continue
|
516 |
-
LOGGER.info(f"Approved {i} in {m.chat.id}")
|
517 |
await sleep(0.1)
|
518 |
return
|
519 |
|
@@ -525,7 +549,7 @@ __alt_name__ = ["grouplock", "lock", "grouplocks"]
|
|
525 |
__buttons__ = [
|
526 |
[
|
527 |
("Lock Types", "LOCK_TYPES"),
|
528 |
-
],]
|
529 |
|
530 |
__HELP__ = """
|
531 |
**Locks**
|
@@ -541,3 +565,21 @@ Allows you to lock and unlock permission types in the chat.
|
|
541 |
|
542 |
**Example:**
|
543 |
`/lock media`: this locks all the media messages in the chat."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from asyncio import sleep
|
2 |
+
from datetime import datetime, timedelta
|
3 |
from traceback import format_exc
|
4 |
|
5 |
from pyrogram import filters
|
6 |
from pyrogram.enums import MessageEntityType as MET
|
7 |
+
from pyrogram.enums import MessageServiceType as MST
|
8 |
from pyrogram.errors import ChatAdminRequired, ChatNotModified, RPCError
|
9 |
+
from pyrogram.types import CallbackQuery, ChatPermissions, Message
|
10 |
|
11 |
+
from Powers import DEV_USERS, LOGGER, SUDO_USERS
|
12 |
from Powers.bot_class import Gojo
|
13 |
from Powers.database.approve_db import Approve
|
14 |
from Powers.database.locks_db import LOCKS
|
|
|
15 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
16 |
from Powers.utils.custom_filters import command, restrict_filter
|
17 |
+
from Powers.utils.kbhelpers import ikb
|
|
|
|
|
18 |
|
19 |
l_t = """
|
20 |
**Lock Types:**
|
|
|
34 |
- `forwardall` = Forwarding from channel and user
|
35 |
- `forwardu` = Forwarding from user
|
36 |
- `forwardc` = Forwarding from channel
|
37 |
+
- `links | url` = Lock links
|
38 |
+
- `bot` = Adding bot will be forbidden
|
39 |
+
"""
|
40 |
+
|
41 |
|
42 |
@Gojo.on_message(command("locktypes"))
|
43 |
async def lock_types(_, m: Message):
|
|
|
69 |
invite = get_perm.can_invite_users
|
70 |
pin = get_perm.can_pin_messages
|
71 |
stickers = animations = games = inlinebots = None
|
72 |
+
lock = LOCKS()
|
73 |
|
74 |
if lock_type == "all":
|
75 |
try:
|
76 |
await c.set_chat_permissions(chat_id, ChatPermissions())
|
77 |
+
lock.insert_lock_channel(m.chat.id, "all")
|
78 |
except ChatNotModified:
|
79 |
pass
|
80 |
except ChatAdminRequired:
|
|
|
83 |
await prevent_approved(m)
|
84 |
return
|
85 |
|
|
|
|
|
86 |
if lock_type == "msg":
|
87 |
msg = False
|
88 |
perm = "messages"
|
|
|
126 |
elif lock_type == "pin":
|
127 |
pin = False
|
128 |
perm = "pin"
|
129 |
+
elif lock_type == "bot":
|
130 |
+
curr = lock.insert_lock_channel(m.chat.id, "bot")
|
131 |
+
if not curr:
|
132 |
+
await m.reply_text("It is already on")
|
133 |
+
return
|
134 |
+
await m.reply_text("Restricted adding bots in the chat.")
|
135 |
+
return
|
136 |
elif lock_type in ["links", "url"]:
|
137 |
curr = lock.insert_lock_channel(m.chat.id, "anti_links")
|
138 |
if not curr:
|
|
|
141 |
await m.reply_text("Locked links in the chat")
|
142 |
return
|
143 |
elif lock_type == "anonchannel":
|
144 |
+
curr = lock.insert_lock_channel(m.chat.id, "anti_c_send")
|
145 |
if not curr:
|
146 |
await m.reply_text("It is already on")
|
147 |
return
|
148 |
await m.reply_text("Locked Send As Chat")
|
149 |
return
|
150 |
elif lock_type == "forwardall":
|
151 |
+
curr = lock.insert_lock_channel(m.chat.id, "anti_fwd")
|
152 |
if not curr:
|
153 |
await m.reply_text("It is already on")
|
154 |
return
|
155 |
await m.reply_text("Locked Forward from user as well as channel")
|
156 |
return
|
157 |
elif lock_type == "forwardu":
|
158 |
+
curr = lock.insert_lock_channel(m.chat.id, "anti_fwd_u")
|
159 |
if not curr:
|
160 |
await m.reply_text("It is already on")
|
161 |
return
|
162 |
await m.reply_text("Locked Forward message from user")
|
163 |
return
|
164 |
elif lock_type == "forwardc":
|
165 |
+
curr = lock.insert_lock_channel(m.chat.id, "anti_fwd_c")
|
166 |
if not curr:
|
167 |
await m.reply_text("It is already on")
|
168 |
return
|
|
|
182 |
ChatPermissions(
|
183 |
can_send_messages=msg,
|
184 |
can_send_media_messages=media,
|
185 |
+
can_send_other_messages=any(
|
186 |
+
[stickers, animations, games, inlinebots]),
|
187 |
can_add_web_page_previews=webprev,
|
188 |
can_send_polls=polls,
|
189 |
can_change_info=info,
|
|
|
191 |
can_pin_messages=pin,
|
192 |
),
|
193 |
)
|
|
|
194 |
except ChatNotModified:
|
195 |
pass
|
196 |
except ChatAdminRequired:
|
|
|
213 |
return "❌"
|
214 |
|
215 |
lock = LOCKS()
|
216 |
+
anon = lock.get_lock_channel(m.chat.id, "anti_c_send")
|
217 |
+
anti_f = lock.get_lock_channel(m.chat.id, "anti_fwd")
|
218 |
+
anti_f_u = lock.get_lock_channel(m.chat.id, "anti_fwd_u")
|
219 |
+
anti_f_c = lock.get_lock_channel(m.chat.id, "anti_fwd_c")
|
220 |
+
antil = lock.get_lock_channel(m.chat.id, "anti_links")
|
221 |
+
bots = lock.get_lock_channel(m.chat.id, "bot")
|
222 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
vmsg = await convert_to_emoji(v_perm.can_send_messages)
|
224 |
vmedia = await convert_to_emoji(v_perm.can_send_media_messages)
|
225 |
vother = await convert_to_emoji(v_perm.can_send_other_messages)
|
|
|
233 |
vantiu = await convert_to_emoji(anti_f_u)
|
234 |
vantic = await convert_to_emoji(anti_f_c)
|
235 |
vantil = await convert_to_emoji(antil)
|
236 |
+
vantibot = await convert_to_emoji(bots)
|
237 |
|
238 |
if v_perm is not None:
|
239 |
try:
|
|
|
254 |
<b>Can forward:</b> {vanti}
|
255 |
<b>Can forward from user:</b> {vantiu}
|
256 |
<b>Can forward from channel and chats:</b> {vantic}
|
257 |
+
<b>Can send links:</b> {vantil}
|
258 |
+
<b>Can bot send messages:</b> {vantibot}
|
259 |
"""
|
|
|
|
|
|
|
260 |
except RPCError as e_f:
|
261 |
await chkmsg.edit_text(text="Something went wrong!")
|
262 |
await m.reply_text(e_f)
|
|
|
275 |
await m.reply_text(text="Specify a permission to unlock!")
|
276 |
return
|
277 |
|
278 |
+
lock = LOCKS()
|
279 |
if unlock_type == "all":
|
280 |
try:
|
281 |
await c.set_chat_permissions(
|
|
|
291 |
can_pin_messages=True,
|
292 |
),
|
293 |
)
|
294 |
+
lock.remove_lock_channel(m.chat.id, "all")
|
295 |
except ChatNotModified:
|
296 |
pass
|
297 |
except ChatAdminRequired:
|
|
|
311 |
upin = get_uperm.can_pin_messages
|
312 |
ustickers = uanimations = ugames = uinlinebots = None
|
313 |
|
|
|
|
|
314 |
if unlock_type == "msg":
|
315 |
umsg = True
|
316 |
uperm = "messages"
|
|
|
354 |
elif unlock_type == "pin":
|
355 |
upin = True
|
356 |
uperm = "pin"
|
357 |
+
elif unlock_type == "bot":
|
358 |
+
curr = lock.remove_lock_channel(m.chat.id, "bot")
|
359 |
+
if not curr:
|
360 |
+
m.reply_text("User already can add bots in the chat")
|
361 |
+
return
|
362 |
+
await m.reply_text("User are now allowed to add bots in the chat.")
|
363 |
elif unlock_type == "anonchannel":
|
364 |
+
curr = lock.remove_lock_channel(m.chat.id, "anti_c_send")
|
365 |
+
|
366 |
if not curr:
|
367 |
await m.reply_text("Send as chat is not allowed in this chat")
|
368 |
return
|
369 |
await m.reply_text("Send as chat is now enabled for this chat")
|
370 |
return
|
371 |
elif unlock_type in ["links", "url"]:
|
372 |
+
curr = lock.remove_lock_channel(m.chat.id, "anti_links")
|
373 |
if curr:
|
374 |
await m.reply_text("Sending link is now allowed")
|
375 |
return
|
|
|
377 |
await m.reply_text("Sending link is not allowed")
|
378 |
return
|
379 |
elif unlock_type == "forwardall":
|
380 |
+
curr = lock.remove_lock_channel(m.chat.id, "anti_fwd")
|
381 |
+
|
382 |
if not curr:
|
383 |
await m.reply_text("Forwarding content is not allowed in this chat")
|
384 |
return
|
385 |
await m.reply_text("Forwarding content is now enabled for this chat")
|
386 |
return
|
387 |
+
|
388 |
elif unlock_type == "forwardu":
|
389 |
+
curr = lock.remove_lock_channel(m.chat.id, "anti_fwd_u")
|
390 |
+
|
391 |
if not curr:
|
392 |
await m.reply_text("Forwarding content from users is not allowed in this chat")
|
393 |
return
|
394 |
+
|
395 |
await m.reply_text("Forwarding content from users is now enabled for this chat")
|
396 |
return
|
397 |
+
|
398 |
elif unlock_type == "forwardc":
|
399 |
+
curr = lock.remove_lock_channel(m.chat.id, "anti_fwd_c")
|
400 |
+
|
401 |
if not curr:
|
402 |
await m.reply_text("Forwarding content from channel is not allowed in this chat")
|
403 |
return
|
404 |
await m.reply_text("Forwarding content from channel is now enabled for this chat")
|
405 |
return
|
406 |
+
|
407 |
else:
|
408 |
await m.reply_text(
|
409 |
text="""Invalid Lock Type!
|
|
|
413 |
return
|
414 |
|
415 |
try:
|
|
|
416 |
await c.set_chat_permissions(
|
417 |
chat_id,
|
418 |
ChatPermissions(
|
|
|
438 |
await prevent_approved(m)
|
439 |
return
|
440 |
|
441 |
+
|
442 |
+
async def delete_messages(c: Gojo, m: Message):
|
443 |
try:
|
444 |
await m.delete()
|
445 |
return
|
|
|
448 |
LOGGER.error(format_exc())
|
449 |
return
|
450 |
|
451 |
+
|
452 |
+
async def is_approved_user(c: Gojo, m: Message):
|
453 |
approved_users = Approve(m.chat.id).list_approved()
|
454 |
ul = [user[0] for user in approved_users]
|
455 |
try:
|
456 |
admins_group = {i[0] for i in ADMIN_CACHE[m.chat.id]}
|
457 |
except KeyError:
|
458 |
admins_group = await admin_cache_reload(m, "lock")
|
459 |
+
|
460 |
+
SUDO_LEVEL = DEV_USERS.union(SUDO_USERS)
|
461 |
+
|
462 |
if m.forward_from:
|
463 |
+
if m.from_user and (m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id):
|
464 |
return True
|
465 |
return False
|
466 |
elif m.forward_from_chat:
|
467 |
+
if m.from_user and (m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id):
|
|
|
468 |
return True
|
469 |
+
elif m.automatic_forward:
|
|
|
|
|
470 |
return True
|
471 |
+
else:
|
472 |
+
return False
|
473 |
elif m.from_user:
|
474 |
+
if m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id:
|
475 |
return True
|
476 |
return False
|
477 |
+
else:
|
478 |
+
return False
|
479 |
|
480 |
+
|
481 |
+
@Gojo.on_message(filters.service & filters.group, 19)
|
482 |
+
async def servicess(c: Gojo, m: Message):
|
483 |
+
if m.service != MST.NEW_CHAT_MEMBERS:
|
|
|
484 |
return
|
485 |
+
approved = await is_approved_user(c, m)
|
486 |
+
if approved:
|
487 |
return
|
488 |
+
for i in m.new_chat_members:
|
489 |
+
if i.is_bot:
|
490 |
+
try:
|
491 |
+
timee = datetime.now() + timedelta(minutes=5)
|
492 |
+
await m.chat.ban_member(i.id, until_date=timee)
|
493 |
+
sleep(1)
|
494 |
+
except Exception as ef:
|
495 |
+
LOGGER.error(ef)
|
496 |
+
LOGGER.error(format_exc())
|
497 |
+
return
|
498 |
+
|
499 |
+
|
500 |
+
@Gojo.on_message(filters.group & ~filters.me, 3)
|
501 |
+
async def lock_del_mess(c: Gojo, m: Message):
|
502 |
+
lock = LOCKS()
|
503 |
+
chat_locks = lock.get_lock_channel(m.chat.id)
|
504 |
+
if not chat_locks:
|
505 |
+
return
|
506 |
+
|
507 |
+
if chat_locks["anti_channel"] and m.sender_chat and not (m.forward_from_chat or m.forward_from):
|
508 |
+
if m.chat.is_admin:
|
509 |
return
|
510 |
+
await delete_messages(c, m)
|
511 |
+
return
|
512 |
+
is_approved = await is_approved_user(c, m)
|
513 |
+
if is_approved:
|
514 |
return
|
|
|
515 |
entity = m.entities if m.text else m.caption_entities
|
516 |
+
if entity and chat_locks["anti_links"]:
|
517 |
for i in entity:
|
518 |
if i.type in [MET.URL or MET.TEXT_LINK]:
|
519 |
+
await delete_messages(c, m)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
return
|
521 |
+
elif any(chat_locks["anti_fwd"].values()) and (m.forward_from or m.forward_from_chat):
|
522 |
+
if all(chat_locks["anti_fwd"].values()):
|
523 |
+
await delete_messages(c, m)
|
524 |
+
return
|
525 |
+
elif chat_locks["anti_fwd"]["user"] and not m.forward_from_chat:
|
526 |
+
await delete_messages(c, m)
|
527 |
+
return
|
528 |
+
elif chat_locks["anti_fwd"]["chat"] and m.forward_from_chat:
|
529 |
+
await delete_messages(c, m)
|
530 |
+
return
|
531 |
+
|
532 |
|
533 |
async def prevent_approved(m: Message):
|
534 |
approved_users = Approve(m.chat.id).list_approved()
|
|
|
538 |
await m.chat.unban_member(user_id=i)
|
539 |
except (ChatAdminRequired, ChatNotModified, RPCError):
|
540 |
continue
|
|
|
541 |
await sleep(0.1)
|
542 |
return
|
543 |
|
|
|
549 |
__buttons__ = [
|
550 |
[
|
551 |
("Lock Types", "LOCK_TYPES"),
|
552 |
+
], ]
|
553 |
|
554 |
__HELP__ = """
|
555 |
**Locks**
|
|
|
565 |
|
566 |
**Example:**
|
567 |
`/lock media`: this locks all the media messages in the chat."""
|
568 |
+
|
569 |
+
|
570 |
+
@Gojo.on_callback_query(filters.regex("^LOCK_TYPES"))
|
571 |
+
async def lock_types_callback(c: Gojo, q: CallbackQuery):
|
572 |
+
data = q.data
|
573 |
+
|
574 |
+
if data == "LOCK_TYPES":
|
575 |
+
kb = ikb([[("Back", "LOCK_TYPES_back")]])
|
576 |
+
await q.edit_message_caption(
|
577 |
+
l_t,
|
578 |
+
reply_markup=kb
|
579 |
+
)
|
580 |
+
else:
|
581 |
+
kb = ikb([[("Lock Types", "LOCK_TYPES")]])
|
582 |
+
await q.edit_message_caption(
|
583 |
+
__HELP__,
|
584 |
+
reply_markup=kb
|
585 |
+
)
|
Powers/plugins/muting.py
CHANGED
@@ -9,18 +9,15 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
|
|
9 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
10 |
Message)
|
11 |
|
12 |
-
from Powers import LOGGER, MESSAGE_DUMP,
|
13 |
from Powers.bot_class import Gojo
|
14 |
-
from Powers.supports import get_support_staff
|
15 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
16 |
from Powers.utils.custom_filters import command, restrict_filter
|
17 |
from Powers.utils.extract_user import extract_user
|
18 |
from Powers.utils.extras import MUTE_GIFS
|
19 |
from Powers.utils.parser import mention_html
|
20 |
from Powers.utils.string import extract_time
|
21 |
-
from Powers.vars import Config
|
22 |
|
23 |
-
SUPPORT_STAFF = get_support_staff()
|
24 |
|
25 |
@Gojo.on_message(command("tmute") & restrict_filter)
|
26 |
async def tmute_usr(c: Gojo, m: Message):
|
@@ -36,14 +33,14 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
36 |
if not user_id:
|
37 |
await m.reply_text("Cannot find user to mute !")
|
38 |
return
|
39 |
-
if user_id ==
|
40 |
await m.reply_text("Huh, why would I mute myself?")
|
41 |
return
|
42 |
|
|
|
|
|
43 |
if user_id in SUPPORT_STAFF:
|
44 |
-
|
45 |
-
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
46 |
-
)
|
47 |
await m.reply_text(
|
48 |
text="This user is in my support staff, cannot restrict them."
|
49 |
)
|
@@ -86,7 +83,6 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
86 |
ChatPermissions(),
|
87 |
mutetime,
|
88 |
)
|
89 |
-
LOGGER.info(f"{m.from_user.id} tmuted {user_id} in {m.chat.id}")
|
90 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
91 |
muted = await mention_html(user_first_name, user_id)
|
92 |
txt = f"Admin {admin} muted {muted}!"
|
@@ -148,14 +144,13 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
148 |
if not user_id:
|
149 |
await m.reply_text("Cannot find user to mute !")
|
150 |
return
|
151 |
-
if user_id ==
|
152 |
await m.reply_text("Huh, why would I mute myself?")
|
153 |
return
|
154 |
|
|
|
155 |
if user_id in SUPPORT_STAFF:
|
156 |
-
|
157 |
-
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
158 |
-
)
|
159 |
await m.reply_text(
|
160 |
text="This user is in my support staff, cannot restrict them."
|
161 |
)
|
@@ -196,7 +191,6 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
196 |
ChatPermissions(),
|
197 |
mutetime,
|
198 |
)
|
199 |
-
LOGGER.info(f"{m.from_user.id} dtmuted {user_id} in {m.chat.id}")
|
200 |
await m.reply_to_message.delete()
|
201 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
202 |
muted = await mention_html(user_first_name, user_id)
|
@@ -256,14 +250,12 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
256 |
if not user_id:
|
257 |
await m.reply_text("Cannot find user to mute !")
|
258 |
return
|
259 |
-
if user_id ==
|
260 |
await m.reply_text("Huh, why would I mute myself?")
|
261 |
return
|
262 |
|
|
|
263 |
if user_id in SUPPORT_STAFF:
|
264 |
-
LOGGER.info(
|
265 |
-
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
266 |
-
)
|
267 |
await m.reply_text(
|
268 |
text="This user is in my support staff, cannot restrict them."
|
269 |
)
|
@@ -305,7 +297,6 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
305 |
ChatPermissions(),
|
306 |
mutetime,
|
307 |
)
|
308 |
-
LOGGER.info(f"{m.from_user.id} stmuted {user_id} in {m.chat.id}")
|
309 |
await m.delete()
|
310 |
if m.reply_to_message:
|
311 |
await m.reply_to_message.delete()
|
@@ -349,14 +340,13 @@ async def mute_usr(c: Gojo, m: Message):
|
|
349 |
if not user_id:
|
350 |
await m.reply_text("Cannot find user to mute")
|
351 |
return
|
352 |
-
if user_id ==
|
353 |
await m.reply_text("Huh, why would I mute myself?")
|
354 |
return
|
355 |
|
|
|
356 |
if user_id in SUPPORT_STAFF:
|
357 |
-
|
358 |
-
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
359 |
-
)
|
360 |
await m.reply_text(
|
361 |
text="This user is in my support staff, cannot restrict them."
|
362 |
)
|
@@ -376,7 +366,6 @@ async def mute_usr(c: Gojo, m: Message):
|
|
376 |
user_id,
|
377 |
ChatPermissions(),
|
378 |
)
|
379 |
-
LOGGER.info(f"{m.from_user.id} muted {user_id} in {m.chat.id}")
|
380 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
381 |
muted = await mention_html(user_first_name, user_id)
|
382 |
txt = f"Admin {admin} muted {muted}!"
|
@@ -434,14 +423,13 @@ async def smute_usr(c: Gojo, m: Message):
|
|
434 |
if not user_id:
|
435 |
await m.reply_text("Cannot find user to mute")
|
436 |
return
|
437 |
-
if user_id ==
|
438 |
await m.reply_text("Huh, why would I mute myself?")
|
439 |
return
|
440 |
|
|
|
|
|
441 |
if user_id in SUPPORT_STAFF:
|
442 |
-
LOGGER.info(
|
443 |
-
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
444 |
-
)
|
445 |
await m.reply_text(
|
446 |
text="This user is in my support staff, cannot restrict them."
|
447 |
)
|
@@ -461,7 +449,6 @@ async def smute_usr(c: Gojo, m: Message):
|
|
461 |
user_id,
|
462 |
ChatPermissions(),
|
463 |
)
|
464 |
-
LOGGER.info(f"{m.from_user.id} smuted {user_id} in {m.chat.id}")
|
465 |
await m.delete()
|
466 |
if m.reply_to_message:
|
467 |
await m.reply_to_message.delete()
|
@@ -505,14 +492,13 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
505 |
if not user_id:
|
506 |
await m.reply_text("Cannot find user to mute")
|
507 |
return
|
508 |
-
if user_id ==
|
509 |
await m.reply_text("Huh, why would I mute myself?")
|
510 |
return
|
511 |
|
|
|
|
|
512 |
if user_id in SUPPORT_STAFF:
|
513 |
-
LOGGER.info(
|
514 |
-
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
515 |
-
)
|
516 |
await m.reply_text(
|
517 |
text="This user is in my support staff, cannot restrict them."
|
518 |
)
|
@@ -532,7 +518,6 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
532 |
user_id,
|
533 |
ChatPermissions(),
|
534 |
)
|
535 |
-
LOGGER.info(f"{m.from_user.id} dmuted {user_id} in {m.chat.id}")
|
536 |
await m.reply_to_message.delete()
|
537 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
538 |
muted = await mention_html(user_first_name, user_id)
|
@@ -587,7 +572,7 @@ async def unmute_usr(c: Gojo, m: Message):
|
|
587 |
except Exception:
|
588 |
return
|
589 |
|
590 |
-
if user_id ==
|
591 |
await m.reply_text("Huh, why would I unmute myself if you are using me?")
|
592 |
return
|
593 |
try:
|
@@ -600,7 +585,6 @@ async def unmute_usr(c: Gojo, m: Message):
|
|
600 |
LOGGER.exception(format_exc())
|
601 |
try:
|
602 |
await m.chat.unban_member(user_id)
|
603 |
-
LOGGER.info(f"{m.from_user.id} unmuted {user_id} in {m.chat.id}")
|
604 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
605 |
unmuted = await mention_html(user_first_name, user_id)
|
606 |
await m.reply_text(text=f"Admin {admin} unmuted {unmuted}!")
|
@@ -626,14 +610,14 @@ async def unmutebutton(c: Gojo, q: CallbackQuery):
|
|
626 |
user_id = int(splitter[1])
|
627 |
user = await q.message.chat.get_member(q.from_user.id)
|
628 |
|
629 |
-
if not user:
|
630 |
await q.answer(
|
631 |
"You don't have enough permission to do this!\nStay in your limits!",
|
632 |
show_alert=True,
|
633 |
)
|
634 |
return
|
635 |
|
636 |
-
if not user.privileges.can_restrict_members
|
637 |
await q.answer(
|
638 |
"You don't have enough permission to do this!\nStay in your limits!",
|
639 |
show_alert=True,
|
|
|
9 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
10 |
Message)
|
11 |
|
12 |
+
from Powers import DEV_USERS, LOGGER, MESSAGE_DUMP, SUDO_USERS, WHITELIST_USERS
|
13 |
from Powers.bot_class import Gojo
|
|
|
14 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
15 |
from Powers.utils.custom_filters import command, restrict_filter
|
16 |
from Powers.utils.extract_user import extract_user
|
17 |
from Powers.utils.extras import MUTE_GIFS
|
18 |
from Powers.utils.parser import mention_html
|
19 |
from Powers.utils.string import extract_time
|
|
|
20 |
|
|
|
21 |
|
22 |
@Gojo.on_message(command("tmute") & restrict_filter)
|
23 |
async def tmute_usr(c: Gojo, m: Message):
|
|
|
33 |
if not user_id:
|
34 |
await m.reply_text("Cannot find user to mute !")
|
35 |
return
|
36 |
+
if user_id == c.me.id:
|
37 |
await m.reply_text("Huh, why would I mute myself?")
|
38 |
return
|
39 |
|
40 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
41 |
+
|
42 |
if user_id in SUPPORT_STAFF:
|
43 |
+
|
|
|
|
|
44 |
await m.reply_text(
|
45 |
text="This user is in my support staff, cannot restrict them."
|
46 |
)
|
|
|
83 |
ChatPermissions(),
|
84 |
mutetime,
|
85 |
)
|
|
|
86 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
87 |
muted = await mention_html(user_first_name, user_id)
|
88 |
txt = f"Admin {admin} muted {muted}!"
|
|
|
144 |
if not user_id:
|
145 |
await m.reply_text("Cannot find user to mute !")
|
146 |
return
|
147 |
+
if user_id == c.me.id:
|
148 |
await m.reply_text("Huh, why would I mute myself?")
|
149 |
return
|
150 |
|
151 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
152 |
if user_id in SUPPORT_STAFF:
|
153 |
+
|
|
|
|
|
154 |
await m.reply_text(
|
155 |
text="This user is in my support staff, cannot restrict them."
|
156 |
)
|
|
|
191 |
ChatPermissions(),
|
192 |
mutetime,
|
193 |
)
|
|
|
194 |
await m.reply_to_message.delete()
|
195 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
196 |
muted = await mention_html(user_first_name, user_id)
|
|
|
250 |
if not user_id:
|
251 |
await m.reply_text("Cannot find user to mute !")
|
252 |
return
|
253 |
+
if user_id == c.me.id:
|
254 |
await m.reply_text("Huh, why would I mute myself?")
|
255 |
return
|
256 |
|
257 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
258 |
if user_id in SUPPORT_STAFF:
|
|
|
|
|
|
|
259 |
await m.reply_text(
|
260 |
text="This user is in my support staff, cannot restrict them."
|
261 |
)
|
|
|
297 |
ChatPermissions(),
|
298 |
mutetime,
|
299 |
)
|
|
|
300 |
await m.delete()
|
301 |
if m.reply_to_message:
|
302 |
await m.reply_to_message.delete()
|
|
|
340 |
if not user_id:
|
341 |
await m.reply_text("Cannot find user to mute")
|
342 |
return
|
343 |
+
if user_id == c.me.id:
|
344 |
await m.reply_text("Huh, why would I mute myself?")
|
345 |
return
|
346 |
|
347 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
348 |
if user_id in SUPPORT_STAFF:
|
349 |
+
|
|
|
|
|
350 |
await m.reply_text(
|
351 |
text="This user is in my support staff, cannot restrict them."
|
352 |
)
|
|
|
366 |
user_id,
|
367 |
ChatPermissions(),
|
368 |
)
|
|
|
369 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
370 |
muted = await mention_html(user_first_name, user_id)
|
371 |
txt = f"Admin {admin} muted {muted}!"
|
|
|
423 |
if not user_id:
|
424 |
await m.reply_text("Cannot find user to mute")
|
425 |
return
|
426 |
+
if user_id == c.me.id:
|
427 |
await m.reply_text("Huh, why would I mute myself?")
|
428 |
return
|
429 |
|
430 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
431 |
+
|
432 |
if user_id in SUPPORT_STAFF:
|
|
|
|
|
|
|
433 |
await m.reply_text(
|
434 |
text="This user is in my support staff, cannot restrict them."
|
435 |
)
|
|
|
449 |
user_id,
|
450 |
ChatPermissions(),
|
451 |
)
|
|
|
452 |
await m.delete()
|
453 |
if m.reply_to_message:
|
454 |
await m.reply_to_message.delete()
|
|
|
492 |
if not user_id:
|
493 |
await m.reply_text("Cannot find user to mute")
|
494 |
return
|
495 |
+
if user_id == c.me.id:
|
496 |
await m.reply_text("Huh, why would I mute myself?")
|
497 |
return
|
498 |
|
499 |
+
|
500 |
+
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
501 |
if user_id in SUPPORT_STAFF:
|
|
|
|
|
|
|
502 |
await m.reply_text(
|
503 |
text="This user is in my support staff, cannot restrict them."
|
504 |
)
|
|
|
518 |
user_id,
|
519 |
ChatPermissions(),
|
520 |
)
|
|
|
521 |
await m.reply_to_message.delete()
|
522 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
523 |
muted = await mention_html(user_first_name, user_id)
|
|
|
572 |
except Exception:
|
573 |
return
|
574 |
|
575 |
+
if user_id == c.me.id:
|
576 |
await m.reply_text("Huh, why would I unmute myself if you are using me?")
|
577 |
return
|
578 |
try:
|
|
|
585 |
LOGGER.exception(format_exc())
|
586 |
try:
|
587 |
await m.chat.unban_member(user_id)
|
|
|
588 |
admin = await mention_html(m.from_user.first_name, m.from_user.id)
|
589 |
unmuted = await mention_html(user_first_name, user_id)
|
590 |
await m.reply_text(text=f"Admin {admin} unmuted {unmuted}!")
|
|
|
610 |
user_id = int(splitter[1])
|
611 |
user = await q.message.chat.get_member(q.from_user.id)
|
612 |
|
613 |
+
if not user or not user.privileges:
|
614 |
await q.answer(
|
615 |
"You don't have enough permission to do this!\nStay in your limits!",
|
616 |
show_alert=True,
|
617 |
)
|
618 |
return
|
619 |
|
620 |
+
if not user.privileges.can_restrict_members:
|
621 |
await q.answer(
|
622 |
"You don't have enough permission to do this!\nStay in your limits!",
|
623 |
show_alert=True,
|
Powers/plugins/notes.py
CHANGED
@@ -4,7 +4,7 @@ from traceback import format_exc
|
|
4 |
from pyrogram import enums, filters
|
5 |
from pyrogram.enums import ChatMemberStatus as CMS
|
6 |
from pyrogram.errors import RPCError
|
7 |
-
from pyrogram.types import CallbackQuery,
|
8 |
|
9 |
from Powers import LOGGER
|
10 |
from Powers.bot_class import Gojo
|
@@ -16,7 +16,6 @@ from Powers.utils.msg_types import Types, get_note_type
|
|
16 |
from Powers.utils.string import (build_keyboard,
|
17 |
escape_mentions_using_curly_brackets,
|
18 |
parse_button)
|
19 |
-
from Powers.vars import Config
|
20 |
|
21 |
# Initialise
|
22 |
db = Notes()
|
@@ -60,7 +59,6 @@ async def save_note(_, m: Message):
|
|
60 |
return
|
61 |
|
62 |
db.save_note(m.chat.id, note_name, text, data_type, content)
|
63 |
-
LOGGER.info(f"{m.from_user.id} saved note ({note_name}) in {m.chat.id}")
|
64 |
await m.reply_text(
|
65 |
f"Saved note <code>{note_name}</code>!\nGet it with <code>/get {note_name}</code> or <code>#{note_name}</code>",
|
66 |
)
|
@@ -84,7 +82,7 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
84 |
[
|
85 |
(
|
86 |
"Click Me!",
|
87 |
-
f"https://t.me/{
|
88 |
"url",
|
89 |
),
|
90 |
],
|
@@ -194,9 +192,7 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
194 |
reply_markup=button,
|
195 |
reply_to_message_id=reply_msg_id,
|
196 |
)
|
197 |
-
|
198 |
-
f"{m.from_user.id} fetched note {note_name} (type - {getnotes}) in {m.chat.id}",
|
199 |
-
)
|
200 |
except Exception as e:
|
201 |
await m.reply_text(f"Error in notes: {e}")
|
202 |
return
|
@@ -245,9 +241,7 @@ async def get_raw_note(c: Gojo, m: Message, note: str):
|
|
245 |
parse_mode=enums.ParseMode.DISABLED,
|
246 |
reply_to_message_id=msg_id,
|
247 |
)
|
248 |
-
|
249 |
-
f"{m.from_user.id} fetched raw note {note} (type - {getnotes}) in {m.chat.id}",
|
250 |
-
)
|
251 |
return
|
252 |
|
253 |
|
@@ -302,11 +296,9 @@ async def priv_notes(_, m: Message):
|
|
302 |
option = (m.text.split())[1]
|
303 |
if option in ("on", "yes"):
|
304 |
db_settings.set_privatenotes(chat_id, True)
|
305 |
-
LOGGER.info(f"{m.from_user.id} enabled privatenotes in {m.chat.id}")
|
306 |
msg = "Set private notes to On"
|
307 |
elif option in ("off", "no"):
|
308 |
db_settings.set_privatenotes(chat_id, False)
|
309 |
-
LOGGER.info(f"{m.from_user.id} disabled privatenotes in {m.chat.id}")
|
310 |
msg = "Set private notes to Off"
|
311 |
else:
|
312 |
msg = "Enter correct option"
|
@@ -314,7 +306,6 @@ async def priv_notes(_, m: Message):
|
|
314 |
elif len(m.text.split()) == 1:
|
315 |
curr_pref = db_settings.get_privatenotes(m.chat.id)
|
316 |
msg = msg = f"Private Notes: {curr_pref}"
|
317 |
-
LOGGER.info(f"{m.from_user.id} fetched privatenotes preference in {m.chat.id}")
|
318 |
await m.reply_text(msg)
|
319 |
else:
|
320 |
await m.replt_text("Check help on how to use this command!")
|
@@ -323,8 +314,7 @@ async def priv_notes(_, m: Message):
|
|
323 |
|
324 |
|
325 |
@Gojo.on_message(command("notes") & filters.group & ~filters.bot)
|
326 |
-
async def local_notes(
|
327 |
-
LOGGER.info(f"{m.from_user.id} listed all notes in {m.chat.id}")
|
328 |
getnotes = db.get_all_notes(m.chat.id)
|
329 |
|
330 |
if not getnotes:
|
@@ -341,7 +331,7 @@ async def local_notes(_, m: Message):
|
|
341 |
[
|
342 |
(
|
343 |
"All Notes",
|
344 |
-
f"https://t.me/{
|
345 |
"url",
|
346 |
),
|
347 |
],
|
@@ -372,7 +362,6 @@ async def clear_note(_, m: Message):
|
|
372 |
|
373 |
note = m.text.split()[1].lower()
|
374 |
getnote = db.rm_note(m.chat.id, note)
|
375 |
-
LOGGER.info(f"{m.from_user.id} cleared note ({note}) in {m.chat.id}")
|
376 |
if not getnote:
|
377 |
await m.reply_text("This note does not exist!")
|
378 |
return
|
@@ -415,7 +404,6 @@ async def clearallnotes_callback(_, q: CallbackQuery):
|
|
415 |
)
|
416 |
return
|
417 |
db.rm_all_notes(q.message.chat.id)
|
418 |
-
LOGGER.info(f"{user_id} removed all notes in {q.message.chat.id}")
|
419 |
await q.message.edit_text("Cleared all notes!")
|
420 |
return
|
421 |
|
|
|
4 |
from pyrogram import enums, filters
|
5 |
from pyrogram.enums import ChatMemberStatus as CMS
|
6 |
from pyrogram.errors import RPCError
|
7 |
+
from pyrogram.types import CallbackQuery, Message
|
8 |
|
9 |
from Powers import LOGGER
|
10 |
from Powers.bot_class import Gojo
|
|
|
16 |
from Powers.utils.string import (build_keyboard,
|
17 |
escape_mentions_using_curly_brackets,
|
18 |
parse_button)
|
|
|
19 |
|
20 |
# Initialise
|
21 |
db = Notes()
|
|
|
59 |
return
|
60 |
|
61 |
db.save_note(m.chat.id, note_name, text, data_type, content)
|
|
|
62 |
await m.reply_text(
|
63 |
f"Saved note <code>{note_name}</code>!\nGet it with <code>/get {note_name}</code> or <code>#{note_name}</code>",
|
64 |
)
|
|
|
82 |
[
|
83 |
(
|
84 |
"Click Me!",
|
85 |
+
f"https://t.me/{c.me.username}?start=note_{m.chat.id}_{note_hash}",
|
86 |
"url",
|
87 |
),
|
88 |
],
|
|
|
192 |
reply_markup=button,
|
193 |
reply_to_message_id=reply_msg_id,
|
194 |
)
|
195 |
+
|
|
|
|
|
196 |
except Exception as e:
|
197 |
await m.reply_text(f"Error in notes: {e}")
|
198 |
return
|
|
|
241 |
parse_mode=enums.ParseMode.DISABLED,
|
242 |
reply_to_message_id=msg_id,
|
243 |
)
|
244 |
+
|
|
|
|
|
245 |
return
|
246 |
|
247 |
|
|
|
296 |
option = (m.text.split())[1]
|
297 |
if option in ("on", "yes"):
|
298 |
db_settings.set_privatenotes(chat_id, True)
|
|
|
299 |
msg = "Set private notes to On"
|
300 |
elif option in ("off", "no"):
|
301 |
db_settings.set_privatenotes(chat_id, False)
|
|
|
302 |
msg = "Set private notes to Off"
|
303 |
else:
|
304 |
msg = "Enter correct option"
|
|
|
306 |
elif len(m.text.split()) == 1:
|
307 |
curr_pref = db_settings.get_privatenotes(m.chat.id)
|
308 |
msg = msg = f"Private Notes: {curr_pref}"
|
|
|
309 |
await m.reply_text(msg)
|
310 |
else:
|
311 |
await m.replt_text("Check help on how to use this command!")
|
|
|
314 |
|
315 |
|
316 |
@Gojo.on_message(command("notes") & filters.group & ~filters.bot)
|
317 |
+
async def local_notes(c: Gojo, m: Message):
|
|
|
318 |
getnotes = db.get_all_notes(m.chat.id)
|
319 |
|
320 |
if not getnotes:
|
|
|
331 |
[
|
332 |
(
|
333 |
"All Notes",
|
334 |
+
f"https://t.me/{c.me.username}?start=notes_{m.chat.id}",
|
335 |
"url",
|
336 |
),
|
337 |
],
|
|
|
362 |
|
363 |
note = m.text.split()[1].lower()
|
364 |
getnote = db.rm_note(m.chat.id, note)
|
|
|
365 |
if not getnote:
|
366 |
await m.reply_text("This note does not exist!")
|
367 |
return
|
|
|
404 |
)
|
405 |
return
|
406 |
db.rm_all_notes(q.message.chat.id)
|
|
|
407 |
await q.message.edit_text("Cleared all notes!")
|
408 |
return
|
409 |
|
Powers/plugins/pin.py
CHANGED
@@ -26,9 +26,7 @@ async def pin_message(_, m: Message):
|
|
26 |
await m.reply_to_message.pin(
|
27 |
disable_notification=disable_notification,
|
28 |
)
|
29 |
-
|
30 |
-
f"{m.from_user.id} pinned msgid-{m.reply_to_message.id} in {m.chat.id}",
|
31 |
-
)
|
32 |
|
33 |
if m.chat.username:
|
34 |
# If chat has a username, use this format
|
@@ -71,9 +69,7 @@ async def unpin_message(c: Gojo, m: Message):
|
|
71 |
try:
|
72 |
if m.reply_to_message:
|
73 |
await m.reply_to_message.unpin()
|
74 |
-
|
75 |
-
f"{m.from_user.id} unpinned msgid: {m.reply_to_message.id} in {m.chat.id}",
|
76 |
-
)
|
77 |
await m.reply_text(text="Unpinned last message.")
|
78 |
else:
|
79 |
m_id = (await c.get_chat(m.chat.id)).pinned_message.id
|
@@ -121,7 +117,6 @@ async def unpinall_calllback(c: Gojo, q: CallbackQuery):
|
|
121 |
return
|
122 |
try:
|
123 |
await c.unpin_all_chat_messages(q.message.chat.id)
|
124 |
-
LOGGER.info(f"{q.from_user.id} unpinned all messages in {q.message.chat.id}")
|
125 |
await q.message.edit_text(text="Unpinned all messages in this chat.")
|
126 |
except ChatAdminRequired:
|
127 |
await q.message.edit_text(text="I'm not admin or I don't have rights.")
|
@@ -149,11 +144,9 @@ async def anti_channel_pin(_, m: Message):
|
|
149 |
if len(m.text.split()) == 2:
|
150 |
if m.command[1] in ("yes", "on", "true"):
|
151 |
pinsdb.antichannelpin_on()
|
152 |
-
LOGGER.info(f"{m.from_user.id} enabled antichannelpin in {m.chat.id}")
|
153 |
msg = "Turned on AntiChannelPin, now all message pinned by channel will be unpinned automtically!"
|
154 |
elif m.command[1] in ("no", "off", "false"):
|
155 |
pinsdb.antichannelpin_off()
|
156 |
-
LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
|
157 |
msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
|
158 |
else:
|
159 |
await m.reply_text(
|
@@ -201,11 +194,9 @@ async def clean_linked(_, m: Message):
|
|
201 |
if len(m.text.split()) == 2:
|
202 |
if m.command[1] in ("yes", "on", "true"):
|
203 |
pinsdb.cleanlinked_on()
|
204 |
-
LOGGER.info(f"{m.from_user.id} enabled CleanLinked in {m.chat.id}")
|
205 |
msg = "Turned on CleanLinked! Now all the messages from linked channel will be deleted!"
|
206 |
elif m.command[1] in ("no", "off", "false"):
|
207 |
pinsdb.cleanlinked_off()
|
208 |
-
LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
|
209 |
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
|
210 |
else:
|
211 |
await m.reply_text(
|
@@ -220,7 +211,6 @@ async def clean_linked(_, m: Message):
|
|
220 |
@Gojo.on_message(command("permapin") & admin_filter)
|
221 |
async def perma_pin(_, m: Message):
|
222 |
if m.reply_to_message or len(m.text.split()) > 1:
|
223 |
-
LOGGER.info(f"{m.from_user.id} used permampin in {m.chat.id}")
|
224 |
if m.reply_to_message:
|
225 |
text = m.reply_to_message.text
|
226 |
elif len(m.text.split()) > 1:
|
|
|
26 |
await m.reply_to_message.pin(
|
27 |
disable_notification=disable_notification,
|
28 |
)
|
29 |
+
|
|
|
|
|
30 |
|
31 |
if m.chat.username:
|
32 |
# If chat has a username, use this format
|
|
|
69 |
try:
|
70 |
if m.reply_to_message:
|
71 |
await m.reply_to_message.unpin()
|
72 |
+
|
|
|
|
|
73 |
await m.reply_text(text="Unpinned last message.")
|
74 |
else:
|
75 |
m_id = (await c.get_chat(m.chat.id)).pinned_message.id
|
|
|
117 |
return
|
118 |
try:
|
119 |
await c.unpin_all_chat_messages(q.message.chat.id)
|
|
|
120 |
await q.message.edit_text(text="Unpinned all messages in this chat.")
|
121 |
except ChatAdminRequired:
|
122 |
await q.message.edit_text(text="I'm not admin or I don't have rights.")
|
|
|
144 |
if len(m.text.split()) == 2:
|
145 |
if m.command[1] in ("yes", "on", "true"):
|
146 |
pinsdb.antichannelpin_on()
|
|
|
147 |
msg = "Turned on AntiChannelPin, now all message pinned by channel will be unpinned automtically!"
|
148 |
elif m.command[1] in ("no", "off", "false"):
|
149 |
pinsdb.antichannelpin_off()
|
|
|
150 |
msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
|
151 |
else:
|
152 |
await m.reply_text(
|
|
|
194 |
if len(m.text.split()) == 2:
|
195 |
if m.command[1] in ("yes", "on", "true"):
|
196 |
pinsdb.cleanlinked_on()
|
|
|
197 |
msg = "Turned on CleanLinked! Now all the messages from linked channel will be deleted!"
|
198 |
elif m.command[1] in ("no", "off", "false"):
|
199 |
pinsdb.cleanlinked_off()
|
|
|
200 |
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
|
201 |
else:
|
202 |
await m.reply_text(
|
|
|
211 |
@Gojo.on_message(command("permapin") & admin_filter)
|
212 |
async def perma_pin(_, m: Message):
|
213 |
if m.reply_to_message or len(m.text.split()) > 1:
|
|
|
214 |
if m.reply_to_message:
|
215 |
text = m.reply_to_message.text
|
216 |
elif len(m.text.split()) > 1:
|