Spaces:
Sleeping
Sleeping
Merge pull request #205 from AshokShau/main
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Powers/__init__.py +16 -28
- Powers/bot_class.py +4 -8
- Powers/database/__init__.py +1 -4
- Powers/database/afk_db.py +7 -15
- Powers/database/antispam_db.py +1 -2
- Powers/database/approve_db.py +9 -5
- Powers/database/autojoin_db.py +4 -13
- Powers/database/blacklist_db.py +3 -2
- Powers/database/captcha_db.py +22 -40
- Powers/database/chats_db.py +4 -4
- Powers/database/disable_db.py +13 -12
- Powers/database/filters_db.py +12 -19
- Powers/database/flood_db.py +31 -33
- Powers/database/greetings_db.py +0 -1
- Powers/database/locks_db.py +48 -52
- Powers/database/notes_db.py +21 -33
- Powers/database/support_db.py +5 -13
- Powers/database/users_db.py +1 -4
- Powers/database/warns_db.py +1 -1
- Powers/plugins/__init__.py +3 -4
- Powers/plugins/admin.py +24 -28
- Powers/plugins/afk.py +29 -33
- Powers/plugins/antispam.py +4 -4
- Powers/plugins/approve.py +1 -4
- Powers/plugins/auto_join.py +44 -50
- Powers/plugins/bans.py +28 -32
- Powers/plugins/birthday.py +46 -60
- Powers/plugins/blacklist.py +8 -9
- Powers/plugins/captcha.py +29 -41
- Powers/plugins/chat_blacklist.py +16 -21
- Powers/plugins/dev.py +115 -148
- Powers/plugins/disable.py +9 -11
- Powers/plugins/filters.py +14 -18
- Powers/plugins/flood.py +106 -140
- Powers/plugins/formatting.py +11 -10
- Powers/plugins/fun.py +7 -8
- Powers/plugins/greetings.py +105 -108
- Powers/plugins/info.py +34 -37
- Powers/plugins/locks.py +28 -21
- Powers/plugins/muting.py +10 -20
- Powers/plugins/notes.py +11 -18
- Powers/plugins/pin.py +10 -11
- Powers/plugins/purge.py +2 -6
- Powers/plugins/report.py +2 -4
- Powers/plugins/rules.py +2 -5
- Powers/plugins/scheduled_jobs.py +13 -11
- Powers/plugins/search.py +12 -14
- Powers/plugins/start.py +30 -22
- Powers/plugins/stats.py +1 -1
- Powers/plugins/stickers.py +105 -87
Powers/__init__.py
CHANGED
@@ -18,13 +18,9 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
|
18 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
19 |
LOGDIR = f"{__name__}/logs"
|
20 |
|
21 |
-
|
22 |
-
if not path.isdir(LOGDIR):
|
23 |
-
mkdir(LOGDIR)
|
24 |
-
else:
|
25 |
shutil.rmtree(LOGDIR)
|
26 |
-
|
27 |
-
|
28 |
LOGFILE = f"{LOGDIR}/{__name__}_{LOG_DATETIME}_log.txt"
|
29 |
|
30 |
file_handler = FileHandler(filename=LOGFILE)
|
@@ -52,6 +48,7 @@ if version_info[0] < 3 or version_info[1] < 7:
|
|
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:
|
@@ -64,12 +61,9 @@ except Exception as ef:
|
|
64 |
TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
|
65 |
|
66 |
Vpath = "./Version"
|
67 |
-
version = [
|
68 |
-
for i in listdir(Vpath)
|
69 |
-
|
70 |
-
version.append(i)
|
71 |
-
else:
|
72 |
-
pass
|
73 |
VERSION = sorted(version)[-1][8:-3]
|
74 |
PYTHON_VERSION = python_version()
|
75 |
PYROGRAM_VERSION = pyrogram.__version__
|
@@ -96,7 +90,7 @@ if Config.GENIUS_API_TOKEN:
|
|
96 |
|
97 |
genius_lyrics.verbose = False
|
98 |
LOGGER.info("Client setup complete")
|
99 |
-
|
100 |
LOGGER.info("Genius api not found lyrics command will not work")
|
101 |
is_genius_lyrics = False
|
102 |
genius_lyrics = False
|
@@ -119,7 +113,7 @@ API_ID = Config.API_ID
|
|
119 |
API_HASH = Config.API_HASH
|
120 |
|
121 |
# General Config
|
122 |
-
MESSAGE_DUMP = Config.MESSAGE_DUMP
|
123 |
SUPPORT_GROUP = Config.SUPPORT_GROUP
|
124 |
SUPPORT_CHANNEL = Config.SUPPORT_CHANNEL
|
125 |
|
@@ -142,21 +136,15 @@ PREFIX_HANDLER = Config.PREFIX_HANDLER
|
|
142 |
HELP_COMMANDS = {} # For help menu
|
143 |
UPTIME = time() # Check bot uptime
|
144 |
|
145 |
-
|
146 |
-
#Make dir
|
147 |
youtube_dir = "./Youtube/"
|
148 |
-
if
|
149 |
-
mkdir(youtube_dir)
|
150 |
-
else:
|
151 |
shutil.rmtree(youtube_dir)
|
152 |
-
|
153 |
-
|
154 |
scrap_dir = "./scrapped/"
|
155 |
-
if
|
156 |
-
mkdir(scrap_dir)
|
157 |
-
else:
|
158 |
shutil.rmtree(scrap_dir)
|
159 |
-
|
160 |
scheduler = AsyncIOScheduler(timezone=TIME_ZONE)
|
161 |
|
162 |
|
@@ -207,7 +195,7 @@ async def load_cmds(all_plugins):
|
|
207 |
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
208 |
|
209 |
return (
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
)
|
|
|
18 |
LOG_DATETIME = datetime.now().strftime("%d_%m_%Y-%H_%M_%S")
|
19 |
LOGDIR = f"{__name__}/logs"
|
20 |
|
21 |
+
if path.isdir(LOGDIR):
|
|
|
|
|
|
|
22 |
shutil.rmtree(LOGDIR)
|
23 |
+
mkdir(LOGDIR)
|
|
|
24 |
LOGFILE = f"{LOGDIR}/{__name__}_{LOG_DATETIME}_log.txt"
|
25 |
|
26 |
file_handler = FileHandler(filename=LOGFILE)
|
|
|
48 |
# the secret configuration specific things
|
49 |
try:
|
50 |
from Powers.vars import is_env
|
51 |
+
|
52 |
if is_env or environ.get("ENV"):
|
53 |
from Powers.vars import Config
|
54 |
else:
|
|
|
61 |
TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
|
62 |
|
63 |
Vpath = "./Version"
|
64 |
+
version = [
|
65 |
+
i for i in listdir(Vpath) if i.startswith("version") and i.endswith("md")
|
66 |
+
]
|
|
|
|
|
|
|
67 |
VERSION = sorted(version)[-1][8:-3]
|
68 |
PYTHON_VERSION = python_version()
|
69 |
PYROGRAM_VERSION = pyrogram.__version__
|
|
|
90 |
|
91 |
genius_lyrics.verbose = False
|
92 |
LOGGER.info("Client setup complete")
|
93 |
+
else:
|
94 |
LOGGER.info("Genius api not found lyrics command will not work")
|
95 |
is_genius_lyrics = False
|
96 |
genius_lyrics = False
|
|
|
113 |
API_HASH = Config.API_HASH
|
114 |
|
115 |
# General Config
|
116 |
+
MESSAGE_DUMP = Config.MESSAGE_DUMP or Config.OWNER_ID
|
117 |
SUPPORT_GROUP = Config.SUPPORT_GROUP
|
118 |
SUPPORT_CHANNEL = Config.SUPPORT_CHANNEL
|
119 |
|
|
|
136 |
HELP_COMMANDS = {} # For help menu
|
137 |
UPTIME = time() # Check bot uptime
|
138 |
|
139 |
+
# Make dir
|
|
|
140 |
youtube_dir = "./Youtube/"
|
141 |
+
if path.isdir(youtube_dir):
|
|
|
|
|
142 |
shutil.rmtree(youtube_dir)
|
143 |
+
mkdir(youtube_dir)
|
|
|
144 |
scrap_dir = "./scrapped/"
|
145 |
+
if path.isdir(scrap_dir):
|
|
|
|
|
146 |
shutil.rmtree(scrap_dir)
|
147 |
+
mkdir(scrap_dir)
|
148 |
scheduler = AsyncIOScheduler(timezone=TIME_ZONE)
|
149 |
|
150 |
|
|
|
195 |
LOGGER.warning(f"Not loading Plugins - {NO_LOAD}")
|
196 |
|
197 |
return (
|
198 |
+
", ".join((i.split(".")[1]).capitalize()
|
199 |
+
for i in list(HELP_COMMANDS.keys()))
|
200 |
+
+ "\n"
|
201 |
)
|
Powers/bot_class.py
CHANGED
@@ -7,8 +7,8 @@ from pyrogram import Client, __version__
|
|
7 |
from pyrogram.raw.all import layer
|
8 |
from pyrogram.types import BotCommand
|
9 |
|
10 |
-
from Powers import (API_HASH, API_ID,
|
11 |
-
LOGFILE, LOGGER, MESSAGE_DUMP, NO_LOAD,
|
12 |
WORKERS, load_cmds, scheduler)
|
13 |
from Powers.database import MongoDB
|
14 |
from Powers.plugins import all_plugins
|
@@ -72,7 +72,7 @@ class Gojo(Client):
|
|
72 |
LOGGER.info(f"Plugins Loaded: {cmd_list}")
|
73 |
if BDB_URI:
|
74 |
scheduler.add_job(send_wishish, 'cron', [
|
75 |
-
|
76 |
scheduler.start()
|
77 |
# Send a message to MESSAGE_DUMP telling that the
|
78 |
# bot has started and has loaded all plugins!
|
@@ -93,11 +93,7 @@ class Gojo(Client):
|
|
93 |
LOGGER.info("Uploading logs before stopping...!\n")
|
94 |
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
95 |
scheduler.remove_all_jobs()
|
96 |
-
|
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,
|
|
|
7 |
from pyrogram.raw.all import layer
|
8 |
from pyrogram.types import BotCommand
|
9 |
|
10 |
+
from Powers import (API_HASH, API_ID, BOT_TOKEN, LOG_DATETIME,
|
11 |
+
LOGFILE, LOGGER, MESSAGE_DUMP, NO_LOAD, UPTIME,
|
12 |
WORKERS, load_cmds, scheduler)
|
13 |
from Powers.database import MongoDB
|
14 |
from Powers.plugins import all_plugins
|
|
|
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!
|
|
|
93 |
LOGGER.info("Uploading logs before stopping...!\n")
|
94 |
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
95 |
scheduler.remove_all_jobs()
|
96 |
+
target = MESSAGE_DUMP or OWNER_ID
|
|
|
|
|
|
|
|
|
97 |
await self.send_document(
|
98 |
target,
|
99 |
document=LOGFILE,
|
Powers/database/__init__.py
CHANGED
@@ -26,10 +26,7 @@ class MongoDB:
|
|
26 |
|
27 |
# Find one entry from collection
|
28 |
def find_one(self, query):
|
29 |
-
result
|
30 |
-
if result:
|
31 |
-
return result
|
32 |
-
return False
|
33 |
|
34 |
# Find entries from collection
|
35 |
def find_all(self, query=None):
|
|
|
26 |
|
27 |
# Find one entry from collection
|
28 |
def find_one(self, query):
|
29 |
+
return result if (result := self.collection.find_one(query)) else False
|
|
|
|
|
|
|
30 |
|
31 |
# Find entries from collection
|
32 |
def find_all(self, query=None):
|
Powers/database/afk_db.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from threading import RLock
|
2 |
|
3 |
-
from Powers import LOGGER
|
4 |
from Powers.database import MongoDB
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
@@ -15,15 +14,13 @@ class AFK(MongoDB):
|
|
15 |
|
16 |
def insert_afk(self, chat_id, user_id, time, reason, media_type, media=None):
|
17 |
with INSERTION_LOCK:
|
18 |
-
curr
|
19 |
-
if curr:
|
20 |
if reason:
|
21 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
22 |
-
|
23 |
if media:
|
24 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
25 |
-
|
26 |
-
return True
|
27 |
else:
|
28 |
self.insert_one(
|
29 |
{
|
@@ -35,23 +32,18 @@ class AFK(MongoDB):
|
|
35 |
"media_type": media_type
|
36 |
}
|
37 |
)
|
38 |
-
|
39 |
|
40 |
def check_afk(self, chat_id, user_id):
|
41 |
-
curr
|
42 |
-
if curr:
|
43 |
-
return True
|
44 |
-
return False
|
45 |
|
46 |
def get_afk(self, chat_id, user_id):
|
47 |
-
curr
|
48 |
-
if curr:
|
49 |
return curr
|
50 |
return
|
51 |
|
52 |
def delete_afk(self, chat_id, user_id):
|
53 |
with INSERTION_LOCK:
|
54 |
-
curr
|
55 |
-
if curr:
|
56 |
self.delete_one({"chat_id": chat_id, "user_id": user_id})
|
57 |
return
|
|
|
1 |
from threading import RLock
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
|
|
14 |
|
15 |
def insert_afk(self, chat_id, user_id, time, reason, media_type, media=None):
|
16 |
with INSERTION_LOCK:
|
17 |
+
if curr := self.check_afk(chat_id=chat_id, user_id=user_id):
|
|
|
18 |
if reason:
|
19 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
20 |
+
"reason": reason, "time": time})
|
21 |
if media:
|
22 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
23 |
+
'media': media, 'media_type': media_type, "time": time})
|
|
|
24 |
else:
|
25 |
self.insert_one(
|
26 |
{
|
|
|
32 |
"media_type": media_type
|
33 |
}
|
34 |
)
|
35 |
+
return True
|
36 |
|
37 |
def check_afk(self, chat_id, user_id):
|
38 |
+
return bool(curr := self.find_one({"chat_id": chat_id, "user_id": user_id}))
|
|
|
|
|
|
|
39 |
|
40 |
def get_afk(self, chat_id, user_id):
|
41 |
+
if curr := self.find_one({"chat_id": chat_id, "user_id": user_id}):
|
|
|
42 |
return curr
|
43 |
return
|
44 |
|
45 |
def delete_afk(self, chat_id, user_id):
|
46 |
with INSERTION_LOCK:
|
47 |
+
if curr := self.check_afk(chat_id, user_id):
|
|
|
48 |
self.delete_one({"chat_id": chat_id, "user_id": user_id})
|
49 |
return
|
Powers/database/antispam_db.py
CHANGED
@@ -50,8 +50,7 @@ class GBan(MongoDB):
|
|
50 |
|
51 |
def get_gban(self, user_id: int):
|
52 |
if self.check_gban(user_id):
|
53 |
-
curr
|
54 |
-
if curr:
|
55 |
return True, curr["reason"]
|
56 |
return False, ""
|
57 |
|
|
|
50 |
|
51 |
def get_gban(self, user_id: int):
|
52 |
if self.check_gban(user_id):
|
53 |
+
if curr := self.find_one({"_id": user_id}):
|
|
|
54 |
return True, curr["reason"]
|
55 |
return False, ""
|
56 |
|
Powers/database/approve_db.py
CHANGED
@@ -41,11 +41,14 @@ class Approve(MongoDB):
|
|
41 |
def remove_approve(self, user_id: int):
|
42 |
with INSERTION_LOCK:
|
43 |
if self.check_approve(user_id):
|
44 |
-
inde =
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
49 |
self.chat_info["users"].pop(inde)
|
50 |
return self.update(
|
51 |
{"_id": self.chat_id},
|
@@ -83,6 +86,7 @@ class Approve(MongoDB):
|
|
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):
|
|
|
41 |
def remove_approve(self, user_id: int):
|
42 |
with INSERTION_LOCK:
|
43 |
if self.check_approve(user_id):
|
44 |
+
inde = next(
|
45 |
+
(
|
46 |
+
index
|
47 |
+
for index, user in enumerate(self.chat_info["users"])
|
48 |
+
if user[0] == user_id
|
49 |
+
),
|
50 |
+
0,
|
51 |
+
)
|
52 |
self.chat_info["users"].pop(inde)
|
53 |
return self.update(
|
54 |
{"_id": self.chat_id},
|
|
|
86 |
self.insert_one(new_data)
|
87 |
return new_data
|
88 |
return chat_data
|
89 |
+
|
90 |
# Migrate if chat id changes!
|
91 |
|
92 |
def migrate_chat(self, new_chat_id: int):
|
Powers/database/autojoin_db.py
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
from threading import RLock
|
2 |
-
from time import time
|
3 |
|
4 |
-
from Powers import LOGGER
|
5 |
from Powers.database import MongoDB
|
6 |
|
7 |
INSERTION_LOCK = RLock()
|
@@ -30,21 +28,14 @@ class AUTOJOIN(MongoDB):
|
|
30 |
|
31 |
def get_autojoin(self, chat):
|
32 |
curr = self.find_one({"chat_id": chat})
|
33 |
-
if
|
34 |
-
return False
|
35 |
-
else:
|
36 |
-
return curr["type"]
|
37 |
|
38 |
def update_join_type(self, chat, mode):
|
39 |
-
curr
|
40 |
-
if curr:
|
41 |
self.update({"chat_id": chat}, {"type": mode})
|
42 |
-
|
43 |
-
else:
|
44 |
-
return
|
45 |
|
46 |
def remove_autojoin(self, chat):
|
47 |
-
curr
|
48 |
-
if curr:
|
49 |
self.delete_one({"chat_id": chat})
|
50 |
return
|
|
|
1 |
from threading import RLock
|
|
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
|
|
28 |
|
29 |
def get_autojoin(self, chat):
|
30 |
curr = self.find_one({"chat_id": chat})
|
31 |
+
return curr["type"] if curr else False
|
|
|
|
|
|
|
32 |
|
33 |
def update_join_type(self, chat, mode):
|
34 |
+
if curr := self.find_one({"chat_id": chat}):
|
|
|
35 |
self.update({"chat_id": chat}, {"type": mode})
|
36 |
+
return
|
|
|
|
|
37 |
|
38 |
def remove_autojoin(self, chat):
|
39 |
+
if curr := self.find_one({"chat_id": chat}):
|
|
|
40 |
self.delete_one({"chat_id": chat})
|
41 |
return
|
Powers/database/blacklist_db.py
CHANGED
@@ -21,7 +21,7 @@ class Blacklist(MongoDB):
|
|
21 |
def check_word_blacklist_status(self, word: str):
|
22 |
with INSERTION_LOCK:
|
23 |
bl_words = self.chat_info["triggers"]
|
24 |
-
return
|
25 |
|
26 |
def add_blacklist(self, trigger: str):
|
27 |
with INSERTION_LOCK:
|
@@ -62,7 +62,8 @@ class Blacklist(MongoDB):
|
|
62 |
with INSERTION_LOCK:
|
63 |
collection = MongoDB(Blacklist.db_name)
|
64 |
curr = collection.find_all()
|
65 |
-
return sum(
|
|
|
66 |
|
67 |
def set_action(self, action: str):
|
68 |
with INSERTION_LOCK:
|
|
|
21 |
def check_word_blacklist_status(self, word: str):
|
22 |
with INSERTION_LOCK:
|
23 |
bl_words = self.chat_info["triggers"]
|
24 |
+
return word in bl_words
|
25 |
|
26 |
def add_blacklist(self, trigger: str):
|
27 |
with INSERTION_LOCK:
|
|
|
62 |
with INSERTION_LOCK:
|
63 |
collection = MongoDB(Blacklist.db_name)
|
64 |
curr = collection.find_all()
|
65 |
+
return sum(bool(chat["triggers"])
|
66 |
+
for chat in curr)
|
67 |
|
68 |
def set_action(self, action: str):
|
69 |
with INSERTION_LOCK:
|
Powers/database/captcha_db.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from threading import RLock
|
2 |
|
3 |
-
from Powers import LOGGER
|
4 |
from Powers.database import MongoDB
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
@@ -27,38 +26,29 @@ class CAPTCHA(MongoDB):
|
|
27 |
return
|
28 |
|
29 |
def is_captcha(self, chat):
|
30 |
-
curr
|
31 |
-
if curr:
|
32 |
-
return True
|
33 |
-
return False
|
34 |
|
35 |
def update_type(self, chat, captcha_type):
|
36 |
with INSERTION_LOCK:
|
37 |
-
curr
|
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
|
45 |
-
if curr:
|
46 |
self.update({"chat_id": chat}, {
|
47 |
-
|
48 |
return
|
49 |
|
50 |
def remove_captcha(self, chat):
|
51 |
with INSERTION_LOCK:
|
52 |
-
curr
|
53 |
-
if curr:
|
54 |
self.delete_one({"chat_id": chat})
|
55 |
return
|
56 |
|
57 |
def get_captcha(self, chat):
|
58 |
-
curr
|
59 |
-
if curr:
|
60 |
-
return curr
|
61 |
-
return False
|
62 |
|
63 |
|
64 |
class CAPTCHA_DATA(MongoDB):
|
@@ -69,49 +59,41 @@ class CAPTCHA_DATA(MongoDB):
|
|
69 |
super().__init__(self.db_name)
|
70 |
|
71 |
def load_cap_data(self, chat, user, data):
|
72 |
-
curr
|
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
|
83 |
-
if curr:
|
84 |
return curr["data"]
|
85 |
else:
|
86 |
return False
|
87 |
|
88 |
def remove_cap_data(self, chat, user):
|
89 |
-
curr
|
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
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
return
|
102 |
-
else:
|
103 |
return
|
104 |
-
|
105 |
def get_message_id(self, chat, user):
|
106 |
-
curr
|
107 |
-
if curr:
|
108 |
return curr["message_id"]
|
109 |
else:
|
110 |
return False
|
111 |
|
112 |
def is_already_data(self, chat, user):
|
113 |
-
curr
|
114 |
-
if curr:
|
115 |
return curr.get("message_id", False)
|
116 |
else:
|
117 |
return False
|
@@ -122,4 +104,4 @@ class CAPTCHA_DATA(MongoDB):
|
|
122 |
with INSERTION_LOCK:
|
123 |
self.delete_one({"chat_id": chat, "user_id": user})
|
124 |
|
125 |
-
return curr["message_id"]
|
|
|
1 |
from threading import RLock
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
|
|
26 |
return
|
27 |
|
28 |
def is_captcha(self, chat):
|
29 |
+
return bool(curr := self.find_one({"chat_id": chat}))
|
|
|
|
|
|
|
30 |
|
31 |
def update_type(self, chat, captcha_type):
|
32 |
with INSERTION_LOCK:
|
33 |
+
if curr := self.is_captcha(chat):
|
|
|
34 |
self.update({"chat_id": chat}, {"captcha_type": captcha_type})
|
35 |
return
|
36 |
|
37 |
def update_action(self, chat, captcha_action):
|
38 |
with INSERTION_LOCK:
|
39 |
+
if curr := self.is_captcha(chat):
|
|
|
40 |
self.update({"chat_id": chat}, {
|
41 |
+
"captcha_action": captcha_action})
|
42 |
return
|
43 |
|
44 |
def remove_captcha(self, chat):
|
45 |
with INSERTION_LOCK:
|
46 |
+
if curr := self.is_captcha(chat):
|
|
|
47 |
self.delete_one({"chat_id": chat})
|
48 |
return
|
49 |
|
50 |
def get_captcha(self, chat):
|
51 |
+
return curr if (curr := self.find_one({"chat_id": chat})) else False
|
|
|
|
|
|
|
52 |
|
53 |
|
54 |
class CAPTCHA_DATA(MongoDB):
|
|
|
59 |
super().__init__(self.db_name)
|
60 |
|
61 |
def load_cap_data(self, chat, user, data):
|
62 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
return
|
64 |
+
with INSERTION_LOCK:
|
65 |
+
self.insert_one(
|
66 |
+
{"chat_id": chat, "user_id": user, "data": data})
|
67 |
+
return True
|
68 |
|
69 |
def get_cap_data(self, chat, user):
|
70 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
71 |
return curr["data"]
|
72 |
else:
|
73 |
return False
|
74 |
|
75 |
def remove_cap_data(self, chat, user):
|
76 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
77 |
with INSERTION_LOCK:
|
78 |
self.delete_one({"chat_id": chat, "user_id": user})
|
79 |
return
|
80 |
|
81 |
def store_message_id(self, chat, user, message):
|
82 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
83 |
+
return
|
84 |
+
with INSERTION_LOCK:
|
85 |
+
self.insert_one(
|
86 |
+
{"chat_id": chat, "user_id": user, "message_id": message})
|
|
|
|
|
87 |
return
|
88 |
+
|
89 |
def get_message_id(self, chat, user):
|
90 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
91 |
return curr["message_id"]
|
92 |
else:
|
93 |
return False
|
94 |
|
95 |
def is_already_data(self, chat, user):
|
96 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
97 |
return curr.get("message_id", False)
|
98 |
else:
|
99 |
return False
|
|
|
104 |
with INSERTION_LOCK:
|
105 |
self.delete_one({"chat_id": chat, "user_id": user})
|
106 |
|
107 |
+
return curr["message_id"]
|
Powers/database/chats_db.py
CHANGED
@@ -19,18 +19,18 @@ class Chats(MongoDB):
|
|
19 |
self.chat_info = self.__ensure_in_db()
|
20 |
|
21 |
def user_is_in_chat(self, user_id: int):
|
22 |
-
return
|
23 |
|
24 |
def update_chat(self, chat_name: str, user_id: int):
|
25 |
with INSERTION_LOCK:
|
26 |
|
27 |
if chat_name == self.chat_info["chat_name"] and self.user_is_in_chat(
|
28 |
-
|
29 |
):
|
30 |
return True
|
31 |
|
32 |
if chat_name != self.chat_info["chat_name"] and self.user_is_in_chat(
|
33 |
-
|
34 |
):
|
35 |
return self.update(
|
36 |
{"_id": self.chat_id},
|
@@ -38,7 +38,7 @@ class Chats(MongoDB):
|
|
38 |
)
|
39 |
|
40 |
if chat_name == self.chat_info["chat_name"] and not self.user_is_in_chat(
|
41 |
-
|
42 |
):
|
43 |
self.chat_info["users"].append(user_id)
|
44 |
return self.update(
|
|
|
19 |
self.chat_info = self.__ensure_in_db()
|
20 |
|
21 |
def user_is_in_chat(self, user_id: int):
|
22 |
+
return user_id in set(self.chat_info["users"])
|
23 |
|
24 |
def update_chat(self, chat_name: str, user_id: int):
|
25 |
with INSERTION_LOCK:
|
26 |
|
27 |
if chat_name == self.chat_info["chat_name"] and self.user_is_in_chat(
|
28 |
+
user_id,
|
29 |
):
|
30 |
return True
|
31 |
|
32 |
if chat_name != self.chat_info["chat_name"] and self.user_is_in_chat(
|
33 |
+
user_id,
|
34 |
):
|
35 |
return self.update(
|
36 |
{"_id": self.chat_id},
|
|
|
38 |
)
|
39 |
|
40 |
if chat_name == self.chat_info["chat_name"] and not self.user_is_in_chat(
|
41 |
+
user_id,
|
42 |
):
|
43 |
self.chat_info["users"].append(user_id)
|
44 |
return self.update(
|
Powers/database/disable_db.py
CHANGED
@@ -27,8 +27,8 @@ class Disabling(MongoDB):
|
|
27 |
cmds = self.chat_info["commands"]
|
28 |
act = self.chat_info["action"]
|
29 |
DISABLED_CMDS[self.chat_id] = {
|
30 |
-
"command": cmds
|
31 |
-
"action": act
|
32 |
}
|
33 |
# return bool(cmd in cmds)
|
34 |
return bool(cmd in cmds if cmds else [])
|
@@ -63,10 +63,10 @@ class Disabling(MongoDB):
|
|
63 |
except KeyError:
|
64 |
cmds = self.chat_info["commands"]
|
65 |
DISABLED_CMDS[self.chat_id] = {
|
66 |
-
"commands": cmds
|
67 |
"action": self.chat_info["action"],
|
68 |
}
|
69 |
-
return cmds
|
70 |
|
71 |
@staticmethod
|
72 |
def count_disabled_all():
|
@@ -74,7 +74,7 @@ class Disabling(MongoDB):
|
|
74 |
collection = MongoDB(Disabling.db_name)
|
75 |
curr = collection.find_all()
|
76 |
return sum(
|
77 |
-
len(chat["commands"]
|
78 |
)
|
79 |
|
80 |
@staticmethod
|
@@ -82,7 +82,8 @@ class Disabling(MongoDB):
|
|
82 |
with INSERTION_LOCK:
|
83 |
collection = MongoDB(Disabling.db_name)
|
84 |
curr = collection.find_all()
|
85 |
-
return sum(
|
|
|
86 |
|
87 |
def set_action(self, action: str):
|
88 |
with INSERTION_LOCK:
|
@@ -91,7 +92,7 @@ class Disabling(MongoDB):
|
|
91 |
except KeyError:
|
92 |
cmds = self.chat_info["commands"]
|
93 |
DISABLED_CMDS[self.chat_id] = {
|
94 |
-
"commands": cmds
|
95 |
"action": action,
|
96 |
}
|
97 |
return self.update(
|
@@ -107,10 +108,10 @@ class Disabling(MongoDB):
|
|
107 |
cmds = self.chat_info["commands"]
|
108 |
val = self.chat_info["action"]
|
109 |
DISABLED_CMDS[self.chat_id] = {
|
110 |
-
"commands": cmds
|
111 |
"action": val,
|
112 |
}
|
113 |
-
return val
|
114 |
|
115 |
@staticmethod
|
116 |
def count_action_dis_all(action: str):
|
@@ -118,7 +119,7 @@ class Disabling(MongoDB):
|
|
118 |
collection = MongoDB(Disabling.db_name)
|
119 |
all_data = collection.find_all({"action": action})
|
120 |
return sum(
|
121 |
-
len(i["commands"]
|
122 |
)
|
123 |
|
124 |
def rm_all_disabled(self):
|
@@ -171,8 +172,8 @@ class Disabling(MongoDB):
|
|
171 |
all_data = collection.find_all()
|
172 |
DISABLED_CMDS = {
|
173 |
i["_id"]: {
|
174 |
-
"action": i["action"]
|
175 |
-
"commands": i["commands"]
|
176 |
}
|
177 |
for i in all_data
|
178 |
}
|
|
|
27 |
cmds = self.chat_info["commands"]
|
28 |
act = self.chat_info["action"]
|
29 |
DISABLED_CMDS[self.chat_id] = {
|
30 |
+
"command": cmds or [],
|
31 |
+
"action": act or "none",
|
32 |
}
|
33 |
# return bool(cmd in cmds)
|
34 |
return bool(cmd in cmds if cmds else [])
|
|
|
63 |
except KeyError:
|
64 |
cmds = self.chat_info["commands"]
|
65 |
DISABLED_CMDS[self.chat_id] = {
|
66 |
+
"commands": cmds or [],
|
67 |
"action": self.chat_info["action"],
|
68 |
}
|
69 |
+
return cmds or []
|
70 |
|
71 |
@staticmethod
|
72 |
def count_disabled_all():
|
|
|
74 |
collection = MongoDB(Disabling.db_name)
|
75 |
curr = collection.find_all()
|
76 |
return sum(
|
77 |
+
len(chat["commands"] or []) for chat in curr
|
78 |
)
|
79 |
|
80 |
@staticmethod
|
|
|
82 |
with INSERTION_LOCK:
|
83 |
collection = MongoDB(Disabling.db_name)
|
84 |
curr = collection.find_all()
|
85 |
+
return sum(bool(chat["commands"])
|
86 |
+
for chat in curr)
|
87 |
|
88 |
def set_action(self, action: str):
|
89 |
with INSERTION_LOCK:
|
|
|
92 |
except KeyError:
|
93 |
cmds = self.chat_info["commands"]
|
94 |
DISABLED_CMDS[self.chat_id] = {
|
95 |
+
"commands": cmds or [],
|
96 |
"action": action,
|
97 |
}
|
98 |
return self.update(
|
|
|
108 |
cmds = self.chat_info["commands"]
|
109 |
val = self.chat_info["action"]
|
110 |
DISABLED_CMDS[self.chat_id] = {
|
111 |
+
"commands": cmds or [],
|
112 |
"action": val,
|
113 |
}
|
114 |
+
return val or "none"
|
115 |
|
116 |
@staticmethod
|
117 |
def count_action_dis_all(action: str):
|
|
|
119 |
collection = MongoDB(Disabling.db_name)
|
120 |
all_data = collection.find_all({"action": action})
|
121 |
return sum(
|
122 |
+
len(i["commands"] or []) >= 1 for i in all_data
|
123 |
)
|
124 |
|
125 |
def rm_all_disabled(self):
|
|
|
172 |
all_data = collection.find_all()
|
173 |
DISABLED_CMDS = {
|
174 |
i["_id"]: {
|
175 |
+
"action": i["action"] or "none",
|
176 |
+
"commands": i["commands"] or [],
|
177 |
}
|
178 |
for i in all_data
|
179 |
}
|
Powers/database/filters_db.py
CHANGED
@@ -13,17 +13,15 @@ class Filters(MongoDB):
|
|
13 |
super().__init__(self.db_name)
|
14 |
|
15 |
def save_filter(
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
):
|
23 |
with INSERTION_LOCK:
|
24 |
-
|
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 |
{
|
@@ -45,23 +43,20 @@ class Filters(MongoDB):
|
|
45 |
|
46 |
def get_filter(self, chat_id: int, keyword: str):
|
47 |
with INSERTION_LOCK:
|
48 |
-
curr
|
49 |
-
if curr:
|
50 |
return curr
|
51 |
return "Filter does not exist!"
|
52 |
|
53 |
def get_all_filters(self, chat_id: int):
|
54 |
with INSERTION_LOCK:
|
55 |
-
curr
|
56 |
-
if curr:
|
57 |
filter_list = {i["keyword"] for i in curr}
|
58 |
return list(filter_list)
|
59 |
return []
|
60 |
|
61 |
def rm_filter(self, chat_id: int, keyword: str):
|
62 |
with INSERTION_LOCK:
|
63 |
-
curr
|
64 |
-
if curr:
|
65 |
self.delete_one(curr)
|
66 |
return True
|
67 |
return False
|
@@ -76,8 +71,7 @@ class Filters(MongoDB):
|
|
76 |
|
77 |
def count_filter_aliases(self):
|
78 |
with INSERTION_LOCK:
|
79 |
-
curr
|
80 |
-
if curr:
|
81 |
return len(
|
82 |
[z for z in (i["keyword"].split("|")
|
83 |
for i in curr) if len(z) >= 2],
|
@@ -105,8 +99,7 @@ class Filters(MongoDB):
|
|
105 |
# Migrate if chat id changes!
|
106 |
def migrate_chat(self, old_chat_id: int, new_chat_id: int):
|
107 |
with INSERTION_LOCK:
|
108 |
-
old_chat_db
|
109 |
-
if old_chat_db:
|
110 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
111 |
self.delete_one({"_id": old_chat_id})
|
112 |
self.insert_one(new_data)
|
|
|
13 |
super().__init__(self.db_name)
|
14 |
|
15 |
def save_filter(
|
16 |
+
self,
|
17 |
+
chat_id: int,
|
18 |
+
keyword: str,
|
19 |
+
filter_reply: str,
|
20 |
+
msgtype: int = Types.TEXT,
|
21 |
+
fileid="",
|
22 |
):
|
23 |
with INSERTION_LOCK:
|
24 |
+
if curr := self.find_one({"chat_id": chat_id, "keyword": keyword}):
|
|
|
|
|
25 |
self.update(
|
26 |
{"chat_id": chat_id, "keyword": keyword},
|
27 |
{
|
|
|
43 |
|
44 |
def get_filter(self, chat_id: int, keyword: str):
|
45 |
with INSERTION_LOCK:
|
46 |
+
if curr := self.find_one({"chat_id": chat_id, "keyword": keyword}):
|
|
|
47 |
return curr
|
48 |
return "Filter does not exist!"
|
49 |
|
50 |
def get_all_filters(self, chat_id: int):
|
51 |
with INSERTION_LOCK:
|
52 |
+
if curr := self.find_all({"chat_id": chat_id}):
|
|
|
53 |
filter_list = {i["keyword"] for i in curr}
|
54 |
return list(filter_list)
|
55 |
return []
|
56 |
|
57 |
def rm_filter(self, chat_id: int, keyword: str):
|
58 |
with INSERTION_LOCK:
|
59 |
+
if curr := self.find_one({"chat_id": chat_id, "keyword": keyword}):
|
|
|
60 |
self.delete_one(curr)
|
61 |
return True
|
62 |
return False
|
|
|
71 |
|
72 |
def count_filter_aliases(self):
|
73 |
with INSERTION_LOCK:
|
74 |
+
if curr := self.find_all():
|
|
|
75 |
return len(
|
76 |
[z for z in (i["keyword"].split("|")
|
77 |
for i in curr) if len(z) >= 2],
|
|
|
99 |
# Migrate if chat id changes!
|
100 |
def migrate_chat(self, old_chat_id: int, new_chat_id: int):
|
101 |
with INSERTION_LOCK:
|
102 |
+
if old_chat_db := self.find_one({"_id": old_chat_id}):
|
|
|
103 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
104 |
self.delete_one({"_id": old_chat_id})
|
105 |
self.insert_one(new_data)
|
Powers/database/flood_db.py
CHANGED
@@ -1,9 +1,6 @@
|
|
1 |
from threading import RLock
|
2 |
-
from traceback import format_exc
|
3 |
|
4 |
-
from Powers import LOGGER
|
5 |
from Powers.database import MongoDB
|
6 |
-
from Powers.utils.msg_types import Types
|
7 |
|
8 |
INSERTION_LOCK = RLock()
|
9 |
|
@@ -16,29 +13,14 @@ class Floods(MongoDB):
|
|
16 |
super().__init__(self.db_name)
|
17 |
|
18 |
def save_flood(
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
):
|
25 |
with INSERTION_LOCK:
|
26 |
-
curr
|
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
|
32 |
-
},
|
33 |
-
{
|
34 |
-
"limit": limit,
|
35 |
-
"within": within,
|
36 |
-
"action": action,
|
37 |
-
}
|
38 |
-
)
|
39 |
-
else:
|
40 |
-
return
|
41 |
-
else:
|
42 |
return self.insert_one(
|
43 |
{
|
44 |
"chat_id": chat_id,
|
@@ -47,27 +29,43 @@ class Floods(MongoDB):
|
|
47 |
"action": action
|
48 |
},
|
49 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
def is_chat(self, chat_id: int):
|
52 |
with INSERTION_LOCK:
|
53 |
-
curr
|
54 |
-
|
55 |
-
|
56 |
-
curr['within']),
|
57 |
-
|
|
|
58 |
return False
|
59 |
|
60 |
def get_action(self, chat_id: int):
|
61 |
with INSERTION_LOCK:
|
62 |
-
curr
|
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
|
70 |
-
if curr:
|
71 |
self.delete_one({"chat_id": chat_id})
|
72 |
return True
|
73 |
return False
|
|
|
1 |
from threading import RLock
|
|
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
|
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
6 |
|
|
|
13 |
super().__init__(self.db_name)
|
14 |
|
15 |
def save_flood(
|
16 |
+
self,
|
17 |
+
chat_id: int,
|
18 |
+
limit: int,
|
19 |
+
within: int,
|
20 |
+
action: str,
|
21 |
):
|
22 |
with INSERTION_LOCK:
|
23 |
+
if not (curr := self.find_one({"chat_id": chat_id})):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
return self.insert_one(
|
25 |
{
|
26 |
"chat_id": chat_id,
|
|
|
29 |
"action": action
|
30 |
},
|
31 |
)
|
32 |
+
if (
|
33 |
+
limit != int(curr['limit'])
|
34 |
+
or within != int(curr['within'])
|
35 |
+
or action != str(curr['action'])
|
36 |
+
):
|
37 |
+
return self.update(
|
38 |
+
{
|
39 |
+
"chat_id": chat_id
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"limit": limit,
|
43 |
+
"within": within,
|
44 |
+
"action": action,
|
45 |
+
}
|
46 |
+
)
|
47 |
+
else:
|
48 |
+
return
|
49 |
|
50 |
def is_chat(self, chat_id: int):
|
51 |
with INSERTION_LOCK:
|
52 |
+
if curr := self.find_one({"chat_id": chat_id}):
|
53 |
+
return [
|
54 |
+
str(curr['limit']),
|
55 |
+
str(curr['within']),
|
56 |
+
str(curr['action']),
|
57 |
+
]
|
58 |
return False
|
59 |
|
60 |
def get_action(self, chat_id: int):
|
61 |
with INSERTION_LOCK:
|
62 |
+
if curr := self.find_one({"chat_id": chat_id}):
|
|
|
63 |
return curr['action']
|
64 |
return "Flood haven't set"
|
65 |
|
66 |
def rm_flood(self, chat_id: int):
|
67 |
with INSERTION_LOCK:
|
68 |
+
if curr := self.find_one({"chat_id": chat_id}):
|
|
|
69 |
self.delete_one({"chat_id": chat_id})
|
70 |
return True
|
71 |
return False
|
Powers/database/greetings_db.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from threading import RLock
|
2 |
|
3 |
-
from Powers import LOGGER
|
4 |
from Powers.database import MongoDB
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
|
|
1 |
from threading import RLock
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
Powers/database/locks_db.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from threading import RLock
|
2 |
|
3 |
-
from Powers import LOGGER
|
4 |
from Powers.database import MongoDB
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
@@ -30,15 +29,13 @@ class LOCKS(MongoDB):
|
|
30 |
continue
|
31 |
self.insert_one({"chat_id": chat, "locktype": i})
|
32 |
return True
|
33 |
-
curr
|
34 |
-
if curr:
|
35 |
return False
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
return True
|
42 |
|
43 |
def remove_lock_channel(self, chat: int, locktype: str):
|
44 |
"""
|
@@ -46,12 +43,10 @@ class LOCKS(MongoDB):
|
|
46 |
"""
|
47 |
if locktype == "all":
|
48 |
for i in lock_t:
|
49 |
-
curr
|
50 |
-
if curr:
|
51 |
self.delete_one({"chat_id": chat, "locktype": i})
|
52 |
return True
|
53 |
-
curr
|
54 |
-
if curr:
|
55 |
with INSERTION_LOCK:
|
56 |
self.delete_one({"chat_id": chat, "locktype": locktype})
|
57 |
return True
|
@@ -62,43 +57,48 @@ class LOCKS(MongoDB):
|
|
62 |
"""
|
63 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links, bot
|
64 |
"""
|
65 |
-
if locktype not in [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
return False
|
|
|
|
|
|
|
|
|
67 |
else:
|
68 |
-
if
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
"
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
else:
|
86 |
-
|
87 |
-
|
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":
|
@@ -119,8 +119,4 @@ class LOCKS(MongoDB):
|
|
119 |
"""
|
120 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
121 |
"""
|
122 |
-
curr
|
123 |
-
if curr:
|
124 |
-
return True
|
125 |
-
else:
|
126 |
-
return False
|
|
|
1 |
from threading import RLock
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
|
|
29 |
continue
|
30 |
self.insert_one({"chat_id": chat, "locktype": i})
|
31 |
return True
|
32 |
+
if curr := self.find_one({"chat_id": chat, "locktype": locktype}):
|
|
|
33 |
return False
|
34 |
+
with INSERTION_LOCK:
|
35 |
+
hmm = self.merge_u_and_c(chat, locktype)
|
36 |
+
if not hmm:
|
37 |
+
self.insert_one({"chat_id": chat, "locktype": locktype})
|
38 |
+
return True
|
|
|
39 |
|
40 |
def remove_lock_channel(self, chat: int, locktype: str):
|
41 |
"""
|
|
|
43 |
"""
|
44 |
if locktype == "all":
|
45 |
for i in lock_t:
|
46 |
+
if curr := self.find_one({"chat_id": chat, "locktype": i}):
|
|
|
47 |
self.delete_one({"chat_id": chat, "locktype": i})
|
48 |
return True
|
49 |
+
if curr := self.find_one({"chat_id": chat, "locktype": locktype}):
|
|
|
50 |
with INSERTION_LOCK:
|
51 |
self.delete_one({"chat_id": chat, "locktype": locktype})
|
52 |
return True
|
|
|
57 |
"""
|
58 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links, bot
|
59 |
"""
|
60 |
+
if locktype not in [
|
61 |
+
"anti_c_send",
|
62 |
+
"anti_fwd",
|
63 |
+
"anti_fwd_u",
|
64 |
+
"anti_fwd_c",
|
65 |
+
"anti_links",
|
66 |
+
"bot",
|
67 |
+
"all",
|
68 |
+
]:
|
69 |
return False
|
70 |
+
if locktype != "all":
|
71 |
+
curr = self.find_one(
|
72 |
+
{"chat_id": chat, "locktype": locktype})
|
73 |
+
return bool(curr)
|
74 |
else:
|
75 |
+
if not (curr := self.find_all({"chat_id": chat})):
|
76 |
+
return None
|
77 |
+
to_return = {
|
78 |
+
"anti_channel": False,
|
79 |
+
"anti_fwd": {
|
80 |
+
"user": False,
|
81 |
+
"chat": False
|
82 |
+
},
|
83 |
+
"anti_links": False,
|
84 |
+
"bot": False
|
85 |
+
}
|
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":
|
|
|
119 |
"""
|
120 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
121 |
"""
|
122 |
+
return bool(curr := self.find_one({"chat_id": chat, "locktype": locktype}))
|
|
|
|
|
|
|
|
Powers/database/notes_db.py
CHANGED
@@ -15,18 +15,17 @@ class Notes(MongoDB):
|
|
15 |
super().__init__(self.db_name)
|
16 |
|
17 |
def save_note(
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
):
|
25 |
with INSERTION_LOCK:
|
26 |
-
curr
|
27 |
-
|
28 |
-
)
|
29 |
-
if curr:
|
30 |
return False
|
31 |
hash_gen = md5(
|
32 |
(note_name + note_value + str(chat_id) + str(int(time()))).encode(),
|
@@ -44,10 +43,9 @@ class Notes(MongoDB):
|
|
44 |
|
45 |
def get_note(self, chat_id: int, note_name: str):
|
46 |
with INSERTION_LOCK:
|
47 |
-
curr
|
48 |
-
|
49 |
-
)
|
50 |
-
if curr:
|
51 |
return curr
|
52 |
return "Note does not exist!"
|
53 |
|
@@ -57,16 +55,13 @@ 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 |
-
|
61 |
-
for note in curr])
|
62 |
-
return note_list
|
63 |
|
64 |
def rm_note(self, chat_id: int, note_name: str):
|
65 |
with INSERTION_LOCK:
|
66 |
-
curr
|
67 |
-
|
68 |
-
)
|
69 |
-
if curr:
|
70 |
self.delete_one(curr)
|
71 |
return True
|
72 |
return False
|
@@ -77,10 +72,7 @@ class Notes(MongoDB):
|
|
77 |
|
78 |
def count_notes(self, chat_id: int):
|
79 |
with INSERTION_LOCK:
|
80 |
-
curr
|
81 |
-
if curr:
|
82 |
-
return len(curr)
|
83 |
-
return 0
|
84 |
|
85 |
def count_notes_chats(self):
|
86 |
with INSERTION_LOCK:
|
@@ -99,8 +91,7 @@ class Notes(MongoDB):
|
|
99 |
# Migrate if chat id changes!
|
100 |
def migrate_chat(self, old_chat_id: int, new_chat_id: int):
|
101 |
with INSERTION_LOCK:
|
102 |
-
old_chat_db
|
103 |
-
if old_chat_db:
|
104 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
105 |
self.delete_one({"_id": old_chat_id})
|
106 |
self.insert_one(new_data)
|
@@ -113,14 +104,12 @@ class NotesSettings(MongoDB):
|
|
113 |
super().__init__(self.db_name)
|
114 |
|
115 |
def set_privatenotes(self, chat_id: int, status: bool = False):
|
116 |
-
curr
|
117 |
-
if curr:
|
118 |
return self.update({"_id": chat_id}, {"privatenotes": status})
|
119 |
return self.insert_one({"_id": chat_id, "privatenotes": status})
|
120 |
|
121 |
def get_privatenotes(self, chat_id: int):
|
122 |
-
curr
|
123 |
-
if curr:
|
124 |
return curr["privatenotes"]
|
125 |
self.update({"_id": chat_id}, {"privatenotes": False})
|
126 |
return False
|
@@ -138,8 +127,7 @@ class NotesSettings(MongoDB):
|
|
138 |
# Migrate if chat id changes!
|
139 |
def migrate_chat(self, old_chat_id: int, new_chat_id: int):
|
140 |
with INSERTION_LOCK:
|
141 |
-
old_chat_db
|
142 |
-
if old_chat_db:
|
143 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
144 |
self.delete_one({"_id": old_chat_id})
|
145 |
self.insert_one(new_data)
|
|
|
15 |
super().__init__(self.db_name)
|
16 |
|
17 |
def save_note(
|
18 |
+
self,
|
19 |
+
chat_id: int,
|
20 |
+
note_name: str,
|
21 |
+
note_value: str,
|
22 |
+
msgtype: int = Types.TEXT,
|
23 |
+
fileid="",
|
24 |
):
|
25 |
with INSERTION_LOCK:
|
26 |
+
if curr := self.find_one(
|
27 |
+
{"chat_id": chat_id, "note_name": note_name},
|
28 |
+
):
|
|
|
29 |
return False
|
30 |
hash_gen = md5(
|
31 |
(note_name + note_value + str(chat_id) + str(int(time()))).encode(),
|
|
|
43 |
|
44 |
def get_note(self, chat_id: int, note_name: str):
|
45 |
with INSERTION_LOCK:
|
46 |
+
if curr := self.find_one(
|
47 |
+
{"chat_id": chat_id, "note_name": note_name},
|
48 |
+
):
|
|
|
49 |
return curr
|
50 |
return "Note does not exist!"
|
51 |
|
|
|
55 |
def get_all_notes(self, chat_id: int):
|
56 |
with INSERTION_LOCK:
|
57 |
curr = self.find_all({"chat_id": chat_id})
|
58 |
+
return sorted([(note["note_name"], note["hash"]) for note in curr])
|
|
|
|
|
59 |
|
60 |
def rm_note(self, chat_id: int, note_name: str):
|
61 |
with INSERTION_LOCK:
|
62 |
+
if curr := self.find_one(
|
63 |
+
{"chat_id": chat_id, "note_name": note_name},
|
64 |
+
):
|
|
|
65 |
self.delete_one(curr)
|
66 |
return True
|
67 |
return False
|
|
|
72 |
|
73 |
def count_notes(self, chat_id: int):
|
74 |
with INSERTION_LOCK:
|
75 |
+
return len(curr) if (curr := self.find_all({"chat_id": chat_id})) else 0
|
|
|
|
|
|
|
76 |
|
77 |
def count_notes_chats(self):
|
78 |
with INSERTION_LOCK:
|
|
|
91 |
# Migrate if chat id changes!
|
92 |
def migrate_chat(self, old_chat_id: int, new_chat_id: int):
|
93 |
with INSERTION_LOCK:
|
94 |
+
if old_chat_db := self.find_one({"_id": old_chat_id}):
|
|
|
95 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
96 |
self.delete_one({"_id": old_chat_id})
|
97 |
self.insert_one(new_data)
|
|
|
104 |
super().__init__(self.db_name)
|
105 |
|
106 |
def set_privatenotes(self, chat_id: int, status: bool = False):
|
107 |
+
if curr := self.find_one({"_id": chat_id}):
|
|
|
108 |
return self.update({"_id": chat_id}, {"privatenotes": status})
|
109 |
return self.insert_one({"_id": chat_id, "privatenotes": status})
|
110 |
|
111 |
def get_privatenotes(self, chat_id: int):
|
112 |
+
if curr := self.find_one({"_id": chat_id}):
|
|
|
113 |
return curr["privatenotes"]
|
114 |
self.update({"_id": chat_id}, {"privatenotes": False})
|
115 |
return False
|
|
|
127 |
# Migrate if chat id changes!
|
128 |
def migrate_chat(self, old_chat_id: int, new_chat_id: int):
|
129 |
with INSERTION_LOCK:
|
130 |
+
if old_chat_db := self.find_one({"_id": old_chat_id}):
|
|
|
131 |
new_data = old_chat_db.update({"_id": new_chat_id})
|
132 |
self.delete_one({"_id": old_chat_id})
|
133 |
self.insert_one(new_data)
|
Powers/database/support_db.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
from threading import RLock
|
2 |
|
3 |
-
from Powers import LOGGER
|
4 |
from Powers.database import MongoDB
|
5 |
|
6 |
INSERTION_LOCK = RLock()
|
@@ -30,8 +29,7 @@ class SUPPORTS(MongoDB):
|
|
30 |
return
|
31 |
|
32 |
def update_support_user_type(self, user, new_type):
|
33 |
-
curr
|
34 |
-
if curr:
|
35 |
with INSERTION_LOCK:
|
36 |
self.update(
|
37 |
{
|
@@ -44,27 +42,21 @@ class SUPPORTS(MongoDB):
|
|
44 |
return
|
45 |
|
46 |
def is_support_user(self, user_id):
|
47 |
-
curr
|
48 |
-
if curr:
|
49 |
-
return True
|
50 |
-
return False
|
51 |
|
52 |
def delete_support_user(self, user):
|
53 |
-
curr
|
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
|
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
|
68 |
-
if curr:
|
69 |
return curr["support_type"]
|
70 |
return False
|
|
|
1 |
from threading import RLock
|
2 |
|
|
|
3 |
from Powers.database import MongoDB
|
4 |
|
5 |
INSERTION_LOCK = RLock()
|
|
|
29 |
return
|
30 |
|
31 |
def update_support_user_type(self, user, new_type):
|
32 |
+
if curr := self.is_support_user(user):
|
|
|
33 |
with INSERTION_LOCK:
|
34 |
self.update(
|
35 |
{
|
|
|
42 |
return
|
43 |
|
44 |
def is_support_user(self, user_id):
|
45 |
+
return bool(curr := self.find_one({"user_id": user_id}))
|
|
|
|
|
|
|
46 |
|
47 |
def delete_support_user(self, user):
|
48 |
+
if curr := self.is_support_user(user):
|
|
|
49 |
with INSERTION_LOCK:
|
50 |
self.delete_one({"user_id": user})
|
51 |
return
|
52 |
|
53 |
def get_particular_support(self, support_type):
|
54 |
+
if curr := self.find_all({"support_type": support_type}):
|
|
|
55 |
return [i['user_id'] for i in curr]
|
56 |
else:
|
57 |
return []
|
58 |
|
59 |
def get_support_type(self, user):
|
60 |
+
if curr := self.find_one({"user_id": user}):
|
|
|
61 |
return curr["support_type"]
|
62 |
return False
|
Powers/database/users_db.py
CHANGED
@@ -59,10 +59,7 @@ class Users(MongoDB):
|
|
59 |
else:
|
60 |
curr = None
|
61 |
|
62 |
-
|
63 |
-
return curr
|
64 |
-
|
65 |
-
return {}
|
66 |
|
67 |
def __ensure_in_db(self):
|
68 |
chat_data = self.find_one({"_id": self.user_id})
|
|
|
59 |
else:
|
60 |
curr = None
|
61 |
|
62 |
+
return curr or {}
|
|
|
|
|
|
|
63 |
|
64 |
def __ensure_in_db(self):
|
65 |
chat_data = self.find_one({"_id": self.user_id})
|
Powers/database/warns_db.py
CHANGED
@@ -94,7 +94,7 @@ class Warns(MongoDB):
|
|
94 |
)
|
95 |
collection.update(
|
96 |
{"chat_id": data["chat_id"],
|
97 |
-
|
98 |
{key: val},
|
99 |
)
|
100 |
|
|
|
94 |
)
|
95 |
collection.update(
|
96 |
{"chat_id": data["chat_id"],
|
97 |
+
"user_id": data["user_id"]},
|
98 |
{key: val},
|
99 |
)
|
100 |
|
Powers/plugins/__init__.py
CHANGED
@@ -5,7 +5,7 @@ async def all_plugins():
|
|
5 |
from glob import glob
|
6 |
from os.path import basename, dirname, isfile
|
7 |
|
8 |
-
mod_paths = glob(dirname(__file__)
|
9 |
all_plugs = [
|
10 |
basename(f)[:-3]
|
11 |
for f in mod_paths
|
@@ -13,6 +13,7 @@ async def all_plugins():
|
|
13 |
]
|
14 |
return sorted(all_plugs)
|
15 |
|
|
|
16 |
from sys import exit as exiter
|
17 |
|
18 |
from pymongo import MongoClient
|
@@ -36,6 +37,4 @@ from datetime import datetime
|
|
36 |
|
37 |
def till_date(date):
|
38 |
form = "%Y-%m-%d %H:%M:%S"
|
39 |
-
|
40 |
-
return z
|
41 |
-
|
|
|
5 |
from glob import glob
|
6 |
from os.path import basename, dirname, isfile
|
7 |
|
8 |
+
mod_paths = glob(f"{dirname(__file__)}/*.py")
|
9 |
all_plugs = [
|
10 |
basename(f)[:-3]
|
11 |
for f in mod_paths
|
|
|
13 |
]
|
14 |
return sorted(all_plugs)
|
15 |
|
16 |
+
|
17 |
from sys import exit as exiter
|
18 |
|
19 |
from pymongo import MongoClient
|
|
|
37 |
|
38 |
def till_date(date):
|
39 |
form = "%Y-%m-%d %H:%M:%S"
|
40 |
+
return datetime.strptime(date, form)
|
|
|
|
Powers/plugins/admin.py
CHANGED
@@ -15,8 +15,7 @@ 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 (
|
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
|
@@ -25,7 +24,7 @@ from Powers.utils.parser import mention_html
|
|
25 |
@Gojo.on_message(command("adminlist"))
|
26 |
async def adminlist_show(_, m: Message):
|
27 |
global ADMIN_CACHE
|
28 |
-
if m.chat.type not in [ChatType.SUPERGROUP,ChatType.GROUP]:
|
29 |
return await m.reply_text(
|
30 |
text="This command is made to be used in groups only!",
|
31 |
)
|
@@ -64,12 +63,12 @@ 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!")
|
71 |
else:
|
72 |
-
ef = str(ef)
|
73 |
await m.reply_text(
|
74 |
text=f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
75 |
)
|
@@ -78,7 +77,6 @@ async def adminlist_show(_, m: Message):
|
|
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
|
@@ -95,27 +93,28 @@ async def zombie_clean(c: Gojo, m: Message):
|
|
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):
|
109 |
global TEMP_ADMIN_CACHE_BLOCK
|
110 |
-
if m.chat.type not in [ChatType.SUPERGROUP,ChatType.GROUP]:
|
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 |
-
|
117 |
-
|
118 |
-
|
119 |
):
|
120 |
await m.reply_text("Can only reload admin cache once per 10 mins!")
|
121 |
return
|
@@ -194,9 +193,9 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
194 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
195 |
title = "Gojo" # Default fullpromote title
|
196 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
197 |
-
title = " ".join(m.text.split()[2:16])
|
198 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
199 |
-
title = " ".join(m.text.split()[1:16])
|
200 |
|
201 |
try:
|
202 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
@@ -297,9 +296,9 @@ async def promote_usr(c: Gojo, m: Message):
|
|
297 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
298 |
title = "Itadori" # Deafult title
|
299 |
if len(m.text.split()) >= 3 and not m.reply_to_message:
|
300 |
-
title = " ".join(m.text.split()[2:16])
|
301 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
302 |
-
title = " ".join(m.text.split()[1:16])
|
303 |
try:
|
304 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
305 |
except RPCError as e:
|
@@ -308,7 +307,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 |
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)),
|
@@ -406,7 +405,8 @@ async def demote_usr(c: Gojo, m: Message):
|
|
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(
|
|
|
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,7 +419,7 @@ async def demote_usr(c: Gojo, m: Message):
|
|
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)
|
@@ -466,6 +466,7 @@ async def setgtitle(_, m: Message):
|
|
466 |
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
|
467 |
)
|
468 |
|
|
|
469 |
@Gojo.on_message(command("setgdes") & admin_filter)
|
470 |
async def setgdes(_, m: Message):
|
471 |
user = await m.chat.get_member(m.from_user.id)
|
@@ -499,9 +500,8 @@ async def set_user_title(c: Gojo, m: Message):
|
|
499 |
if m.reply_to_message:
|
500 |
if len(m.text.split()) >= 2:
|
501 |
reason = m.text.split(None, 1)[1]
|
502 |
-
|
503 |
-
|
504 |
-
reason = m.text.split(None, 2)[2]
|
505 |
try:
|
506 |
user_id, _, _ = await extract_user(c, m)
|
507 |
except Exception:
|
@@ -536,11 +536,9 @@ async def setgpic(c: Gojo, m: Message):
|
|
536 |
if not m.reply_to_message.photo and not m.reply_to_message.document:
|
537 |
return await m.reply_text("Reply to a photo to set it as chat photo")
|
538 |
photo = await m.reply_to_message.download()
|
539 |
-
is_vid =
|
540 |
-
if m.reply_to_message.video:
|
541 |
-
is_vid = True
|
542 |
try:
|
543 |
-
await m.chat.set_photo(photo,video=is_vid)
|
544 |
except Exception as e:
|
545 |
remove(photo)
|
546 |
return await m.reply_text(f"Error: {e}")
|
@@ -586,5 +584,3 @@ __HELP__ = """
|
|
586 |
|
587 |
**Example:**
|
588 |
`/promote @username`: this promotes a user to admin."""
|
589 |
-
|
590 |
-
|
|
|
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_reload)
|
|
|
19 |
from Powers.utils.custom_filters import admin_filter, command, promote_filter
|
20 |
from Powers.utils.extract_user import extract_user
|
21 |
from Powers.utils.parser import mention_html
|
|
|
24 |
@Gojo.on_message(command("adminlist"))
|
25 |
async def adminlist_show(_, m: Message):
|
26 |
global ADMIN_CACHE
|
27 |
+
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
28 |
return await m.reply_text(
|
29 |
text="This command is made to be used in groups only!",
|
30 |
)
|
|
|
63 |
adminstr += "\n\n<b>Bots:</b>\n"
|
64 |
adminstr += "\n".join(f"- {i}" for i in mention_bots)
|
65 |
await m.reply_text(adminstr + "\n\n" + note)
|
66 |
+
|
67 |
except Exception as ef:
|
68 |
if str(ef) == str(m.chat.id):
|
69 |
await m.reply_text(text="Use /admincache to reload admins!")
|
70 |
else:
|
71 |
+
ef = f"{str(ef)}{admin_list}\n"
|
72 |
await m.reply_text(
|
73 |
text=f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
74 |
)
|
|
|
77 |
return
|
78 |
|
79 |
|
|
|
80 |
@Gojo.on_message(command("zombies") & admin_filter)
|
81 |
async def zombie_clean(c: Gojo, m: Message):
|
82 |
zombie = 0
|
|
|
93 |
await sleep(e.value)
|
94 |
try:
|
95 |
await c.ban_chat_member(m.chat.id, member.user.id)
|
96 |
+
except Exception:
|
97 |
pass
|
98 |
if zombie == 0:
|
99 |
return await wait.edit_text("Group is clean!")
|
100 |
await wait.delete()
|
101 |
+
txt = f"<b>{zombie}</b> Zombies found and {zombie - failed} has been banned!\n{failed} zombies' are immune to me",
|
102 |
await m.reply_animation("https://graph.org/file/02a1dcf7788186ffb36cb.mp4", caption=txt)
|
103 |
return
|
104 |
|
105 |
+
|
106 |
@Gojo.on_message(command("admincache"))
|
107 |
async def reload_admins(_, m: Message):
|
108 |
global TEMP_ADMIN_CACHE_BLOCK
|
109 |
+
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
110 |
return await m.reply_text(
|
111 |
"This command is made to be used in groups only!",
|
112 |
)
|
113 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
114 |
if (
|
115 |
+
(m.chat.id in set(TEMP_ADMIN_CACHE_BLOCK.keys()))
|
116 |
+
and (m.from_user.id not in SUPPORT_STAFF)
|
117 |
+
and TEMP_ADMIN_CACHE_BLOCK[m.chat.id] == "manualblock"
|
118 |
):
|
119 |
await m.reply_text("Can only reload admin cache once per 10 mins!")
|
120 |
return
|
|
|
193 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
194 |
title = "Gojo" # Default fullpromote title
|
195 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
196 |
+
title = " ".join(m.text.split()[2:16]) # trim title to 16 characters
|
197 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
198 |
+
title = " ".join(m.text.split()[1:16]) # trim title to 16 characters
|
199 |
|
200 |
try:
|
201 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
|
296 |
if m.chat.type in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
297 |
title = "Itadori" # Deafult title
|
298 |
if len(m.text.split()) >= 3 and not m.reply_to_message:
|
299 |
+
title = " ".join(m.text.split()[2:16]) # trim title to 16 characters
|
300 |
elif len(m.text.split()) >= 2 and m.reply_to_message:
|
301 |
+
title = " ".join(m.text.split()[1:16]) # trim title to 16 characters
|
302 |
try:
|
303 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
304 |
except RPCError as e:
|
|
|
307 |
except Exception as e:
|
308 |
LOGGER.error(e)
|
309 |
LOGGER.error(format_exc())
|
310 |
+
|
311 |
await m.reply_text(
|
312 |
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
313 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
|
|
405 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
406 |
)
|
407 |
except BotChannelsNa:
|
408 |
+
await m.reply_text(
|
409 |
+
"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)
|
|
|
466 |
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
|
467 |
)
|
468 |
|
469 |
+
|
470 |
@Gojo.on_message(command("setgdes") & admin_filter)
|
471 |
async def setgdes(_, m: Message):
|
472 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
500 |
if m.reply_to_message:
|
501 |
if len(m.text.split()) >= 2:
|
502 |
reason = m.text.split(None, 1)[1]
|
503 |
+
elif len(m.text.split()) >= 3:
|
504 |
+
reason = m.text.split(None, 2)[2]
|
|
|
505 |
try:
|
506 |
user_id, _, _ = await extract_user(c, m)
|
507 |
except Exception:
|
|
|
536 |
if not m.reply_to_message.photo and not m.reply_to_message.document:
|
537 |
return await m.reply_text("Reply to a photo to set it as chat photo")
|
538 |
photo = await m.reply_to_message.download()
|
539 |
+
is_vid = bool(m.reply_to_message.video)
|
|
|
|
|
540 |
try:
|
541 |
+
await m.chat.set_photo(photo, video=is_vid)
|
542 |
except Exception as e:
|
543 |
remove(photo)
|
544 |
return await m.reply_text(f"Error: {e}")
|
|
|
584 |
|
585 |
**Example:**
|
586 |
`/promote @username`: this promotes a user to admin."""
|
|
|
|
Powers/plugins/afk.py
CHANGED
@@ -30,40 +30,42 @@ back = [
|
|
30 |
"{first} is now finally back from the dead"
|
31 |
]
|
32 |
|
33 |
-
|
|
|
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 |
-
|
|
|
58 |
tim = hour.strip().split(":")
|
59 |
txt = ""
|
60 |
if int(tim[0]):
|
61 |
-
txt += tim[0]
|
62 |
if int(tim[1]):
|
63 |
-
txt += tim[1]
|
64 |
if int(round(float(tim[2]))):
|
65 |
-
txt += str(round(float(tim[2])))
|
66 |
-
|
67 |
return txt
|
68 |
|
69 |
|
@@ -74,19 +76,12 @@ async def afk_checker(c: Gojo, m: Message):
|
|
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"]
|
@@ -96,7 +91,7 @@ async def afk_checker(c: Gojo, m: Message):
|
|
96 |
if len(tim_) == 1:
|
97 |
tims = tim
|
98 |
elif len(tim_) == 2:
|
99 |
-
tims = tim_[0]
|
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)}"
|
@@ -104,22 +99,22 @@ async def afk_checker(c: Gojo, m: Message):
|
|
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:
|
@@ -127,10 +122,10 @@ async def afk_checker(c: Gojo, m: Message):
|
|
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(",")
|
@@ -138,15 +133,16 @@ async def afk_checker(c: Gojo, m: Message):
|
|
138 |
if len(tim_) == 1:
|
139 |
tims = tim
|
140 |
elif len(tim_) == 2:
|
141 |
-
tims = tim_[0]
|
142 |
-
txt = back_.format(first=m.from_user.mention)
|
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 |
|
@@ -155,4 +151,4 @@ __HELP__ = """
|
|
155 |
• /afk (/brb) [reason | reply to a message]
|
156 |
|
157 |
`reply to a message` can be any media or text
|
158 |
-
"""
|
|
|
30 |
"{first} is now finally back from the dead"
|
31 |
]
|
32 |
|
33 |
+
|
34 |
+
@Gojo.on_message(command(["afk", "brb"]) & ~filters.private)
|
35 |
async def going_afk(c: Gojo, m: Message):
|
36 |
user = m.from_user.id
|
37 |
chat = m.chat.id
|
38 |
afk = AFK()
|
39 |
text, data_type, content = await get_afk_type(m)
|
40 |
+
|
41 |
+
time = str(datetime.now()).rsplit(".", 1)[0]
|
42 |
|
43 |
if len(m.command) == 1:
|
44 |
text = choice(res)
|
45 |
|
46 |
elif len(m.command) > 1:
|
47 |
+
text = m.text.markdown.split(None, 1)[1]
|
48 |
|
49 |
if not data_type:
|
50 |
data_type = Types.TEXT
|
51 |
|
52 |
+
afk.insert_afk(chat, user, str(time), text, data_type, content)
|
53 |
|
54 |
await m.reply_text(f"{m.from_user.mention} is now AFK")
|
55 |
|
56 |
return
|
57 |
|
58 |
+
|
59 |
+
async def get_hours(hour: str):
|
60 |
tim = hour.strip().split(":")
|
61 |
txt = ""
|
62 |
if int(tim[0]):
|
63 |
+
txt += f"{tim[0]} hours "
|
64 |
if int(tim[1]):
|
65 |
+
txt += f"{tim[1]} minutes "
|
66 |
if int(round(float(tim[2]))):
|
67 |
+
txt += f"{str(round(float(tim[2])))} seconds"
|
68 |
+
|
69 |
return txt
|
70 |
|
71 |
|
|
|
76 |
user = m.from_user.id
|
77 |
chat = m.chat.id
|
78 |
repl = m.reply_to_message
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
+
rep_user = repl.from_user.id if repl and repl.from_user else False
|
81 |
+
is_afk = afk.check_afk(chat, user)
|
82 |
+
is_rep_afk = afk.check_afk(chat, rep_user) if rep_user else False
|
83 |
if is_rep_afk and rep_user != user:
|
84 |
+
con = afk.get_afk(chat, rep_user)
|
85 |
time = till_date(con["time"])
|
86 |
media = con["media"]
|
87 |
media_type = con["media_type"]
|
|
|
91 |
if len(tim_) == 1:
|
92 |
tims = tim
|
93 |
elif len(tim_) == 2:
|
94 |
+
tims = f"{tim_[0]} {tim}"
|
95 |
reason = f"{repl.from_user.first_name} is afk since {tims}\n"
|
96 |
if con['reason'] not in res:
|
97 |
reason += f"\nDue to: {con['reason'].format(first=repl.from_user.first_name)}"
|
|
|
99 |
reason += f"\n{con['reason'].format(first=repl.from_user.first_name)}"
|
100 |
txt = reason
|
101 |
|
102 |
+
if media_type == Types.TEXT:
|
103 |
+
await (await send_cmd(c, media_type))(
|
104 |
chat,
|
105 |
txt,
|
106 |
parse_mode=PM.MARKDOWN,
|
107 |
reply_to_message_id=m.id,
|
108 |
)
|
109 |
else:
|
110 |
+
await (await send_cmd(c, media_type))(
|
111 |
chat,
|
112 |
media,
|
113 |
txt,
|
114 |
parse_mode=PM.MARKDOWN,
|
115 |
reply_to_message_id=repl.id
|
116 |
)
|
117 |
+
|
118 |
if is_afk:
|
119 |
txt = False
|
120 |
try:
|
|
|
122 |
except Exception:
|
123 |
pass
|
124 |
|
125 |
+
if txt and txt in ["afk", "brb"]:
|
126 |
raise ContinuePropagation
|
127 |
else:
|
128 |
+
con = afk.get_afk(chat, user)
|
129 |
time = till_date(con["time"])
|
130 |
tim_ = datetime.now() - time
|
131 |
tim_ = str(tim_).split(",")
|
|
|
133 |
if len(tim_) == 1:
|
134 |
tims = tim
|
135 |
elif len(tim_) == 2:
|
136 |
+
tims = f"{tim_[0]} {tim}"
|
137 |
+
txt = f"{back_.format(first=m.from_user.mention)}\n\nAfk for: {tims}"
|
138 |
await m.reply_text(txt)
|
139 |
+
afk.delete_afk(chat, user)
|
140 |
raise ContinuePropagation
|
141 |
|
142 |
+
|
143 |
__PLUGIN__ = "afk"
|
144 |
|
145 |
+
_DISABLE_CMDS_ = ["afk", "brb"]
|
146 |
|
147 |
__alt_name__ = ["brb"]
|
148 |
|
|
|
151 |
• /afk (/brb) [reason | reply to a message]
|
152 |
|
153 |
`reply to a message` can be any media or text
|
154 |
+
"""
|
Powers/plugins/antispam.py
CHANGED
@@ -18,6 +18,7 @@ from Powers.utils.parser import mention_html
|
|
18 |
# Initialize
|
19 |
db = GBan()
|
20 |
|
|
|
21 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
22 |
async def gban(c: Gojo, m: Message):
|
23 |
if len(m.text.split()) == 1:
|
@@ -72,7 +73,7 @@ async def gban(c: Gojo, m: Message):
|
|
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:
|
@@ -170,14 +171,13 @@ async def gban_list(_, m: Message):
|
|
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 |
|
@@ -186,4 +186,4 @@ __HELP__ = """
|
|
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 |
-
"""
|
|
|
18 |
# Initialize
|
19 |
db = GBan()
|
20 |
|
21 |
+
|
22 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
23 |
async def gban(c: Gojo, m: Message):
|
24 |
if len(m.text.split()) == 1:
|
|
|
73 |
try:
|
74 |
await c.ban_chat_member(m.chat.id, user_id)
|
75 |
except Exception as e:
|
76 |
+
await m.reply_text(f"Failed to ban this user\n{e}")
|
77 |
except UserIsBlocked:
|
78 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
79 |
except PeerIdInvalid:
|
|
|
171 |
document=f, caption="Here are all the globally banned geys!\n\n"
|
172 |
)
|
173 |
|
|
|
174 |
return
|
175 |
|
176 |
+
|
177 |
__PLUGIN__ = "global"
|
178 |
|
179 |
__alt_name__ = ["antispam", "global"]
|
180 |
|
|
|
181 |
__HELP__ = """
|
182 |
**Global**
|
183 |
|
|
|
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
@@ -3,7 +3,6 @@ from pyrogram.enums import ChatMemberStatus as CMS
|
|
3 |
from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
|
4 |
from pyrogram.types import CallbackQuery, Message
|
5 |
|
6 |
-
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.approve_db import Approve
|
9 |
from Powers.utils.custom_filters import admin_filter, command, owner_filter
|
@@ -44,8 +43,7 @@ async def approve_user(c: Gojo, m: Message):
|
|
44 |
"User is already admin - blacklists and locks already don't apply to them.",
|
45 |
)
|
46 |
return
|
47 |
-
already_approved
|
48 |
-
if already_approved:
|
49 |
await m.reply_text(
|
50 |
f"{(await mention_html(user_first_name, user_id))} is already approved in {chat_title}",
|
51 |
)
|
@@ -223,7 +221,6 @@ _DISABLE_CMDS_ = ["approval"]
|
|
223 |
|
224 |
__alt_name__ = ["approved"]
|
225 |
|
226 |
-
|
227 |
__HELP__ = """
|
228 |
**Apporve**
|
229 |
|
|
|
3 |
from pyrogram.errors import PeerIdInvalid, RPCError, UserNotParticipant
|
4 |
from pyrogram.types import CallbackQuery, Message
|
5 |
|
|
|
6 |
from Powers.bot_class import Gojo
|
7 |
from Powers.database.approve_db import Approve
|
8 |
from Powers.utils.custom_filters import admin_filter, command, owner_filter
|
|
|
43 |
"User is already admin - blacklists and locks already don't apply to them.",
|
44 |
)
|
45 |
return
|
46 |
+
if already_approved := db.check_approve(user_id):
|
|
|
47 |
await m.reply_text(
|
48 |
f"{(await mention_html(user_first_name, user_id))} is already approved in {chat_title}",
|
49 |
)
|
|
|
221 |
|
222 |
__alt_name__ = ["approved"]
|
223 |
|
|
|
224 |
__HELP__ = """
|
225 |
**Apporve**
|
226 |
|
Powers/plugins/auto_join.py
CHANGED
@@ -34,33 +34,25 @@ async def accept_join_requests(c: Gojo, m: Message):
|
|
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
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
else:
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
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):
|
@@ -68,24 +60,22 @@ async def join_request_mode(c: Gojo, m: Message):
|
|
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 |
-
|
|
|
89 |
|
90 |
|
91 |
@Gojo.on_chat_join_request(auto_join_filter)
|
@@ -101,11 +91,12 @@ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
|
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,
|
|
|
109 |
LOGGER.error(ef)
|
110 |
LOGGER.error(format_exc())
|
111 |
return
|
@@ -114,20 +105,21 @@ async def join_request_handler(c: Gojo, j: ChatJoinRequest):
|
|
114 |
txt += f"Name: {userr.full_name}"
|
115 |
txt += f"Mention: {userr.mention}"
|
116 |
txt += f"Id: {user}"
|
117 |
-
txt += f"Scam: {'True' if
|
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:
|
@@ -138,7 +130,7 @@ async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
|
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("_")
|
@@ -147,39 +139,41 @@ async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
|
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,
|
|
|
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,
|
|
|
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 |
-
"""
|
|
|
34 |
return
|
35 |
if len(split) == 1:
|
36 |
txt = "**USAGE**\n/joinreq [on | off]"
|
|
|
|
|
37 |
else:
|
38 |
yes_no = split[1].lower()
|
39 |
+
if yes_no == "on":
|
40 |
+
is_al = a_j.load_autojoin(m.chat.id)
|
41 |
+
|
42 |
+
txt = (
|
43 |
+
"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]"
|
44 |
+
if is_al
|
45 |
+
else "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]"
|
46 |
+
)
|
47 |
+
elif yes_no == "off":
|
48 |
+
a_j.remove_autojoin(m.chat.id)
|
49 |
+
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
50 |
else:
|
51 |
+
txt = "**USAGE**\n/joinreq [on | off]"
|
52 |
+
|
53 |
+
await m.reply_text(txt)
|
54 |
+
return
|
55 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
58 |
async def join_request_mode(c: Gojo, m: Message):
|
|
|
60 |
await m.reply_text("Use it in groups")
|
61 |
return
|
62 |
u_text = "**USAGE**\n/joinreqmode [auto | manual]\nauto: auto approve joins\nmanual: will notify admin about the join request"
|
63 |
+
|
64 |
split = m.command
|
65 |
a_j = AUTOJOIN()
|
66 |
+
|
67 |
if len(split) == 1:
|
68 |
await m.reply_text(u_text)
|
|
|
|
|
69 |
else:
|
70 |
auto_manual = split[1]
|
71 |
+
if auto_manual not in ["auto", "manual"]:
|
72 |
await m.reply_text(u_text)
|
|
|
73 |
else:
|
74 |
+
a_j.update_join_type(m.chat.id, auto_manual)
|
75 |
txt = "Changed join request type"
|
76 |
await m.reply_text(txt)
|
77 |
+
|
78 |
+
return
|
79 |
|
80 |
|
81 |
@Gojo.on_chat_join_request(auto_join_filter)
|
|
|
91 |
return
|
92 |
if join_type == "auto" or user in SUPPORT_STAFF:
|
93 |
try:
|
94 |
+
await c.approve_chat_join_request(chat, user)
|
95 |
await c.send_message(chat, f"Accepted join request of the {userr.mention}")
|
96 |
return
|
97 |
except Exception as ef:
|
98 |
+
await c.send_message(chat,
|
99 |
+
f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
100 |
LOGGER.error(ef)
|
101 |
LOGGER.error(format_exc())
|
102 |
return
|
|
|
105 |
txt += f"Name: {userr.full_name}"
|
106 |
txt += f"Mention: {userr.mention}"
|
107 |
txt += f"Id: {user}"
|
108 |
+
txt += f"Scam: {'True' if userr.is_scam else 'False'}"
|
109 |
if userr.username:
|
110 |
+
txt += f"Username: @{userr.username}"
|
111 |
kb = [
|
112 |
[
|
113 |
+
ikb("Accept", f"accept_joinreq_uest_{user}"),
|
114 |
+
ikb("Decline", f"decline_joinreq_uest_{user}")
|
115 |
]
|
116 |
]
|
117 |
+
await c.send_message(chat, txt, reply_markup=ikm(kb))
|
118 |
return
|
119 |
|
120 |
+
|
121 |
@Gojo.on_callback_query(filters.regex("^accept_joinreq_uest_") | filters.regex("^decline_joinreq_uest_"))
|
122 |
+
async def accept_decline_request(c: Gojo, q: CallbackQuery):
|
123 |
user_id = q.from_user.id
|
124 |
chat = q.message.chat.id
|
125 |
try:
|
|
|
130 |
show_alert=True,
|
131 |
)
|
132 |
return
|
133 |
+
except Exception:
|
134 |
await q.answer("Unknow error occured. You are not admin or owner")
|
135 |
return
|
136 |
split = q.data.split("_")
|
|
|
139 |
data = split[0]
|
140 |
try:
|
141 |
userr = await c.get_users(user)
|
142 |
+
except Exception:
|
143 |
userr = None
|
144 |
if data == "accept":
|
145 |
try:
|
146 |
+
await c.approve_chat_join_request(chat, user)
|
147 |
+
await q.answer(f"Accepted join request of the {userr.mention if userr else user}", True)
|
148 |
await q.edit_message_text(f"Accepted join request of the {userr.mention if userr else user}")
|
149 |
except Exception as ef:
|
150 |
+
await c.send_message(chat,
|
151 |
+
f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
152 |
LOGGER.error(ef)
|
153 |
LOGGER.error(format_exc())
|
154 |
+
|
155 |
elif data == "decline":
|
156 |
try:
|
157 |
+
await c.decline_chat_join_request(chat, user)
|
158 |
await q.answer(f"DECLINED: {user}")
|
159 |
await q.edit_message_text()
|
160 |
except Exception as ef:
|
161 |
+
await c.send_message(chat,
|
162 |
+
f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
163 |
LOGGER.error(ef)
|
164 |
LOGGER.error(format_exc())
|
165 |
|
166 |
return
|
167 |
|
168 |
+
|
169 |
__PLUGIN__ = "auto join"
|
170 |
|
171 |
__alt_name__ = ["join_request"]
|
172 |
|
|
|
173 |
__HELP__ = """
|
174 |
**Auto join request**
|
175 |
|
176 |
**Admin commands:**
|
177 |
• /joinreq [on | off]: To switch on auto accept join request
|
178 |
• /joinreqmode [auto | manual]: `auto` to accept join request automatically and `manual` to get notified when new join request is available
|
179 |
+
"""
|
Powers/plugins/bans.py
CHANGED
@@ -44,7 +44,7 @@ async def tban_usr(c: Gojo, m: Message):
|
|
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
|
@@ -86,10 +86,11 @@ async def tban_usr(c: Gojo, m: Message):
|
|
86 |
await m.chat.ban_member(
|
87 |
user_id,
|
88 |
until_date=bantime)
|
89 |
-
t_t=f"{admin} banned {banned} in <b>{chat_title}</b>!",
|
90 |
txt = t_t
|
91 |
if type(t_t) is tuple:
|
92 |
-
txt = t_t[
|
|
|
93 |
if reason:
|
94 |
txt += f"\n<b>Reason</b>: {reason}"
|
95 |
if time_val:
|
@@ -114,14 +115,14 @@ async def tban_usr(c: Gojo, m: Message):
|
|
114 |
parse_mode=enums.ParseMode.HTML,
|
115 |
)
|
116 |
except Exception:
|
117 |
-
|
118 |
await m.reply_text(
|
119 |
reply_to_message_id=r_id,
|
120 |
text=txt,
|
121 |
reply_markup=keyboard,
|
122 |
parse_mode=enums.ParseMode.HTML,
|
123 |
)
|
124 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
125 |
# await m.reply_text(txt, reply_markup=keyboard,
|
126 |
# reply_to_message_id=r_id)
|
127 |
except ChatAdminRequired:
|
@@ -175,7 +176,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
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:
|
@@ -266,7 +267,7 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
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:
|
@@ -329,13 +330,13 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
329 |
parse_mode=enums.ParseMode.HTML,
|
330 |
)
|
331 |
except Exception:
|
332 |
-
|
333 |
await m.reply_text(
|
334 |
txt,
|
335 |
reply_markup=keyboard,
|
336 |
parse_mode=enums.ParseMode.HTML,
|
337 |
)
|
338 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
339 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
340 |
except ChatAdminRequired:
|
341 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
@@ -395,7 +396,7 @@ async def kick_usr(c: Gojo, m: Message):
|
|
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:
|
@@ -424,13 +425,13 @@ async def kick_usr(c: Gojo, m: Message):
|
|
424 |
caption=txt,
|
425 |
parse_mode=enums.ParseMode.HTML,
|
426 |
)
|
427 |
-
except:
|
428 |
await m.reply_text(
|
429 |
reply_to_message_id=r_id,
|
430 |
text=txt,
|
431 |
parse_mode=enums.ParseMode.HTML,
|
432 |
)
|
433 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from KICK_GFIS\n{kickk}")
|
434 |
await m.chat.unban_member(user_id)
|
435 |
except ChatAdminRequired:
|
436 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
@@ -483,7 +484,7 @@ async def skick_usr(c: Gojo, m: Message):
|
|
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:
|
@@ -554,7 +555,7 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
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:
|
@@ -582,12 +583,12 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
582 |
caption=txt,
|
583 |
parse_mode=enums.ParseMode.HTML,
|
584 |
)
|
585 |
-
except:
|
586 |
await m.reply_text(
|
587 |
txt,
|
588 |
parse_mode=enums.ParseMode.HTML,
|
589 |
)
|
590 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from KICK_GFIS\n{kickk}")
|
591 |
await m.chat.unban_member(user_id)
|
592 |
except ChatAdminRequired:
|
593 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
@@ -641,7 +642,7 @@ async def unban_usr(c: Gojo, m: Message):
|
|
641 |
|
642 |
try:
|
643 |
statu = (await m.chat.get_member(user_id)).status
|
644 |
-
if statu not in [enums.ChatMemberStatus.BANNED,enums.ChatMemberStatus.RESTRICTED]:
|
645 |
await m.reply_text("User is not banned in this chat\nOr using this command as reply to his message")
|
646 |
return
|
647 |
except Exception as e:
|
@@ -752,7 +753,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
752 |
if not m.reply_to_message:
|
753 |
return await m.reply_text("Reply to a message to delete it and ban the user!")
|
754 |
|
755 |
-
if
|
756 |
user_id, user_first_name = (
|
757 |
m.reply_to_message.sender_chat.id,
|
758 |
m.reply_to_message.sender_chat.title,
|
@@ -790,10 +791,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
790 |
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
791 |
await m.stop_propagation()
|
792 |
|
793 |
-
reason = None
|
794 |
-
if len(m.text.split()) >= 2:
|
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)
|
@@ -816,8 +814,8 @@ async def dban_usr(c: Gojo, m: Message):
|
|
816 |
m.chat.id, animation=str(animm), caption=txt, reply_markup=keyboard
|
817 |
)
|
818 |
except Exception:
|
819 |
-
await c.send_message(m.chat.id,txt,enums.ParseMode.HTML,reply_markup=keyboard)
|
820 |
-
await c.send_messagea(MESSAGE_DUMP,f"#REMOVE from BAN_GIFS\n{animm}")
|
821 |
except ChatAdminRequired:
|
822 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
823 |
except PeerIdInvalid:
|
@@ -924,14 +922,14 @@ async def ban_usr(c: Gojo, m: Message):
|
|
924 |
parse_mode=enums.ParseMode.HTML,
|
925 |
)
|
926 |
except Exception:
|
927 |
-
|
928 |
await m.reply_text(
|
929 |
reply_to_message_id=r_id,
|
930 |
text=txt,
|
931 |
reply_markup=keyboard,
|
932 |
parse_mode=enums.ParseMode.HTML,
|
933 |
)
|
934 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from BAN_GFIS\n{anim}")
|
935 |
except ChatAdminRequired:
|
936 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
937 |
except PeerIdInvalid:
|
@@ -970,14 +968,14 @@ async def unbanbutton(c: Gojo, q: CallbackQuery):
|
|
970 |
)
|
971 |
return
|
972 |
|
973 |
-
elif
|
974 |
await q.answer(
|
975 |
"You don't have enough permission to do this!\nStay in your limits!",
|
976 |
show_alert=True,
|
977 |
)
|
978 |
return
|
979 |
whoo = await c.get_chat(user_id)
|
980 |
-
doneto = whoo.first_name
|
981 |
try:
|
982 |
await q.message.chat.unban_member(user_id)
|
983 |
except RPCError as e:
|
@@ -989,11 +987,9 @@ async def unbanbutton(c: Gojo, q: CallbackQuery):
|
|
989 |
|
990 |
@Gojo.on_message(command("kickme"))
|
991 |
async def kickme(c: Gojo, m: Message):
|
992 |
-
reason = None
|
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:
|
999 |
await c.promote_chat_member(
|
|
|
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
|
|
|
86 |
await m.chat.ban_member(
|
87 |
user_id,
|
88 |
until_date=bantime)
|
89 |
+
t_t = f"{admin} banned {banned} in <b>{chat_title}</b>!",
|
90 |
txt = t_t
|
91 |
if type(t_t) is tuple:
|
92 |
+
txt = t_t[
|
93 |
+
0] # Done this bcuz idk why t_t is tuple type data. SO now if it is tuple this will get text from it
|
94 |
if reason:
|
95 |
txt += f"\n<b>Reason</b>: {reason}"
|
96 |
if time_val:
|
|
|
115 |
parse_mode=enums.ParseMode.HTML,
|
116 |
)
|
117 |
except Exception:
|
118 |
+
|
119 |
await m.reply_text(
|
120 |
reply_to_message_id=r_id,
|
121 |
text=txt,
|
122 |
reply_markup=keyboard,
|
123 |
parse_mode=enums.ParseMode.HTML,
|
124 |
)
|
125 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
126 |
# await m.reply_text(txt, reply_markup=keyboard,
|
127 |
# reply_to_message_id=r_id)
|
128 |
except ChatAdminRequired:
|
|
|
176 |
await m.reply_text(
|
177 |
text="This user is in my support staff, cannot restrict them."
|
178 |
)
|
179 |
+
|
180 |
await m.stop_propagation()
|
181 |
|
182 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
267 |
|
268 |
if user_id in SUPPORT_STAFF:
|
269 |
await m.reply_text(text="I am not going to ban one of my support staff")
|
270 |
+
|
271 |
await m.stop_propagation()
|
272 |
|
273 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
330 |
parse_mode=enums.ParseMode.HTML,
|
331 |
)
|
332 |
except Exception:
|
333 |
+
|
334 |
await m.reply_text(
|
335 |
txt,
|
336 |
reply_markup=keyboard,
|
337 |
parse_mode=enums.ParseMode.HTML,
|
338 |
)
|
339 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
340 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
341 |
except ChatAdminRequired:
|
342 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
396 |
await m.reply_text(
|
397 |
text="This user is in my support staff, cannot restrict them."
|
398 |
)
|
399 |
+
|
400 |
await m.stop_propagation()
|
401 |
|
402 |
try:
|
|
|
425 |
caption=txt,
|
426 |
parse_mode=enums.ParseMode.HTML,
|
427 |
)
|
428 |
+
except Exception:
|
429 |
await m.reply_text(
|
430 |
reply_to_message_id=r_id,
|
431 |
text=txt,
|
432 |
parse_mode=enums.ParseMode.HTML,
|
433 |
)
|
434 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from KICK_GFIS\n{kickk}")
|
435 |
await m.chat.unban_member(user_id)
|
436 |
except ChatAdminRequired:
|
437 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
484 |
await m.reply_text(
|
485 |
text="This user is in my support staff, cannot restrict them."
|
486 |
)
|
487 |
+
|
488 |
await m.stop_propagation()
|
489 |
|
490 |
try:
|
|
|
555 |
await m.reply_text(
|
556 |
text="This user is in my support staff, cannot restrict them."
|
557 |
)
|
558 |
+
|
559 |
await m.stop_propagation()
|
560 |
|
561 |
try:
|
|
|
583 |
caption=txt,
|
584 |
parse_mode=enums.ParseMode.HTML,
|
585 |
)
|
586 |
+
except Exception:
|
587 |
await m.reply_text(
|
588 |
txt,
|
589 |
parse_mode=enums.ParseMode.HTML,
|
590 |
)
|
591 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from KICK_GFIS\n{kickk}")
|
592 |
await m.chat.unban_member(user_id)
|
593 |
except ChatAdminRequired:
|
594 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
642 |
|
643 |
try:
|
644 |
statu = (await m.chat.get_member(user_id)).status
|
645 |
+
if statu not in [enums.ChatMemberStatus.BANNED, enums.ChatMemberStatus.RESTRICTED]:
|
646 |
await m.reply_text("User is not banned in this chat\nOr using this command as reply to his message")
|
647 |
return
|
648 |
except Exception as e:
|
|
|
753 |
if not m.reply_to_message:
|
754 |
return await m.reply_text("Reply to a message to delete it and ban the user!")
|
755 |
|
756 |
+
if not m.reply_to_message.from_user:
|
757 |
user_id, user_first_name = (
|
758 |
m.reply_to_message.sender_chat.id,
|
759 |
m.reply_to_message.sender_chat.title,
|
|
|
791 |
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
792 |
await m.stop_propagation()
|
793 |
|
794 |
+
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
|
|
795 |
try:
|
796 |
await m.reply_to_message.delete()
|
797 |
await m.chat.ban_member(user_id)
|
|
|
814 |
m.chat.id, animation=str(animm), caption=txt, reply_markup=keyboard
|
815 |
)
|
816 |
except Exception:
|
817 |
+
await c.send_message(m.chat.id, txt, enums.ParseMode.HTML, reply_markup=keyboard)
|
818 |
+
await c.send_messagea(MESSAGE_DUMP, f"#REMOVE from BAN_GIFS\n{animm}")
|
819 |
except ChatAdminRequired:
|
820 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
821 |
except PeerIdInvalid:
|
|
|
922 |
parse_mode=enums.ParseMode.HTML,
|
923 |
)
|
924 |
except Exception:
|
925 |
+
|
926 |
await m.reply_text(
|
927 |
reply_to_message_id=r_id,
|
928 |
text=txt,
|
929 |
reply_markup=keyboard,
|
930 |
parse_mode=enums.ParseMode.HTML,
|
931 |
)
|
932 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
933 |
except ChatAdminRequired:
|
934 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
935 |
except PeerIdInvalid:
|
|
|
968 |
)
|
969 |
return
|
970 |
|
971 |
+
elif not user.privileges.can_restrict_members and q.from_user.id != OWNER_ID:
|
972 |
await q.answer(
|
973 |
"You don't have enough permission to do this!\nStay in your limits!",
|
974 |
show_alert=True,
|
975 |
)
|
976 |
return
|
977 |
whoo = await c.get_chat(user_id)
|
978 |
+
doneto = whoo.first_name or whoo.title
|
979 |
try:
|
980 |
await q.message.chat.unban_member(user_id)
|
981 |
except RPCError as e:
|
|
|
987 |
|
988 |
@Gojo.on_message(command("kickme"))
|
989 |
async def kickme(c: Gojo, m: Message):
|
990 |
+
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
991 |
try:
|
992 |
+
mem = await c.get_chat_member(m.chat.id, m.from_user.id)
|
993 |
if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
|
994 |
try:
|
995 |
await c.promote_chat_member(
|
Powers/plugins/birthday.py
CHANGED
@@ -8,7 +8,7 @@ from pyrogram.types import InlineKeyboardButton as IKB
|
|
8 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
9 |
from pyrogram.types import Message
|
10 |
|
11 |
-
from Powers import BDB_URI, LOGGER
|
12 |
from Powers.bot_class import Gojo
|
13 |
from Powers.database.chats_db import Chats
|
14 |
|
@@ -18,9 +18,9 @@ if BDB_URI:
|
|
18 |
from Powers.utils.custom_filters import command
|
19 |
|
20 |
|
21 |
-
def give_date(date,form
|
22 |
-
|
23 |
-
|
24 |
|
25 |
@Gojo.on_message(command("remember"))
|
26 |
async def remember_me(c: Gojo, m: Message):
|
@@ -29,38 +29,24 @@ async def remember_me(c: Gojo, m: Message):
|
|
29 |
return
|
30 |
splited = m.text.split()
|
31 |
if len(splited) == 1:
|
32 |
-
await m.reply_text(
|
|
|
33 |
return
|
34 |
if len(splited) != 2 and m.reply_to_message:
|
35 |
-
await m.reply_text(
|
|
|
36 |
return
|
37 |
DOB = splited[1] if len(splited) == 2 else splited[2]
|
38 |
if len(splited) == 2 and m.reply_to_message:
|
39 |
user = m.reply_to_message.from_user.id
|
40 |
-
elif not m.reply_to_message:
|
41 |
-
user = m.from_user.id
|
42 |
else:
|
43 |
-
|
44 |
-
u_id = int(splited[1])
|
45 |
-
except ValueError:
|
46 |
-
pass
|
47 |
-
try:
|
48 |
-
user = await c.get_users(u_id)
|
49 |
-
except Exception:
|
50 |
-
u_u = await c.resolve_peer(u_id)
|
51 |
-
try:
|
52 |
-
user = (await c.get_users(u_u.user_id)).id
|
53 |
-
except KeyError:
|
54 |
-
await m.reply_text("Unable to find the user")
|
55 |
-
return
|
56 |
DOB = DOB.split("/")
|
57 |
-
if len(DOB)
|
58 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
59 |
return
|
60 |
-
is_correct = False
|
61 |
-
if len(DOB)
|
62 |
-
is_correct = (len(DOB[2]) == 4)
|
63 |
-
if len(DOB[0]) != 2 and len(DOB[1]) !=2 and not is_correct:
|
64 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
65 |
return
|
66 |
try:
|
@@ -72,15 +58,14 @@ async def remember_me(c: Gojo, m: Message):
|
|
72 |
else:
|
73 |
year = "1900"
|
74 |
is_year = 0
|
75 |
-
DOB = f"{
|
76 |
except ValueError:
|
77 |
await m.reply_text("DOB should be numbers only")
|
78 |
return
|
79 |
|
80 |
-
data = {"user_id":user,"dob":DOB,"is_year":is_year}
|
81 |
try:
|
82 |
-
result
|
83 |
-
if result:
|
84 |
await m.reply_text("User is already in my database")
|
85 |
return
|
86 |
except Exception as e:
|
@@ -97,26 +82,26 @@ async def remember_me(c: Gojo, m: Message):
|
|
97 |
LOGGER.error(format_exc())
|
98 |
return
|
99 |
|
100 |
-
|
|
|
101 |
async def who_are_you_again(c: Gojo, m: Message):
|
102 |
if not BDB_URI:
|
103 |
await m.reply_text("BDB_URI is not configured")
|
104 |
return
|
105 |
user = m.from_user.id
|
106 |
try:
|
107 |
-
result
|
108 |
-
|
109 |
-
await m.reply_text("User is not in my database")
|
110 |
-
return
|
111 |
-
elif result:
|
112 |
-
bday_info.delete_one({"user_id":user})
|
113 |
await m.reply_text("Removed your birthday")
|
114 |
-
|
|
|
|
|
115 |
except Exception as e:
|
116 |
await m.reply_text(f"Got an error\n{e}")
|
117 |
return
|
118 |
|
119 |
-
|
|
|
120 |
async def who_is_next(c: Gojo, m: Message):
|
121 |
if not BDB_URI:
|
122 |
await m.reply_text("BDB_URI is not configured")
|
@@ -133,28 +118,27 @@ async def who_is_next(c: Gojo, m: Message):
|
|
133 |
if Chats(m.chat.id).user_is_in_chat(i["user_id"]):
|
134 |
dob = give_date(i["dob"])
|
135 |
if dob.month >= curr.month:
|
136 |
-
|
137 |
-
users.append(i)
|
138 |
-
elif dob.month < curr.month:
|
139 |
-
pass
|
140 |
if len(users) == 10:
|
141 |
break
|
142 |
if not users:
|
143 |
await xx.delete()
|
144 |
-
await m.reply_text(
|
|
|
145 |
return
|
146 |
txt = "🎊 Upcomming Birthdays Are 🎊\n"
|
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)
|
155 |
return
|
156 |
|
157 |
-
|
|
|
158 |
async def cant_recall_it(c: Gojo, m: Message):
|
159 |
if not BDB_URI:
|
160 |
await m.reply_text("BDB_URI is not configured")
|
@@ -165,27 +149,27 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
165 |
user = m.reply_to_message.from_user.id
|
166 |
men = m.reply_to_message.from_user.mention
|
167 |
try:
|
168 |
-
result = bday_info.find_one({"user_id":user})
|
169 |
if not result:
|
170 |
await m.reply_text("User is not in my database")
|
171 |
return
|
172 |
except Exception as e:
|
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)
|
@@ -193,11 +177,12 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
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"
|
197 |
await m.reply_text(txt)
|
198 |
return
|
199 |
|
200 |
-
|
|
|
201 |
async def chat_birthday_settings(c: Gojo, m: Message):
|
202 |
if not BDB_URI:
|
203 |
await m.reply_text("BDB_URI is not configured")
|
@@ -206,20 +191,21 @@ async def chat_birthday_settings(c: Gojo, m: Message):
|
|
206 |
await m.reply_text("Use in groups")
|
207 |
return
|
208 |
chats = m.chat.id
|
209 |
-
c_in = bday_cinfo.find_one({"chat_id":chats})
|
210 |
kb = IKM(
|
211 |
[
|
212 |
[
|
213 |
-
IKB(f"{'
|
214 |
IKB("Close", "f_close")
|
215 |
]
|
216 |
]
|
217 |
)
|
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)
|
225 |
if user not in [ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
@@ -227,16 +213,16 @@ async def switch_on_off(c:Gojo, q: CallbackQuery):
|
|
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'}",
|
|
|
236 |
return
|
237 |
|
238 |
|
239 |
-
|
240 |
__PLUGIN__ = "birthday"
|
241 |
|
242 |
__HELP__ = """
|
|
|
8 |
from pyrogram.types import InlineKeyboardMarkup as IKM
|
9 |
from pyrogram.types import Message
|
10 |
|
11 |
+
from Powers import BDB_URI, LOGGER
|
12 |
from Powers.bot_class import Gojo
|
13 |
from Powers.database.chats_db import Chats
|
14 |
|
|
|
18 |
from Powers.utils.custom_filters import command
|
19 |
|
20 |
|
21 |
+
def give_date(date, form="%d/%m/%Y"):
|
22 |
+
return datetime.strptime(date, form).date()
|
23 |
+
|
24 |
|
25 |
@Gojo.on_message(command("remember"))
|
26 |
async def remember_me(c: Gojo, m: Message):
|
|
|
29 |
return
|
30 |
splited = m.text.split()
|
31 |
if len(splited) == 1:
|
32 |
+
await m.reply_text(
|
33 |
+
"**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
34 |
return
|
35 |
if len(splited) != 2 and m.reply_to_message:
|
36 |
+
await m.reply_text(
|
37 |
+
"**USAGE**:\n/remember [username or user id or reply to user] [DOB]\nDOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
38 |
return
|
39 |
DOB = splited[1] if len(splited) == 2 else splited[2]
|
40 |
if len(splited) == 2 and m.reply_to_message:
|
41 |
user = m.reply_to_message.from_user.id
|
|
|
|
|
42 |
else:
|
43 |
+
user = m.from_user.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
DOB = DOB.split("/")
|
45 |
+
if len(DOB) not in [3, 2]:
|
46 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
47 |
return
|
48 |
+
is_correct = (len(DOB[2]) == 4) if len(DOB) == 3 else False
|
49 |
+
if len(DOB[0]) != 2 and len(DOB[1]) != 2 and not is_correct:
|
|
|
|
|
50 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
51 |
return
|
52 |
try:
|
|
|
58 |
else:
|
59 |
year = "1900"
|
60 |
is_year = 0
|
61 |
+
DOB = f"{date}/{month}/{str(year)}"
|
62 |
except ValueError:
|
63 |
await m.reply_text("DOB should be numbers only")
|
64 |
return
|
65 |
|
66 |
+
data = {"user_id": user, "dob": DOB, "is_year": is_year}
|
67 |
try:
|
68 |
+
if result := bday_info.find_one({"user_id": user}):
|
|
|
69 |
await m.reply_text("User is already in my database")
|
70 |
return
|
71 |
except Exception as e:
|
|
|
82 |
LOGGER.error(format_exc())
|
83 |
return
|
84 |
|
85 |
+
|
86 |
+
@Gojo.on_message(command(["removebday", "rmbday"]))
|
87 |
async def who_are_you_again(c: Gojo, m: Message):
|
88 |
if not BDB_URI:
|
89 |
await m.reply_text("BDB_URI is not configured")
|
90 |
return
|
91 |
user = m.from_user.id
|
92 |
try:
|
93 |
+
if result := bday_info.find_one({"user_id": user}):
|
94 |
+
bday_info.delete_one({"user_id": user})
|
|
|
|
|
|
|
|
|
95 |
await m.reply_text("Removed your birthday")
|
96 |
+
else:
|
97 |
+
await m.reply_text("User is not in my database")
|
98 |
+
return
|
99 |
except Exception as e:
|
100 |
await m.reply_text(f"Got an error\n{e}")
|
101 |
return
|
102 |
|
103 |
+
|
104 |
+
@Gojo.on_message(command(["nextbdays", "nbdays", "birthdays", "bdays"]))
|
105 |
async def who_is_next(c: Gojo, m: Message):
|
106 |
if not BDB_URI:
|
107 |
await m.reply_text("BDB_URI is not configured")
|
|
|
118 |
if Chats(m.chat.id).user_is_in_chat(i["user_id"]):
|
119 |
dob = give_date(i["dob"])
|
120 |
if dob.month >= curr.month:
|
121 |
+
users.append(i)
|
|
|
|
|
|
|
122 |
if len(users) == 10:
|
123 |
break
|
124 |
if not users:
|
125 |
await xx.delete()
|
126 |
+
await m.reply_text(
|
127 |
+
"There are no upcoming birthdays of any user in this chat:/\nEither all the birthdays are passed or no user from this chat have registered their birthday")
|
128 |
return
|
129 |
txt = "🎊 Upcomming Birthdays Are 🎊\n"
|
130 |
for i in users:
|
131 |
DOB = give_date(i["dob"])
|
132 |
dete = date(curr.year, DOB.month, DOB.day)
|
133 |
+
leff = (dete - curr).days
|
134 |
txt += f"`{i['user_id']}` : {leff} days left\n"
|
135 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
136 |
await xx.delete()
|
137 |
await m.reply_text(txt)
|
138 |
return
|
139 |
|
140 |
+
|
141 |
+
@Gojo.on_message(command(["getbday", "gbday", "mybirthday", "mybday"]))
|
142 |
async def cant_recall_it(c: Gojo, m: Message):
|
143 |
if not BDB_URI:
|
144 |
await m.reply_text("BDB_URI is not configured")
|
|
|
149 |
user = m.reply_to_message.from_user.id
|
150 |
men = m.reply_to_message.from_user.mention
|
151 |
try:
|
152 |
+
result = bday_info.find_one({"user_id": user})
|
153 |
if not result:
|
154 |
await m.reply_text("User is not in my database")
|
155 |
return
|
156 |
except Exception as e:
|
157 |
await m.reply_text(f"Got an error\n{e}")
|
158 |
return
|
159 |
+
|
160 |
+
curr = datetime.now().date()
|
161 |
u_dob = give_date(result["dob"])
|
162 |
formatted = str(u_dob.strftime('%d' + '%B %Y'))[2:-5]
|
163 |
day = int(result["dob"].split('/')[0])
|
164 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
|
165 |
bday_on = f"{day}{suffix} {formatted}"
|
166 |
+
if (u_dob.day, u_dob.month) < (curr.day, curr.month):
|
167 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
168 |
days_left = (next_b - curr).days
|
169 |
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {abs(days_left)}"
|
170 |
txt += f"\nBirthday on: {bday_on}"
|
171 |
txt += f"\n\nDate of birth: {result['dob']}"
|
172 |
+
elif (u_dob.day, u_dob.month) == (curr.day, curr.month):
|
173 |
txt = f"Today is {men}'s birthday."
|
174 |
else:
|
175 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
|
|
177 |
txt = f"User's birthday is coming🥳\nDays left: {abs(days_left)}"
|
178 |
txt += f"\nBirthday on: {bday_on}"
|
179 |
txt += f"\n\nDate of birth: {result['dob']}"
|
180 |
+
txt += "\n\n**NOTE**:\nDOB may be wrong if user haven't entered his/her birth year"
|
181 |
await m.reply_text(txt)
|
182 |
return
|
183 |
|
184 |
+
|
185 |
+
@Gojo.on_message(command(["settingbday", "sbday"]))
|
186 |
async def chat_birthday_settings(c: Gojo, m: Message):
|
187 |
if not BDB_URI:
|
188 |
await m.reply_text("BDB_URI is not configured")
|
|
|
191 |
await m.reply_text("Use in groups")
|
192 |
return
|
193 |
chats = m.chat.id
|
194 |
+
c_in = bday_cinfo.find_one({"chat_id": chats})
|
195 |
kb = IKM(
|
196 |
[
|
197 |
[
|
198 |
+
IKB(f"{'No' if c_in else 'Yes'}", f"switchh_{'no' if c_in else 'yes'}"),
|
199 |
IKB("Close", "f_close")
|
200 |
]
|
201 |
]
|
202 |
)
|
203 |
+
await m.reply_text("Do you want to wish members for their birthday in the group?", reply_markup=kb)
|
204 |
return
|
205 |
|
206 |
+
|
207 |
@Gojo.on_callback_query(filters.regex(r"^switchh_(yes|no)$"))
|
208 |
+
async def switch_on_off(c: Gojo, q: CallbackQuery):
|
209 |
user = (await q.message.chat.get_member(q.from_user.id)).status
|
210 |
await q.message.chat.get_member(q.from_user.id)
|
211 |
if user not in [ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
|
|
213 |
return
|
214 |
data = q.data.split("_")[1]
|
215 |
chats = q.message.chat.id
|
216 |
+
query = {"chat_id": chats}
|
217 |
if data == "yes":
|
218 |
bday_cinfo.delete_one(query)
|
219 |
elif data == "no":
|
220 |
bday_cinfo.insert_one(query)
|
221 |
+
await q.edit_message_text(f"Done! I will {'wish' if data == 'yes' else 'not wish'}",
|
222 |
+
reply_markup=IKM([[IKB("Close", "f_close")]]))
|
223 |
return
|
224 |
|
225 |
|
|
|
226 |
__PLUGIN__ = "birthday"
|
227 |
|
228 |
__HELP__ = """
|
Powers/plugins/blacklist.py
CHANGED
@@ -4,7 +4,6 @@ from pyrogram import filters
|
|
4 |
from pyrogram.enums import ChatMemberStatus as CMS
|
5 |
from pyrogram.types import CallbackQuery, Message
|
6 |
|
7 |
-
from Powers import LOGGER
|
8 |
from Powers.bot_class import Gojo
|
9 |
from Powers.database.blacklist_db import Blacklist
|
10 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
@@ -53,13 +52,13 @@ async def add_blacklist(_, m: Message):
|
|
53 |
|
54 |
if already_added_words:
|
55 |
rep_text = (
|
56 |
-
|
57 |
-
|
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!"
|
62 |
-
|
63 |
)
|
64 |
|
65 |
await m.stop_propagation()
|
@@ -110,13 +109,13 @@ async def rm_blacklist(_, m: Message):
|
|
110 |
|
111 |
if non_found_words:
|
112 |
rep_text = (
|
113 |
-
|
114 |
-
|
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!"
|
119 |
-
|
120 |
)
|
121 |
|
122 |
await m.stop_propagation()
|
@@ -134,8 +133,8 @@ async def set_bl_action(_, m: Message):
|
|
134 |
if action not in valid_actions:
|
135 |
await m.reply_text(
|
136 |
(
|
137 |
-
|
138 |
-
|
139 |
),
|
140 |
)
|
141 |
|
|
|
4 |
from pyrogram.enums import ChatMemberStatus as CMS
|
5 |
from pyrogram.types import CallbackQuery, Message
|
6 |
|
|
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.blacklist_db import Blacklist
|
9 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
|
|
52 |
|
53 |
if already_added_words:
|
54 |
rep_text = (
|
55 |
+
", ".join([f"<code>{i}</code>" for i in bl_words])
|
56 |
+
+ " already added in blacklist, skipped them!"
|
57 |
)
|
58 |
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
59 |
await m.reply_text(
|
60 |
text=f"Added <code>{trigger}</code> in blacklist words!"
|
61 |
+
+ (f"\n{rep_text}" if rep_text else ""),
|
62 |
)
|
63 |
|
64 |
await m.stop_propagation()
|
|
|
109 |
|
110 |
if non_found_words:
|
111 |
rep_text = (
|
112 |
+
"Could not find " + ", ".join(f"<code>{i}</code>" for i in non_found_words)
|
113 |
+
) + " in blcklisted words, skipped them."
|
114 |
|
115 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
116 |
await m.reply_text(
|
117 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
118 |
+
+ (f"\n{rep_text}" if rep_text else ""),
|
119 |
)
|
120 |
|
121 |
await m.stop_propagation()
|
|
|
133 |
if action not in valid_actions:
|
134 |
await m.reply_text(
|
135 |
(
|
136 |
+
"Choose a valid blacklist action from "
|
137 |
+
+ ", ".join(f"<code>{i}</code>" for i in valid_actions)
|
138 |
),
|
139 |
)
|
140 |
|
Powers/plugins/captcha.py
CHANGED
@@ -3,7 +3,6 @@ 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
|
@@ -32,20 +31,18 @@ async def start_captcha(_, m: Message):
|
|
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 |
-
|
|
|
49 |
|
50 |
|
51 |
@Gojo.on_message(command("captchamode") & admin_filter & ~filters.private)
|
@@ -53,28 +50,23 @@ async def set_captcha_mode(c: Gojo, m: Message):
|
|
53 |
split = m.command
|
54 |
captcha = CAPTCHA()
|
55 |
if len(split) == 1:
|
56 |
-
curr
|
57 |
-
if curr:
|
58 |
capatcha_type = curr["captcha_type"]
|
59 |
-
await m.reply_text(
|
60 |
-
|
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 |
-
|
|
|
78 |
|
79 |
|
80 |
@Gojo.on_callback_query(filters.regex("^captcha_"))
|
@@ -103,7 +95,6 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
|
|
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
|
@@ -139,20 +130,20 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
|
|
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 |
-
|
|
|
156 |
|
157 |
|
158 |
@Gojo.on_message(filters.group & captcha_filter & filters.new_chat_members, group=3)
|
@@ -163,7 +154,7 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
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)
|
@@ -172,7 +163,7 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
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
|
@@ -201,24 +192,16 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
201 |
continue
|
202 |
|
203 |
if not is_already:
|
204 |
-
captcha_type = "image"
|
205 |
-
if captcha_type == "
|
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
|
220 |
-
|
221 |
-
rand.append(hehe)
|
222 |
|
223 |
shuffle(rand)
|
224 |
|
@@ -227,26 +210,31 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
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 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
250 |
kb = ikm(
|
251 |
[
|
252 |
[
|
|
|
3 |
from traceback import format_exc
|
4 |
from typing import List
|
5 |
|
|
|
6 |
from pyrogram import filters
|
7 |
from pyrogram.enums import ChatMemberStatus as CMS
|
8 |
from pyrogram.enums import ParseMode as PM
|
|
|
31 |
else:
|
32 |
txt = "Captcha verification is currently **off** for this chat"
|
33 |
await m.reply_text(txt)
|
|
|
34 |
else:
|
35 |
on_off = split[1].lower()
|
36 |
if on_off in ["on", "yes", "enable"]:
|
37 |
captcha.insert_captcha(m.chat.id)
|
38 |
await m.reply_text("Captcha verification is now **on** for this chat")
|
|
|
39 |
elif on_off in ["off", "no", "disable"]:
|
40 |
captcha.remove_captcha(m.chat.id)
|
41 |
await m.reply_text("Captcha verification is now **off** for this chat")
|
|
|
42 |
else:
|
43 |
await m.reply_text("**USAGE**\n/captcha [on | yes | enable | off | no | disable]")
|
44 |
+
|
45 |
+
return
|
46 |
|
47 |
|
48 |
@Gojo.on_message(command("captchamode") & admin_filter & ~filters.private)
|
|
|
50 |
split = m.command
|
51 |
captcha = CAPTCHA()
|
52 |
if len(split) == 1:
|
53 |
+
if curr := captcha.get_captcha(m.chat.id):
|
|
|
54 |
capatcha_type = curr["captcha_type"]
|
55 |
+
await m.reply_text(
|
56 |
+
f"Current captcha verification methode is {capatcha_type}\nAvailable methodes:\n■ qr\n■ image")
|
57 |
else:
|
58 |
await m.reply_text("Captcha verification is off for the current chat")
|
|
|
59 |
else:
|
60 |
type_ = split[1].lower()
|
61 |
if type_ == "qr":
|
62 |
await m.reply_text("This feature is not implemented yet\nUse /captchamode image")
|
|
|
|
|
|
|
63 |
elif type_ == "image":
|
64 |
captcha.update_type(m.chat.id, "image")
|
65 |
await m.reply_text("Captcha verication is now changed to image")
|
|
|
66 |
else:
|
67 |
await m.reply_text("**USAGE**\n/captchamode [qr | image]")
|
68 |
+
|
69 |
+
return
|
70 |
|
71 |
|
72 |
@Gojo.on_callback_query(filters.regex("^captcha_"))
|
|
|
95 |
return
|
96 |
await c.send_message(chat, f"{q.from_user.mention} now you are free to talk")
|
97 |
await q.message.delete()
|
|
|
98 |
else:
|
99 |
caps = q.message.caption.split(":")
|
100 |
tries = int(caps[1].strip()) - 1
|
|
|
130 |
parse_mode=PM.HTML,
|
131 |
)
|
132 |
except Exception:
|
133 |
+
|
134 |
await c.send_animation(
|
135 |
chat_id=q.message.chat.id,
|
136 |
text=txt,
|
137 |
reply_markup=keyboard,
|
138 |
parse_mode=PM.HTML,
|
139 |
)
|
140 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from BAN_GFIS\n{anim}")
|
141 |
c_data.remove_cap_data(chat, user)
|
142 |
c_data.del_message_id(q.message.chat.id, user)
|
|
|
143 |
else:
|
144 |
await q.edit_message_caption(new_cap, reply_markup=q.message.reply_markup)
|
145 |
+
|
146 |
+
return
|
147 |
|
148 |
|
149 |
@Gojo.on_message(filters.group & captcha_filter & filters.new_chat_members, group=3)
|
|
|
154 |
for user in users:
|
155 |
captcha = CAPTCHA()
|
156 |
cap_data = CAPTCHA_DATA()
|
157 |
+
|
158 |
if user.is_bot:
|
159 |
continue
|
160 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
|
|
163 |
status = (await m.chat.get_member(user)).status
|
164 |
if status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
165 |
continue
|
166 |
+
except Exception:
|
167 |
pass
|
168 |
if user.id in SUPPORT_STAFF:
|
169 |
continue
|
|
|
192 |
continue
|
193 |
|
194 |
if not is_already:
|
195 |
+
captcha_type = "image" # I am not going to apply qr captcha in this update
|
196 |
+
if captcha_type == "image":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
img, code = await get_image_captcha(chat, user.id)
|
198 |
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"
|
199 |
cap_data.load_cap_data(chat, user.id, code)
|
200 |
rand = [code]
|
201 |
while len(rand) != 5:
|
202 |
hehe = genrator()
|
203 |
+
if hehe != code:
|
204 |
+
rand.append(hehe)
|
|
|
205 |
|
206 |
shuffle(rand)
|
207 |
|
|
|
210 |
kb = ikm(
|
211 |
[
|
212 |
[
|
213 |
+
IKB(rand[0], ini + rand[0])
|
214 |
],
|
215 |
[
|
216 |
+
IKB(rand[1], ini + rand[1])
|
217 |
],
|
218 |
[
|
219 |
+
IKB(rand[2], ini + rand[2])
|
220 |
],
|
221 |
[
|
222 |
+
IKB(rand[3], ini + rand[3])
|
223 |
],
|
224 |
[
|
225 |
+
IKB(rand[4], ini + rand[4])
|
226 |
]
|
227 |
]
|
228 |
)
|
229 |
await c.send_photo(chat, img, caption=cap, reply_markup=kb)
|
230 |
os.remove(img)
|
231 |
+
elif captcha_type == "qr":
|
232 |
+
pic = await get_qr_captcha(chat, user.id, c.me.username)
|
233 |
+
cap = f"Please {user.mention} scan this qr code with your phone to verify that you are human"
|
234 |
+
ms = await c.send_photo(chat, pic, caption=cap)
|
235 |
+
os.remove(pic)
|
236 |
+
cap_data.store_message_id(chat, user.id, ms.id)
|
237 |
+
elif mess:
|
238 |
kb = ikm(
|
239 |
[
|
240 |
[
|
Powers/plugins/chat_blacklist.py
CHANGED
@@ -33,13 +33,12 @@ 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 |
else:
|
37 |
-
|
38 |
-
|
39 |
-
|
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 |
|
@@ -69,16 +68,15 @@ async def unblacklist_chat(c: Gojo, m: Message):
|
|
69 |
await replymsg.edit_text(
|
70 |
f"Removed the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
71 |
)
|
|
|
|
|
72 |
else:
|
73 |
-
|
74 |
-
|
|
|
|
|
75 |
else:
|
76 |
-
|
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 |
|
@@ -86,12 +84,11 @@ async def unblacklist_chat(c: Gojo, m: Message):
|
|
86 |
command(["blchatlist", "blchats"], dev_cmd=True),
|
87 |
)
|
88 |
async def list_blacklist_chats(_, m: Message):
|
89 |
-
bl_chats
|
90 |
-
if bl_chats:
|
91 |
txt = (
|
92 |
(
|
93 |
-
|
94 |
-
|
95 |
),
|
96 |
)
|
97 |
|
@@ -103,8 +100,6 @@ async def list_blacklist_chats(_, m: Message):
|
|
103 |
|
104 |
__PLUGIN__ = "Chat blacklist"
|
105 |
|
106 |
-
|
107 |
-
|
108 |
__HELP__ = """
|
109 |
**Chat blacklist**
|
110 |
|
@@ -112,4 +107,4 @@ __HELP__ = """
|
|
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 |
-
"""
|
|
|
33 |
await replymsg.edit_text(
|
34 |
f"Added the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
35 |
)
|
36 |
+
elif m.chat.type == CT.PRIVATE:
|
37 |
+
await m.reply_text("Use in groups")
|
38 |
else:
|
39 |
+
chat_id = m.chat.id
|
40 |
+
db.add_chat(chat_id)
|
41 |
+
await m.reply_text("Added this chat to blacklist chats")
|
|
|
|
|
|
|
42 |
return
|
43 |
|
44 |
|
|
|
68 |
await replymsg.edit_text(
|
69 |
f"Removed the following chats to Blacklist.\n<code>{', '.join(chat_ids)}</code>.",
|
70 |
)
|
71 |
+
elif m.chat.type == CT.PRIVATE:
|
72 |
+
await m.reply_text("Use in groups")
|
73 |
else:
|
74 |
+
chat_id = m.chat.id
|
75 |
+
bl_chats = bl_chats = db.list_all_chats()
|
76 |
+
if chat_id in bl_chats:
|
77 |
+
await m.reply_text("Removed this chat from blacklist chats")
|
78 |
else:
|
79 |
+
await m.reply_text("This chat is not in my list of blacklisted chats")
|
|
|
|
|
|
|
|
|
|
|
80 |
return
|
81 |
|
82 |
|
|
|
84 |
command(["blchatlist", "blchats"], dev_cmd=True),
|
85 |
)
|
86 |
async def list_blacklist_chats(_, m: Message):
|
87 |
+
if bl_chats := db.list_all_chats():
|
|
|
88 |
txt = (
|
89 |
(
|
90 |
+
"These Chats are Blacklisted:\n"
|
91 |
+
+ "\n".join(f"<code>{i}</code>" for i in bl_chats)
|
92 |
),
|
93 |
)
|
94 |
|
|
|
100 |
|
101 |
__PLUGIN__ = "Chat blacklist"
|
102 |
|
|
|
|
|
103 |
__HELP__ = """
|
104 |
**Chat blacklist**
|
105 |
|
|
|
107 |
• /blchat [space separated id or username of chats]: Add chats to black list if given or the current chat.
|
108 |
• /rmblchat [space separated id or username of chats]: Remove chats from black list if given or the current chat.
|
109 |
• /blchats: Give the list of blacklisted chats
|
110 |
+
"""
|
Powers/plugins/dev.py
CHANGED
@@ -8,7 +8,6 @@ from sys import executable
|
|
8 |
from time import gmtime, strftime, time
|
9 |
from traceback import format_exc
|
10 |
|
11 |
-
from pyrogram import filters
|
12 |
from pyrogram.errors import (ChannelInvalid, ChannelPrivate, ChatAdminRequired,
|
13 |
EntityBoundsInvalid, FloodWait, MessageTooLong,
|
14 |
PeerIdInvalid, RPCError)
|
@@ -31,23 +30,23 @@ from Powers.utils.parser import mention_markdown
|
|
31 |
|
32 |
|
33 |
def can_change_type(curr, to_user):
|
34 |
-
if curr == "dev" and to_user in ["whitelist","sudo"]:
|
35 |
return True
|
36 |
elif curr == "sudo" and to_user == "whitelist":
|
37 |
return True
|
38 |
else:
|
39 |
return False
|
40 |
|
|
|
41 |
@Gojo.on_message(command(["addsupport"]))
|
42 |
-
async def add_support(c: Gojo, m:Message):
|
43 |
support = SUPPORTS()
|
44 |
curr_user = support.get_support_type(m.from_user.id)
|
45 |
if not curr_user:
|
46 |
await m.reply_text("Stay in you limit")
|
47 |
return
|
48 |
split = m.command
|
49 |
-
reply_to
|
50 |
-
if reply_to:
|
51 |
try:
|
52 |
userr = reply_to.from_user.id
|
53 |
except Exception:
|
@@ -59,26 +58,25 @@ async def add_support(c: Gojo, m:Message):
|
|
59 |
except IndexError:
|
60 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
61 |
return
|
62 |
-
if to not in ["dev","sudo","whitelist"]:
|
63 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
64 |
return
|
65 |
if m.from_user.id == int(OWNER_ID):
|
66 |
if to == curr:
|
67 |
await m.reply_text(f"This user is already in {to} users")
|
68 |
-
return
|
69 |
elif curr:
|
70 |
kb = IKM(
|
71 |
[
|
72 |
[
|
73 |
-
IKB("Yes",f"change_support_type:{to}"),
|
74 |
-
IKB("No","change_support_type:no")
|
75 |
]
|
76 |
]
|
77 |
)
|
78 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
79 |
-
|
80 |
else:
|
81 |
-
support.insert_support_user(userr,to)
|
82 |
if to == "dev":
|
83 |
DEV_USERS.add(userr)
|
84 |
elif to == "sudo":
|
@@ -86,34 +84,31 @@ async def add_support(c: Gojo, m:Message):
|
|
86 |
else:
|
87 |
WHITELIST_USERS.add(userr)
|
88 |
await m.reply_text(f"This user is now a {to} user")
|
89 |
-
|
90 |
-
can_do
|
91 |
-
if can_do:
|
92 |
if to == curr:
|
93 |
await m.reply_text(f"This user is already in {to} users")
|
94 |
-
return
|
95 |
elif curr:
|
96 |
kb = IKM(
|
97 |
[
|
98 |
[
|
99 |
-
IKB("Yes",f"change_support_type:{to}"),
|
100 |
-
IKB("No","change_support_type:no")
|
101 |
]
|
102 |
]
|
103 |
)
|
104 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
105 |
-
|
106 |
else:
|
107 |
-
support.insert_support_user(userr,to)
|
108 |
await m.reply_text(f"This user is now a {to} user")
|
109 |
-
return
|
110 |
else:
|
111 |
await m.reply_text("Sorry you can't do it")
|
112 |
-
|
113 |
elif len(split) >= 3:
|
114 |
user = split[1]
|
115 |
try:
|
116 |
-
userr,_,_ = extract_user(user)
|
117 |
except Exception:
|
118 |
await m.reply_text("Tell the user to start me first")
|
119 |
return
|
@@ -121,53 +116,51 @@ async def add_support(c: Gojo, m:Message):
|
|
121 |
try:
|
122 |
to = m.command[2].lower()
|
123 |
except IndexError:
|
124 |
-
await m.reply_text(
|
|
|
125 |
return
|
126 |
-
if to not in ["dev","sudo","whitelist"]:
|
127 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
128 |
return
|
129 |
if m.from_user.id == int(OWNER_ID):
|
130 |
if to == curr:
|
131 |
await m.reply_text(f"This user is already in {to} users")
|
132 |
-
return
|
133 |
elif curr:
|
134 |
kb = IKM(
|
135 |
[
|
136 |
[
|
137 |
-
IKB("Yes",f"change_support_type:{to}"),
|
138 |
-
IKB("No","change_support_type:no")
|
139 |
]
|
140 |
]
|
141 |
)
|
142 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
143 |
-
|
144 |
else:
|
145 |
-
support.insert_support_user(userr,to)
|
146 |
await m.reply_text(f"This user is now a {to} user")
|
147 |
-
|
148 |
-
can_do
|
149 |
-
if can_do:
|
150 |
if to == curr:
|
151 |
await m.reply_text(f"This user is already in {to} users")
|
152 |
-
return
|
153 |
elif curr:
|
154 |
kb = IKM(
|
155 |
[
|
156 |
[
|
157 |
-
IKB("Yes",f"change_support_type:{to}"),
|
158 |
-
IKB("No","change_support_type:no")
|
159 |
]
|
160 |
]
|
161 |
)
|
162 |
-
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
163 |
-
|
164 |
else:
|
165 |
-
support.insert_support_user(userr,to)
|
166 |
await m.reply_text(f"This user is now a {to} user")
|
167 |
-
return
|
168 |
else:
|
169 |
await m.reply_text("Sorry you can't do it")
|
170 |
-
|
|
|
171 |
|
172 |
@Gojo.on_message(command("rmsupport"))
|
173 |
async def rm_support(c: Gojo, m: Message):
|
@@ -177,9 +170,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
177 |
await m.reply_text("Stay in you limit")
|
178 |
return
|
179 |
split = m.command
|
180 |
-
reply_to
|
181 |
-
|
182 |
-
if reply_to:
|
183 |
try:
|
184 |
curr = reply_to.from_user.id
|
185 |
except Exception:
|
@@ -190,7 +181,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
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
|
@@ -198,7 +189,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
198 |
await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
|
199 |
return
|
200 |
to_user = support.get_support_type(curr)
|
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)
|
@@ -209,6 +200,7 @@ async def rm_support(c: Gojo, m: Message):
|
|
209 |
await m.reply_text("Sorry you can't do that...")
|
210 |
return
|
211 |
|
|
|
212 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
213 |
async def ping(_, m: Message):
|
214 |
start = time()
|
@@ -217,18 +209,20 @@ async def ping(_, m: Message):
|
|
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:
|
@@ -236,7 +230,7 @@ async def check_module_info(_, m: Message):
|
|
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"]
|
@@ -262,7 +256,6 @@ Here are the info about the module **{name}**
|
|
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):
|
@@ -292,12 +285,8 @@ async def neofetch_stats(_, m: Message):
|
|
292 |
stderr=subprocess.PIPE,
|
293 |
)
|
294 |
stdout, stderr = await process.communicate()
|
295 |
-
e = stderr.decode()
|
296 |
-
|
297 |
-
e = "No Error"
|
298 |
-
OUTPUT = stdout.decode()
|
299 |
-
if not OUTPUT:
|
300 |
-
OUTPUT = "No Output"
|
301 |
|
302 |
try:
|
303 |
await m.reply_text(OUTPUT, quote=True)
|
@@ -308,6 +297,7 @@ async def neofetch_stats(_, m: Message):
|
|
308 |
await m.delete()
|
309 |
return
|
310 |
|
|
|
311 |
HARMFUL = [
|
312 |
"base64",
|
313 |
"bash",
|
@@ -325,7 +315,7 @@ HARMFUL = [
|
|
325 |
"SSH_CLIENT",
|
326 |
"SSH_CONNECTION"
|
327 |
"SSH"
|
328 |
-
|
329 |
]
|
330 |
|
331 |
|
@@ -345,17 +335,15 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
345 |
await c.send_message(
|
346 |
MESSAGE_DUMP,
|
347 |
f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
|
348 |
-
|
349 |
return
|
350 |
-
if m.reply_to_message and m.reply_to_message.document
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
if m.reply_to_message
|
357 |
-
reply_to_id = m.reply_to_message.id
|
358 |
-
|
359 |
old_stderr = sys.stderr
|
360 |
old_stdout = sys.stdout
|
361 |
redirected_output = sys.stdout = StringIO()
|
@@ -385,8 +373,8 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
385 |
for i in evaluation.split(None):
|
386 |
ev = i.strip()
|
387 |
if (
|
388 |
-
|
389 |
-
|
390 |
) and m.from_user.id != OWNER_ID:
|
391 |
evaluation = "Bhaag ja bsdk"
|
392 |
await c.send_message(
|
@@ -398,27 +386,25 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
398 |
return
|
399 |
|
400 |
for j in HARMFUL:
|
401 |
-
if j in evaluation.split() or j in cmd:
|
402 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
403 |
evaluation = "Bhaag ja bsdk"
|
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:
|
413 |
-
if m.from_user.id != OWNER_ID:
|
414 |
-
evaluation = "Bhaag ja bsdk"
|
415 |
-
await c.send_message(
|
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"
|
@@ -443,8 +429,6 @@ async def aexec(code, c, m):
|
|
443 |
return await locals()["__aexec"](c, m)
|
444 |
|
445 |
|
446 |
-
|
447 |
-
|
448 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
449 |
async def execution(c: Gojo, m: Message):
|
450 |
protect = BOT_TOKEN.split(":")
|
@@ -456,55 +440,36 @@ async def execution(c: Gojo, m: Message):
|
|
456 |
sm = await m.reply_text("`Processing...`\n")
|
457 |
cmd = m.text.split(maxsplit=1)[1]
|
458 |
|
459 |
-
reply_to_id = m.id
|
460 |
-
if m.reply_to_message:
|
461 |
-
reply_to_id = m.reply_to_message.id
|
462 |
-
|
463 |
process = await create_subprocess_shell(
|
464 |
cmd,
|
465 |
stdout=subprocess.PIPE,
|
466 |
stderr=subprocess.PIPE,
|
467 |
)
|
468 |
stdout, stderr = await process.communicate()
|
469 |
-
e = stderr.decode().strip()
|
470 |
-
|
471 |
-
e = "No Error"
|
472 |
-
o = stdout.decode().strip()
|
473 |
-
if not o:
|
474 |
-
o = "No Output"
|
475 |
out = o
|
476 |
xxx = o.split()
|
477 |
for OwO in xxx:
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
for x in xxx:
|
482 |
xx = x.split("=")
|
483 |
-
if xx and xx[0] in HARMFUL:
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
)
|
490 |
-
else:
|
491 |
-
pass
|
492 |
-
else:
|
493 |
-
pass
|
494 |
for x in HARMFUL:
|
495 |
-
if x in out:
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
)
|
502 |
-
else:
|
503 |
-
pass
|
504 |
-
else:
|
505 |
-
pass
|
506 |
-
|
507 |
-
|
508 |
OUTPUT = ""
|
509 |
OUTPUT += f"<b>QUERY:</b>\n<u>Command:</u>\n<code>{cmd}</code> \n"
|
510 |
OUTPUT += f"<u>PID</u>: <code>{process.pid}</code>\n\n"
|
@@ -525,38 +490,41 @@ async def execution(c: Gojo, m: Message):
|
|
525 |
await sm.delete()
|
526 |
return
|
527 |
|
528 |
-
|
|
|
529 |
runtime = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
|
530 |
LOGGER.info("Uploading logs before stopping...!\n")
|
531 |
-
|
532 |
await c.send_document(
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
if MESSAGE_DUMP:
|
540 |
# LOG_CHANNEL is not necessary
|
541 |
await c.send_document(
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
MongoDB.close()
|
547 |
LOGGER.info(
|
548 |
-
|
549 |
Logs have been uploaded to the MESSAGE_DUMP Group!
|
550 |
Runtime: {runtime}s\n
|
551 |
""",
|
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
|
559 |
-
await m.reply_text(
|
|
|
560 |
if cmds[0] == "update":
|
561 |
try:
|
562 |
out = subp.check_output(["git", "pull"]).decode("UTF-8")
|
@@ -566,7 +534,7 @@ async def restart_the_bot(c:Gojo,m:Message):
|
|
566 |
except Exception as e:
|
567 |
return await m.reply_text(str(e))
|
568 |
m = await m.reply_text("**Updated with main branch, restarting now.**")
|
569 |
-
await stop_and_send_logger(c,True)
|
570 |
if cmds[0] == "restart":
|
571 |
await stop_and_send_logger(c)
|
572 |
execvp(executable, [executable, "-m", "Powers"])
|
@@ -576,6 +544,7 @@ async def restart_the_bot(c:Gojo,m:Message):
|
|
576 |
LOGGER.error(format_exc())
|
577 |
return
|
578 |
|
|
|
579 |
@Gojo.on_message(command("chatlist", dev_cmd=True))
|
580 |
async def chats(c: Gojo, m: Message):
|
581 |
exmsg = await m.reply_text(text="Exporting Charlist...")
|
@@ -685,14 +654,15 @@ async def chat_broadcast(c: Gojo, m: Message):
|
|
685 |
|
686 |
return
|
687 |
|
688 |
-
|
|
|
689 |
async def forward_type_broadcast(c: Gojo, m: Message):
|
690 |
repl = m.reply_to_message
|
691 |
if not repl:
|
692 |
await m.reply_text("Please reply to message to broadcast it")
|
693 |
return
|
694 |
split = m.command
|
695 |
-
|
696 |
chat = Chats.list_chats_by_id()
|
697 |
user = [i["_id"] for i in Users.list_users()]
|
698 |
alll = chat + user
|
@@ -714,7 +684,7 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
714 |
peers = user
|
715 |
else:
|
716 |
peers = alll
|
717 |
-
|
718 |
xx = await m.reply_text("Broadcasting...")
|
719 |
|
720 |
failed = 0
|
@@ -725,8 +695,7 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
725 |
await sleep(0.1)
|
726 |
except Exception:
|
727 |
failed += 1
|
728 |
-
|
729 |
-
txt = f"Broadcasted message to {total-failed} peers out of {total}\nFailed to broadcast message to {failed} peers"
|
730 |
if not failed:
|
731 |
txt = f"Broadcasted message to {total} peers"
|
732 |
await m.reply_text(txt)
|
@@ -737,10 +706,8 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
737 |
return
|
738 |
|
739 |
|
740 |
-
|
741 |
__PLUGIN__ = "devs"
|
742 |
|
743 |
-
|
744 |
__HELP__ = """
|
745 |
**DEV and SUDOERS commands**
|
746 |
|
|
|
8 |
from time import gmtime, strftime, time
|
9 |
from traceback import format_exc
|
10 |
|
|
|
11 |
from pyrogram.errors import (ChannelInvalid, ChannelPrivate, ChatAdminRequired,
|
12 |
EntityBoundsInvalid, FloodWait, MessageTooLong,
|
13 |
PeerIdInvalid, RPCError)
|
|
|
30 |
|
31 |
|
32 |
def can_change_type(curr, to_user):
|
33 |
+
if curr == "dev" and to_user in ["whitelist", "sudo"]:
|
34 |
return True
|
35 |
elif curr == "sudo" and to_user == "whitelist":
|
36 |
return True
|
37 |
else:
|
38 |
return False
|
39 |
|
40 |
+
|
41 |
@Gojo.on_message(command(["addsupport"]))
|
42 |
+
async def add_support(c: Gojo, m: Message):
|
43 |
support = SUPPORTS()
|
44 |
curr_user = support.get_support_type(m.from_user.id)
|
45 |
if not curr_user:
|
46 |
await m.reply_text("Stay in you limit")
|
47 |
return
|
48 |
split = m.command
|
49 |
+
if reply_to := m.reply_to_message:
|
|
|
50 |
try:
|
51 |
userr = reply_to.from_user.id
|
52 |
except Exception:
|
|
|
58 |
except IndexError:
|
59 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
60 |
return
|
61 |
+
if to not in ["dev", "sudo", "whitelist"]:
|
62 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
63 |
return
|
64 |
if m.from_user.id == int(OWNER_ID):
|
65 |
if to == curr:
|
66 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
67 |
elif curr:
|
68 |
kb = IKM(
|
69 |
[
|
70 |
[
|
71 |
+
IKB("Yes", f"change_support_type:{to}"),
|
72 |
+
IKB("No", "change_support_type:no")
|
73 |
]
|
74 |
]
|
75 |
)
|
76 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
77 |
+
reply_markup=kb)
|
78 |
else:
|
79 |
+
support.insert_support_user(userr, to)
|
80 |
if to == "dev":
|
81 |
DEV_USERS.add(userr)
|
82 |
elif to == "sudo":
|
|
|
84 |
else:
|
85 |
WHITELIST_USERS.add(userr)
|
86 |
await m.reply_text(f"This user is now a {to} user")
|
87 |
+
return
|
88 |
+
if can_do := can_change_type(curr_user, to):
|
|
|
89 |
if to == curr:
|
90 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
91 |
elif curr:
|
92 |
kb = IKM(
|
93 |
[
|
94 |
[
|
95 |
+
IKB("Yes", f"change_support_type:{to}"),
|
96 |
+
IKB("No", "change_support_type:no")
|
97 |
]
|
98 |
]
|
99 |
)
|
100 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
101 |
+
reply_markup=kb)
|
102 |
else:
|
103 |
+
support.insert_support_user(userr, to)
|
104 |
await m.reply_text(f"This user is now a {to} user")
|
|
|
105 |
else:
|
106 |
await m.reply_text("Sorry you can't do it")
|
107 |
+
return
|
108 |
elif len(split) >= 3:
|
109 |
user = split[1]
|
110 |
try:
|
111 |
+
userr, _, _ = extract_user(user)
|
112 |
except Exception:
|
113 |
await m.reply_text("Tell the user to start me first")
|
114 |
return
|
|
|
116 |
try:
|
117 |
to = m.command[2].lower()
|
118 |
except IndexError:
|
119 |
+
await m.reply_text(
|
120 |
+
"**USAGE**\n/addsupport [reply to message | user id | username] [dev | sudo | whitelist]")
|
121 |
return
|
122 |
+
if to not in ["dev", "sudo", "whitelist"]:
|
123 |
await m.reply_text("**USAGE**\n/addsupport [reply to message | user id] [dev | sudo | whitelist]")
|
124 |
return
|
125 |
if m.from_user.id == int(OWNER_ID):
|
126 |
if to == curr:
|
127 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
128 |
elif curr:
|
129 |
kb = IKM(
|
130 |
[
|
131 |
[
|
132 |
+
IKB("Yes", f"change_support_type:{to}"),
|
133 |
+
IKB("No", "change_support_type:no")
|
134 |
]
|
135 |
]
|
136 |
)
|
137 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
138 |
+
reply_markup=kb)
|
139 |
else:
|
140 |
+
support.insert_support_user(userr, to)
|
141 |
await m.reply_text(f"This user is now a {to} user")
|
142 |
+
return
|
143 |
+
if can_do := can_change_type(curr_user, to):
|
|
|
144 |
if to == curr:
|
145 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
146 |
elif curr:
|
147 |
kb = IKM(
|
148 |
[
|
149 |
[
|
150 |
+
IKB("Yes", f"change_support_type:{to}"),
|
151 |
+
IKB("No", "change_support_type:no")
|
152 |
]
|
153 |
]
|
154 |
)
|
155 |
+
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",
|
156 |
+
reply_markup=kb)
|
157 |
else:
|
158 |
+
support.insert_support_user(userr, to)
|
159 |
await m.reply_text(f"This user is now a {to} user")
|
|
|
160 |
else:
|
161 |
await m.reply_text("Sorry you can't do it")
|
162 |
+
return
|
163 |
+
|
164 |
|
165 |
@Gojo.on_message(command("rmsupport"))
|
166 |
async def rm_support(c: Gojo, m: Message):
|
|
|
170 |
await m.reply_text("Stay in you limit")
|
171 |
return
|
172 |
split = m.command
|
173 |
+
if reply_to := m.reply_to_message:
|
|
|
|
|
174 |
try:
|
175 |
curr = reply_to.from_user.id
|
176 |
except Exception:
|
|
|
181 |
curr = int(split[1])
|
182 |
except Exception:
|
183 |
try:
|
184 |
+
curr, _, _ = extract_user(m)
|
185 |
except Exception:
|
186 |
await m.reply_text("Dunno who u r talking abt")
|
187 |
return
|
|
|
189 |
await m.reply_text("**USAGE**\n/rmsupport [reply to user | user id | username]")
|
190 |
return
|
191 |
to_user = support.get_support_type(curr)
|
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 |
DEV_USERS.discard(curr)
|
|
|
200 |
await m.reply_text("Sorry you can't do that...")
|
201 |
return
|
202 |
|
203 |
+
|
204 |
@Gojo.on_message(command("ping", sudo_cmd=True))
|
205 |
async def ping(_, m: Message):
|
206 |
start = time()
|
|
|
209 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
210 |
return
|
211 |
|
212 |
+
|
213 |
"""
|
214 |
|
215 |
['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']
|
216 |
|
217 |
"""
|
218 |
|
219 |
+
|
220 |
@Gojo.on_message(command(["minfo", "moduleinfo"], dev_cmd=True))
|
221 |
async def check_module_info(_, m: Message):
|
222 |
if len(m.command) != 2:
|
223 |
await m.reply_text("**USAGE**\n/minfo [module name]")
|
224 |
return
|
225 |
+
|
226 |
module = m.command[-1]
|
227 |
|
228 |
try:
|
|
|
230 |
except PackageNotFoundError:
|
231 |
await m.reply_text(f"No module found with name {module}")
|
232 |
return
|
233 |
+
|
234 |
name = minfo["Name"]
|
235 |
version = minfo["Version"]
|
236 |
summary = minfo["Summary"]
|
|
|
256 |
await m.reply_text(txt, disable_web_page_preview=True)
|
257 |
return
|
258 |
|
|
|
259 |
|
260 |
@Gojo.on_message(command("logs", dev_cmd=True))
|
261 |
async def send_log(c: Gojo, m: Message):
|
|
|
285 |
stderr=subprocess.PIPE,
|
286 |
)
|
287 |
stdout, stderr = await process.communicate()
|
288 |
+
e = stderr.decode() or "No Error"
|
289 |
+
OUTPUT = stdout.decode() or "No Output"
|
|
|
|
|
|
|
|
|
290 |
|
291 |
try:
|
292 |
await m.reply_text(OUTPUT, quote=True)
|
|
|
297 |
await m.delete()
|
298 |
return
|
299 |
|
300 |
+
|
301 |
HARMFUL = [
|
302 |
"base64",
|
303 |
"bash",
|
|
|
315 |
"SSH_CLIENT",
|
316 |
"SSH_CONNECTION"
|
317 |
"SSH"
|
318 |
+
|
319 |
]
|
320 |
|
321 |
|
|
|
335 |
await c.send_message(
|
336 |
MESSAGE_DUMP,
|
337 |
f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
|
338 |
+
)
|
339 |
return
|
340 |
+
if m.reply_to_message and m.reply_to_message.document and (m.reply_to_message.document.mime_type.split("/")[
|
341 |
+
1] == "x-python" or m.reply_to_message.document.file_name.endswith(
|
342 |
+
"py")):
|
343 |
+
await sm.delete()
|
344 |
+
await m.reply_text("Loading external plugin is prohibited")
|
345 |
+
return
|
346 |
+
reply_to_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
|
|
|
347 |
old_stderr = sys.stderr
|
348 |
old_stdout = sys.stdout
|
349 |
redirected_output = sys.stdout = StringIO()
|
|
|
373 |
for i in evaluation.split(None):
|
374 |
ev = i.strip()
|
375 |
if (
|
376 |
+
(ev.startswith(initial) or ev.endswith(end))
|
377 |
+
or (BOT_TOKEN in ev)
|
378 |
) and m.from_user.id != OWNER_ID:
|
379 |
evaluation = "Bhaag ja bsdk"
|
380 |
await c.send_message(
|
|
|
386 |
return
|
387 |
|
388 |
for j in HARMFUL:
|
389 |
+
if (j in evaluation.split() or j in cmd) and m.from_user.id != OWNER_ID:
|
390 |
+
evaluation = "Bhaag ja bsdk"
|
391 |
+
await c.send_message(
|
392 |
+
MESSAGE_DUMP,
|
393 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}")
|
394 |
+
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
395 |
+
await sm.edit(final_output)
|
396 |
+
return
|
397 |
+
for i in evaluation.split():
|
398 |
+
for j in i.split("="):
|
399 |
+
if j and j[0] in HARMFUL and m.from_user.id != OWNER_ID:
|
400 |
evaluation = "Bhaag ja bsdk"
|
401 |
await c.send_message(
|
402 |
MESSAGE_DUMP,
|
403 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}"
|
404 |
+
)
|
405 |
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
406 |
await sm.edit(final_output)
|
407 |
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
408 |
|
409 |
try:
|
410 |
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
|
|
429 |
return await locals()["__aexec"](c, m)
|
430 |
|
431 |
|
|
|
|
|
432 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
433 |
async def execution(c: Gojo, m: Message):
|
434 |
protect = BOT_TOKEN.split(":")
|
|
|
440 |
sm = await m.reply_text("`Processing...`\n")
|
441 |
cmd = m.text.split(maxsplit=1)[1]
|
442 |
|
443 |
+
reply_to_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
|
|
|
|
|
444 |
process = await create_subprocess_shell(
|
445 |
cmd,
|
446 |
stdout=subprocess.PIPE,
|
447 |
stderr=subprocess.PIPE,
|
448 |
)
|
449 |
stdout, stderr = await process.communicate()
|
450 |
+
e = stderr.decode().strip() or "No Error"
|
451 |
+
o = stdout.decode().strip() or "No Output"
|
|
|
|
|
|
|
|
|
452 |
out = o
|
453 |
xxx = o.split()
|
454 |
for OwO in xxx:
|
455 |
+
if OwO.startswith(initial) or OwO.endswith(end):
|
456 |
+
out = "You can't access them"
|
457 |
+
break
|
458 |
for x in xxx:
|
459 |
xx = x.split("=")
|
460 |
+
if xx and xx[0] in HARMFUL and m.from_user.id != OWNER_ID:
|
461 |
+
out = "You can't access them"
|
462 |
+
await c.send_message(
|
463 |
+
MESSAGE_DUMP,
|
464 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}",
|
465 |
+
)
|
|
|
|
|
|
|
|
|
|
|
466 |
for x in HARMFUL:
|
467 |
+
if x in out and m.from_user.id != OWNER_ID:
|
468 |
+
out = "You can't access them"
|
469 |
+
await c.send_message(
|
470 |
+
MESSAGE_DUMP,
|
471 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}",
|
472 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
473 |
OUTPUT = ""
|
474 |
OUTPUT += f"<b>QUERY:</b>\n<u>Command:</u>\n<code>{cmd}</code> \n"
|
475 |
OUTPUT += f"<u>PID</u>: <code>{process.pid}</code>\n\n"
|
|
|
490 |
await sm.delete()
|
491 |
return
|
492 |
|
493 |
+
|
494 |
+
async def stop_and_send_logger(c: Gojo, is_update=False):
|
495 |
runtime = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
|
496 |
LOGGER.info("Uploading logs before stopping...!\n")
|
497 |
+
# Send Logs to MESSAGE_DUMP and LOG_CHANNEL
|
498 |
await c.send_document(
|
499 |
+
MESSAGE_DUMP,
|
500 |
+
document=LOGFILE,
|
501 |
+
caption=(
|
502 |
+
f"{'Updating and Restarting' if is_update else 'Restarting'} The Bot !\n\n" f"Uptime: {runtime}\n" f"<code>{LOG_DATETIME}</code>"
|
503 |
+
),
|
504 |
+
)
|
505 |
if MESSAGE_DUMP:
|
506 |
# LOG_CHANNEL is not necessary
|
507 |
await c.send_document(
|
508 |
+
MESSAGE_DUMP,
|
509 |
+
document=LOGFILE,
|
510 |
+
caption=f"Uptime: {runtime}",
|
511 |
+
)
|
512 |
MongoDB.close()
|
513 |
LOGGER.info(
|
514 |
+
f"""Bot Stopped.
|
515 |
Logs have been uploaded to the MESSAGE_DUMP Group!
|
516 |
Runtime: {runtime}s\n
|
517 |
""",
|
518 |
+
)
|
519 |
return
|
520 |
|
521 |
+
|
522 |
@Gojo.on_message(command(["restart", "update"], owner_cmd=True))
|
523 |
+
async def restart_the_bot(c: Gojo, m: Message):
|
524 |
try:
|
525 |
cmds = m.command
|
526 |
+
await m.reply_text(
|
527 |
+
f"Restarting{' and updating ' if cmds[0] == 'update' else ' '}the bot...\nType `/ping` after few minutes")
|
528 |
if cmds[0] == "update":
|
529 |
try:
|
530 |
out = subp.check_output(["git", "pull"]).decode("UTF-8")
|
|
|
534 |
except Exception as e:
|
535 |
return await m.reply_text(str(e))
|
536 |
m = await m.reply_text("**Updated with main branch, restarting now.**")
|
537 |
+
await stop_and_send_logger(c, True)
|
538 |
if cmds[0] == "restart":
|
539 |
await stop_and_send_logger(c)
|
540 |
execvp(executable, [executable, "-m", "Powers"])
|
|
|
544 |
LOGGER.error(format_exc())
|
545 |
return
|
546 |
|
547 |
+
|
548 |
@Gojo.on_message(command("chatlist", dev_cmd=True))
|
549 |
async def chats(c: Gojo, m: Message):
|
550 |
exmsg = await m.reply_text(text="Exporting Charlist...")
|
|
|
654 |
|
655 |
return
|
656 |
|
657 |
+
|
658 |
+
@Gojo.on_message(command(["forward", "fwd"], dev_cmd=True))
|
659 |
async def forward_type_broadcast(c: Gojo, m: Message):
|
660 |
repl = m.reply_to_message
|
661 |
if not repl:
|
662 |
await m.reply_text("Please reply to message to broadcast it")
|
663 |
return
|
664 |
split = m.command
|
665 |
+
|
666 |
chat = Chats.list_chats_by_id()
|
667 |
user = [i["_id"] for i in Users.list_users()]
|
668 |
alll = chat + user
|
|
|
684 |
peers = user
|
685 |
else:
|
686 |
peers = alll
|
687 |
+
|
688 |
xx = await m.reply_text("Broadcasting...")
|
689 |
|
690 |
failed = 0
|
|
|
695 |
await sleep(0.1)
|
696 |
except Exception:
|
697 |
failed += 1
|
698 |
+
txt = f"Broadcasted message to {total - failed} peers out of {total}\nFailed to broadcast message to {failed} peers"
|
|
|
699 |
if not failed:
|
700 |
txt = f"Broadcasted message to {total} peers"
|
701 |
await m.reply_text(txt)
|
|
|
706 |
return
|
707 |
|
708 |
|
|
|
709 |
__PLUGIN__ = "devs"
|
710 |
|
|
|
711 |
__HELP__ = """
|
712 |
**DEV and SUDOERS commands**
|
713 |
|
Powers/plugins/disable.py
CHANGED
@@ -5,7 +5,7 @@ from pyrogram.enums import ChatMemberStatus as CMS
|
|
5 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
6 |
InlineKeyboardMarkup, Message)
|
7 |
|
8 |
-
from Powers import HELP_COMMANDS
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.disable_db import Disabling
|
11 |
from Powers.utils.custom_filters import (admin_filter, can_change_filter,
|
@@ -41,10 +41,7 @@ async def set_dsbl_action(_, m: Message):
|
|
41 |
db = Disabling(m.chat.id)
|
42 |
|
43 |
status = db.get_action()
|
44 |
-
|
45 |
-
cur = False
|
46 |
-
else:
|
47 |
-
cur = True
|
48 |
args = m.text.split(" ", 1)
|
49 |
|
50 |
if len(args) >= 2:
|
@@ -80,8 +77,9 @@ async def disabling(_, m: Message):
|
|
80 |
for j in [HELP_COMMANDS[i]["disablable"] for i in list(HELP_COMMANDS.keys())]
|
81 |
for k in j
|
82 |
)
|
83 |
-
tes = "List of commnds that can be disabled:\n"
|
84 |
-
|
|
|
85 |
return await m.reply_text(tes)
|
86 |
|
87 |
|
@@ -92,8 +90,9 @@ async def disabled(_, m: Message):
|
|
92 |
if not disable_list:
|
93 |
await m.reply_text("No disabled items!")
|
94 |
return
|
95 |
-
tex = "Disabled commands:\n"
|
96 |
-
|
|
|
97 |
return await m.reply_text(tex)
|
98 |
|
99 |
|
@@ -147,7 +146,6 @@ __PLUGIN__ = "disable able"
|
|
147 |
|
148 |
__alt_name__ = ["disable commands", "disable"]
|
149 |
|
150 |
-
|
151 |
__HELP__ = """
|
152 |
**Disable commands**
|
153 |
|
@@ -160,4 +158,4 @@ __HELP__ = """
|
|
160 |
|
161 |
**Owner command:**
|
162 |
• /enableall : Enable all the disabled commands.
|
163 |
-
"""
|
|
|
5 |
from pyrogram.types import (CallbackQuery, InlineKeyboardButton,
|
6 |
InlineKeyboardMarkup, Message)
|
7 |
|
8 |
+
from Powers import HELP_COMMANDS
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.disable_db import Disabling
|
11 |
from Powers.utils.custom_filters import (admin_filter, can_change_filter,
|
|
|
41 |
db = Disabling(m.chat.id)
|
42 |
|
43 |
status = db.get_action()
|
44 |
+
cur = status != "none"
|
|
|
|
|
|
|
45 |
args = m.text.split(" ", 1)
|
46 |
|
47 |
if len(args) >= 2:
|
|
|
77 |
for j in [HELP_COMMANDS[i]["disablable"] for i in list(HELP_COMMANDS.keys())]
|
78 |
for k in j
|
79 |
)
|
80 |
+
tes = "List of commnds that can be disabled:\n" + "\n".join(
|
81 |
+
f" • <code>{escape(i)}</code>" for i in disable_cmd_keys
|
82 |
+
)
|
83 |
return await m.reply_text(tes)
|
84 |
|
85 |
|
|
|
90 |
if not disable_list:
|
91 |
await m.reply_text("No disabled items!")
|
92 |
return
|
93 |
+
tex = "Disabled commands:\n" + "\n".join(
|
94 |
+
f" • <code>{escape(i)}</code>" for i in disable_list
|
95 |
+
)
|
96 |
return await m.reply_text(tex)
|
97 |
|
98 |
|
|
|
146 |
|
147 |
__alt_name__ = ["disable commands", "disable"]
|
148 |
|
|
|
149 |
__HELP__ = """
|
150 |
**Disable commands**
|
151 |
|
|
|
158 |
|
159 |
**Owner command:**
|
160 |
• /enableall : Enable all the disabled commands.
|
161 |
+
"""
|
Powers/plugins/filters.py
CHANGED
@@ -6,7 +6,7 @@ from pyrogram import filters
|
|
6 |
from pyrogram.enums import ChatMemberStatus as CMS
|
7 |
from pyrogram.enums import ParseMode as PM
|
8 |
from pyrogram.errors import RPCError
|
9 |
-
from pyrogram.types import CallbackQuery,
|
10 |
|
11 |
from Powers.bot_class import LOGGER, Gojo
|
12 |
from Powers.database.filters_db import Filters
|
@@ -44,7 +44,6 @@ async def view_filters(_, m: Message):
|
|
44 |
|
45 |
@Gojo.on_message(command(["filter", "addfilter"]) & admin_filter & ~filters.bot)
|
46 |
async def add_filter(_, m: Message):
|
47 |
-
|
48 |
args = m.text.split(" ", 1)
|
49 |
all_filters = db.get_all_filters(m.chat.id)
|
50 |
actual_filters = {j for i in all_filters for j in i.split("|")}
|
@@ -95,8 +94,7 @@ async def add_filter(_, m: Message):
|
|
95 |
"Please provide data for this filter reply with!",
|
96 |
)
|
97 |
|
98 |
-
add
|
99 |
-
if add:
|
100 |
await m.reply_text(
|
101 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
102 |
)
|
@@ -137,17 +135,16 @@ async def stop_filter(_, m: Message):
|
|
137 |
& owner_filter,
|
138 |
)
|
139 |
async def rm_allfilters(_, m: Message):
|
140 |
-
all_bls
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
return await m.reply_text("No filters to stop in this chat.")
|
143 |
|
144 |
-
return await m.reply_text(
|
145 |
-
"Are you sure you want to clear all filters?",
|
146 |
-
reply_markup=ikb(
|
147 |
-
[[("⚠️ Confirm", "rm_allfilters"), ("❌ Cancel", "close_admin")]],
|
148 |
-
),
|
149 |
-
)
|
150 |
-
|
151 |
|
152 |
@Gojo.on_callback_query(filters.regex("^rm_allfilters$"))
|
153 |
async def rm_allfilters_callback(_, q: CallbackQuery):
|
@@ -239,10 +236,10 @@ async def send_filter_reply(c: Gojo, m: Message, trigger: str):
|
|
239 |
return
|
240 |
|
241 |
elif msgtype in (
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
):
|
247 |
await (await send_cmd(c, msgtype))(
|
248 |
m.chat.id,
|
@@ -268,7 +265,6 @@ async def send_filter_reply(c: Gojo, m: Message, trigger: str):
|
|
268 |
|
269 |
@Gojo.on_message(filters.text & filters.group & ~filters.bot, group=69)
|
270 |
async def filters_watcher(c: Gojo, m: Message):
|
271 |
-
|
272 |
chat_filters = db.get_all_filters(m.chat.id)
|
273 |
actual_filters = {j for i in chat_filters for j in i.split("|")}
|
274 |
|
|
|
6 |
from pyrogram.enums import ChatMemberStatus as CMS
|
7 |
from pyrogram.enums import ParseMode as PM
|
8 |
from pyrogram.errors import RPCError
|
9 |
+
from pyrogram.types import CallbackQuery, Message
|
10 |
|
11 |
from Powers.bot_class import LOGGER, Gojo
|
12 |
from Powers.database.filters_db import Filters
|
|
|
44 |
|
45 |
@Gojo.on_message(command(["filter", "addfilter"]) & admin_filter & ~filters.bot)
|
46 |
async def add_filter(_, m: Message):
|
|
|
47 |
args = m.text.split(" ", 1)
|
48 |
all_filters = db.get_all_filters(m.chat.id)
|
49 |
actual_filters = {j for i in all_filters for j in i.split("|")}
|
|
|
94 |
"Please provide data for this filter reply with!",
|
95 |
)
|
96 |
|
97 |
+
if add := db.save_filter(m.chat.id, keyword, teks, msgtype, file_id):
|
|
|
98 |
await m.reply_text(
|
99 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
100 |
)
|
|
|
135 |
& owner_filter,
|
136 |
)
|
137 |
async def rm_allfilters(_, m: Message):
|
138 |
+
if all_bls := db.get_all_filters(m.chat.id):
|
139 |
+
return await m.reply_text(
|
140 |
+
"Are you sure you want to clear all filters?",
|
141 |
+
reply_markup=ikb(
|
142 |
+
[[("⚠️ Confirm", "rm_allfilters"), ("❌ Cancel", "close_admin")]],
|
143 |
+
),
|
144 |
+
)
|
145 |
+
else:
|
146 |
return await m.reply_text("No filters to stop in this chat.")
|
147 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
@Gojo.on_callback_query(filters.regex("^rm_allfilters$"))
|
150 |
async def rm_allfilters_callback(_, q: CallbackQuery):
|
|
|
236 |
return
|
237 |
|
238 |
elif msgtype in (
|
239 |
+
Types.STICKER,
|
240 |
+
Types.VIDEO_NOTE,
|
241 |
+
Types.CONTACT,
|
242 |
+
Types.ANIMATED_STICKER,
|
243 |
):
|
244 |
await (await send_cmd(c, msgtype))(
|
245 |
m.chat.id,
|
|
|
265 |
|
266 |
@Gojo.on_message(filters.text & filters.group & ~filters.bot, group=69)
|
267 |
async def filters_watcher(c: Gojo, m: Message):
|
|
|
268 |
chat_filters = db.get_all_filters(m.chat.id)
|
269 |
actual_filters = {j for i in chat_filters for j in i.split("|")}
|
270 |
|
Powers/plugins/flood.py
CHANGED
@@ -20,38 +20,25 @@ from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
|
20 |
on_key = ["on", "start", "disable"]
|
21 |
off_key = ["off", "end", "enable", "stop"]
|
22 |
|
|
|
23 |
async def get_what_temp(what):
|
24 |
-
|
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 |
-
|
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 |
-
|
|
|
55 |
[
|
56 |
[
|
57 |
InlineKeyboardButton(
|
@@ -147,20 +134,19 @@ limit_kb = InlineKeyboardMarkup(
|
|
147 |
]
|
148 |
)
|
149 |
|
150 |
-
|
|
|
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
|
156 |
-
if not bot.privileges.can_restrict_members:
|
157 |
return await m.reply_text("Give me permission to restict member first")
|
158 |
if m.chat.type == CT.PRIVATE:
|
159 |
await m.reply_text("Use this command in group")
|
160 |
return
|
161 |
c_id = m.chat.id
|
162 |
-
is_flood
|
163 |
-
if is_flood:
|
164 |
saction = is_flood[2]
|
165 |
await m.reply_text(
|
166 |
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
@@ -170,28 +156,30 @@ async def flood_action(c: Gojo, m: Message):
|
|
170 |
await m.reply_text("Switch on the flood protection first.")
|
171 |
return
|
172 |
|
|
|
173 |
@Gojo.on_message(command(['isflood', 'flood']) & ~filters.bot)
|
174 |
async def flood_on_off(c: Gojo, m: Message):
|
175 |
-
if m.chat.type == CT.PRIVATE:
|
176 |
-
|
177 |
Flood = Floods()
|
178 |
c_id = m.chat.id
|
179 |
is_flood = Flood.is_chat(c_id)
|
180 |
c_id = m.chat.id
|
181 |
if is_flood:
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
|
|
186 |
return await m.reply_text("Flood protection is off for this chat.")
|
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
|
194 |
-
if not bot.privileges.can_restrict_members:
|
195 |
return await m.reply_text("Give me permission to restict member first")
|
196 |
if m.chat.type == CT.PRIVATE:
|
197 |
return await m.reply_text("This command is ment to be used in groups.")
|
@@ -201,22 +189,24 @@ async def flood_set(c: Gojo, m: Message):
|
|
201 |
|
202 |
if len(split) == 1:
|
203 |
c_id = m.chat.id
|
204 |
-
if is_flood:
|
205 |
saction = is_flood[2]
|
206 |
slimit = is_flood[0]
|
207 |
-
swithin = is_flood[1]
|
208 |
-
return await m.reply_text(
|
|
|
209 |
return await m.reply_text("Flood protection is off of this chat.")
|
210 |
-
|
211 |
if len(split) == 2:
|
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(
|
|
|
220 |
return
|
221 |
if split[1].lower() in off_key:
|
222 |
x = Flood.rm_flood(c_id)
|
@@ -231,6 +221,7 @@ async def flood_set(c: Gojo, m: Message):
|
|
231 |
await m.reply_text("**Usage:**\n `/setflood on/off`")
|
232 |
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)
|
@@ -241,8 +232,7 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
241 |
return
|
242 |
c_id = q.message.chat.id
|
243 |
Flood = Floods()
|
244 |
-
is_flood
|
245 |
-
if is_flood:
|
246 |
saction = is_flood[2]
|
247 |
slimit = is_flood[0]
|
248 |
swithin = is_flood[1]
|
@@ -251,7 +241,7 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
251 |
if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
252 |
if data in ["f_mute", "f_ban", "f_kick", "f_skip"]:
|
253 |
change = data.split("_")[1]
|
254 |
-
if
|
255 |
Flood.save_flood(c_id, slimit, swithin, change)
|
256 |
await q.answer("Updated action", show_alert=True)
|
257 |
await q.edit_message_text(
|
@@ -279,7 +269,7 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
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=
|
283 |
)
|
284 |
return
|
285 |
kb = await get_what_temp(to_do)
|
@@ -303,21 +293,16 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
303 |
reply_markup=within_kb
|
304 |
)
|
305 |
return
|
306 |
-
if
|
307 |
Flood.save_flood(c_id, change, swithin, saction)
|
308 |
await q.answer("Updated limit", show_alert=True)
|
309 |
-
await q.edit_message_text(
|
310 |
-
f"Set the time with the number of message recived treated as flood\n **CUURENT TIME** {swithin}",
|
311 |
-
reply_markup=within_kb
|
312 |
-
)
|
313 |
-
return
|
314 |
else:
|
315 |
await q.answer("Updated action", show_alert=True)
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
elif data in ["f_f_5", "f_f_10", "f_f_15", "f_f_skip"]:
|
322 |
data = data.split("_")[-1]
|
323 |
try:
|
@@ -329,7 +314,7 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
329 |
)
|
330 |
await q.answer("skip")
|
331 |
return
|
332 |
-
if
|
333 |
Flood.save_flood(c_id, slimit, change, saction)
|
334 |
await q.answer("Updated", show_alert=True)
|
335 |
await q.edit_message_text(
|
@@ -347,9 +332,10 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
347 |
await q.answer(
|
348 |
"You don't have enough permission to do this!\nStay in your limits!",
|
349 |
show_alert=True,
|
350 |
-
|
351 |
return
|
352 |
|
|
|
353 |
@Gojo.on_callback_query(filters.regex("^un_"))
|
354 |
async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
355 |
data = q.data.split("_")
|
@@ -367,7 +353,7 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
367 |
)
|
368 |
return
|
369 |
whoo = await c.get_chat(user_id)
|
370 |
-
doneto = whoo.first_name
|
371 |
try:
|
372 |
await q.message.chat.unban_member(user_id)
|
373 |
except RPCError as e:
|
@@ -394,61 +380,63 @@ async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
|
394 |
await q.message.edit_text(f"{q.from_user.mention} unmuted {whoo.mention}!")
|
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])
|
412 |
-
|
413 |
if not len(dic):
|
414 |
-
z = {c_id
|
415 |
dic.update(z)
|
416 |
-
|
417 |
try:
|
418 |
-
|
419 |
except KeyError:
|
420 |
-
|
421 |
-
|
422 |
|
423 |
try:
|
424 |
-
|
425 |
except KeyError:
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
sec = round(time.time())
|
430 |
-
|
431 |
try:
|
432 |
dic[c_id][u_id][0].append(sec)
|
433 |
dic[c_id][u_id][1].append("x")
|
434 |
except KeyError:
|
435 |
-
dic[c_id].update({u_id
|
436 |
-
|
437 |
x = int(dic[c_id][u_id][0][0])
|
438 |
y = int(dic[c_id][u_id][0][-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 |
-
|
451 |
-
|
452 |
await m.chat.ban_member(u_id, until_date=for_how_much)
|
453 |
keyboard = InlineKeyboardMarkup(
|
454 |
[
|
@@ -466,30 +454,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
466 |
caption=txt,
|
467 |
reply_markup=keyboard,
|
468 |
)
|
469 |
-
|
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(),
|
@@ -511,27 +476,28 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
511 |
caption=txt,
|
512 |
reply_markup=keyboard,
|
513 |
)
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
|
|
527 |
|
528 |
<b>Error:</b> <code>{ef}</code>"""
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
else:
|
536 |
action = action[0]
|
537 |
if action == "ban":
|
@@ -560,7 +526,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
560 |
except UserAdminInvalid:
|
561 |
await m.reply_text(
|
562 |
"I can't protect this chat from this user",
|
563 |
-
|
564 |
dic[c_id][u_id][1].clear()
|
565 |
dic[c_id][u_id][0].clear()
|
566 |
return
|
@@ -569,16 +535,17 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
569 |
text=f"""Some error occured, report it using `/bug`
|
570 |
|
571 |
<b>Error:</b> <code>{ef}</code>"""
|
572 |
-
|
573 |
LOGGER.error(ef)
|
574 |
LOGGER.error(format_exc())
|
575 |
dic[c_id][u_id][1].clear()
|
576 |
dic[c_id][u_id][0].clear()
|
577 |
return
|
578 |
-
|
579 |
elif action == "kick":
|
580 |
try:
|
581 |
-
d = datetime.now()+timedelta(
|
|
|
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"
|
@@ -656,23 +623,23 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
656 |
dic[c_id][u_id][1].clear()
|
657 |
dic[c_id][u_id][0].clear()
|
658 |
return
|
659 |
-
elif y-x > within:
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
else:
|
667 |
return
|
668 |
|
669 |
|
670 |
__PLUGIN__ = "flood"
|
671 |
__alt_name__ = [
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
]
|
677 |
__HELP__ = """
|
678 |
**Anti Flood**
|
@@ -686,4 +653,3 @@ __HELP__ = """
|
|
686 |
**Example:**
|
687 |
`/setflood on`
|
688 |
"""
|
689 |
-
|
|
|
20 |
on_key = ["on", "start", "disable"]
|
21 |
off_key = ["off", "end", "enable", "stop"]
|
22 |
|
23 |
+
|
24 |
async def get_what_temp(what):
|
25 |
+
return InlineKeyboardMarkup(
|
26 |
[
|
27 |
[
|
28 |
+
InlineKeyboardButton("5 minutes", f"f_temp_{what}_5min"),
|
|
|
|
|
|
|
29 |
InlineKeyboardButton(
|
30 |
"10 minute",
|
31 |
f"f_temp_{what}_10min",
|
32 |
),
|
33 |
+
InlineKeyboardButton("30 minute", f"f_temp_{what}_30min"),
|
34 |
+
InlineKeyboardButton("1 hour", f"f_temp_{what}_60min"),
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
],
|
36 |
+
[InlineKeyboardButton("« Back", "f_temp_back")],
|
|
|
|
|
|
|
|
|
|
|
37 |
]
|
38 |
)
|
|
|
39 |
|
40 |
+
|
41 |
+
close_kb = InlineKeyboardMarkup(
|
42 |
[
|
43 |
[
|
44 |
InlineKeyboardButton(
|
|
|
134 |
]
|
135 |
)
|
136 |
|
137 |
+
|
138 |
+
@Gojo.on_message(command(['floodaction', 'actionflood']) & admin_filter)
|
139 |
async def flood_action(c: Gojo, m: Message):
|
140 |
Flood = Floods()
|
141 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
142 |
status = bot.status
|
143 |
+
if status not in [CMS.OWNER, CMS.ADMINISTRATOR] and not bot.privileges.can_restrict_members:
|
|
|
144 |
return await m.reply_text("Give me permission to restict member first")
|
145 |
if m.chat.type == CT.PRIVATE:
|
146 |
await m.reply_text("Use this command in group")
|
147 |
return
|
148 |
c_id = m.chat.id
|
149 |
+
if is_flood := Flood.is_chat(c_id):
|
|
|
150 |
saction = is_flood[2]
|
151 |
await m.reply_text(
|
152 |
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
|
|
156 |
await m.reply_text("Switch on the flood protection first.")
|
157 |
return
|
158 |
|
159 |
+
|
160 |
@Gojo.on_message(command(['isflood', 'flood']) & ~filters.bot)
|
161 |
async def flood_on_off(c: Gojo, m: Message):
|
162 |
+
if m.chat.type == CT.PRIVATE:
|
163 |
+
return await m.reply_text("This command is ment to be used in groups.")
|
164 |
Flood = Floods()
|
165 |
c_id = m.chat.id
|
166 |
is_flood = Flood.is_chat(c_id)
|
167 |
c_id = m.chat.id
|
168 |
if is_flood:
|
169 |
+
saction = is_flood[2]
|
170 |
+
slimit = is_flood[0]
|
171 |
+
swithin = is_flood[1]
|
172 |
+
return await m.reply_text(
|
173 |
+
f"Flood is on for this chat\n**Action**: {saction}\n**Messages**: {slimit} within {swithin} sec")
|
174 |
return await m.reply_text("Flood protection is off for this chat.")
|
175 |
|
176 |
+
|
177 |
@Gojo.on_message(command(['setflood']) & ~filters.bot & admin_filter)
|
178 |
async def flood_set(c: Gojo, m: Message):
|
179 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
180 |
Flood = Floods()
|
181 |
status = bot.status
|
182 |
+
if status not in [CMS.OWNER, CMS.ADMINISTRATOR] and not bot.privileges.can_restrict_members:
|
|
|
183 |
return await m.reply_text("Give me permission to restict member first")
|
184 |
if m.chat.type == CT.PRIVATE:
|
185 |
return await m.reply_text("This command is ment to be used in groups.")
|
|
|
189 |
|
190 |
if len(split) == 1:
|
191 |
c_id = m.chat.id
|
192 |
+
if is_flood:
|
193 |
saction = is_flood[2]
|
194 |
slimit = is_flood[0]
|
195 |
+
swithin = is_flood[1]
|
196 |
+
return await m.reply_text(
|
197 |
+
f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
198 |
return await m.reply_text("Flood protection is off of this chat.")
|
199 |
+
|
200 |
if len(split) == 2:
|
201 |
c_id = m.chat.id
|
202 |
if split[1].lower() in on_key:
|
203 |
+
if is_flood:
|
204 |
saction = is_flood[2]
|
205 |
slimit = is_flood[0]
|
206 |
swithin = is_flood[1]
|
207 |
|
208 |
+
await m.reply_text(
|
209 |
+
f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
210 |
return
|
211 |
if split[1].lower() in off_key:
|
212 |
x = Flood.rm_flood(c_id)
|
|
|
221 |
await m.reply_text("**Usage:**\n `/setflood on/off`")
|
222 |
return
|
223 |
|
224 |
+
|
225 |
@Gojo.on_callback_query(filters.regex("^f_"))
|
226 |
async def callbacks(c: Gojo, q: CallbackQuery):
|
227 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
|
|
232 |
return
|
233 |
c_id = q.message.chat.id
|
234 |
Flood = Floods()
|
235 |
+
if is_flood := Flood.is_chat(c_id):
|
|
|
236 |
saction = is_flood[2]
|
237 |
slimit = is_flood[0]
|
238 |
swithin = is_flood[1]
|
|
|
241 |
if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
242 |
if data in ["f_mute", "f_ban", "f_kick", "f_skip"]:
|
243 |
change = data.split("_")[1]
|
244 |
+
if change != saction:
|
245 |
Flood.save_flood(c_id, slimit, swithin, change)
|
246 |
await q.answer("Updated action", show_alert=True)
|
247 |
await q.edit_message_text(
|
|
|
269 |
kb = action_kb
|
270 |
await q.edit_message_text(
|
271 |
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
272 |
+
reply_markup=kb,
|
273 |
)
|
274 |
return
|
275 |
kb = await get_what_temp(to_do)
|
|
|
293 |
reply_markup=within_kb
|
294 |
)
|
295 |
return
|
296 |
+
if change != slimit:
|
297 |
Flood.save_flood(c_id, change, swithin, saction)
|
298 |
await q.answer("Updated limit", show_alert=True)
|
|
|
|
|
|
|
|
|
|
|
299 |
else:
|
300 |
await q.answer("Updated action", show_alert=True)
|
301 |
+
await q.edit_message_text(
|
302 |
+
f"Set the time with the number of message recived treated as flood\n **CUURENT TIME** {swithin}",
|
303 |
+
reply_markup=within_kb
|
304 |
+
)
|
305 |
+
return
|
306 |
elif data in ["f_f_5", "f_f_10", "f_f_15", "f_f_skip"]:
|
307 |
data = data.split("_")[-1]
|
308 |
try:
|
|
|
314 |
)
|
315 |
await q.answer("skip")
|
316 |
return
|
317 |
+
if change != swithin:
|
318 |
Flood.save_flood(c_id, slimit, change, saction)
|
319 |
await q.answer("Updated", show_alert=True)
|
320 |
await q.edit_message_text(
|
|
|
332 |
await q.answer(
|
333 |
"You don't have enough permission to do this!\nStay in your limits!",
|
334 |
show_alert=True,
|
335 |
+
)
|
336 |
return
|
337 |
|
338 |
+
|
339 |
@Gojo.on_callback_query(filters.regex("^un_"))
|
340 |
async def reverse_callbacks(c: Gojo, q: CallbackQuery):
|
341 |
data = q.data.split("_")
|
|
|
353 |
)
|
354 |
return
|
355 |
whoo = await c.get_chat(user_id)
|
356 |
+
doneto = whoo.first_name or whoo.title
|
357 |
try:
|
358 |
await q.message.chat.unban_member(user_id)
|
359 |
except RPCError as e:
|
|
|
380 |
await q.message.edit_text(f"{q.from_user.mention} unmuted {whoo.mention}!")
|
381 |
return
|
382 |
|
383 |
+
|
384 |
dic = {}
|
385 |
+
|
386 |
+
|
387 |
@Gojo.on_message(flood_filter, 18)
|
388 |
async def flood_watcher(c: Gojo, m: Message):
|
389 |
c_id = m.chat.id
|
390 |
+
|
391 |
Flood = Floods()
|
392 |
+
|
393 |
u_id = m.from_user.id
|
394 |
+
|
395 |
is_flood = Flood.is_chat(c_id)
|
|
|
396 |
|
397 |
action = is_flood[2]
|
398 |
limit = int(is_flood[0])
|
399 |
within = int(is_flood[1])
|
400 |
+
|
401 |
if not len(dic):
|
402 |
+
z = {c_id: {u_id: [[], []]}}
|
403 |
dic.update(z)
|
404 |
+
|
405 |
try:
|
406 |
+
dic[c_id] # access and check weather the c_id present or not
|
407 |
except KeyError:
|
408 |
+
z = {c_id: {u_id: [[], []]}}
|
409 |
+
dic.update(z)
|
410 |
|
411 |
try:
|
412 |
+
dic[c_id][u_id]
|
413 |
except KeyError:
|
414 |
+
z = {u_id: [[], []]}
|
415 |
+
dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
|
416 |
+
|
417 |
sec = round(time.time())
|
418 |
+
|
419 |
try:
|
420 |
dic[c_id][u_id][0].append(sec)
|
421 |
dic[c_id][u_id][1].append("x")
|
422 |
except KeyError:
|
423 |
+
dic[c_id].update({u_id: [[sec], ["x"]]})
|
424 |
+
|
425 |
x = int(dic[c_id][u_id][0][0])
|
426 |
y = int(dic[c_id][u_id][0][-1])
|
427 |
+
|
428 |
if len(dic[c_id][u_id][1]) == limit:
|
429 |
+
if y - x <= within:
|
430 |
action = action.split("_")
|
431 |
if len(action) == 2:
|
432 |
try:
|
433 |
to_do = action[0]
|
434 |
+
for_tim = int(action[1].replace("min", ""))
|
435 |
+
except Exception:
|
436 |
for_tim = 30
|
437 |
for_how_much = datetime.now() + timedelta(minutes=for_tim)
|
438 |
+
try:
|
439 |
+
if to_do == "ban":
|
440 |
await m.chat.ban_member(u_id, until_date=for_how_much)
|
441 |
keyboard = InlineKeyboardMarkup(
|
442 |
[
|
|
|
454 |
caption=txt,
|
455 |
reply_markup=keyboard,
|
456 |
)
|
457 |
+
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
458 |
await m.chat.restrict_member(
|
459 |
u_id,
|
460 |
ChatPermissions(),
|
|
|
476 |
caption=txt,
|
477 |
reply_markup=keyboard,
|
478 |
)
|
479 |
+
dic[c_id][u_id][1].clear()
|
480 |
+
dic[c_id][u_id][0].clear()
|
481 |
+
return
|
482 |
+
|
483 |
+
except UserAdminInvalid:
|
484 |
+
await m.reply_text(
|
485 |
+
"I can't protect this chat from this user",
|
486 |
+
)
|
487 |
+
dic[c_id][u_id][1].clear()
|
488 |
+
dic[c_id][u_id][0].clear()
|
489 |
+
return
|
490 |
+
except RPCError as ef:
|
491 |
+
await m.reply_text(
|
492 |
+
text=f"""Some error occured, report it using `/bug`
|
493 |
|
494 |
<b>Error:</b> <code>{ef}</code>"""
|
495 |
+
)
|
496 |
+
LOGGER.error(ef)
|
497 |
+
LOGGER.error(format_exc())
|
498 |
+
dic[c_id][u_id][1].clear()
|
499 |
+
dic[c_id][u_id][0].clear()
|
500 |
+
return
|
501 |
else:
|
502 |
action = action[0]
|
503 |
if action == "ban":
|
|
|
526 |
except UserAdminInvalid:
|
527 |
await m.reply_text(
|
528 |
"I can't protect this chat from this user",
|
529 |
+
)
|
530 |
dic[c_id][u_id][1].clear()
|
531 |
dic[c_id][u_id][0].clear()
|
532 |
return
|
|
|
535 |
text=f"""Some error occured, report it using `/bug`
|
536 |
|
537 |
<b>Error:</b> <code>{ef}</code>"""
|
538 |
+
)
|
539 |
LOGGER.error(ef)
|
540 |
LOGGER.error(format_exc())
|
541 |
dic[c_id][u_id][1].clear()
|
542 |
dic[c_id][u_id][0].clear()
|
543 |
return
|
544 |
+
|
545 |
elif action == "kick":
|
546 |
try:
|
547 |
+
d = datetime.now() + timedelta(
|
548 |
+
seconds=31) # will automatically unban user after 31 seconds kind of fail safe if unban members doesn't work properly
|
549 |
await m.chat.ban_member(u_id, until_date=d)
|
550 |
success = await c.unban_chat_member(m.chat.id, u_id)
|
551 |
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"
|
|
|
623 |
dic[c_id][u_id][1].clear()
|
624 |
dic[c_id][u_id][0].clear()
|
625 |
return
|
626 |
+
elif y - x > within:
|
627 |
+
try:
|
628 |
+
dic[c_id][u_id][1].clear()
|
629 |
+
dic[c_id][u_id][0].clear()
|
630 |
+
return
|
631 |
+
except Exception:
|
632 |
+
pass
|
633 |
else:
|
634 |
return
|
635 |
|
636 |
|
637 |
__PLUGIN__ = "flood"
|
638 |
__alt_name__ = [
|
639 |
+
"anit-flood",
|
640 |
+
"flood",
|
641 |
+
"spam",
|
642 |
+
"anti-spam",
|
643 |
]
|
644 |
__HELP__ = """
|
645 |
**Anti Flood**
|
|
|
653 |
**Example:**
|
654 |
`/setflood on`
|
655 |
"""
|
|
Powers/plugins/formatting.py
CHANGED
@@ -4,7 +4,6 @@ from pyrogram import enums, filters
|
|
4 |
from pyrogram.errors import MediaCaptionTooLong
|
5 |
from pyrogram.types import CallbackQuery, Message
|
6 |
|
7 |
-
from Powers import LOGGER
|
8 |
from Powers.bot_class import Gojo
|
9 |
from Powers.utils.custom_filters import command
|
10 |
from Powers.utils.extras import StartPic
|
@@ -59,6 +58,7 @@ If you would like to send buttons on the same row, use the <code>:same</code> fo
|
|
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)
|
@@ -71,7 +71,7 @@ async def get_splited_formatting(msg, page=1):
|
|
71 |
new_msg += f"{i}\n"
|
72 |
kb = [
|
73 |
[
|
74 |
-
("Next page ▶️", f"next_format_{page+1}")
|
75 |
]
|
76 |
]
|
77 |
else:
|
@@ -81,38 +81,39 @@ async def get_splited_formatting(msg, page=1):
|
|
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 |
-
|
93 |
-
|
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,
|
|
|
4 |
from pyrogram.errors import MediaCaptionTooLong
|
5 |
from pyrogram.types import CallbackQuery, Message
|
6 |
|
|
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.utils.custom_filters import command
|
9 |
from Powers.utils.extras import StartPic
|
|
|
58 |
<code>[button 3](buttonurl://example.com)</code>
|
59 |
This will show button 1 and 2 on the same line, while 3 will be underneath."""
|
60 |
|
61 |
+
|
62 |
async def get_splited_formatting(msg, page=1):
|
63 |
msg = msg.split("\n")
|
64 |
l = len(msg)
|
|
|
71 |
new_msg += f"{i}\n"
|
72 |
kb = [
|
73 |
[
|
74 |
+
("Next page ▶️", f"next_format_{page + 1}")
|
75 |
]
|
76 |
]
|
77 |
else:
|
|
|
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 |
kb = ikb(kb, True, "back.formatting")
|
98 |
|
99 |
return new_msg, kb
|
100 |
|
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 |
+
|
110 |
@Gojo.on_callback_query(filters.regex("^formatting."))
|
111 |
async def get_formatting_info(c: Gojo, q: CallbackQuery):
|
112 |
cmd = q.data.split(".")[1]
|
113 |
kb = ikb([[("Back", "back.formatting")]])
|
114 |
|
115 |
if cmd == "md_formatting":
|
116 |
+
|
117 |
try:
|
118 |
await q.edit_message_caption(
|
119 |
caption=md_txt,
|
Powers/plugins/fun.py
CHANGED
@@ -24,8 +24,10 @@ async def fun_shout(_, m: Message):
|
|
24 |
try:
|
25 |
text = " ".join(m.text.split(None, 1)[1])
|
26 |
result = [" ".join(list(text))]
|
27 |
-
|
28 |
-
|
|
|
|
|
29 |
result = list("\n".join(result))
|
30 |
result[0] = text[0]
|
31 |
result = "".join(result)
|
@@ -50,12 +52,9 @@ async def fun_slap(c: Gojo, m: Message):
|
|
50 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
51 |
|
52 |
curr_user = escape(m.from_user.first_name)
|
53 |
-
if m.reply_to_message
|
54 |
-
user = m.reply_to_message.from_user
|
55 |
-
else:
|
56 |
-
user = m.from_user
|
57 |
user_id = user.id
|
58 |
-
|
59 |
if user_id == me.id:
|
60 |
temp = choice(extras.SLAP_GOJO_TEMPLATES)
|
61 |
else:
|
@@ -64,7 +63,7 @@ async def fun_slap(c: Gojo, m: Message):
|
|
64 |
if user_id != m.from_user.id:
|
65 |
user1 = curr_user
|
66 |
user2 = user.first_name
|
67 |
-
|
68 |
else:
|
69 |
user1 = me.first_name
|
70 |
user2 = curr_user
|
|
|
24 |
try:
|
25 |
text = " ".join(m.text.split(None, 1)[1])
|
26 |
result = [" ".join(list(text))]
|
27 |
+
result.extend(
|
28 |
+
f"{symbol} " + " " * pos + symbol
|
29 |
+
for pos, symbol in enumerate(text[1:])
|
30 |
+
)
|
31 |
result = list("\n".join(result))
|
32 |
result[0] = text[0]
|
33 |
result = "".join(result)
|
|
|
52 |
reply_text = m.reply_to_message.reply_text if m.reply_to_message else m.reply_text
|
53 |
|
54 |
curr_user = escape(m.from_user.first_name)
|
55 |
+
user = m.reply_to_message.from_user if m.reply_to_message else m.from_user
|
|
|
|
|
|
|
56 |
user_id = user.id
|
57 |
+
|
58 |
if user_id == me.id:
|
59 |
temp = choice(extras.SLAP_GOJO_TEMPLATES)
|
60 |
else:
|
|
|
63 |
if user_id != m.from_user.id:
|
64 |
user1 = curr_user
|
65 |
user2 = user.first_name
|
66 |
+
|
67 |
else:
|
68 |
user1 = me.first_name
|
69 |
user2 = curr_user
|
Powers/plugins/greetings.py
CHANGED
@@ -26,11 +26,11 @@ gdb = GBan()
|
|
26 |
ChatType = enums.ChatType
|
27 |
|
28 |
|
29 |
-
async def
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
) -> str:
|
35 |
teks = await escape_invalid_curly_brackets(text, parse_words)
|
36 |
if teks:
|
@@ -157,7 +157,7 @@ async def save_wlcm(_, m: Message):
|
|
157 |
await m.reply_text("Please provide some data for this to reply with!")
|
158 |
return
|
159 |
|
160 |
-
db.set_welcome_text(text,msgtype,file)
|
161 |
await m.reply_text("Saved welcome!")
|
162 |
return
|
163 |
|
@@ -195,7 +195,7 @@ async def save_gdbye(_, m: Message):
|
|
195 |
await m.reply_text("Please provide some data for this to reply with!")
|
196 |
return
|
197 |
|
198 |
-
db.set_goodbye_text(text,msgtype,file)
|
199 |
await m.reply_text("Saved goodbye!")
|
200 |
return
|
201 |
|
@@ -206,7 +206,7 @@ async def resetgb(_, m: Message):
|
|
206 |
if m and not m.from_user:
|
207 |
return
|
208 |
text = "Sad to see you leaving {first}.\nTake Care!"
|
209 |
-
db.set_goodbye_text(text,None)
|
210 |
await m.reply_text("Ok Done!")
|
211 |
return
|
212 |
|
@@ -217,7 +217,7 @@ async def resetwlcm(_, m: Message):
|
|
217 |
if m and not m.from_user:
|
218 |
return
|
219 |
text = "Hey {first}, welcome to {chatname}!"
|
220 |
-
db.set_welcome_text(text,None)
|
221 |
await m.reply_text("Done!")
|
222 |
return
|
223 |
|
@@ -232,6 +232,7 @@ async def cleannnnn(_, m: Message):
|
|
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
|
@@ -256,7 +257,7 @@ async def member_has_joined(c: Gojo, m: Message):
|
|
256 |
)
|
257 |
continue
|
258 |
if user.is_bot:
|
259 |
-
continue
|
260 |
except ChatAdminRequired:
|
261 |
continue
|
262 |
status = db.get_welcome_status()
|
@@ -273,78 +274,8 @@ async def member_has_joined(c: Gojo, m: Message):
|
|
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()
|
333 |
-
mtype = db.get_goodbye_msgtype()
|
334 |
-
parse_words = [
|
335 |
-
"first",
|
336 |
-
"last",
|
337 |
-
"fullname",
|
338 |
-
"id",
|
339 |
-
"username",
|
340 |
-
"mention",
|
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)
|
350 |
button = ikb(button) if button else None
|
@@ -355,50 +286,115 @@ async def member_has_left(c: Gojo, m: Message):
|
|
355 |
else:
|
356 |
teks = tek
|
357 |
|
358 |
-
if not teks:
|
359 |
-
teks = f"
|
360 |
-
|
361 |
-
ifff = db.
|
362 |
-
|
363 |
-
if ifff and
|
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:
|
375 |
-
teks = "
|
376 |
try:
|
377 |
if not UwU:
|
378 |
-
|
379 |
m.chat.id,
|
380 |
text=teks,
|
381 |
reply_markup=button,
|
382 |
disable_web_page_preview=True,
|
383 |
)
|
384 |
-
|
385 |
-
|
386 |
m.chat.id,
|
387 |
UwU,
|
388 |
caption=teks,
|
389 |
reply_markup=button,
|
390 |
)
|
391 |
|
392 |
-
if
|
393 |
-
db.
|
394 |
-
return
|
395 |
except ChannelPrivate:
|
396 |
-
|
397 |
except RPCError as e:
|
398 |
LOGGER.error(e)
|
399 |
LOGGER.error(format_exc(e))
|
400 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
401 |
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
return
|
403 |
|
404 |
|
@@ -450,14 +446,14 @@ async def welcome(c: Gojo, m: Message):
|
|
450 |
button = await build_keyboard(button)
|
451 |
button = ikb(button) if button else None
|
452 |
if not UwU:
|
453 |
-
|
454 |
m.chat.id,
|
455 |
text=tek,
|
456 |
reply_markup=button,
|
457 |
disable_web_page_preview=True,
|
458 |
)
|
459 |
-
|
460 |
-
|
461 |
m.chat.id,
|
462 |
UwU,
|
463 |
caption=tek,
|
@@ -512,14 +508,14 @@ async def goodbye(c: Gojo, m: Message):
|
|
512 |
button = await build_keyboard(button)
|
513 |
button = ikb(button) if button else None
|
514 |
if not UwU:
|
515 |
-
|
516 |
m.chat.id,
|
517 |
text=tek,
|
518 |
reply_markup=button,
|
519 |
disable_web_page_preview=True,
|
520 |
)
|
521 |
-
|
522 |
-
|
523 |
m.chat.id,
|
524 |
UwU,
|
525 |
caption=tek,
|
@@ -527,6 +523,7 @@ async def goodbye(c: Gojo, m: Message):
|
|
527 |
)
|
528 |
return
|
529 |
|
|
|
530 |
__PLUGIN__ = "greetings"
|
531 |
__alt_name__ = ["welcome", "goodbye", "cleanservice"]
|
532 |
|
|
|
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:
|
|
|
157 |
await m.reply_text("Please provide some data for this to reply with!")
|
158 |
return
|
159 |
|
160 |
+
db.set_welcome_text(text, msgtype, file)
|
161 |
await m.reply_text("Saved welcome!")
|
162 |
return
|
163 |
|
|
|
195 |
await m.reply_text("Please provide some data for this to reply with!")
|
196 |
return
|
197 |
|
198 |
+
db.set_goodbye_text(text, msgtype, file)
|
199 |
await m.reply_text("Saved goodbye!")
|
200 |
return
|
201 |
|
|
|
206 |
if m and not m.from_user:
|
207 |
return
|
208 |
text = "Sad to see you leaving {first}.\nTake Care!"
|
209 |
+
db.set_goodbye_text(text, None)
|
210 |
await m.reply_text("Ok Done!")
|
211 |
return
|
212 |
|
|
|
217 |
if m and not m.from_user:
|
218 |
return
|
219 |
text = "Hey {first}, welcome to {chatname}!"
|
220 |
+
db.set_welcome_text(text, None)
|
221 |
await m.reply_text("Done!")
|
222 |
return
|
223 |
|
|
|
232 |
except Exception:
|
233 |
pass
|
234 |
|
235 |
+
|
236 |
@Gojo.on_message(filters.group & filters.new_chat_members & ~captcha_filter, group=69)
|
237 |
async def member_has_joined(c: Gojo, m: Message):
|
238 |
users: List[User] = m.new_chat_members
|
|
|
257 |
)
|
258 |
continue
|
259 |
if user.is_bot:
|
260 |
+
continue # ignore bots
|
261 |
except ChatAdminRequired:
|
262 |
continue
|
263 |
status = db.get_welcome_status()
|
|
|
274 |
"chatname",
|
275 |
]
|
276 |
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
277 |
+
if not status:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
tek, button = await parse_button(hmm)
|
280 |
button = await build_keyboard(button)
|
281 |
button = ikb(button) if button else None
|
|
|
286 |
else:
|
287 |
teks = tek
|
288 |
|
289 |
+
if not teks:
|
290 |
+
teks = f"A wild {user.mention} appeared in {m.chat.title}! Everyone be aware."
|
291 |
+
|
292 |
+
ifff = db.get_current_cleanwelcome_id()
|
293 |
+
gg = db.get_current_cleanwelcome_settings()
|
294 |
+
if ifff and gg:
|
295 |
try:
|
296 |
await c.delete_messages(m.chat.id, int(ifff))
|
297 |
except RPCError:
|
298 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
299 |
if not teks:
|
300 |
+
teks = "Hey {first}, welcome to {chatname}"
|
301 |
try:
|
302 |
if not UwU:
|
303 |
+
jj = await c.send_message(
|
304 |
m.chat.id,
|
305 |
text=teks,
|
306 |
reply_markup=button,
|
307 |
disable_web_page_preview=True,
|
308 |
)
|
309 |
+
else:
|
310 |
+
jj = await (await send_cmd(c, mtype))(
|
311 |
m.chat.id,
|
312 |
UwU,
|
313 |
caption=teks,
|
314 |
reply_markup=button,
|
315 |
)
|
316 |
|
317 |
+
if jj:
|
318 |
+
db.set_cleanwlcm_id(int(jj.id))
|
|
|
319 |
except ChannelPrivate:
|
320 |
+
continue
|
321 |
except RPCError as e:
|
322 |
LOGGER.error(e)
|
323 |
LOGGER.error(format_exc(e))
|
324 |
+
|
325 |
+
|
326 |
+
@Gojo.on_message(filters.group & filters.left_chat_member, group=99)
|
327 |
+
async def member_has_left(c: Gojo, m: Message):
|
328 |
+
db = Greetings(m.chat.id)
|
329 |
+
status = db.get_goodbye_status()
|
330 |
+
oo = db.get_goodbye_text()
|
331 |
+
UwU = db.get_goodbye_media()
|
332 |
+
mtype = db.get_goodbye_msgtype()
|
333 |
+
parse_words = [
|
334 |
+
"first",
|
335 |
+
"last",
|
336 |
+
"fullname",
|
337 |
+
"id",
|
338 |
+
"username",
|
339 |
+
"mention",
|
340 |
+
"chatname",
|
341 |
+
]
|
342 |
+
|
343 |
+
user = m.left_chat_member or m.from_user
|
344 |
+
|
345 |
+
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
346 |
+
if not status:
|
347 |
+
return
|
348 |
+
tek, button = await parse_button(hmm)
|
349 |
+
button = await build_keyboard(button)
|
350 |
+
button = ikb(button) if button else None
|
351 |
+
|
352 |
+
if "%%%" in tek:
|
353 |
+
filter_reply = tek.split("%%%")
|
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:
|
375 |
+
teks = "Sad to see you leaving {first}\nTake Care!"
|
376 |
+
try:
|
377 |
+
ooo = (
|
378 |
+
await (await send_cmd(c, mtype))(
|
379 |
+
m.chat.id,
|
380 |
+
UwU,
|
381 |
+
caption=teks,
|
382 |
+
reply_markup=button,
|
383 |
+
) if UwU else await c.send_message(
|
384 |
+
m.chat.id,
|
385 |
+
text=teks,
|
386 |
+
reply_markup=button,
|
387 |
+
disable_web_page_preview=True,
|
388 |
+
)
|
389 |
+
)
|
390 |
+
if ooo:
|
391 |
+
db.set_cleangoodbye_id(int(ooo.id))
|
392 |
+
return
|
393 |
+
except ChannelPrivate:
|
394 |
+
pass
|
395 |
+
except RPCError as e:
|
396 |
+
LOGGER.error(e)
|
397 |
+
LOGGER.error(format_exc(e))
|
398 |
return
|
399 |
|
400 |
|
|
|
446 |
button = await build_keyboard(button)
|
447 |
button = ikb(button) if button else None
|
448 |
if not UwU:
|
449 |
+
await c.send_message(
|
450 |
m.chat.id,
|
451 |
text=tek,
|
452 |
reply_markup=button,
|
453 |
disable_web_page_preview=True,
|
454 |
)
|
455 |
+
else:
|
456 |
+
await (await send_cmd(c, mtype))(
|
457 |
m.chat.id,
|
458 |
UwU,
|
459 |
caption=tek,
|
|
|
508 |
button = await build_keyboard(button)
|
509 |
button = ikb(button) if button else None
|
510 |
if not UwU:
|
511 |
+
await c.send_message(
|
512 |
m.chat.id,
|
513 |
text=tek,
|
514 |
reply_markup=button,
|
515 |
disable_web_page_preview=True,
|
516 |
)
|
517 |
+
else:
|
518 |
+
await (await send_cmd(c, mtype))(
|
519 |
m.chat.id,
|
520 |
UwU,
|
521 |
caption=tek,
|
|
|
523 |
)
|
524 |
return
|
525 |
|
526 |
+
|
527 |
__PLUGIN__ = "greetings"
|
528 |
__alt_name__ = ["welcome", "goodbye", "cleanservice"]
|
529 |
|
Powers/plugins/info.py
CHANGED
@@ -22,13 +22,13 @@ async def count(c: Gojo, chat):
|
|
22 |
try:
|
23 |
administrator = []
|
24 |
async for admin in c.get_chat_members(
|
25 |
-
|
26 |
):
|
27 |
administrator.append(admin)
|
28 |
total_admin = administrator
|
29 |
bot = []
|
30 |
async for tbot in c.get_chat_members(
|
31 |
-
|
32 |
):
|
33 |
bot.append(tbot)
|
34 |
|
@@ -36,7 +36,7 @@ async def count(c: Gojo, chat):
|
|
36 |
bot_admin = 0
|
37 |
ban = []
|
38 |
async for banned in c.get_chat_members(
|
39 |
-
|
40 |
):
|
41 |
ban.append(banned)
|
42 |
|
@@ -90,7 +90,7 @@ async def user_info(c: Gojo, user, already=False):
|
|
90 |
is_verified = user.is_verified
|
91 |
is_restricted = user.is_restricted
|
92 |
photo_id = user.photo.big_file_id if user.photo else None
|
93 |
-
is_support =
|
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?"
|
@@ -107,29 +107,29 @@ async def user_info(c: Gojo, user, already=False):
|
|
107 |
omp = "Owner of the bot"
|
108 |
if user_id in DEV_USERS and user_id == OWNER_ID:
|
109 |
omp = "Dev and Owner"
|
110 |
-
|
111 |
is_scam = user.is_scam
|
112 |
is_bot = user.is_bot
|
113 |
is_fake = user.is_fake
|
114 |
status = user.status
|
115 |
last_date = "Unable to fetch"
|
116 |
if is_bot is True:
|
117 |
-
|
118 |
if status == enums.UserStatus.RECENTLY:
|
119 |
-
|
120 |
if status == enums.UserStatus.LAST_WEEK:
|
121 |
-
|
122 |
if status == enums.UserStatus.LAST_MONTH:
|
123 |
-
|
124 |
if status == enums.UserStatus.LONG_AGO:
|
125 |
-
|
126 |
if status == enums.UserStatus.ONLINE:
|
127 |
-
|
128 |
-
if status == enums.UserStatus.OFFLINE:
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
|
134 |
caption = f"""
|
135 |
<b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
|
@@ -173,10 +173,10 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
173 |
GetFullChannel(
|
174 |
channel=chat_r
|
175 |
)
|
176 |
-
)
|
177 |
u_name = ll.chats[0].usernames
|
178 |
except Exception:
|
179 |
-
pass
|
180 |
except Exception:
|
181 |
try:
|
182 |
chat_r = await c.resolve_peer(chat)
|
@@ -186,7 +186,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
186 |
GetFullChannel(
|
187 |
channel=chat_r
|
188 |
)
|
189 |
-
)
|
190 |
u_name = ll.chats[0].usernames
|
191 |
except Exception:
|
192 |
pass
|
@@ -194,10 +194,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
194 |
caption = f"Failed to find the chat due to\n{e}"
|
195 |
return caption, None
|
196 |
chat_id = chat.id
|
197 |
-
if u_name
|
198 |
-
username = " ".join([f"@{i}"for i in u_name])
|
199 |
-
elif not u_name:
|
200 |
-
username = chat.username
|
201 |
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
|
202 |
title = chat.title
|
203 |
type_ = str(chat.type).split(".")[1]
|
@@ -218,7 +215,7 @@ async def chat_info(c: Gojo, chat, already=False):
|
|
218 |
<b>🚀 Chat Title</b>: {title}
|
219 |
<b>✨ Chat Type</b>: {type_}
|
220 |
<b>🌐 DataCentre ID</b>: {dc_id}
|
221 |
-
<b>🔍 Username</b>: {
|
222 |
<b>⚜️ Administrators</b>: {total_admin}
|
223 |
<b>🤖 Bots</b>: {total_bot}
|
224 |
<b>🚫 Banned</b>: {total_banned}
|
@@ -243,7 +240,7 @@ async def info_func(c: Gojo, message: Message):
|
|
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)
|
@@ -251,7 +248,7 @@ async def info_func(c: Gojo, message: Message):
|
|
251 |
await message.reply_text("Can't find user to fetch info!")
|
252 |
|
253 |
m = await message.reply_text(
|
254 |
-
f"Fetching {
|
255 |
)
|
256 |
|
257 |
try:
|
@@ -285,9 +282,10 @@ async def info_func(c: Gojo, message: Message):
|
|
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(
|
|
|
289 |
return
|
290 |
-
|
291 |
await message.reply_text(text=e)
|
292 |
LOGGER.error(e)
|
293 |
LOGGER.error(format_exc())
|
@@ -303,7 +301,7 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
303 |
if len(splited) == 1:
|
304 |
if message.reply_to_message and message.reply_to_message.sender_chat:
|
305 |
chat = message.reply_to_message.sender_chat.id
|
306 |
-
else:
|
307 |
chat = message.chat.id
|
308 |
|
309 |
else:
|
@@ -311,20 +309,19 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
311 |
|
312 |
try:
|
313 |
chat = int(chat)
|
314 |
-
except
|
315 |
-
if "invalid literal for int() with base 10:" in str(ef):
|
316 |
-
chat = str(chat)
|
317 |
-
if chat.startswith("https://"):
|
318 |
-
chat = '@'+chat.split("/")[-1]
|
319 |
-
else:
|
320 |
return await message.reply_text(
|
321 |
f"Got and exception {ef}\n**Usage:**/chinfo [USERNAME|ID]"
|
322 |
)
|
323 |
|
|
|
|
|
|
|
324 |
m = await message.reply_text(
|
325 |
-
|
326 |
)
|
327 |
-
|
328 |
try:
|
329 |
info_caption, photo_id = await chat_info(c, chat=chat)
|
330 |
if info_caption.startswith("Failed to find the chat due"):
|
|
|
22 |
try:
|
23 |
administrator = []
|
24 |
async for admin in c.get_chat_members(
|
25 |
+
chat_id=chat, filter=enums.ChatMembersFilter.ADMINISTRATORS
|
26 |
):
|
27 |
administrator.append(admin)
|
28 |
total_admin = administrator
|
29 |
bot = []
|
30 |
async for tbot in c.get_chat_members(
|
31 |
+
chat_id=chat, filter=enums.ChatMembersFilter.BOTS
|
32 |
):
|
33 |
bot.append(tbot)
|
34 |
|
|
|
36 |
bot_admin = 0
|
37 |
ban = []
|
38 |
async for banned in c.get_chat_members(
|
39 |
+
chat, filter=enums.ChatMembersFilter.BANNED
|
40 |
):
|
41 |
ban.append(banned)
|
42 |
|
|
|
90 |
is_verified = user.is_verified
|
91 |
is_restricted = user.is_restricted
|
92 |
photo_id = user.photo.big_file_id if user.photo else None
|
93 |
+
is_support = user_id in SUPPORT_STAFF
|
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?"
|
|
|
107 |
omp = "Owner of the bot"
|
108 |
if user_id in DEV_USERS and user_id == OWNER_ID:
|
109 |
omp = "Dev and Owner"
|
110 |
+
|
111 |
is_scam = user.is_scam
|
112 |
is_bot = user.is_bot
|
113 |
is_fake = user.is_fake
|
114 |
status = user.status
|
115 |
last_date = "Unable to fetch"
|
116 |
if is_bot is True:
|
117 |
+
last_date = "Targeted user is a bot"
|
118 |
if status == enums.UserStatus.RECENTLY:
|
119 |
+
last_date = "User was seen recently"
|
120 |
if status == enums.UserStatus.LAST_WEEK:
|
121 |
+
last_date = "User was seen last week"
|
122 |
if status == enums.UserStatus.LAST_MONTH:
|
123 |
+
last_date = "User was seen last month"
|
124 |
if status == enums.UserStatus.LONG_AGO:
|
125 |
+
last_date = "User was seen long ago or may be I am blocked by the user :("
|
126 |
if status == enums.UserStatus.ONLINE:
|
127 |
+
last_date = "User is online"
|
128 |
+
if status == enums.UserStatus.OFFLINE:
|
129 |
+
try:
|
130 |
+
last_date = datetime.fromtimestamp(user.status.date).strftime("%Y-%m-%d %H:%M:%S")
|
131 |
+
except Exception:
|
132 |
+
last_date = "User is offline"
|
133 |
|
134 |
caption = f"""
|
135 |
<b><i><u>⚡️ Extracted User info From Telegram ⚡️</b></i></u>
|
|
|
173 |
GetFullChannel(
|
174 |
channel=chat_r
|
175 |
)
|
176 |
+
)
|
177 |
u_name = ll.chats[0].usernames
|
178 |
except Exception:
|
179 |
+
pass
|
180 |
except Exception:
|
181 |
try:
|
182 |
chat_r = await c.resolve_peer(chat)
|
|
|
186 |
GetFullChannel(
|
187 |
channel=chat_r
|
188 |
)
|
189 |
+
)
|
190 |
u_name = ll.chats[0].usernames
|
191 |
except Exception:
|
192 |
pass
|
|
|
194 |
caption = f"Failed to find the chat due to\n{e}"
|
195 |
return caption, None
|
196 |
chat_id = chat.id
|
197 |
+
username = " ".join([f"@{i}" for i in u_name]) if u_name else chat.username
|
|
|
|
|
|
|
198 |
total_bot, total_admin, total_bot_admin, total_banned = await count(c, chat.id)
|
199 |
title = chat.title
|
200 |
type_ = str(chat.type).split(".")[1]
|
|
|
215 |
<b>🚀 Chat Title</b>: {title}
|
216 |
<b>✨ Chat Type</b>: {type_}
|
217 |
<b>🌐 DataCentre ID</b>: {dc_id}
|
218 |
+
<b>🔍 Username</b>: {f"@{username}" if username else "NA"}
|
219 |
<b>⚜️ Administrators</b>: {total_admin}
|
220 |
<b>🤖 Bots</b>: {total_bot}
|
221 |
<b>🚫 Banned</b>: {total_banned}
|
|
|
240 |
return
|
241 |
try:
|
242 |
user, _, user_name = await extract_user(c, message)
|
243 |
+
except Exception:
|
244 |
await message.reply_text("Got Some errors failed to fetch user info")
|
245 |
LOGGER.error(e)
|
246 |
LOGGER.error(format_exc)
|
|
|
248 |
await message.reply_text("Can't find user to fetch info!")
|
249 |
|
250 |
m = await message.reply_text(
|
251 |
+
f"Fetching {f'@{user_name}' if user_name else 'user'} info from telegram's database..."
|
252 |
)
|
253 |
|
254 |
try:
|
|
|
282 |
LOGGER.error(format_exc())
|
283 |
except Exception as e:
|
284 |
if e == "User not found ! Error: 'InputPeerChannel' object has no attribute 'user_id'":
|
285 |
+
await m.reply_text(
|
286 |
+
"Looks like you are trying to fetch info of a chat not an user. In that case please use /chinfo")
|
287 |
return
|
288 |
+
|
289 |
await message.reply_text(text=e)
|
290 |
LOGGER.error(e)
|
291 |
LOGGER.error(format_exc())
|
|
|
301 |
if len(splited) == 1:
|
302 |
if message.reply_to_message and message.reply_to_message.sender_chat:
|
303 |
chat = message.reply_to_message.sender_chat.id
|
304 |
+
else:
|
305 |
chat = message.chat.id
|
306 |
|
307 |
else:
|
|
|
309 |
|
310 |
try:
|
311 |
chat = int(chat)
|
312 |
+
except Exception as ef:
|
313 |
+
if "invalid literal for int() with base 10:" not in str(ef):
|
|
|
|
|
|
|
|
|
314 |
return await message.reply_text(
|
315 |
f"Got and exception {ef}\n**Usage:**/chinfo [USERNAME|ID]"
|
316 |
)
|
317 |
|
318 |
+
chat = str(chat)
|
319 |
+
if chat.startswith("https://"):
|
320 |
+
chat = '@' + chat.split("/")[-1]
|
321 |
m = await message.reply_text(
|
322 |
+
"Fetching chat info of chat from telegram's database....."
|
323 |
)
|
324 |
+
|
325 |
try:
|
326 |
info_caption, photo_id = await chat_info(c, chat=chat)
|
327 |
if info_caption.startswith("Failed to find the chat due"):
|
Powers/plugins/locks.py
CHANGED
@@ -195,9 +195,7 @@ Use /locktypes to get the lock types"""
|
|
195 |
pass
|
196 |
except ChatAdminRequired:
|
197 |
await m.reply_text(text="I don't have permission to do that")
|
198 |
-
await m.reply_text(
|
199 |
-
"🔒 " + f"Locked <b>{perm}</b> for this Chat.",
|
200 |
-
)
|
201 |
await prevent_approved(m)
|
202 |
return
|
203 |
|
@@ -208,9 +206,7 @@ async def view_locks(_, m: Message):
|
|
208 |
v_perm = m.chat.permissions
|
209 |
|
210 |
async def convert_to_emoji(val: bool):
|
211 |
-
if val
|
212 |
-
return "✅"
|
213 |
-
return "❌"
|
214 |
|
215 |
lock = LOCKS()
|
216 |
anon = lock.get_lock_channel(m.chat.id, "anti_c_send")
|
@@ -369,13 +365,11 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
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
|
373 |
-
if curr:
|
374 |
await m.reply_text("Sending link is now allowed")
|
375 |
-
return
|
376 |
else:
|
377 |
await m.reply_text("Sending link is not allowed")
|
378 |
-
|
379 |
elif unlock_type == "forwardall":
|
380 |
curr = lock.remove_lock_channel(m.chat.id, "anti_fwd")
|
381 |
|
@@ -432,9 +426,7 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
432 |
pass
|
433 |
except ChatAdminRequired:
|
434 |
await m.reply_text(text="I don't have permission to do that")
|
435 |
-
await m.reply_text(
|
436 |
-
"🔓 " + f"Unlocked <b>{uperm}</b> for this Chat.",
|
437 |
-
)
|
438 |
await prevent_approved(m)
|
439 |
return
|
440 |
|
@@ -460,20 +452,30 @@ async def is_approved_user(c: Gojo, m: Message):
|
|
460 |
SUDO_LEVEL = DEV_USERS.union(SUDO_USERS)
|
461 |
|
462 |
if m.forward_from:
|
463 |
-
|
464 |
-
|
465 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
elif m.forward_from_chat:
|
467 |
-
if m.from_user and (
|
|
|
468 |
return True
|
469 |
elif m.automatic_forward:
|
470 |
return True
|
471 |
else:
|
472 |
return False
|
473 |
elif m.from_user:
|
474 |
-
|
475 |
-
|
476 |
-
|
|
|
|
|
|
|
477 |
else:
|
478 |
return False
|
479 |
|
@@ -504,7 +506,12 @@ async def lock_del_mess(c: Gojo, m: Message):
|
|
504 |
if not chat_locks:
|
505 |
return
|
506 |
|
507 |
-
if
|
|
|
|
|
|
|
|
|
|
|
508 |
if m.chat.is_admin:
|
509 |
return
|
510 |
await delete_messages(c, m)
|
|
|
195 |
pass
|
196 |
except ChatAdminRequired:
|
197 |
await m.reply_text(text="I don't have permission to do that")
|
198 |
+
await m.reply_text(f"🔒 Locked <b>{perm}</b> for this Chat.")
|
|
|
|
|
199 |
await prevent_approved(m)
|
200 |
return
|
201 |
|
|
|
206 |
v_perm = m.chat.permissions
|
207 |
|
208 |
async def convert_to_emoji(val: bool):
|
209 |
+
return "✅" if val else "❌"
|
|
|
|
|
210 |
|
211 |
lock = LOCKS()
|
212 |
anon = lock.get_lock_channel(m.chat.id, "anti_c_send")
|
|
|
365 |
await m.reply_text("Send as chat is now enabled for this chat")
|
366 |
return
|
367 |
elif unlock_type in ["links", "url"]:
|
368 |
+
if curr := lock.remove_lock_channel(m.chat.id, "anti_links"):
|
|
|
369 |
await m.reply_text("Sending link is now allowed")
|
|
|
370 |
else:
|
371 |
await m.reply_text("Sending link is not allowed")
|
372 |
+
return
|
373 |
elif unlock_type == "forwardall":
|
374 |
curr = lock.remove_lock_channel(m.chat.id, "anti_fwd")
|
375 |
|
|
|
426 |
pass
|
427 |
except ChatAdminRequired:
|
428 |
await m.reply_text(text="I don't have permission to do that")
|
429 |
+
await m.reply_text(f"🔓 Unlocked <b>{uperm}</b> for this Chat.")
|
|
|
|
|
430 |
await prevent_approved(m)
|
431 |
return
|
432 |
|
|
|
452 |
SUDO_LEVEL = DEV_USERS.union(SUDO_USERS)
|
453 |
|
454 |
if m.forward_from:
|
455 |
+
return bool(
|
456 |
+
m.from_user
|
457 |
+
and (
|
458 |
+
m.from_user.id in ul
|
459 |
+
or m.from_user.id in SUDO_LEVEL
|
460 |
+
or m.from_user.id in admins_group
|
461 |
+
or m.from_user.id == c.me.id
|
462 |
+
)
|
463 |
+
)
|
464 |
elif m.forward_from_chat:
|
465 |
+
if m.from_user and (
|
466 |
+
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):
|
467 |
return True
|
468 |
elif m.automatic_forward:
|
469 |
return True
|
470 |
else:
|
471 |
return False
|
472 |
elif m.from_user:
|
473 |
+
return (
|
474 |
+
m.from_user.id in ul
|
475 |
+
or m.from_user.id in SUDO_LEVEL
|
476 |
+
or m.from_user.id in admins_group
|
477 |
+
or m.from_user.id == c.me.id
|
478 |
+
)
|
479 |
else:
|
480 |
return False
|
481 |
|
|
|
506 |
if not chat_locks:
|
507 |
return
|
508 |
|
509 |
+
if (
|
510 |
+
chat_locks["anti_channel"]
|
511 |
+
and m.sender_chat
|
512 |
+
and not m.forward_from_chat
|
513 |
+
and not m.forward_from
|
514 |
+
):
|
515 |
if m.chat.is_admin:
|
516 |
return
|
517 |
await delete_messages(c, m)
|
Powers/plugins/muting.py
CHANGED
@@ -40,7 +40,6 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
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 |
)
|
@@ -109,8 +108,8 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
109 |
reply_to_message_id=r_id,
|
110 |
)
|
111 |
except Exception:
|
112 |
-
await m.reply_text(txt,reply_markup=keyboard, reply_to_message_id=r_id)
|
113 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
114 |
except ChatAdminRequired:
|
115 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
116 |
except RightForbidden:
|
@@ -150,7 +149,6 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
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 |
)
|
@@ -217,8 +215,8 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
217 |
reply_markup=keyboard,
|
218 |
)
|
219 |
except Exception:
|
220 |
-
await m.reply_text(txt,reply_markup=keyboard)
|
221 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
222 |
except ChatAdminRequired:
|
223 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
224 |
except RightForbidden:
|
@@ -346,7 +344,6 @@ async def mute_usr(c: Gojo, m: Message):
|
|
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 |
)
|
@@ -390,8 +387,8 @@ async def mute_usr(c: Gojo, m: Message):
|
|
390 |
reply_to_message_id=r_id,
|
391 |
)
|
392 |
except Exception:
|
393 |
-
await m.reply_text(txt,reply_markup=keyboard, reply_to_message_id=r_id)
|
394 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
395 |
except ChatAdminRequired:
|
396 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
397 |
except RightForbidden:
|
@@ -479,13 +476,7 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
479 |
if not m.reply_to_message:
|
480 |
return await m.reply_text("No replied message and user to delete and mute!")
|
481 |
|
482 |
-
reason = None
|
483 |
-
if m.reply_to_message:
|
484 |
-
if len(m.text.split()) >= 2:
|
485 |
-
reason = m.text.split(None, 1)[1]
|
486 |
-
else:
|
487 |
-
if len(m.text.split()) >= 3:
|
488 |
-
reason = m.text.split(None, 2)[2]
|
489 |
user_id = m.reply_to_message.from_user.id
|
490 |
user_first_name = m.reply_to_message.from_user.first_name
|
491 |
|
@@ -496,7 +487,6 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
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(
|
@@ -542,8 +532,8 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
542 |
reply_markup=keyboard,
|
543 |
)
|
544 |
except Exception:
|
545 |
-
await m.reply_text(txt,reply_markup=keyboard)
|
546 |
-
await c.send_message(MESSAGE_DUMP,f"#REMOVE from MUTE_GIFS\n{mutt}")
|
547 |
except ChatAdminRequired:
|
548 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
549 |
except RightForbidden:
|
@@ -577,7 +567,7 @@ async def unmute_usr(c: Gojo, m: Message):
|
|
577 |
return
|
578 |
try:
|
579 |
statu = (await m.chat.get_member(user_id)).status
|
580 |
-
if statu not in [enums.ChatMemberStatus.BANNED,enums.ChatMemberStatus.RESTRICTED]:
|
581 |
await m.reply_text("User is not muted in this chat\nOr using this command as reply to his message")
|
582 |
return
|
583 |
except Exception as e:
|
|
|
40 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
41 |
|
42 |
if user_id in SUPPORT_STAFF:
|
|
|
43 |
await m.reply_text(
|
44 |
text="This user is in my support staff, cannot restrict them."
|
45 |
)
|
|
|
108 |
reply_to_message_id=r_id,
|
109 |
)
|
110 |
except Exception:
|
111 |
+
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
112 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
113 |
except ChatAdminRequired:
|
114 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
115 |
except RightForbidden:
|
|
|
149 |
|
150 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
151 |
if user_id in SUPPORT_STAFF:
|
|
|
152 |
await m.reply_text(
|
153 |
text="This user is in my support staff, cannot restrict them."
|
154 |
)
|
|
|
215 |
reply_markup=keyboard,
|
216 |
)
|
217 |
except Exception:
|
218 |
+
await m.reply_text(txt, reply_markup=keyboard)
|
219 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
220 |
except ChatAdminRequired:
|
221 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
222 |
except RightForbidden:
|
|
|
344 |
|
345 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
346 |
if user_id in SUPPORT_STAFF:
|
|
|
347 |
await m.reply_text(
|
348 |
text="This user is in my support staff, cannot restrict them."
|
349 |
)
|
|
|
387 |
reply_to_message_id=r_id,
|
388 |
)
|
389 |
except Exception:
|
390 |
+
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
391 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
392 |
except ChatAdminRequired:
|
393 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
394 |
except RightForbidden:
|
|
|
476 |
if not m.reply_to_message:
|
477 |
return await m.reply_text("No replied message and user to delete and mute!")
|
478 |
|
479 |
+
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
user_id = m.reply_to_message.from_user.id
|
481 |
user_first_name = m.reply_to_message.from_user.first_name
|
482 |
|
|
|
487 |
await m.reply_text("Huh, why would I mute myself?")
|
488 |
return
|
489 |
|
|
|
490 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
491 |
if user_id in SUPPORT_STAFF:
|
492 |
await m.reply_text(
|
|
|
532 |
reply_markup=keyboard,
|
533 |
)
|
534 |
except Exception:
|
535 |
+
await m.reply_text(txt, reply_markup=keyboard)
|
536 |
+
await c.send_message(MESSAGE_DUMP, f"#REMOVE from MUTE_GIFS\n{mutt}")
|
537 |
except ChatAdminRequired:
|
538 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
539 |
except RightForbidden:
|
|
|
567 |
return
|
568 |
try:
|
569 |
statu = (await m.chat.get_member(user_id)).status
|
570 |
+
if statu not in [enums.ChatMemberStatus.BANNED, enums.ChatMemberStatus.RESTRICTED]:
|
571 |
await m.reply_text("User is not muted in this chat\nOr using this command as reply to his message")
|
572 |
return
|
573 |
except Exception as e:
|
Powers/plugins/notes.py
CHANGED
@@ -73,7 +73,6 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
73 |
return
|
74 |
|
75 |
if priv_notes_status:
|
76 |
-
|
77 |
note_hash = next(i[1] for i in db.get_all_notes(m.chat.id) if i[0] == note_name)
|
78 |
await reply_text(
|
79 |
f"Click on the button to get the note <code>{note_name}</code>",
|
@@ -150,10 +149,10 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
150 |
)
|
151 |
return
|
152 |
elif msgtype in (
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
):
|
158 |
await (await send_cmd(c, msgtype))(
|
159 |
m.chat.id,
|
@@ -192,7 +191,7 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
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
|
@@ -222,10 +221,10 @@ async def get_raw_note(c: Gojo, m: Message, note: str):
|
|
222 |
teks, parse_mode=enums.ParseMode.DISABLED, reply_to_message_id=msg_id
|
223 |
)
|
224 |
elif msgtype in (
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
):
|
230 |
await (await send_cmd(c, msgtype))(
|
231 |
m.chat.id,
|
@@ -241,7 +240,7 @@ async def get_raw_note(c: Gojo, m: Message, note: str):
|
|
241 |
parse_mode=enums.ParseMode.DISABLED,
|
242 |
reply_to_message_id=msg_id,
|
243 |
)
|
244 |
-
|
245 |
return
|
246 |
|
247 |
|
@@ -267,7 +266,6 @@ async def hash_get(c: Gojo, m: Message):
|
|
267 |
|
268 |
@Gojo.on_message(command("get") & filters.group & ~filters.bot)
|
269 |
async def get_note(c: Gojo, m: Message):
|
270 |
-
|
271 |
if len(m.text.split()) == 2:
|
272 |
priv_notes_status = db_settings.get_privatenotes(m.chat.id)
|
273 |
note = ((m.text.split())[1]).lower()
|
@@ -290,7 +288,6 @@ async def get_note(c: Gojo, m: Message):
|
|
290 |
|
291 |
@Gojo.on_message(command(["privnotes", "privatenotes"]) & admin_filter & ~filters.bot)
|
292 |
async def priv_notes(_, m: Message):
|
293 |
-
|
294 |
chat_id = m.chat.id
|
295 |
if len(m.text.split()) == 2:
|
296 |
option = (m.text.split())[1]
|
@@ -323,9 +320,7 @@ async def local_notes(c: Gojo, m: Message):
|
|
323 |
|
324 |
msg_id = m.reply_to_message.id if m.reply_to_message else m.id
|
325 |
|
326 |
-
curr_pref
|
327 |
-
if curr_pref:
|
328 |
-
|
329 |
pm_kb = ikb(
|
330 |
[
|
331 |
[
|
@@ -355,7 +350,6 @@ async def local_notes(c: Gojo, m: Message):
|
|
355 |
|
356 |
@Gojo.on_message(command("clear") & admin_filter & ~filters.bot)
|
357 |
async def clear_note(_, m: Message):
|
358 |
-
|
359 |
if len(m.text.split()) <= 1:
|
360 |
await m.reply_text("What do you want to clear?")
|
361 |
return
|
@@ -372,7 +366,6 @@ async def clear_note(_, m: Message):
|
|
372 |
|
373 |
@Gojo.on_message(command("clearall") & owner_filter & ~filters.bot)
|
374 |
async def clear_allnote(_, m: Message):
|
375 |
-
|
376 |
all_notes = {i[0] for i in db.get_all_notes(m.chat.id)}
|
377 |
if not all_notes:
|
378 |
await m.reply_text("No notes are there in this chat")
|
|
|
73 |
return
|
74 |
|
75 |
if priv_notes_status:
|
|
|
76 |
note_hash = next(i[1] for i in db.get_all_notes(m.chat.id) if i[0] == note_name)
|
77 |
await reply_text(
|
78 |
f"Click on the button to get the note <code>{note_name}</code>",
|
|
|
149 |
)
|
150 |
return
|
151 |
elif msgtype in (
|
152 |
+
Types.STICKER,
|
153 |
+
Types.VIDEO_NOTE,
|
154 |
+
Types.CONTACT,
|
155 |
+
Types.ANIMATED_STICKER,
|
156 |
):
|
157 |
await (await send_cmd(c, msgtype))(
|
158 |
m.chat.id,
|
|
|
191 |
reply_markup=button,
|
192 |
reply_to_message_id=reply_msg_id,
|
193 |
)
|
194 |
+
|
195 |
except Exception as e:
|
196 |
await m.reply_text(f"Error in notes: {e}")
|
197 |
return
|
|
|
221 |
teks, parse_mode=enums.ParseMode.DISABLED, reply_to_message_id=msg_id
|
222 |
)
|
223 |
elif msgtype in (
|
224 |
+
Types.STICKER,
|
225 |
+
Types.VIDEO_NOTE,
|
226 |
+
Types.CONTACT,
|
227 |
+
Types.ANIMATED_STICKER,
|
228 |
):
|
229 |
await (await send_cmd(c, msgtype))(
|
230 |
m.chat.id,
|
|
|
240 |
parse_mode=enums.ParseMode.DISABLED,
|
241 |
reply_to_message_id=msg_id,
|
242 |
)
|
243 |
+
|
244 |
return
|
245 |
|
246 |
|
|
|
266 |
|
267 |
@Gojo.on_message(command("get") & filters.group & ~filters.bot)
|
268 |
async def get_note(c: Gojo, m: Message):
|
|
|
269 |
if len(m.text.split()) == 2:
|
270 |
priv_notes_status = db_settings.get_privatenotes(m.chat.id)
|
271 |
note = ((m.text.split())[1]).lower()
|
|
|
288 |
|
289 |
@Gojo.on_message(command(["privnotes", "privatenotes"]) & admin_filter & ~filters.bot)
|
290 |
async def priv_notes(_, m: Message):
|
|
|
291 |
chat_id = m.chat.id
|
292 |
if len(m.text.split()) == 2:
|
293 |
option = (m.text.split())[1]
|
|
|
320 |
|
321 |
msg_id = m.reply_to_message.id if m.reply_to_message else m.id
|
322 |
|
323 |
+
if curr_pref := db_settings.get_privatenotes(m.chat.id):
|
|
|
|
|
324 |
pm_kb = ikb(
|
325 |
[
|
326 |
[
|
|
|
350 |
|
351 |
@Gojo.on_message(command("clear") & admin_filter & ~filters.bot)
|
352 |
async def clear_note(_, m: Message):
|
|
|
353 |
if len(m.text.split()) <= 1:
|
354 |
await m.reply_text("What do you want to clear?")
|
355 |
return
|
|
|
366 |
|
367 |
@Gojo.on_message(command("clearall") & owner_filter & ~filters.bot)
|
368 |
async def clear_allnote(_, m: Message):
|
|
|
369 |
all_notes = {i[0] for i in db.get_all_notes(m.chat.id)}
|
370 |
if not all_notes:
|
371 |
await m.reply_text("No notes are there in this chat")
|
Powers/plugins/pin.py
CHANGED
@@ -5,7 +5,7 @@ from pyrogram.errors import ChatAdminRequired, RightForbidden, RPCError
|
|
5 |
from pyrogram.filters import regex
|
6 |
from pyrogram.types import CallbackQuery, Message
|
7 |
|
8 |
-
from Powers import LOGGER
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.pins_db import Pins
|
11 |
from Powers.utils.custom_filters import admin_filter, command
|
@@ -18,15 +18,14 @@ async def pin_message(_, m: Message):
|
|
18 |
pin_args = m.text.split(None, 1)
|
19 |
if m.reply_to_message:
|
20 |
try:
|
21 |
-
disable_notification =
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
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,11 +68,11 @@ async def unpin_message(c: Gojo, m: Message):
|
|
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
|
76 |
-
await c.unpin_chat_message(m.chat.id,m_id)
|
77 |
await m.reply_text(text="Unpinned last pinned message!")
|
78 |
except ChatAdminRequired:
|
79 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
@@ -162,8 +161,6 @@ async def anti_channel_pin(_, m: Message):
|
|
162 |
async def pinned_message(c: Gojo, m: Message):
|
163 |
chat_title = m.chat.title
|
164 |
chat = await c.get_chat(chat_id=m.chat.id)
|
165 |
-
msg_id = m.reply_to_message.id if m.reply_to_message else m.id
|
166 |
-
|
167 |
if chat.pinned_message:
|
168 |
pinned_id = chat.pinned_message.id
|
169 |
if m.chat.username:
|
@@ -173,6 +170,8 @@ async def pinned_message(c: Gojo, m: Message):
|
|
173 |
link_chat_id = (str(m.chat.id)).replace("-100", "")
|
174 |
message_link = f"https://t.me/c/{link_chat_id}/{pinned_id}"
|
175 |
|
|
|
|
|
176 |
await m.reply_text(
|
177 |
f"The pinned message of {escape_html(chat_title)} is [here]({message_link}).",
|
178 |
reply_to_message_id=msg_id,
|
|
|
5 |
from pyrogram.filters import regex
|
6 |
from pyrogram.types import CallbackQuery, Message
|
7 |
|
8 |
+
from Powers import LOGGER
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.pins_db import Pins
|
11 |
from Powers.utils.custom_filters import admin_filter, command
|
|
|
18 |
pin_args = m.text.split(None, 1)
|
19 |
if m.reply_to_message:
|
20 |
try:
|
21 |
+
disable_notification = len(pin_args) < 2 or pin_args[1] not in [
|
22 |
+
"alert",
|
23 |
+
"notify",
|
24 |
+
"loud",
|
25 |
+
]
|
26 |
await m.reply_to_message.pin(
|
27 |
disable_notification=disable_notification,
|
28 |
)
|
|
|
29 |
|
30 |
if m.chat.username:
|
31 |
# If chat has a username, use this format
|
|
|
68 |
try:
|
69 |
if m.reply_to_message:
|
70 |
await m.reply_to_message.unpin()
|
71 |
+
|
72 |
await m.reply_text(text="Unpinned last message.")
|
73 |
else:
|
74 |
m_id = (await c.get_chat(m.chat.id)).pinned_message.id
|
75 |
+
await c.unpin_chat_message(m.chat.id, m_id)
|
76 |
await m.reply_text(text="Unpinned last pinned message!")
|
77 |
except ChatAdminRequired:
|
78 |
await m.reply_text(text="I'm not admin or I don't have rights.")
|
|
|
161 |
async def pinned_message(c: Gojo, m: Message):
|
162 |
chat_title = m.chat.title
|
163 |
chat = await c.get_chat(chat_id=m.chat.id)
|
|
|
|
|
164 |
if chat.pinned_message:
|
165 |
pinned_id = chat.pinned_message.id
|
166 |
if m.chat.username:
|
|
|
170 |
link_chat_id = (str(m.chat.id)).replace("-100", "")
|
171 |
message_link = f"https://t.me/c/{link_chat_id}/{pinned_id}"
|
172 |
|
173 |
+
msg_id = m.reply_to_message.id if m.reply_to_message else m.id
|
174 |
+
|
175 |
await m.reply_text(
|
176 |
f"The pinned message of {escape_html(chat_title)} is [here]({message_link}).",
|
177 |
reply_to_message_id=msg_id,
|
Powers/plugins/purge.py
CHANGED
@@ -4,14 +4,12 @@ from pyrogram.enums import ChatType
|
|
4 |
from pyrogram.errors import MessageDeleteForbidden, RPCError
|
5 |
from pyrogram.types import Message
|
6 |
|
7 |
-
from Powers import SUPPORT_GROUP
|
8 |
from Powers.bot_class import Gojo
|
9 |
from Powers.utils.custom_filters import admin_filter, command
|
10 |
|
11 |
|
12 |
@Gojo.on_message(command("purge") & admin_filter)
|
13 |
async def purge(c: Gojo, m: Message):
|
14 |
-
|
15 |
if m.chat.type != ChatType.SUPERGROUP:
|
16 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
17 |
return
|
@@ -21,7 +19,7 @@ async def purge(c: Gojo, m: Message):
|
|
21 |
|
22 |
def divide_chunks(l: list, n: int = 100):
|
23 |
for i in range(0, len(l), n):
|
24 |
-
yield l[i
|
25 |
|
26 |
# Dielete messages in chunks of 100 messages
|
27 |
m_list = list(divide_chunks(message_ids))
|
@@ -58,7 +56,6 @@ async def purge(c: Gojo, m: Message):
|
|
58 |
|
59 |
@Gojo.on_message(command("spurge") & admin_filter)
|
60 |
async def spurge(c: Gojo, m: Message):
|
61 |
-
|
62 |
if m.chat.type != ChatType.SUPERGROUP:
|
63 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
64 |
return
|
@@ -68,7 +65,7 @@ async def spurge(c: Gojo, m: Message):
|
|
68 |
|
69 |
def divide_chunks(l: list, n: int = 100):
|
70 |
for i in range(0, len(l), n):
|
71 |
-
yield l[i
|
72 |
|
73 |
# Dielete messages in chunks of 100 messages
|
74 |
m_list = list(divide_chunks(message_ids))
|
@@ -101,7 +98,6 @@ async def spurge(c: Gojo, m: Message):
|
|
101 |
command("del") & admin_filter,
|
102 |
)
|
103 |
async def del_msg(c: Gojo, m: Message):
|
104 |
-
|
105 |
if m.chat.type != ChatType.SUPERGROUP:
|
106 |
return
|
107 |
|
|
|
4 |
from pyrogram.errors import MessageDeleteForbidden, RPCError
|
5 |
from pyrogram.types import Message
|
6 |
|
|
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.utils.custom_filters import admin_filter, command
|
9 |
|
10 |
|
11 |
@Gojo.on_message(command("purge") & admin_filter)
|
12 |
async def purge(c: Gojo, m: Message):
|
|
|
13 |
if m.chat.type != ChatType.SUPERGROUP:
|
14 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
15 |
return
|
|
|
19 |
|
20 |
def divide_chunks(l: list, n: int = 100):
|
21 |
for i in range(0, len(l), n):
|
22 |
+
yield l[i: i + n]
|
23 |
|
24 |
# Dielete messages in chunks of 100 messages
|
25 |
m_list = list(divide_chunks(message_ids))
|
|
|
56 |
|
57 |
@Gojo.on_message(command("spurge") & admin_filter)
|
58 |
async def spurge(c: Gojo, m: Message):
|
|
|
59 |
if m.chat.type != ChatType.SUPERGROUP:
|
60 |
await m.reply_text(text="Cannot purge messages in a basic group")
|
61 |
return
|
|
|
65 |
|
66 |
def divide_chunks(l: list, n: int = 100):
|
67 |
for i in range(0, len(l), n):
|
68 |
+
yield l[i: i + n]
|
69 |
|
70 |
# Dielete messages in chunks of 100 messages
|
71 |
m_list = list(divide_chunks(message_ids))
|
|
|
98 |
command("del") & admin_filter,
|
99 |
)
|
100 |
async def del_msg(c: Gojo, m: Message):
|
|
|
101 |
if m.chat.type != ChatType.SUPERGROUP:
|
102 |
return
|
103 |
|
Powers/plugins/report.py
CHANGED
@@ -58,7 +58,6 @@ async def report_setting(_, m: Message):
|
|
58 |
|
59 |
@Gojo.on_message(command("report") & filters.group)
|
60 |
async def report_watcher(c: Gojo, m: Message):
|
61 |
-
|
62 |
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
63 |
return
|
64 |
|
@@ -76,7 +75,7 @@ async def report_watcher(c: Gojo, m: Message):
|
|
76 |
if reported_user.id == me.id:
|
77 |
await m.reply_text("Nice try.")
|
78 |
return
|
79 |
-
|
80 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
81 |
if reported_user.id in SUPPORT_STAFF:
|
82 |
await m.reply_text("Uh? You reporting my support team?")
|
@@ -118,7 +117,6 @@ async def report_watcher(c: Gojo, m: Message):
|
|
118 |
],
|
119 |
)
|
120 |
|
121 |
-
|
122 |
await m.reply_text(
|
123 |
(
|
124 |
f"{(await mention_html(m.from_user.first_name, m.from_user.id))} "
|
@@ -129,7 +127,7 @@ async def report_watcher(c: Gojo, m: Message):
|
|
129 |
|
130 |
async for admin in c.get_chat_members(m.chat.id, filter=cmf.ADMINISTRATORS):
|
131 |
if (
|
132 |
-
|
133 |
): # can't message bots or deleted accounts
|
134 |
continue
|
135 |
if Reporting(admin.user.id).get_settings():
|
|
|
58 |
|
59 |
@Gojo.on_message(command("report") & filters.group)
|
60 |
async def report_watcher(c: Gojo, m: Message):
|
|
|
61 |
if m.chat.type not in [ChatType.SUPERGROUP, ChatType.GROUP]:
|
62 |
return
|
63 |
|
|
|
75 |
if reported_user.id == me.id:
|
76 |
await m.reply_text("Nice try.")
|
77 |
return
|
78 |
+
|
79 |
SUPPORT_STAFF = DEV_USERS.union(SUDO_USERS).union(WHITELIST_USERS)
|
80 |
if reported_user.id in SUPPORT_STAFF:
|
81 |
await m.reply_text("Uh? You reporting my support team?")
|
|
|
117 |
],
|
118 |
)
|
119 |
|
|
|
120 |
await m.reply_text(
|
121 |
(
|
122 |
f"{(await mention_html(m.from_user.first_name, m.from_user.id))} "
|
|
|
127 |
|
128 |
async for admin in c.get_chat_members(m.chat.id, filter=cmf.ADMINISTRATORS):
|
129 |
if (
|
130 |
+
admin.user.is_bot or admin.user.is_deleted
|
131 |
): # can't message bots or deleted accounts
|
132 |
continue
|
133 |
if Reporting(admin.user.id).get_settings():
|
Powers/plugins/rules.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from pyrogram import filters
|
2 |
from pyrogram.types import CallbackQuery, Message
|
3 |
|
4 |
-
from Powers import LOGGER
|
5 |
from Powers.bot_class import Gojo
|
6 |
from Powers.database.rules_db import Rules
|
7 |
from Powers.utils.custom_filters import admin_filter, command
|
@@ -25,9 +24,7 @@ async def get_rules(c: Gojo, m: Message):
|
|
25 |
)
|
26 |
return
|
27 |
|
28 |
-
priv_rules_status
|
29 |
-
|
30 |
-
if priv_rules_status:
|
31 |
pm_kb = ikb(
|
32 |
[
|
33 |
[
|
@@ -76,7 +73,7 @@ async def set_rules(_, m: Message):
|
|
76 |
return await m.reply_text("Provide some text to set as rules !!")
|
77 |
|
78 |
if len(rules) > 4000:
|
79 |
-
rules = rules[
|
80 |
await m.reply_text("Rules are truncated to 3950 characters!")
|
81 |
|
82 |
db.set_rules(rules)
|
|
|
1 |
from pyrogram import filters
|
2 |
from pyrogram.types import CallbackQuery, Message
|
3 |
|
|
|
4 |
from Powers.bot_class import Gojo
|
5 |
from Powers.database.rules_db import Rules
|
6 |
from Powers.utils.custom_filters import admin_filter, command
|
|
|
24 |
)
|
25 |
return
|
26 |
|
27 |
+
if priv_rules_status := db.get_privrules():
|
|
|
|
|
28 |
pm_kb = ikb(
|
29 |
[
|
30 |
[
|
|
|
73 |
return await m.reply_text("Provide some text to set as rules !!")
|
74 |
|
75 |
if len(rules) > 4000:
|
76 |
+
rules = rules[:3949]
|
77 |
await m.reply_text("Rules are truncated to 3950 characters!")
|
78 |
|
79 |
db.set_rules(rules)
|
Powers/plugins/scheduled_jobs.py
CHANGED
@@ -16,13 +16,15 @@ from pyrogram.enums import ChatMemberStatus
|
|
16 |
from Powers.utils.extras import birthday_wish
|
17 |
|
18 |
|
19 |
-
def give_date(date,form
|
20 |
-
|
21 |
-
|
22 |
|
23 |
scheduler = AsyncIOScheduler()
|
24 |
scheduler.timezone = TIME_ZONE
|
25 |
-
scheduler_time = time(0,0,0)
|
|
|
|
|
26 |
async def send_wishish(JJK: Client):
|
27 |
c_list = Chats.list_chats_by_id()
|
28 |
blist = list(bday_info.find())
|
@@ -38,16 +40,16 @@ async def send_wishish(JJK: Client):
|
|
38 |
agee = ""
|
39 |
if i["is_year"]:
|
40 |
agee = curr.year - dob.year
|
41 |
-
|
42 |
-
if int(agee/10) == 1:
|
43 |
suf = "th"
|
44 |
else:
|
45 |
-
suffix
|
|
|
46 |
agee = f"{agee}{suf}"
|
47 |
-
U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
|
48 |
wish = choice(birthday_wish)
|
49 |
-
if U.status in [ChatMemberStatus.MEMBER,ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
50 |
-
xXx = await JJK.send_message(j,f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
|
51 |
try:
|
52 |
await xXx.pin()
|
53 |
except Exception:
|
@@ -55,6 +57,7 @@ async def send_wishish(JJK: Client):
|
|
55 |
except Exception:
|
56 |
pass
|
57 |
|
|
|
58 |
""""
|
59 |
from datetime import date, datetime
|
60 |
|
@@ -72,4 +75,3 @@ else:
|
|
72 |
print(days_left)
|
73 |
print(x.year - timm.year)
|
74 |
"""
|
75 |
-
|
|
|
16 |
from Powers.utils.extras import birthday_wish
|
17 |
|
18 |
|
19 |
+
def give_date(date, form="%d/%m/%Y"):
|
20 |
+
return datetime.strptime(date, form).date()
|
21 |
+
|
22 |
|
23 |
scheduler = AsyncIOScheduler()
|
24 |
scheduler.timezone = TIME_ZONE
|
25 |
+
scheduler_time = time(0, 0, 0)
|
26 |
+
|
27 |
+
|
28 |
async def send_wishish(JJK: Client):
|
29 |
c_list = Chats.list_chats_by_id()
|
30 |
blist = list(bday_info.find())
|
|
|
40 |
agee = ""
|
41 |
if i["is_year"]:
|
42 |
agee = curr.year - dob.year
|
43 |
+
if int(agee / 10) == 1:
|
|
|
44 |
suf = "th"
|
45 |
else:
|
46 |
+
suffix = {1: 'st', 2: 'nd', 3: 'rd'}
|
47 |
+
suffix.get((agee % 10), "th")
|
48 |
agee = f"{agee}{suf}"
|
49 |
+
U = await JJK.get_chat_member(chat_id=j, user_id=i["user_id"])
|
50 |
wish = choice(birthday_wish)
|
51 |
+
if U.status in [ChatMemberStatus.MEMBER, ChatMemberStatus.ADMINISTRATOR, ChatMemberStatus.OWNER]:
|
52 |
+
xXx = await JJK.send_message(j, f"Happy {agee} birthday {U.user.mention}🥳\n{wish}")
|
53 |
try:
|
54 |
await xXx.pin()
|
55 |
except Exception:
|
|
|
57 |
except Exception:
|
58 |
pass
|
59 |
|
60 |
+
|
61 |
""""
|
62 |
from datetime import date, datetime
|
63 |
|
|
|
75 |
print(days_left)
|
76 |
print(x.year - timm.year)
|
77 |
"""
|
|
Powers/plugins/search.py
CHANGED
@@ -14,12 +14,13 @@ from Powers.utils.custom_filters import command
|
|
14 |
from Powers.utils.http_helper import *
|
15 |
from Powers.utils.kbhelpers import ikb
|
16 |
|
17 |
-
#have to add youtube
|
18 |
|
19 |
gsearch = GoogleSearch()
|
20 |
anisearch = AnimeSearch()
|
21 |
stsearch = StackSearch()
|
22 |
|
|
|
23 |
@Gojo.on_message(command('google'))
|
24 |
async def g_search(c: Gojo, m: Message):
|
25 |
split = m.text.split(None, 1)
|
@@ -157,6 +158,7 @@ async def anime_search(c: Gojo, m: Message):
|
|
157 |
LOGGER.error(format_exc())
|
158 |
return
|
159 |
|
|
|
160 |
@Gojo.on_message(command('stack'))
|
161 |
async def stack_search(c: Gojo, m: Message):
|
162 |
split = m.text.split(None, 1)
|
@@ -233,17 +235,15 @@ async def getText(message: Message):
|
|
233 |
text_to_return = message.text
|
234 |
if message.text is None:
|
235 |
return None
|
236 |
-
if " " in text_to_return:
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
except Exception:
|
242 |
-
return None
|
243 |
-
else:
|
244 |
return None
|
245 |
|
246 |
-
|
|
|
247 |
async def get_image_search(_, m: Message):
|
248 |
# Credits: https://t.me/NovaXMod
|
249 |
# https://t.me/NovaXMod/98
|
@@ -258,17 +258,15 @@ async def get_image_search(_, m: Message):
|
|
258 |
return
|
259 |
image_urls = resp.get("image_urls", [])[:10]
|
260 |
ab = await m.reply_text("Getting Your Images... Wait A Min..\nCredits: @NovaXMod")
|
261 |
-
Ok = []
|
262 |
-
for a in image_urls:
|
263 |
-
Ok.append(InputMediaPhoto(a))
|
264 |
try:
|
265 |
await m.reply_media_group(media=Ok)
|
266 |
await ab.delete()
|
267 |
except Exception:
|
268 |
await ab.edit("Error occurred while sending images. Please try again.")
|
269 |
|
270 |
-
__PLUGIN__ = "search"
|
271 |
|
|
|
272 |
|
273 |
__alt_name__ = [
|
274 |
"google",
|
|
|
14 |
from Powers.utils.http_helper import *
|
15 |
from Powers.utils.kbhelpers import ikb
|
16 |
|
17 |
+
# have to add youtube
|
18 |
|
19 |
gsearch = GoogleSearch()
|
20 |
anisearch = AnimeSearch()
|
21 |
stsearch = StackSearch()
|
22 |
|
23 |
+
|
24 |
@Gojo.on_message(command('google'))
|
25 |
async def g_search(c: Gojo, m: Message):
|
26 |
split = m.text.split(None, 1)
|
|
|
158 |
LOGGER.error(format_exc())
|
159 |
return
|
160 |
|
161 |
+
|
162 |
@Gojo.on_message(command('stack'))
|
163 |
async def stack_search(c: Gojo, m: Message):
|
164 |
split = m.text.split(None, 1)
|
|
|
235 |
text_to_return = message.text
|
236 |
if message.text is None:
|
237 |
return None
|
238 |
+
if " " not in text_to_return:
|
239 |
+
return None
|
240 |
+
try:
|
241 |
+
return message.text.split(None, 1)[1]
|
242 |
+
except Exception:
|
|
|
|
|
|
|
243 |
return None
|
244 |
|
245 |
+
|
246 |
+
@Gojo.on_message(command(["images", "imgs"]))
|
247 |
async def get_image_search(_, m: Message):
|
248 |
# Credits: https://t.me/NovaXMod
|
249 |
# https://t.me/NovaXMod/98
|
|
|
258 |
return
|
259 |
image_urls = resp.get("image_urls", [])[:10]
|
260 |
ab = await m.reply_text("Getting Your Images... Wait A Min..\nCredits: @NovaXMod")
|
261 |
+
Ok = [InputMediaPhoto(a) for a in image_urls]
|
|
|
|
|
262 |
try:
|
263 |
await m.reply_media_group(media=Ok)
|
264 |
await ab.delete()
|
265 |
except Exception:
|
266 |
await ab.edit("Error occurred while sending images. Please try again.")
|
267 |
|
|
|
268 |
|
269 |
+
__PLUGIN__ = "search"
|
270 |
|
271 |
__alt_name__ = [
|
272 |
"google",
|
Powers/plugins/start.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import os
|
2 |
from random import choice
|
3 |
from time import gmtime, strftime, time
|
4 |
|
@@ -67,14 +66,13 @@ async def close_admin_callback(_, q: CallbackQuery):
|
|
67 |
command("start") & (filters.group | filters.private),
|
68 |
)
|
69 |
async def start(c: Gojo, m: Message):
|
70 |
-
|
71 |
if m.chat.type == ChatType.PRIVATE:
|
72 |
if len(m.text.strip().split()) > 1:
|
73 |
arg = m.text.split(None, 1)[1]
|
74 |
help_option = arg.lower()
|
75 |
|
76 |
if help_option.startswith("note") and (
|
77 |
-
|
78 |
):
|
79 |
await get_private_note(c, m, help_option)
|
80 |
return
|
@@ -127,13 +125,13 @@ async def start(c: Gojo, m: Message):
|
|
127 |
]
|
128 |
]
|
129 |
)
|
130 |
-
except:
|
131 |
chat_ = False
|
132 |
kb = None
|
133 |
await m.reply_text("You can now talk in the chat", reply_markup=kb)
|
134 |
try:
|
135 |
await c.delete_messages(chat, msg)
|
136 |
-
except:
|
137 |
pass
|
138 |
return
|
139 |
except Exception:
|
@@ -229,7 +227,7 @@ You can use {", ".join(PREFIX_HANDLER)} as your prefix handler
|
|
229 |
@Gojo.on_message(command("help"))
|
230 |
async def help_menu(c: Gojo, m: Message):
|
231 |
if len(m.text.split()) >= 2:
|
232 |
-
textt = m.text.replace(" ", "_",).replace("_", " ", 1)
|
233 |
help_option = (textt.split(None)[1]).lower()
|
234 |
help_msg, help_kb = await get_help_msg(c, m, help_option)
|
235 |
|
@@ -299,7 +297,7 @@ Commands available:
|
|
299 |
return
|
300 |
|
301 |
|
302 |
-
async def get_divided_msg(plugin_name: str, page:int=1, back_to_do
|
303 |
msg = HELP_COMMANDS[plugin_name]["help_msg"]
|
304 |
msg = msg.split("\n")
|
305 |
l = len(msg)
|
@@ -313,7 +311,10 @@ async def get_divided_msg(plugin_name: str, page:int=1, back_to_do = None):
|
|
313 |
new_msg += f"{i}\n"
|
314 |
kb = [
|
315 |
[
|
316 |
-
(
|
|
|
|
|
|
|
317 |
]
|
318 |
]
|
319 |
else:
|
@@ -323,32 +324,38 @@ async def get_divided_msg(plugin_name: str, page:int=1, back_to_do = None):
|
|
323 |
new_msg += f"{i}\n"
|
324 |
kb = [
|
325 |
[
|
326 |
-
(
|
|
|
|
|
|
|
327 |
]
|
328 |
]
|
329 |
else:
|
330 |
for i in msg[first:last]:
|
331 |
new_msg += f"{i}\n"
|
332 |
kb = [
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
|
|
|
|
|
|
|
|
|
|
337 |
]
|
338 |
-
|
339 |
-
|
340 |
-
else:
|
341 |
-
kb = ikb(kb)
|
342 |
-
|
343 |
return new_msg, kb
|
344 |
-
|
|
|
345 |
@Gojo.on_callback_query(filters.regex(r"^iter_page_.*[0-9]$"))
|
346 |
async def helppp_page_iter(c: Gojo, q: CallbackQuery):
|
347 |
data = q.data.split("_")
|
348 |
plugin_ = data[2]
|
349 |
try:
|
350 |
back_to = data[-2]
|
351 |
-
except:
|
352 |
back_to = None
|
353 |
curr_page = int(data[-1])
|
354 |
msg, kb = await get_divided_msg(plugin_, curr_page, back_to_do=back_to)
|
@@ -420,7 +427,7 @@ async def give_bot_staffs(c: Gojo, q: CallbackQuery):
|
|
420 |
pass
|
421 |
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
422 |
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
423 |
-
if true_sudo
|
424 |
reply += "No Sudo Users\n"
|
425 |
else:
|
426 |
for each_user in true_sudo:
|
@@ -442,7 +449,8 @@ async def give_bot_staffs(c: Gojo, q: CallbackQuery):
|
|
442 |
except RPCError:
|
443 |
pass
|
444 |
|
445 |
-
await q.edit_message_caption(reply,
|
|
|
446 |
return
|
447 |
|
448 |
|
|
|
|
|
1 |
from random import choice
|
2 |
from time import gmtime, strftime, time
|
3 |
|
|
|
66 |
command("start") & (filters.group | filters.private),
|
67 |
)
|
68 |
async def start(c: Gojo, m: Message):
|
|
|
69 |
if m.chat.type == ChatType.PRIVATE:
|
70 |
if len(m.text.strip().split()) > 1:
|
71 |
arg = m.text.split(None, 1)[1]
|
72 |
help_option = arg.lower()
|
73 |
|
74 |
if help_option.startswith("note") and (
|
75 |
+
help_option not in ("note", "notes")
|
76 |
):
|
77 |
await get_private_note(c, m, help_option)
|
78 |
return
|
|
|
125 |
]
|
126 |
]
|
127 |
)
|
128 |
+
except Exception:
|
129 |
chat_ = False
|
130 |
kb = None
|
131 |
await m.reply_text("You can now talk in the chat", reply_markup=kb)
|
132 |
try:
|
133 |
await c.delete_messages(chat, msg)
|
134 |
+
except Exception:
|
135 |
pass
|
136 |
return
|
137 |
except Exception:
|
|
|
227 |
@Gojo.on_message(command("help"))
|
228 |
async def help_menu(c: Gojo, m: Message):
|
229 |
if len(m.text.split()) >= 2:
|
230 |
+
textt = m.text.replace(" ", "_", ).replace("_", " ", 1)
|
231 |
help_option = (textt.split(None)[1]).lower()
|
232 |
help_msg, help_kb = await get_help_msg(c, m, help_option)
|
233 |
|
|
|
297 |
return
|
298 |
|
299 |
|
300 |
+
async def get_divided_msg(plugin_name: str, page: int = 1, back_to_do=None):
|
301 |
msg = HELP_COMMANDS[plugin_name]["help_msg"]
|
302 |
msg = msg.split("\n")
|
303 |
l = len(msg)
|
|
|
311 |
new_msg += f"{i}\n"
|
312 |
kb = [
|
313 |
[
|
314 |
+
(
|
315 |
+
"Next page ▶️",
|
316 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page + 1}",
|
317 |
+
)
|
318 |
]
|
319 |
]
|
320 |
else:
|
|
|
324 |
new_msg += f"{i}\n"
|
325 |
kb = [
|
326 |
[
|
327 |
+
(
|
328 |
+
"◀️ Previous page",
|
329 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page - 1}",
|
330 |
+
)
|
331 |
]
|
332 |
]
|
333 |
else:
|
334 |
for i in msg[first:last]:
|
335 |
new_msg += f"{i}\n"
|
336 |
kb = [
|
337 |
+
[
|
338 |
+
(
|
339 |
+
"◀️ Previous page",
|
340 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page - 1}",
|
341 |
+
),
|
342 |
+
(
|
343 |
+
"Next page ▶️",
|
344 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page + 1}",
|
345 |
+
),
|
346 |
]
|
347 |
+
]
|
348 |
+
kb = ikb(kb, True, back_to_do) if back_to_do else ikb(kb)
|
|
|
|
|
|
|
349 |
return new_msg, kb
|
350 |
+
|
351 |
+
|
352 |
@Gojo.on_callback_query(filters.regex(r"^iter_page_.*[0-9]$"))
|
353 |
async def helppp_page_iter(c: Gojo, q: CallbackQuery):
|
354 |
data = q.data.split("_")
|
355 |
plugin_ = data[2]
|
356 |
try:
|
357 |
back_to = data[-2]
|
358 |
+
except Exception:
|
359 |
back_to = None
|
360 |
curr_page = int(data[-1])
|
361 |
msg, kb = await get_divided_msg(plugin_, curr_page, back_to_do=back_to)
|
|
|
427 |
pass
|
428 |
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
429 |
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
430 |
+
if not true_sudo:
|
431 |
reply += "No Sudo Users\n"
|
432 |
else:
|
433 |
for each_user in true_sudo:
|
|
|
449 |
except RPCError:
|
450 |
pass
|
451 |
|
452 |
+
await q.edit_message_caption(reply,
|
453 |
+
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("« Back", "start_back")]]))
|
454 |
return
|
455 |
|
456 |
|
Powers/plugins/stats.py
CHANGED
@@ -67,6 +67,6 @@ async def get_stats(c: Gojo, m: Message):
|
|
67 |
)
|
68 |
try:
|
69 |
await replymsg.edit_text(rply, parse_mode=enums.ParseMode.HTML)
|
70 |
-
except:
|
71 |
await c.send_message(m.chat.id, rply, parse_mode=enums.ParseMode.HTML)
|
72 |
return
|
|
|
67 |
)
|
68 |
try:
|
69 |
await replymsg.edit_text(rply, parse_mode=enums.ParseMode.HTML)
|
70 |
+
except Exception:
|
71 |
await c.send_message(m.chat.id, rply, parse_mode=enums.ParseMode.HTML)
|
72 |
return
|
Powers/plugins/stickers.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
import os
|
2 |
from random import choice
|
3 |
from traceback import format_exc
|
4 |
|
@@ -13,19 +12,15 @@ from pyrogram.types import InlineKeyboardMarkup as IKM
|
|
13 |
from pyrogram.types import Message
|
14 |
|
15 |
from Powers import LOGGER
|
16 |
-
from Powers.bot_class import Gojo
|
17 |
from Powers.utils.custom_filters import command
|
18 |
from Powers.utils.sticker_help import *
|
19 |
from Powers.utils.string import encode_decode
|
20 |
from Powers.utils.web_helpers import get_file_size
|
21 |
|
22 |
|
23 |
-
@Gojo.on_message(command(["stickerinfo","stinfo"]))
|
24 |
-
async def give_st_info(c: Gojo
|
25 |
-
if not m.reply_to_message:
|
26 |
-
await m.reply_text("Reply to a sticker")
|
27 |
-
return
|
28 |
-
elif not m.reply_to_message.sticker:
|
29 |
await m.reply_text("Reply to a sticker")
|
30 |
return
|
31 |
st_in = m.reply_to_message.sticker
|
@@ -44,15 +39,13 @@ Emoji : {st_in.emoji}
|
|
44 |
Pack name : {st_in.set_name}
|
45 |
"""
|
46 |
kb = IKM([[IKB("➕ Add sticker to pack", url=f"https://t.me/addstickers/{st_in.set_name}")]])
|
47 |
-
await m.reply_text(st_to_gib,reply_markup=kb)
|
48 |
return
|
49 |
|
50 |
-
|
|
|
51 |
async def sticker_id_gib(c: Gojo, m: Message):
|
52 |
-
if not m.reply_to_message:
|
53 |
-
await m.reply_text("Reply to a sticker")
|
54 |
-
return
|
55 |
-
elif not m.reply_to_message.sticker:
|
56 |
await m.reply_text("Reply to a sticker")
|
57 |
return
|
58 |
st_in = m.reply_to_message.sticker
|
@@ -61,18 +54,22 @@ async def sticker_id_gib(c: Gojo, m: Message):
|
|
61 |
|
62 |
|
63 |
@Gojo.on_message(command(["kang", "steal"]))
|
64 |
-
async def kang(c:Gojo, m: Message):
|
65 |
if not m.reply_to_message:
|
66 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
67 |
-
elif not (m.reply_to_message.animation or m.reply_to_message.sticker or m.reply_to_message.photo or (
|
|
|
68 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
69 |
if not m.from_user:
|
70 |
return await m.reply_text("You are anon admin, kang stickers in my pm.")
|
71 |
msg = await m.reply_text("Kanging Sticker..")
|
72 |
-
is_requ =
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
|
|
76 |
# Find the proper emoji
|
77 |
args = m.text.split()
|
78 |
if len(args) > 1:
|
@@ -81,23 +78,38 @@ async def kang(c:Gojo, m: Message):
|
|
81 |
try:
|
82 |
sticker_emoji = m.reply_to_message.sticker.emoji
|
83 |
if not sticker_emoji:
|
84 |
-
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂",
|
|
|
|
|
|
|
|
|
85 |
sticker_emoji = choice(ran)
|
86 |
except Exception:
|
87 |
-
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹",
|
|
|
|
|
|
|
|
|
88 |
sticker_emoji = choice(ran)
|
89 |
else:
|
90 |
edit = await msg.reply_text("No emoji provided choosing a random emoji")
|
91 |
-
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺",
|
|
|
|
|
|
|
|
|
92 |
sticker_emoji = choice(ran)
|
93 |
await edit.delete()
|
94 |
await msg.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
|
95 |
|
96 |
# Get the corresponding fileid, resize the file if necessary
|
97 |
try:
|
98 |
-
if is_requ or m.reply_to_message.animation or m.reply_to_message.video or m.reply_to_message.photo or (
|
|
|
|
|
99 |
# telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
|
100 |
-
if m.reply_to_message.animation or m.reply_to_message.video or (
|
|
|
101 |
path = await Vsticker(c, m.reply_to_message)
|
102 |
SIZE = os.path.getsize(path)
|
103 |
if SIZE > 261120:
|
@@ -105,7 +117,7 @@ async def kang(c:Gojo, m: Message):
|
|
105 |
os.remove(path)
|
106 |
return
|
107 |
elif is_requ:
|
108 |
-
path = await m.reply_to_message.download()
|
109 |
else:
|
110 |
sizee = (await get_file_size(m.reply_to_message)).split()
|
111 |
if (sizee[1] == "mb" and int(sizee[0]) > 10) or sizee[1] == "gb":
|
@@ -120,7 +132,7 @@ async def kang(c:Gojo, m: Message):
|
|
120 |
sticker_emoji
|
121 |
)
|
122 |
os.remove(path)
|
123 |
-
elif m.reply_to_message.sticker
|
124 |
sticker = await create_sticker(
|
125 |
await get_document_from_file_id(
|
126 |
m.reply_to_message.sticker.file_id
|
@@ -128,8 +140,8 @@ async def kang(c:Gojo, m: Message):
|
|
128 |
sticker_emoji
|
129 |
)
|
130 |
else:
|
131 |
-
|
132 |
-
|
133 |
except ShortnameOccupyFailed:
|
134 |
await m.reply_text("Change Your Name Or Username")
|
135 |
return
|
@@ -151,11 +163,12 @@ async def kang(c:Gojo, m: Message):
|
|
151 |
try:
|
152 |
while not packname_found:
|
153 |
packname = f"CE{m.from_user.id}{packnum}_by_{c.me.username}"
|
154 |
-
kangpack = f"{
|
155 |
-
if limit >= 50:
|
156 |
-
await m.reply_text(
|
|
|
157 |
return
|
158 |
-
sticker_set = await get_sticker_set_by_name(c,packname)
|
159 |
if not sticker_set:
|
160 |
try:
|
161 |
sticker_set = await create_sticker_set(
|
@@ -173,14 +186,14 @@ async def kang(c:Gojo, m: Message):
|
|
173 |
volume += 1
|
174 |
continue
|
175 |
try:
|
176 |
-
await add_sticker_to_set(c,sticker_set,sticker)
|
177 |
packname_found = True
|
178 |
except StickerEmojiInvalid:
|
179 |
return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
|
180 |
kb = IKM(
|
181 |
[
|
182 |
[
|
183 |
-
IKB("➕ Add Pack ➕",url=f"t.me/addstickers/{packname}")
|
184 |
]
|
185 |
]
|
186 |
)
|
@@ -219,34 +232,36 @@ async def kang(c:Gojo, m: Message):
|
|
219 |
LOGGER.error(format_exc())
|
220 |
return
|
221 |
|
|
|
222 |
@Gojo.on_message(command(["rmsticker", "removesticker"]))
|
223 |
async def remove_sticker_from_pack(c: Gojo, m: Message):
|
224 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
225 |
return await m.reply_text(
|
226 |
"Reply to a sticker to remove it from the pack."
|
227 |
)
|
228 |
-
|
229 |
sticker = m.reply_to_message.sticker
|
230 |
|
231 |
-
to_modify = await m.reply_text(
|
232 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
233 |
|
234 |
if not sticker_set:
|
235 |
await to_modify.edit_text("This sticker is not part for your pack")
|
236 |
return
|
237 |
-
|
238 |
try:
|
239 |
await remove_sticker(c, sticker.file_id)
|
240 |
-
await to_modify.edit_text(
|
|
|
241 |
except Exception as e:
|
242 |
await to_modify.delete()
|
243 |
await m.reply_text(f"Failed to remove sticker due to:\n{e}\nPlease report this bug using `/bug`")
|
244 |
LOGGER.error(e)
|
245 |
LOGGER.error(format_exc())
|
246 |
return
|
247 |
-
|
248 |
|
249 |
-
|
|
|
250 |
async def memify_it(c: Gojo, m: Message):
|
251 |
if not m.reply_to_message:
|
252 |
await m.reply_text("Invalid type.")
|
@@ -261,7 +276,7 @@ async def memify_it(c: Gojo, m: Message):
|
|
261 |
kb = IKM(
|
262 |
[
|
263 |
[
|
264 |
-
IKB("Join for memes",url="https://t.me/memesofdank")
|
265 |
]
|
266 |
]
|
267 |
)
|
@@ -269,21 +284,16 @@ async def memify_it(c: Gojo, m: Message):
|
|
269 |
await m.reply_text("Give me something to write")
|
270 |
return
|
271 |
filll = m.command[0][-1]
|
272 |
-
if filll == "b"
|
273 |
-
fiil = "black"
|
274 |
-
else:
|
275 |
-
fiil = "white"
|
276 |
x = await m.reply_text("Memifying...")
|
277 |
-
meme = m.text.split(None,1)[1].strip()
|
278 |
name = f"@memesofdank_{m.id}.png"
|
279 |
path = await rep_to.download(name)
|
280 |
-
is_sticker =
|
281 |
-
|
282 |
-
is_sticker = True
|
283 |
-
output = await draw_meme(path,meme,is_sticker,fiil)
|
284 |
await x.delete()
|
285 |
-
xNx = await m.reply_photo(output[0],reply_markup=kb)
|
286 |
-
await xNx.reply_sticker(output[1],reply_markup=kb)
|
287 |
try:
|
288 |
os.remove(output[0])
|
289 |
os.remove(output[1])
|
@@ -292,63 +302,72 @@ async def memify_it(c: Gojo, m: Message):
|
|
292 |
LOGGER.error(format_exc())
|
293 |
return
|
294 |
|
295 |
-
|
|
|
296 |
async def get_sticker_from_file(c: Gojo, m: Message):
|
297 |
Caption = f"Converted by:\n@{c.me.username}"
|
298 |
repl = m.reply_to_message
|
299 |
if not repl:
|
300 |
await m.reply_text("Reply to a sticker or file")
|
301 |
return
|
302 |
-
|
303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
await m.reply_text("I only support conversion of plain stickers, images, videos and animation for now")
|
305 |
return
|
306 |
-
|
307 |
-
|
|
|
|
|
|
|
308 |
x = await m.reply_text("Converting...")
|
309 |
if repl.sticker:
|
310 |
if repl.sticker.is_animated:
|
311 |
upp = await repl.download()
|
312 |
-
up = tgs_to_gif(upp,True)
|
313 |
await x.delete()
|
314 |
-
await m.reply_animation(up,caption=Caption)
|
315 |
-
os.remove(up)
|
316 |
-
return
|
317 |
elif repl.sticker.is_video:
|
318 |
upp = await repl.download()
|
319 |
up = await webm_to_gif(upp)
|
320 |
await x.delete()
|
321 |
-
await m.reply_animation(up,caption=Caption)
|
322 |
-
os.remove(up)
|
323 |
-
return
|
324 |
else:
|
325 |
upp = await repl.download()
|
326 |
-
up = toimage(upp,is_direc=True)
|
327 |
await x.delete()
|
328 |
await m.reply_document(up, caption=Caption)
|
329 |
-
|
330 |
-
|
331 |
elif repl.photo:
|
332 |
upp = await repl.download()
|
333 |
-
up = tosticker(upp,is_direc=True)
|
334 |
await x.delete()
|
335 |
await m.reply_sticker(up)
|
336 |
os.remove(up)
|
337 |
return
|
338 |
-
|
339 |
elif to_vid:
|
340 |
-
up = await Vsticker(c,repl)
|
341 |
await x.delete()
|
342 |
await m.reply_sticker(up)
|
343 |
os.remove(up)
|
344 |
return
|
345 |
|
|
|
346 |
@Gojo.on_message(command(["rmsticker", "rmst", "removesticker"]))
|
347 |
async def remove_from_MY_pack(c: Gojo, m: Message):
|
348 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
349 |
await m.reply_text("Please reply to a sticker to remove it from your pack")
|
350 |
return
|
351 |
-
|
352 |
sticker = m.reply_to_message.sticker
|
353 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
354 |
|
@@ -366,10 +385,11 @@ async def remove_from_MY_pack(c: Gojo, m: Message):
|
|
366 |
LOGGER.error(format_exc(e))
|
367 |
return
|
368 |
|
|
|
369 |
@Gojo.on_message(command(["getmypacks", "mypacks", "mysets", "stickerset", "stset"]))
|
370 |
async def get_my_sticker_sets(c: Gojo, m: Message):
|
371 |
to_del = await m.reply_text("Please wait while I fetch all the sticker set I have created for you.")
|
372 |
-
|
373 |
txt, kb = await get_all_sticker_packs(c, m.from_user.id)
|
374 |
|
375 |
await to_del.delete()
|
@@ -378,6 +398,7 @@ async def get_my_sticker_sets(c: Gojo, m: Message):
|
|
378 |
return
|
379 |
await m.reply_text(txt, reply_markup=kb)
|
380 |
|
|
|
381 |
@Gojo.on_message(command(["q", "ss"]))
|
382 |
async def quote_the_msg(_, m: Message):
|
383 |
if not m.reply_to_message:
|
@@ -386,12 +407,9 @@ async def quote_the_msg(_, m: Message):
|
|
386 |
|
387 |
to_edit = await m.reply_text("Genrating quote...")
|
388 |
|
389 |
-
msg_data = []
|
390 |
if len(m.command) > 1 and m.command[1].lower() == "r":
|
391 |
reply_msg = m.reply_to_message.reply_to_message
|
392 |
-
if not reply_msg:
|
393 |
-
reply_message = {}
|
394 |
-
elif reply_msg and not reply_msg.text:
|
395 |
reply_message = {}
|
396 |
else:
|
397 |
to_edit = await to_edit.edit_text("Genrating quote with reply to the message...")
|
@@ -415,7 +433,7 @@ async def quote_the_msg(_, m: Message):
|
|
415 |
if m.reply_to_message.from_user.emoji_status:
|
416 |
emoji_status = str(m.reply_to_message.from_user.emoji_status.custom_emoji_id)
|
417 |
|
418 |
-
msg_data
|
419 |
{
|
420 |
"entities": get_msg_entities(m.reply_to_message),
|
421 |
"avatar": True,
|
@@ -427,8 +445,7 @@ async def quote_the_msg(_, m: Message):
|
|
427 |
"text": m.reply_to_message.text,
|
428 |
"replyMessage": reply_message,
|
429 |
}
|
430 |
-
|
431 |
-
|
432 |
status, path = quotify(msg_data)
|
433 |
|
434 |
if not status:
|
@@ -439,26 +456,27 @@ async def quote_the_msg(_, m: Message):
|
|
439 |
await to_edit.delete()
|
440 |
os.remove(path)
|
441 |
|
|
|
442 |
@Gojo.on_callback_query(filters.regex(r"^stickers_.*"))
|
443 |
async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
444 |
data = q.data.split("_")
|
445 |
decoded = await encode_decode(data[-1], "decode")
|
446 |
user = int(decoded.split("_")[-1])
|
447 |
-
offset = int(decoded.split("_")[0])
|
448 |
-
|
449 |
if q.from_user.id != user:
|
450 |
await q.answer("This is not for you")
|
451 |
-
return
|
452 |
else:
|
|
|
|
|
453 |
txt, kb = await get_all_sticker_packs(c, q.from_user.id, offset)
|
454 |
if not txt:
|
455 |
await q.answer("No sticker pack found....")
|
456 |
-
return
|
457 |
else:
|
458 |
-
await q.answer(
|
459 |
await q.edit_message_text(txt, reply_markup=kb)
|
460 |
-
|
461 |
-
|
|
|
|
|
462 |
__PLUGIN__ = "sticker"
|
463 |
__alt_name__ = [
|
464 |
"sticker",
|
|
|
|
|
1 |
from random import choice
|
2 |
from traceback import format_exc
|
3 |
|
|
|
12 |
from pyrogram.types import Message
|
13 |
|
14 |
from Powers import LOGGER
|
|
|
15 |
from Powers.utils.custom_filters import command
|
16 |
from Powers.utils.sticker_help import *
|
17 |
from Powers.utils.string import encode_decode
|
18 |
from Powers.utils.web_helpers import get_file_size
|
19 |
|
20 |
|
21 |
+
@Gojo.on_message(command(["stickerinfo", "stinfo"]))
|
22 |
+
async def give_st_info(c: Gojo, m: Message):
|
23 |
+
if not m.reply_to_message or not m.reply_to_message.sticker:
|
|
|
|
|
|
|
24 |
await m.reply_text("Reply to a sticker")
|
25 |
return
|
26 |
st_in = m.reply_to_message.sticker
|
|
|
39 |
Pack name : {st_in.set_name}
|
40 |
"""
|
41 |
kb = IKM([[IKB("➕ Add sticker to pack", url=f"https://t.me/addstickers/{st_in.set_name}")]])
|
42 |
+
await m.reply_text(st_to_gib, reply_markup=kb)
|
43 |
return
|
44 |
|
45 |
+
|
46 |
+
@Gojo.on_message(command(["stickerid", "stid"]))
|
47 |
async def sticker_id_gib(c: Gojo, m: Message):
|
48 |
+
if not m.reply_to_message or not m.reply_to_message.sticker:
|
|
|
|
|
|
|
49 |
await m.reply_text("Reply to a sticker")
|
50 |
return
|
51 |
st_in = m.reply_to_message.sticker
|
|
|
54 |
|
55 |
|
56 |
@Gojo.on_message(command(["kang", "steal"]))
|
57 |
+
async def kang(c: Gojo, m: Message):
|
58 |
if not m.reply_to_message:
|
59 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
60 |
+
elif not (m.reply_to_message.animation or m.reply_to_message.sticker or m.reply_to_message.photo or (
|
61 |
+
m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] in ["image", "video"])):
|
62 |
return await m.reply_text("Reply to a sticker or image to kang it.")
|
63 |
if not m.from_user:
|
64 |
return await m.reply_text("You are anon admin, kang stickers in my pm.")
|
65 |
msg = await m.reply_text("Kanging Sticker..")
|
66 |
+
is_requ = bool(
|
67 |
+
m.reply_to_message.sticker
|
68 |
+
and (
|
69 |
+
m.reply_to_message.sticker.is_animated
|
70 |
+
or m.reply_to_message.sticker.is_video
|
71 |
+
)
|
72 |
+
)
|
73 |
# Find the proper emoji
|
74 |
args = m.text.split()
|
75 |
if len(args) > 1:
|
|
|
78 |
try:
|
79 |
sticker_emoji = m.reply_to_message.sticker.emoji
|
80 |
if not sticker_emoji:
|
81 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂",
|
82 |
+
"🥹", "🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿",
|
83 |
+
"💩", "🤡", "🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨",
|
84 |
+
"👨❤️👨", "💑", "👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲",
|
85 |
+
"🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰", "😇", "🤣", "😂", "😜", "😎"]
|
86 |
sticker_emoji = choice(ran)
|
87 |
except Exception:
|
88 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹",
|
89 |
+
"🥺", "🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡",
|
90 |
+
"🫶", "🙌", "👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨", "👨❤️👨", "💑",
|
91 |
+
"👩❤️👩", "👩❤️👨", "💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖",
|
92 |
+
"👾", "🙌", "🥴", "🥰", "😇", "🤣", "😂", "😜", "😎"]
|
93 |
sticker_emoji = choice(ran)
|
94 |
else:
|
95 |
edit = await msg.reply_text("No emoji provided choosing a random emoji")
|
96 |
+
ran = ["🤣", "😑", "😁", "👍", "🔥", "🙈", "🙏", "😍", "😘", "😱", "☺️", "🙃", "😌", "🤧", "😐", "😬", "🤩", "😀", "🙂", "🥹", "🥺",
|
97 |
+
"🫥", "🙄", "🫡", "🫠", "🤫", "😓", "🥵", "🥶", "😤", "😡", "🤬", "🤯", "🥴", "🤢", "🤮", "💀", "🗿", "💩", "🤡", "🫶", "🙌",
|
98 |
+
"👐", "✊", "👎", "🫰", "🤌", "👌", "👀", "💃", "🕺", "👩❤️💋👩", "👩❤️💋👨", "👨❤️👨", "💑", "👩❤️👩", "👩❤️👨",
|
99 |
+
"💏", "👨❤️💋👨", "😪", "😴", "😭", "🥸", "🤓", "🫤", "😮", "😧", "😲", "🥱", "😈", "👿", "🤖", "👾", "🙌", "🥴", "🥰",
|
100 |
+
"😇", "🤣", "😂", "😜", "😎"]
|
101 |
sticker_emoji = choice(ran)
|
102 |
await edit.delete()
|
103 |
await msg.edit_text(f"Makeing a sticker with {sticker_emoji} emoji")
|
104 |
|
105 |
# Get the corresponding fileid, resize the file if necessary
|
106 |
try:
|
107 |
+
if is_requ or m.reply_to_message.animation or m.reply_to_message.video or m.reply_to_message.photo or (
|
108 |
+
m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] in ["video",
|
109 |
+
"image"]):
|
110 |
# telegram doesn't allow animated and video sticker to be kanged as we do for normal stickers
|
111 |
+
if m.reply_to_message.animation or m.reply_to_message.video or (
|
112 |
+
m.reply_to_message.document and m.reply_to_message.document.mime_type.split("/")[0] == "video"):
|
113 |
path = await Vsticker(c, m.reply_to_message)
|
114 |
SIZE = os.path.getsize(path)
|
115 |
if SIZE > 261120:
|
|
|
117 |
os.remove(path)
|
118 |
return
|
119 |
elif is_requ:
|
120 |
+
path = await m.reply_to_message.download()
|
121 |
else:
|
122 |
sizee = (await get_file_size(m.reply_to_message)).split()
|
123 |
if (sizee[1] == "mb" and int(sizee[0]) > 10) or sizee[1] == "gb":
|
|
|
132 |
sticker_emoji
|
133 |
)
|
134 |
os.remove(path)
|
135 |
+
elif m.reply_to_message.sticker:
|
136 |
sticker = await create_sticker(
|
137 |
await get_document_from_file_id(
|
138 |
m.reply_to_message.sticker.file_id
|
|
|
140 |
sticker_emoji
|
141 |
)
|
142 |
else:
|
143 |
+
await m.reply_text("Unsupported media file...")
|
144 |
+
return
|
145 |
except ShortnameOccupyFailed:
|
146 |
await m.reply_text("Change Your Name Or Username")
|
147 |
return
|
|
|
163 |
try:
|
164 |
while not packname_found:
|
165 |
packname = f"CE{m.from_user.id}{packnum}_by_{c.me.username}"
|
166 |
+
kangpack = f"{f'@{m.from_user.username}' if m.from_user.username else m.from_user.first_name[:10]} {f'vOl {str(volume)}' if volume else ''} by @{c.me.username}"
|
167 |
+
if limit >= 50: # To prevent this loop from running forever
|
168 |
+
await m.reply_text(
|
169 |
+
"Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
|
170 |
return
|
171 |
+
sticker_set = await get_sticker_set_by_name(c, packname)
|
172 |
if not sticker_set:
|
173 |
try:
|
174 |
sticker_set = await create_sticker_set(
|
|
|
186 |
volume += 1
|
187 |
continue
|
188 |
try:
|
189 |
+
await add_sticker_to_set(c, sticker_set, sticker)
|
190 |
packname_found = True
|
191 |
except StickerEmojiInvalid:
|
192 |
return await msg.edit("[ERROR]: INVALID_EMOJI_IN_ARGUMENT")
|
193 |
kb = IKM(
|
194 |
[
|
195 |
[
|
196 |
+
IKB("➕ Add Pack ➕", url=f"t.me/addstickers/{packname}")
|
197 |
]
|
198 |
]
|
199 |
)
|
|
|
232 |
LOGGER.error(format_exc())
|
233 |
return
|
234 |
|
235 |
+
|
236 |
@Gojo.on_message(command(["rmsticker", "removesticker"]))
|
237 |
async def remove_sticker_from_pack(c: Gojo, m: Message):
|
238 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
239 |
return await m.reply_text(
|
240 |
"Reply to a sticker to remove it from the pack."
|
241 |
)
|
242 |
+
|
243 |
sticker = m.reply_to_message.sticker
|
244 |
|
245 |
+
to_modify = await m.reply_text("Removing the sticker from your pack")
|
246 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
247 |
|
248 |
if not sticker_set:
|
249 |
await to_modify.edit_text("This sticker is not part for your pack")
|
250 |
return
|
251 |
+
|
252 |
try:
|
253 |
await remove_sticker(c, sticker.file_id)
|
254 |
+
await to_modify.edit_text(
|
255 |
+
f"Successfully removed [sticker]({m.reply_to_message.link}) from {sticker_set.set.title}")
|
256 |
except Exception as e:
|
257 |
await to_modify.delete()
|
258 |
await m.reply_text(f"Failed to remove sticker due to:\n{e}\nPlease report this bug using `/bug`")
|
259 |
LOGGER.error(e)
|
260 |
LOGGER.error(format_exc())
|
261 |
return
|
|
|
262 |
|
263 |
+
|
264 |
+
@Gojo.on_message(command(["mmfb", "mmfw", "mmf"]))
|
265 |
async def memify_it(c: Gojo, m: Message):
|
266 |
if not m.reply_to_message:
|
267 |
await m.reply_text("Invalid type.")
|
|
|
276 |
kb = IKM(
|
277 |
[
|
278 |
[
|
279 |
+
IKB("Join for memes", url="https://t.me/memesofdank")
|
280 |
]
|
281 |
]
|
282 |
)
|
|
|
284 |
await m.reply_text("Give me something to write")
|
285 |
return
|
286 |
filll = m.command[0][-1]
|
287 |
+
fiil = "black" if filll == "b" else "white"
|
|
|
|
|
|
|
288 |
x = await m.reply_text("Memifying...")
|
289 |
+
meme = m.text.split(None, 1)[1].strip()
|
290 |
name = f"@memesofdank_{m.id}.png"
|
291 |
path = await rep_to.download(name)
|
292 |
+
is_sticker = bool(rep_to.sticker)
|
293 |
+
output = await draw_meme(path, meme, is_sticker, fiil)
|
|
|
|
|
294 |
await x.delete()
|
295 |
+
xNx = await m.reply_photo(output[0], reply_markup=kb)
|
296 |
+
await xNx.reply_sticker(output[1], reply_markup=kb)
|
297 |
try:
|
298 |
os.remove(output[0])
|
299 |
os.remove(output[1])
|
|
|
302 |
LOGGER.error(format_exc())
|
303 |
return
|
304 |
|
305 |
+
|
306 |
+
@Gojo.on_message(command(["getsticker", "getst"]))
|
307 |
async def get_sticker_from_file(c: Gojo, m: Message):
|
308 |
Caption = f"Converted by:\n@{c.me.username}"
|
309 |
repl = m.reply_to_message
|
310 |
if not repl:
|
311 |
await m.reply_text("Reply to a sticker or file")
|
312 |
return
|
313 |
+
if (
|
314 |
+
not repl.animation
|
315 |
+
and not repl.video
|
316 |
+
and not repl.sticker
|
317 |
+
and not repl.photo
|
318 |
+
and (
|
319 |
+
not repl.document
|
320 |
+
or repl.document.mime_type.split("/")[0] not in ["image", "video"]
|
321 |
+
)
|
322 |
+
):
|
323 |
await m.reply_text("I only support conversion of plain stickers, images, videos and animation for now")
|
324 |
return
|
325 |
+
to_vid = bool(
|
326 |
+
repl.animation
|
327 |
+
or repl.video
|
328 |
+
or (repl.document and repl.document.mime_type.split("/")[0] == "video")
|
329 |
+
)
|
330 |
x = await m.reply_text("Converting...")
|
331 |
if repl.sticker:
|
332 |
if repl.sticker.is_animated:
|
333 |
upp = await repl.download()
|
334 |
+
up = tgs_to_gif(upp, True)
|
335 |
await x.delete()
|
336 |
+
await m.reply_animation(up, caption=Caption)
|
|
|
|
|
337 |
elif repl.sticker.is_video:
|
338 |
upp = await repl.download()
|
339 |
up = await webm_to_gif(upp)
|
340 |
await x.delete()
|
341 |
+
await m.reply_animation(up, caption=Caption)
|
|
|
|
|
342 |
else:
|
343 |
upp = await repl.download()
|
344 |
+
up = toimage(upp, is_direc=True)
|
345 |
await x.delete()
|
346 |
await m.reply_document(up, caption=Caption)
|
347 |
+
os.remove(up)
|
348 |
+
return
|
349 |
elif repl.photo:
|
350 |
upp = await repl.download()
|
351 |
+
up = tosticker(upp, is_direc=True)
|
352 |
await x.delete()
|
353 |
await m.reply_sticker(up)
|
354 |
os.remove(up)
|
355 |
return
|
356 |
+
|
357 |
elif to_vid:
|
358 |
+
up = await Vsticker(c, repl)
|
359 |
await x.delete()
|
360 |
await m.reply_sticker(up)
|
361 |
os.remove(up)
|
362 |
return
|
363 |
|
364 |
+
|
365 |
@Gojo.on_message(command(["rmsticker", "rmst", "removesticker"]))
|
366 |
async def remove_from_MY_pack(c: Gojo, m: Message):
|
367 |
if not m.reply_to_message or not m.reply_to_message.sticker:
|
368 |
await m.reply_text("Please reply to a sticker to remove it from your pack")
|
369 |
return
|
370 |
+
|
371 |
sticker = m.reply_to_message.sticker
|
372 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
373 |
|
|
|
385 |
LOGGER.error(format_exc(e))
|
386 |
return
|
387 |
|
388 |
+
|
389 |
@Gojo.on_message(command(["getmypacks", "mypacks", "mysets", "stickerset", "stset"]))
|
390 |
async def get_my_sticker_sets(c: Gojo, m: Message):
|
391 |
to_del = await m.reply_text("Please wait while I fetch all the sticker set I have created for you.")
|
392 |
+
|
393 |
txt, kb = await get_all_sticker_packs(c, m.from_user.id)
|
394 |
|
395 |
await to_del.delete()
|
|
|
398 |
return
|
399 |
await m.reply_text(txt, reply_markup=kb)
|
400 |
|
401 |
+
|
402 |
@Gojo.on_message(command(["q", "ss"]))
|
403 |
async def quote_the_msg(_, m: Message):
|
404 |
if not m.reply_to_message:
|
|
|
407 |
|
408 |
to_edit = await m.reply_text("Genrating quote...")
|
409 |
|
|
|
410 |
if len(m.command) > 1 and m.command[1].lower() == "r":
|
411 |
reply_msg = m.reply_to_message.reply_to_message
|
412 |
+
if not reply_msg or not reply_msg.text:
|
|
|
|
|
413 |
reply_message = {}
|
414 |
else:
|
415 |
to_edit = await to_edit.edit_text("Genrating quote with reply to the message...")
|
|
|
433 |
if m.reply_to_message.from_user.emoji_status:
|
434 |
emoji_status = str(m.reply_to_message.from_user.emoji_status.custom_emoji_id)
|
435 |
|
436 |
+
msg_data = [
|
437 |
{
|
438 |
"entities": get_msg_entities(m.reply_to_message),
|
439 |
"avatar": True,
|
|
|
445 |
"text": m.reply_to_message.text,
|
446 |
"replyMessage": reply_message,
|
447 |
}
|
448 |
+
]
|
|
|
449 |
status, path = quotify(msg_data)
|
450 |
|
451 |
if not status:
|
|
|
456 |
await to_edit.delete()
|
457 |
os.remove(path)
|
458 |
|
459 |
+
|
460 |
@Gojo.on_callback_query(filters.regex(r"^stickers_.*"))
|
461 |
async def sticker_callbacks(c: Gojo, q: CallbackQuery):
|
462 |
data = q.data.split("_")
|
463 |
decoded = await encode_decode(data[-1], "decode")
|
464 |
user = int(decoded.split("_")[-1])
|
|
|
|
|
465 |
if q.from_user.id != user:
|
466 |
await q.answer("This is not for you")
|
|
|
467 |
else:
|
468 |
+
offset = int(decoded.split("_")[0])
|
469 |
+
|
470 |
txt, kb = await get_all_sticker_packs(c, q.from_user.id, offset)
|
471 |
if not txt:
|
472 |
await q.answer("No sticker pack found....")
|
|
|
473 |
else:
|
474 |
+
await q.answer("Showing your sticker set")
|
475 |
await q.edit_message_text(txt, reply_markup=kb)
|
476 |
+
|
477 |
+
return
|
478 |
+
|
479 |
+
|
480 |
__PLUGIN__ = "sticker"
|
481 |
__alt_name__ = [
|
482 |
"sticker",
|