Spaces:
Sleeping
Sleeping
AshokShau
commited on
Commit
·
89ad488
1
Parent(s):
52c02ac
Code Cleanup
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- Powers/__init__.py +11 -23
- Powers/bot_class.py +1 -5
- Powers/database/__init__.py +1 -4
- Powers/database/afk_db.py +5 -12
- Powers/database/antispam_db.py +1 -2
- Powers/database/approve_db.py +8 -5
- Powers/database/autojoin_db.py +4 -11
- Powers/database/blacklist_db.py +3 -2
- Powers/database/captcha_db.py +19 -36
- Powers/database/chats_db.py +1 -1
- Powers/database/disable_db.py +13 -12
- Powers/database/filters_db.py +6 -13
- Powers/database/flood_db.py +26 -25
- Powers/database/locks_db.py +41 -43
- Powers/database/notes_db.py +12 -24
- Powers/database/support_db.py +5 -12
- Powers/database/users_db.py +1 -4
- Powers/plugins/__init__.py +2 -3
- Powers/plugins/admin.py +6 -9
- Powers/plugins/afk.py +8 -12
- Powers/plugins/approve.py +1 -2
- Powers/plugins/auto_join.py +21 -31
- Powers/plugins/bans.py +9 -14
- Powers/plugins/birthday.py +11 -32
- Powers/plugins/captcha.py +20 -32
- Powers/plugins/chat_blacklist.py +13 -16
- Powers/plugins/dev.py +45 -90
- Powers/plugins/disable.py +7 -8
- Powers/plugins/filters.py +9 -11
- Powers/plugins/flood.py +53 -99
- Powers/plugins/fun.py +7 -8
- Powers/plugins/greetings.py +89 -94
- Powers/plugins/info.py +10 -13
- Powers/plugins/locks.py +26 -20
- Powers/plugins/muting.py +1 -7
- Powers/plugins/notes.py +1 -3
- Powers/plugins/pin.py +8 -8
- Powers/plugins/rules.py +2 -4
- Powers/plugins/scheduled_jobs.py +2 -3
- Powers/plugins/search.py +6 -11
- Powers/plugins/start.py +23 -15
- Powers/plugins/stats.py +1 -1
- Powers/plugins/stickers.py +37 -45
- Powers/plugins/utils.py +6 -11
- Powers/plugins/warns.py +22 -33
- Powers/plugins/web_con.py +14 -29
- Powers/supports.py +1 -1
- Powers/utils/captcha_helper.py +1 -5
- Powers/utils/custom_filters.py +12 -21
- Powers/utils/extract_user.py +2 -2
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)
|
@@ -64,12 +60,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 +89,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 +112,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 |
|
@@ -145,18 +138,13 @@ UPTIME = time() # Check bot uptime
|
|
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 |
|
|
|
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)
|
|
|
60 |
TIME_ZONE = pytz.timezone(Config.TIME_ZONE)
|
61 |
|
62 |
Vpath = "./Version"
|
63 |
+
version = [
|
64 |
+
i for i in listdir(Vpath) if i.startswith("version") and i.endswith("md")
|
65 |
+
]
|
|
|
|
|
|
|
66 |
VERSION = sorted(version)[-1][8:-3]
|
67 |
PYTHON_VERSION = python_version()
|
68 |
PYROGRAM_VERSION = pyrogram.__version__
|
|
|
89 |
|
90 |
genius_lyrics.verbose = False
|
91 |
LOGGER.info("Client setup complete")
|
92 |
+
else:
|
93 |
LOGGER.info("Genius api not found lyrics command will not work")
|
94 |
is_genius_lyrics = False
|
95 |
genius_lyrics = False
|
|
|
112 |
API_HASH = Config.API_HASH
|
113 |
|
114 |
# General Config
|
115 |
+
MESSAGE_DUMP = Config.MESSAGE_DUMP or Config.OWNER_ID
|
116 |
SUPPORT_GROUP = Config.SUPPORT_GROUP
|
117 |
SUPPORT_CHANNEL = Config.SUPPORT_CHANNEL
|
118 |
|
|
|
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 |
|
Powers/bot_class.py
CHANGED
@@ -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,
|
|
|
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
@@ -15,15 +15,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 |
"reason": reason, "time": time})
|
23 |
if media:
|
24 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
25 |
'media': media, 'media_type': media_type, "time": time})
|
26 |
-
return True
|
27 |
else:
|
28 |
self.insert_one(
|
29 |
{
|
@@ -35,23 +33,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
|
|
|
15 |
|
16 |
def insert_afk(self, chat_id, user_id, time, reason, media_type, media=None):
|
17 |
with INSERTION_LOCK:
|
18 |
+
if curr := self.check_afk(chat_id=chat_id, user_id=user_id):
|
|
|
19 |
if reason:
|
20 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
21 |
"reason": reason, "time": time})
|
22 |
if media:
|
23 |
self.update({"chat_id": chat_id, "user_id": user_id}, {
|
24 |
'media': media, 'media_type': media_type, "time": time})
|
|
|
25 |
else:
|
26 |
self.insert_one(
|
27 |
{
|
|
|
33 |
"media_type": media_type
|
34 |
}
|
35 |
)
|
36 |
+
return True
|
37 |
|
38 |
def check_afk(self, chat_id, user_id):
|
39 |
+
return bool(curr := self.find_one({"chat_id": chat_id, "user_id": user_id}))
|
|
|
|
|
|
|
40 |
|
41 |
def get_afk(self, chat_id, user_id):
|
42 |
+
if curr := self.find_one({"chat_id": chat_id, "user_id": user_id}):
|
|
|
43 |
return curr
|
44 |
return
|
45 |
|
46 |
def delete_afk(self, chat_id, user_id):
|
47 |
with INSERTION_LOCK:
|
48 |
+
if curr := self.check_afk(chat_id, user_id):
|
|
|
49 |
self.delete_one({"chat_id": chat_id, "user_id": user_id})
|
50 |
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},
|
|
|
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},
|
Powers/database/autojoin_db.py
CHANGED
@@ -30,21 +30,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
|
|
|
30 |
|
31 |
def get_autojoin(self, chat):
|
32 |
curr = self.find_one({"chat_id": chat})
|
33 |
+
return curr["type"] if curr else False
|
|
|
|
|
|
|
34 |
|
35 |
def update_join_type(self, chat, mode):
|
36 |
+
if curr := self.find_one({"chat_id": chat}):
|
|
|
37 |
self.update({"chat_id": chat}, {"type": mode})
|
38 |
+
return
|
|
|
|
|
39 |
|
40 |
def remove_autojoin(self, chat):
|
41 |
+
if curr := self.find_one({"chat_id": chat}):
|
|
|
42 |
self.delete_one({"chat_id": chat})
|
43 |
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
@@ -27,38 +27,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 |
"captcha_action": captcha_action})
|
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 +60,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
|
|
|
27 |
return
|
28 |
|
29 |
def is_captcha(self, chat):
|
30 |
+
return bool(curr := self.find_one({"chat_id": chat}))
|
|
|
|
|
|
|
31 |
|
32 |
def update_type(self, chat, captcha_type):
|
33 |
with INSERTION_LOCK:
|
34 |
+
if curr := self.is_captcha(chat):
|
|
|
35 |
self.update({"chat_id": chat}, {"captcha_type": captcha_type})
|
36 |
return
|
37 |
|
38 |
def update_action(self, chat, captcha_action):
|
39 |
with INSERTION_LOCK:
|
40 |
+
if curr := self.is_captcha(chat):
|
|
|
41 |
self.update({"chat_id": chat}, {
|
42 |
"captcha_action": captcha_action})
|
43 |
return
|
44 |
|
45 |
def remove_captcha(self, chat):
|
46 |
with INSERTION_LOCK:
|
47 |
+
if curr := self.is_captcha(chat):
|
|
|
48 |
self.delete_one({"chat_id": chat})
|
49 |
return
|
50 |
|
51 |
def get_captcha(self, chat):
|
52 |
+
return curr if (curr := self.find_one({"chat_id": chat})) else False
|
|
|
|
|
|
|
53 |
|
54 |
|
55 |
class CAPTCHA_DATA(MongoDB):
|
|
|
60 |
super().__init__(self.db_name)
|
61 |
|
62 |
def load_cap_data(self, chat, user, data):
|
63 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
return
|
65 |
+
with INSERTION_LOCK:
|
66 |
+
self.insert_one(
|
67 |
+
{"chat_id": chat, "user_id": user, "data": data})
|
68 |
+
return True
|
69 |
|
70 |
def get_cap_data(self, chat, user):
|
71 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
72 |
return curr["data"]
|
73 |
else:
|
74 |
return False
|
75 |
|
76 |
def remove_cap_data(self, chat, user):
|
77 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
78 |
with INSERTION_LOCK:
|
79 |
self.delete_one({"chat_id": chat, "user_id": user})
|
80 |
return
|
81 |
|
82 |
def store_message_id(self, chat, user, message):
|
83 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
84 |
+
return
|
85 |
+
with INSERTION_LOCK:
|
86 |
+
self.insert_one(
|
87 |
+
{"chat_id": chat, "user_id": user, "message_id": message})
|
|
|
|
|
88 |
return
|
89 |
|
90 |
def get_message_id(self, chat, user):
|
91 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
92 |
return curr["message_id"]
|
93 |
else:
|
94 |
return False
|
95 |
|
96 |
def is_already_data(self, chat, user):
|
97 |
+
if curr := self.find_one({"chat_id": chat, "user_id": user}):
|
|
|
98 |
return curr.get("message_id", False)
|
99 |
else:
|
100 |
return False
|
Powers/database/chats_db.py
CHANGED
@@ -19,7 +19,7 @@ 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:
|
|
|
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:
|
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
@@ -21,9 +21,7 @@ class Filters(MongoDB):
|
|
21 |
fileid="",
|
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)
|
|
|
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
@@ -23,22 +23,7 @@ class Floods(MongoDB):
|
|
23 |
action: str,
|
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 +32,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
|
|
|
23 |
action: str,
|
24 |
):
|
25 |
with INSERTION_LOCK:
|
26 |
+
if not (curr := self.find_one({"chat_id": chat_id})):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
return self.insert_one(
|
28 |
{
|
29 |
"chat_id": chat_id,
|
|
|
32 |
"action": action
|
33 |
},
|
34 |
)
|
35 |
+
if (
|
36 |
+
limit != int(curr['limit'])
|
37 |
+
or within != int(curr['within'])
|
38 |
+
or action != str(curr['action'])
|
39 |
+
):
|
40 |
+
return self.update(
|
41 |
+
{
|
42 |
+
"chat_id": chat_id
|
43 |
+
},
|
44 |
+
{
|
45 |
+
"limit": limit,
|
46 |
+
"within": within,
|
47 |
+
"action": action,
|
48 |
+
}
|
49 |
+
)
|
50 |
+
else:
|
51 |
+
return
|
52 |
|
53 |
def is_chat(self, chat_id: int):
|
54 |
with INSERTION_LOCK:
|
55 |
+
if curr := self.find_one({"chat_id": chat_id}):
|
56 |
+
return [
|
57 |
+
str(curr['limit']),
|
58 |
+
str(curr['within']),
|
59 |
+
str(curr['action']),
|
60 |
+
]
|
61 |
return False
|
62 |
|
63 |
def get_action(self, chat_id: int):
|
64 |
with INSERTION_LOCK:
|
65 |
+
if curr := self.find_one({"chat_id": chat_id}):
|
|
|
66 |
return curr['action']
|
67 |
return "Flood haven't set"
|
68 |
|
69 |
def rm_flood(self, chat_id: int):
|
70 |
with INSERTION_LOCK:
|
71 |
+
if curr := self.find_one({"chat_id": chat_id}):
|
|
|
72 |
self.delete_one({"chat_id": chat_id})
|
73 |
return True
|
74 |
return False
|
Powers/database/locks_db.py
CHANGED
@@ -30,15 +30,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 +44,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,14 +58,22 @@ 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 |
-
curr = self.find_one(
|
70 |
-
{"chat_id": chat, "locktype": locktype})
|
71 |
-
return bool(curr)
|
72 |
-
else:
|
73 |
to_return = {
|
74 |
"anti_channel": False,
|
75 |
"anti_fwd": {
|
@@ -79,26 +83,24 @@ class LOCKS(MongoDB):
|
|
79 |
"anti_links": False,
|
80 |
"bot": False
|
81 |
}
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
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 +121,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
|
|
|
30 |
continue
|
31 |
self.insert_one({"chat_id": chat, "locktype": i})
|
32 |
return True
|
33 |
+
if curr := self.find_one({"chat_id": chat, "locktype": locktype}):
|
|
|
34 |
return False
|
35 |
+
with INSERTION_LOCK:
|
36 |
+
hmm = self.merge_u_and_c(chat, locktype)
|
37 |
+
if not hmm:
|
38 |
+
self.insert_one({"chat_id": chat, "locktype": locktype})
|
39 |
+
return True
|
|
|
40 |
|
41 |
def remove_lock_channel(self, chat: int, locktype: str):
|
42 |
"""
|
|
|
44 |
"""
|
45 |
if locktype == "all":
|
46 |
for i in lock_t:
|
47 |
+
if curr := self.find_one({"chat_id": chat, "locktype": i}):
|
|
|
48 |
self.delete_one({"chat_id": chat, "locktype": i})
|
49 |
return True
|
50 |
+
if curr := self.find_one({"chat_id": chat, "locktype": locktype}):
|
|
|
51 |
with INSERTION_LOCK:
|
52 |
self.delete_one({"chat_id": chat, "locktype": locktype})
|
53 |
return True
|
|
|
58 |
"""
|
59 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links, bot
|
60 |
"""
|
61 |
+
if locktype not in [
|
62 |
+
"anti_c_send",
|
63 |
+
"anti_fwd",
|
64 |
+
"anti_fwd_u",
|
65 |
+
"anti_fwd_c",
|
66 |
+
"anti_links",
|
67 |
+
"bot",
|
68 |
+
"all",
|
69 |
+
]:
|
70 |
return False
|
71 |
+
if locktype != "all":
|
72 |
+
curr = self.find_one(
|
73 |
+
{"chat_id": chat, "locktype": locktype})
|
74 |
+
return bool(curr)
|
75 |
else:
|
76 |
+
if curr := self.find_all({"chat_id": chat}):
|
|
|
|
|
|
|
|
|
77 |
to_return = {
|
78 |
"anti_channel": False,
|
79 |
"anti_fwd": {
|
|
|
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 |
+
else:
|
103 |
+
return None
|
|
|
|
|
104 |
|
105 |
def merge_u_and_c(self, chat: int, locktype: str):
|
106 |
if locktype == "anti_fwd_u":
|
|
|
121 |
"""
|
122 |
locktypes: anti_c_send, anti_fwd, anti_fwd_u, anti_fwd_c, anti_links
|
123 |
"""
|
124 |
+
return bool(curr := self.find_one({"chat_id": chat, "locktype": locktype}))
|
|
|
|
|
|
|
|
Powers/database/notes_db.py
CHANGED
@@ -23,10 +23,9 @@ class Notes(MongoDB):
|
|
23 |
fileid="",
|
24 |
):
|
25 |
with INSERTION_LOCK:
|
26 |
-
curr
|
27 |
{"chat_id": chat_id, "note_name": note_name},
|
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 |
{"chat_id": chat_id, "note_name": note_name},
|
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 |
{"chat_id": chat_id, "note_name": note_name},
|
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)
|
|
|
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
@@ -30,8 +30,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 +43,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
|
|
|
30 |
return
|
31 |
|
32 |
def update_support_user_type(self, user, new_type):
|
33 |
+
if curr := self.is_support_user(user):
|
|
|
34 |
with INSERTION_LOCK:
|
35 |
self.update(
|
36 |
{
|
|
|
43 |
return
|
44 |
|
45 |
def is_support_user(self, user_id):
|
46 |
+
return bool(curr := self.find_one({"user_id": user_id}))
|
|
|
|
|
|
|
47 |
|
48 |
def delete_support_user(self, user):
|
49 |
+
if curr := self.is_support_user(user):
|
|
|
50 |
with INSERTION_LOCK:
|
51 |
self.delete_one({"user_id": user})
|
52 |
return
|
53 |
|
54 |
def get_particular_support(self, support_type):
|
55 |
+
if curr := self.find_all({"support_type": support_type}):
|
|
|
56 |
return [i['user_id'] for i in curr]
|
57 |
else:
|
58 |
return []
|
59 |
|
60 |
def get_support_type(self, user):
|
61 |
+
if curr := self.find_one({"user_id": user}):
|
|
|
62 |
return curr["support_type"]
|
63 |
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/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
|
@@ -36,6 +36,5 @@ 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
|
|
|
36 |
|
37 |
def till_date(date):
|
38 |
form = "%Y-%m-%d %H:%M:%S"
|
39 |
+
return datetime.strptime(date,form)
|
|
|
40 |
|
Powers/plugins/admin.py
CHANGED
@@ -64,12 +64,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 |
)
|
@@ -95,7 +95,7 @@ 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!")
|
@@ -499,9 +499,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,9 +535,7 @@ 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:
|
|
|
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 = f"{str(ef)}{admin_list}\n"
|
73 |
await m.reply_text(
|
74 |
text=f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
75 |
)
|
|
|
95 |
await sleep(e.value)
|
96 |
try:
|
97 |
await c.ban_chat_member(m.chat.id, member.user.id)
|
98 |
+
except Exception:
|
99 |
pass
|
100 |
if zombie == 0:
|
101 |
return await wait.edit_text("Group is clean!")
|
|
|
499 |
if m.reply_to_message:
|
500 |
if len(m.text.split()) >= 2:
|
501 |
reason = m.text.split(None, 1)[1]
|
502 |
+
elif len(m.text.split()) >= 3:
|
503 |
+
reason = m.text.split(None, 2)[2]
|
|
|
504 |
try:
|
505 |
user_id, _, _ = await extract_user(c, m)
|
506 |
except Exception:
|
|
|
535 |
if not m.reply_to_message.photo and not m.reply_to_message.document:
|
536 |
return await m.reply_text("Reply to a photo to set it as chat photo")
|
537 |
photo = await m.reply_to_message.download()
|
538 |
+
is_vid = bool(m.reply_to_message.video)
|
|
|
|
|
539 |
try:
|
540 |
await m.chat.set_photo(photo,video=is_vid)
|
541 |
except Exception as e:
|
Powers/plugins/afk.py
CHANGED
@@ -58,12 +58,12 @@ async def get_hours(hour:str):
|
|
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,12 +74,8 @@ 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:
|
@@ -96,7 +92,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)}"
|
@@ -119,7 +115,7 @@ async def afk_checker(c: Gojo, m: Message):
|
|
119 |
parse_mode=PM.MARKDOWN,
|
120 |
reply_to_message_id=repl.id
|
121 |
)
|
122 |
-
|
123 |
if is_afk:
|
124 |
txt = False
|
125 |
try:
|
@@ -138,7 +134,7 @@ 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) + f"\n\nAfk for: {tims}"
|
143 |
await m.reply_text(txt)
|
144 |
afk.delete_afk(chat,user)
|
|
|
58 |
tim = hour.strip().split(":")
|
59 |
txt = ""
|
60 |
if int(tim[0]):
|
61 |
+
txt += f"{tim[0]} hours "
|
62 |
if int(tim[1]):
|
63 |
+
txt += f"{tim[1]} minutes "
|
64 |
if int(round(float(tim[2]))):
|
65 |
+
txt += f"{str(round(float(tim[2])))} seconds"
|
66 |
+
|
67 |
return txt
|
68 |
|
69 |
|
|
|
74 |
user = m.from_user.id
|
75 |
chat = m.chat.id
|
76 |
repl = m.reply_to_message
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
+
rep_user = repl.from_user.id if repl and repl.from_user else False
|
79 |
is_afk = afk.check_afk(chat,user)
|
80 |
is_rep_afk = False
|
81 |
if rep_user:
|
|
|
92 |
if len(tim_) == 1:
|
93 |
tims = tim
|
94 |
elif len(tim_) == 2:
|
95 |
+
tims = f"{tim_[0]} {tim}"
|
96 |
reason = f"{repl.from_user.first_name} is afk since {tims}\n"
|
97 |
if con['reason'] not in res:
|
98 |
reason += f"\nDue to: {con['reason'].format(first=repl.from_user.first_name)}"
|
|
|
115 |
parse_mode=PM.MARKDOWN,
|
116 |
reply_to_message_id=repl.id
|
117 |
)
|
118 |
+
|
119 |
if is_afk:
|
120 |
txt = False
|
121 |
try:
|
|
|
134 |
if len(tim_) == 1:
|
135 |
tims = tim
|
136 |
elif len(tim_) == 2:
|
137 |
+
tims = f"{tim_[0]} " + tim
|
138 |
txt = back_.format(first=m.from_user.mention) + f"\n\nAfk for: {tims}"
|
139 |
await m.reply_text(txt)
|
140 |
afk.delete_afk(chat,user)
|
Powers/plugins/approve.py
CHANGED
@@ -44,8 +44,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 |
)
|
|
|
44 |
"User is already admin - blacklists and locks already don't apply to them.",
|
45 |
)
|
46 |
return
|
47 |
+
if already_approved := db.check_approve(user_id):
|
|
|
48 |
await m.reply_text(
|
49 |
f"{(await mention_html(user_first_name, user_id))} is already approved in {chat_title}",
|
50 |
)
|
Powers/plugins/auto_join.py
CHANGED
@@ -38,29 +38,21 @@ async def accept_join_requests(c: Gojo, m: Message):
|
|
38 |
return
|
39 |
else:
|
40 |
yes_no = split[1].lower()
|
41 |
-
if yes_no
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
else:
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
if is_al:
|
51 |
-
txt = "Now I will approve all the join request of the chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
|
52 |
-
await m.reply_text(txt)
|
53 |
-
return
|
54 |
-
else:
|
55 |
-
txt = "Auto approve join request is already on for this chat\nIf you want that I will just notify admins about the join request use command\n/joinreqmode [manual | auto]"
|
56 |
-
await m.reply_text(txt)
|
57 |
-
return
|
58 |
-
|
59 |
-
elif yes_no == "off":
|
60 |
-
a_j.remove_autojoin(m.chat.id)
|
61 |
-
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
62 |
-
await m.reply_text(txt)
|
63 |
-
return
|
64 |
|
65 |
@Gojo.on_message(command("joinreqmode") & admin_filter)
|
66 |
async def join_request_mode(c: Gojo, m: Message):
|
@@ -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)
|
@@ -138,7 +128,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,7 +137,7 @@ 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:
|
@@ -158,7 +148,7 @@ async def accept_decline_request(c:Gojo, q: CallbackQuery):
|
|
158 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
159 |
LOGGER.error(ef)
|
160 |
LOGGER.error(format_exc())
|
161 |
-
|
162 |
elif data == "decline":
|
163 |
try:
|
164 |
await c.decline_chat_join_request(chat,user)
|
|
|
38 |
return
|
39 |
else:
|
40 |
yes_no = split[1].lower()
|
41 |
+
if yes_no == "on":
|
42 |
+
is_al = a_j.load_autojoin(m.chat.id)
|
43 |
+
|
44 |
+
txt = (
|
45 |
+
"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]"
|
46 |
+
if is_al
|
47 |
+
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]"
|
48 |
+
)
|
49 |
+
elif yes_no == "off":
|
50 |
+
a_j.remove_autojoin(m.chat.id)
|
51 |
+
txt = "Now I will neither auto approve join request nor notify any admins about it"
|
52 |
else:
|
53 |
+
txt = "**USAGE**\n/joinreq [on | off]"
|
54 |
+
await m.reply_text(txt)
|
55 |
+
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
128 |
show_alert=True,
|
129 |
)
|
130 |
return
|
131 |
+
except Exception:
|
132 |
await q.answer("Unknow error occured. You are not admin or owner")
|
133 |
return
|
134 |
split = q.data.split("_")
|
|
|
137 |
data = split[0]
|
138 |
try:
|
139 |
userr = await c.get_users(user)
|
140 |
+
except Exception:
|
141 |
userr = None
|
142 |
if data == "accept":
|
143 |
try:
|
|
|
148 |
await c.send_message(chat,f"Some error occured while approving request, report it using `/bug`\n<b>Error:</b> <code>{ef}</code>")
|
149 |
LOGGER.error(ef)
|
150 |
LOGGER.error(format_exc())
|
151 |
+
|
152 |
elif data == "decline":
|
153 |
try:
|
154 |
await c.decline_chat_join_request(chat,user)
|
Powers/plugins/bans.py
CHANGED
@@ -395,7 +395,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,7 +424,7 @@ 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,
|
@@ -554,7 +554,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,7 +582,7 @@ 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,
|
@@ -752,7 +752,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 +790,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)
|
@@ -970,14 +967,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,9 +986,7 @@ 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]:
|
|
|
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 |
caption=txt,
|
425 |
parse_mode=enums.ParseMode.HTML,
|
426 |
)
|
427 |
+
except Exception:
|
428 |
await m.reply_text(
|
429 |
reply_to_message_id=r_id,
|
430 |
text=txt,
|
|
|
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 |
caption=txt,
|
583 |
parse_mode=enums.ParseMode.HTML,
|
584 |
)
|
585 |
+
except Exception:
|
586 |
await m.reply_text(
|
587 |
txt,
|
588 |
parse_mode=enums.ParseMode.HTML,
|
|
|
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 not m.reply_to_message.from_user:
|
756 |
user_id, user_first_name = (
|
757 |
m.reply_to_message.sender_chat.id,
|
758 |
m.reply_to_message.sender_chat.title,
|
|
|
790 |
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
791 |
await m.stop_propagation()
|
792 |
|
793 |
+
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
|
|
794 |
try:
|
795 |
await m.reply_to_message.delete()
|
796 |
await m.chat.ban_member(user_id)
|
|
|
967 |
)
|
968 |
return
|
969 |
|
970 |
+
elif not user.privileges.can_restrict_members and q.from_user.id != OWNER_ID:
|
971 |
await q.answer(
|
972 |
"You don't have enough permission to do this!\nStay in your limits!",
|
973 |
show_alert=True,
|
974 |
)
|
975 |
return
|
976 |
whoo = await c.get_chat(user_id)
|
977 |
+
doneto = whoo.first_name or whoo.title
|
978 |
try:
|
979 |
await q.message.chat.unban_member(user_id)
|
980 |
except RPCError as e:
|
|
|
986 |
|
987 |
@Gojo.on_message(command("kickme"))
|
988 |
async def kickme(c: Gojo, m: Message):
|
989 |
+
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
990 |
try:
|
991 |
mem = await c.get_chat_member(m.chat.id,m.from_user.id)
|
992 |
if mem.status in [enums.ChatMemberStatus.ADMINISTRATOR, enums.ChatMemberStatus.OWNER]:
|
Powers/plugins/birthday.py
CHANGED
@@ -19,8 +19,7 @@ from Powers.utils.custom_filters import command
|
|
19 |
|
20 |
|
21 |
def give_date(date,form = "%d/%m/%Y"):
|
22 |
-
|
23 |
-
return datee
|
24 |
|
25 |
@Gojo.on_message(command("remember"))
|
26 |
async def remember_me(c: Gojo, m: Message):
|
@@ -37,24 +36,10 @@ async def remember_me(c: Gojo, m: Message):
|
|
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
|
@@ -72,15 +57,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:
|
@@ -104,14 +88,12 @@ async def who_are_you_again(c: Gojo, m: Message):
|
|
104 |
return
|
105 |
user = m.from_user.id
|
106 |
try:
|
107 |
-
result
|
108 |
-
if not result:
|
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
|
@@ -133,10 +115,7 @@ 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:
|
@@ -210,7 +189,7 @@ async def chat_birthday_settings(c: Gojo, m: Message):
|
|
210 |
kb = IKM(
|
211 |
[
|
212 |
[
|
213 |
-
IKB(f"{'
|
214 |
IKB("Close", "f_close")
|
215 |
]
|
216 |
]
|
|
|
19 |
|
20 |
|
21 |
def give_date(date,form = "%d/%m/%Y"):
|
22 |
+
return datetime.strptime(date,form).date()
|
|
|
23 |
|
24 |
@Gojo.on_message(command("remember"))
|
25 |
async def remember_me(c: Gojo, m: Message):
|
|
|
36 |
DOB = splited[1] if len(splited) == 2 else splited[2]
|
37 |
if len(splited) == 2 and m.reply_to_message:
|
38 |
user = m.reply_to_message.from_user.id
|
|
|
|
|
39 |
else:
|
40 |
+
user = m.from_user.id
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
DOB = DOB.split("/")
|
42 |
+
if len(DOB) not in [3, 2]:
|
43 |
await m.reply_text("DOB should be in format of dd/mm/yyyy\nYear is optional it is not necessary to pass it")
|
44 |
return
|
45 |
is_correct = False
|
|
|
57 |
else:
|
58 |
year = "1900"
|
59 |
is_year = 0
|
60 |
+
DOB = f"{date}/{str(month)}/{str(year)}"
|
61 |
except ValueError:
|
62 |
await m.reply_text("DOB should be numbers only")
|
63 |
return
|
64 |
|
65 |
data = {"user_id":user,"dob":DOB,"is_year":is_year}
|
66 |
try:
|
67 |
+
if result := bday_info.find_one({"user_id": user}):
|
|
|
68 |
await m.reply_text("User is already in my database")
|
69 |
return
|
70 |
except Exception as e:
|
|
|
88 |
return
|
89 |
user = m.from_user.id
|
90 |
try:
|
91 |
+
if result := bday_info.find_one({"user_id": user}):
|
|
|
|
|
|
|
|
|
92 |
bday_info.delete_one({"user_id":user})
|
93 |
await m.reply_text("Removed your birthday")
|
94 |
+
else:
|
95 |
+
await m.reply_text("User is not in my database")
|
96 |
+
return
|
97 |
except Exception as e:
|
98 |
await m.reply_text(f"Got an error\n{e}")
|
99 |
return
|
|
|
115 |
if Chats(m.chat.id).user_is_in_chat(i["user_id"]):
|
116 |
dob = give_date(i["dob"])
|
117 |
if dob.month >= curr.month:
|
118 |
+
users.append(i)
|
|
|
|
|
|
|
119 |
if len(users) == 10:
|
120 |
break
|
121 |
if not users:
|
|
|
189 |
kb = IKM(
|
190 |
[
|
191 |
[
|
192 |
+
IKB(f"{'No' if c_in else 'Yes'}",f"switchh_{'no' if c_in else 'yes'}"),
|
193 |
IKB("Close", "f_close")
|
194 |
]
|
195 |
]
|
Powers/plugins/captcha.py
CHANGED
@@ -32,20 +32,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 +51,22 @@ 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(f"Current captcha verification methode is {capatcha_type}\nAvailable methodes:\n■ qr\n■ image")
|
60 |
-
return
|
61 |
else:
|
62 |
await m.reply_text("Captcha verification is off for the current chat")
|
63 |
-
return
|
64 |
else:
|
65 |
type_ = split[1].lower()
|
66 |
if type_ == "qr":
|
67 |
await m.reply_text("This feature is not implemented yet\nUse /captchamode image")
|
68 |
-
# captcha.update_type(m.chat.id, "qr")
|
69 |
-
# await m.reply_text("Captcha verification is now changed to qr code")
|
70 |
-
return
|
71 |
elif type_ == "image":
|
72 |
captcha.update_type(m.chat.id, "image")
|
73 |
await m.reply_text("Captcha verication is now changed to image")
|
74 |
-
return
|
75 |
else:
|
76 |
await m.reply_text("**USAGE**\n/captchamode [qr | image]")
|
77 |
-
|
|
|
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,7 +130,7 @@ 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,
|
@@ -149,10 +140,10 @@ async def captcha_codes_check(c: Gojo, q: CallbackQuery):
|
|
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
|
@@ -202,23 +193,15 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
202 |
|
203 |
if not is_already:
|
204 |
captcha_type = "image" # I am not going to apply qr captcha in this update
|
205 |
-
if captcha_type == "
|
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 |
|
@@ -245,8 +228,13 @@ async def on_chat_members_updatess(c: Gojo, m: Message):
|
|
245 |
)
|
246 |
await c.send_photo(chat, img, caption=cap, reply_markup=kb)
|
247 |
os.remove(img)
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
250 |
kb = ikm(
|
251 |
[
|
252 |
[
|
|
|
32 |
else:
|
33 |
txt = "Captcha verification is currently **off** for this chat"
|
34 |
await m.reply_text(txt)
|
|
|
35 |
else:
|
36 |
on_off = split[1].lower()
|
37 |
if on_off in ["on", "yes", "enable"]:
|
38 |
captcha.insert_captcha(m.chat.id)
|
39 |
await m.reply_text("Captcha verification is now **on** for this chat")
|
|
|
40 |
elif on_off in ["off", "no", "disable"]:
|
41 |
captcha.remove_captcha(m.chat.id)
|
42 |
await m.reply_text("Captcha verification is now **off** for this chat")
|
|
|
43 |
else:
|
44 |
await m.reply_text("**USAGE**\n/captcha [on | yes | enable | off | no | disable]")
|
45 |
+
|
46 |
+
return
|
47 |
|
48 |
|
49 |
@Gojo.on_message(command("captchamode") & admin_filter & ~filters.private)
|
|
|
51 |
split = m.command
|
52 |
captcha = CAPTCHA()
|
53 |
if len(split) == 1:
|
54 |
+
if curr := captcha.get_captcha(m.chat.id):
|
|
|
55 |
capatcha_type = curr["captcha_type"]
|
56 |
await m.reply_text(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,
|
|
|
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
|
|
|
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 |
|
|
|
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,8 +84,7 @@ 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 |
"These Chats are Blacklisted:\n"
|
|
|
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"
|
Powers/plugins/dev.py
CHANGED
@@ -46,8 +46,7 @@ async def add_support(c: Gojo, m:Message):
|
|
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:
|
@@ -65,7 +64,6 @@ async def add_support(c: Gojo, m:Message):
|
|
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 |
[
|
@@ -76,7 +74,6 @@ async def add_support(c: Gojo, m:Message):
|
|
76 |
]
|
77 |
)
|
78 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
79 |
-
return
|
80 |
else:
|
81 |
support.insert_support_user(userr,to)
|
82 |
if to == "dev":
|
@@ -86,12 +83,10 @@ 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 |
[
|
@@ -102,14 +97,12 @@ async def add_support(c: Gojo, m:Message):
|
|
102 |
]
|
103 |
)
|
104 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
105 |
-
return
|
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:
|
@@ -129,7 +122,6 @@ async def add_support(c: Gojo, m:Message):
|
|
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 |
[
|
@@ -140,16 +132,13 @@ async def add_support(c: Gojo, m:Message):
|
|
140 |
]
|
141 |
)
|
142 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
143 |
-
return
|
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 |
[
|
@@ -160,14 +149,12 @@ async def add_support(c: Gojo, m:Message):
|
|
160 |
]
|
161 |
)
|
162 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
163 |
-
return
|
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 +164,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:
|
@@ -292,12 +277,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)
|
@@ -347,15 +328,11 @@ async def evaluate_code(c: Gojo, m: Message):
|
|
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 |
-
reply_to_id = m.id
|
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()
|
@@ -398,27 +375,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"
|
@@ -456,22 +431,15 @@ 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:
|
@@ -480,31 +448,19 @@ async def execution(c: Gojo, m: Message):
|
|
480 |
break
|
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"
|
@@ -692,7 +648,7 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
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 +670,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,7 +681,6 @@ async def forward_type_broadcast(c: Gojo, m: Message):
|
|
725 |
await sleep(0.1)
|
726 |
except Exception:
|
727 |
failed += 1
|
728 |
-
pass
|
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"
|
|
|
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:
|
|
|
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 |
[
|
|
|
74 |
]
|
75 |
)
|
76 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
|
|
77 |
else:
|
78 |
support.insert_support_user(userr,to)
|
79 |
if to == "dev":
|
|
|
83 |
else:
|
84 |
WHITELIST_USERS.add(userr)
|
85 |
await m.reply_text(f"This user is now a {to} user")
|
86 |
+
return
|
87 |
+
if can_do := can_change_type(curr_user, to):
|
|
|
88 |
if to == curr:
|
89 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
90 |
elif curr:
|
91 |
kb = IKM(
|
92 |
[
|
|
|
97 |
]
|
98 |
)
|
99 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
|
|
100 |
else:
|
101 |
support.insert_support_user(userr,to)
|
102 |
await m.reply_text(f"This user is now a {to} user")
|
|
|
103 |
else:
|
104 |
await m.reply_text("Sorry you can't do it")
|
105 |
+
return
|
106 |
elif len(split) >= 3:
|
107 |
user = split[1]
|
108 |
try:
|
|
|
122 |
if m.from_user.id == int(OWNER_ID):
|
123 |
if to == curr:
|
124 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
125 |
elif curr:
|
126 |
kb = IKM(
|
127 |
[
|
|
|
132 |
]
|
133 |
)
|
134 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
|
|
135 |
else:
|
136 |
support.insert_support_user(userr,to)
|
137 |
await m.reply_text(f"This user is now a {to} user")
|
138 |
+
return
|
139 |
+
if can_do := can_change_type(curr_user, to):
|
|
|
140 |
if to == curr:
|
141 |
await m.reply_text(f"This user is already in {to} users")
|
|
|
142 |
elif curr:
|
143 |
kb = IKM(
|
144 |
[
|
|
|
149 |
]
|
150 |
)
|
151 |
await m.reply_text(f"This is user is already in {curr} users\nDo you want to make him {to} user?",reply_markup=kb)
|
|
|
152 |
else:
|
153 |
support.insert_support_user(userr,to)
|
154 |
await m.reply_text(f"This user is now a {to} user")
|
|
|
155 |
else:
|
156 |
await m.reply_text("Sorry you can't do it")
|
157 |
+
return
|
158 |
|
159 |
@Gojo.on_message(command("rmsupport"))
|
160 |
async def rm_support(c: Gojo, m: Message):
|
|
|
164 |
await m.reply_text("Stay in you limit")
|
165 |
return
|
166 |
split = m.command
|
167 |
+
if reply_to := m.reply_to_message:
|
|
|
|
|
168 |
try:
|
169 |
curr = reply_to.from_user.id
|
170 |
except Exception:
|
|
|
277 |
stderr=subprocess.PIPE,
|
278 |
)
|
279 |
stdout, stderr = await process.communicate()
|
280 |
+
e = stderr.decode() or "No Error"
|
281 |
+
OUTPUT = stdout.decode() or "No Output"
|
|
|
|
|
|
|
|
|
282 |
|
283 |
try:
|
284 |
await m.reply_text(OUTPUT, quote=True)
|
|
|
328 |
f"@{m.from_user.username} TREID TO USE `while True` \n userid = {m.from_user.id}"
|
329 |
)
|
330 |
return
|
331 |
+
if m.reply_to_message and m.reply_to_message.document and (m.reply_to_message.document.mime_type.split("/")[1] == "x-python" or m.reply_to_message.document.file_name.endswith("py")):
|
332 |
+
await sm.delete()
|
333 |
+
await m.reply_text("Loading external plugin is prohibited")
|
334 |
+
return
|
335 |
+
reply_to_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
|
|
|
|
|
|
|
336 |
old_stderr = sys.stderr
|
337 |
old_stdout = sys.stdout
|
338 |
redirected_output = sys.stdout = StringIO()
|
|
|
375 |
return
|
376 |
|
377 |
for j in HARMFUL:
|
378 |
+
if (j in evaluation.split() or j in cmd) and m.from_user.id != OWNER_ID:
|
379 |
+
evaluation = "Bhaag ja bsdk"
|
380 |
+
await c.send_message(
|
381 |
+
MESSAGE_DUMP,
|
382 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}")
|
383 |
+
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
384 |
+
await sm.edit(final_output)
|
385 |
+
return
|
386 |
+
for i in evaluation.split():
|
387 |
+
for j in i.split("="):
|
388 |
+
if j and j[0] in HARMFUL and m.from_user.id != OWNER_ID:
|
389 |
evaluation = "Bhaag ja bsdk"
|
390 |
await c.send_message(
|
391 |
MESSAGE_DUMP,
|
392 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}"
|
393 |
+
)
|
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 |
|
398 |
try:
|
399 |
final_output = f"**EVAL**: ```python\n{cmd}```\n\n<b>OUTPUT</b>:\n```powershell\n{evaluation}```</code> \n"
|
|
|
431 |
sm = await m.reply_text("`Processing...`\n")
|
432 |
cmd = m.text.split(maxsplit=1)[1]
|
433 |
|
434 |
+
reply_to_id = m.reply_to_message.id if m.reply_to_message else m.id
|
|
|
|
|
|
|
435 |
process = await create_subprocess_shell(
|
436 |
cmd,
|
437 |
stdout=subprocess.PIPE,
|
438 |
stderr=subprocess.PIPE,
|
439 |
)
|
440 |
stdout, stderr = await process.communicate()
|
441 |
+
e = stderr.decode().strip() or "No Error"
|
442 |
+
o = stdout.decode().strip() or "No Output"
|
|
|
|
|
|
|
|
|
443 |
out = o
|
444 |
xxx = o.split()
|
445 |
for OwO in xxx:
|
|
|
448 |
break
|
449 |
for x in xxx:
|
450 |
xx = x.split("=")
|
451 |
+
if xx and xx[0] in HARMFUL and m.from_user.id != OWNER_ID:
|
452 |
+
out = "You can't access them"
|
453 |
+
await c.send_message(
|
454 |
+
MESSAGE_DUMP,
|
455 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}",
|
456 |
+
)
|
|
|
|
|
|
|
|
|
|
|
457 |
for x in HARMFUL:
|
458 |
+
if x in out and m.from_user.id != OWNER_ID:
|
459 |
+
out = "You can't access them"
|
460 |
+
await c.send_message(
|
461 |
+
MESSAGE_DUMP,
|
462 |
+
f"@{m.from_user.username} TREID TO FETCH ENV OF BOT \n userid = {m.from_user.id}",
|
463 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
OUTPUT = ""
|
465 |
OUTPUT += f"<b>QUERY:</b>\n<u>Command:</u>\n<code>{cmd}</code> \n"
|
466 |
OUTPUT += f"<u>PID</u>: <code>{process.pid}</code>\n\n"
|
|
|
648 |
await m.reply_text("Please reply to message to broadcast it")
|
649 |
return
|
650 |
split = m.command
|
651 |
+
|
652 |
chat = Chats.list_chats_by_id()
|
653 |
user = [i["_id"] for i in Users.list_users()]
|
654 |
alll = chat + user
|
|
|
670 |
peers = user
|
671 |
else:
|
672 |
peers = alll
|
673 |
+
|
674 |
xx = await m.reply_text("Broadcasting...")
|
675 |
|
676 |
failed = 0
|
|
|
681 |
await sleep(0.1)
|
682 |
except Exception:
|
683 |
failed += 1
|
|
|
684 |
txt = f"Broadcasted message to {total-failed} peers out of {total}\nFailed to broadcast message to {failed} peers"
|
685 |
if not failed:
|
686 |
txt = f"Broadcasted message to {total} peers"
|
Powers/plugins/disable.py
CHANGED
@@ -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 |
|
|
|
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 |
|
Powers/plugins/filters.py
CHANGED
@@ -95,8 +95,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 +136,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):
|
|
|
95 |
"Please provide data for this filter reply with!",
|
96 |
)
|
97 |
|
98 |
+
if add := db.save_filter(m.chat.id, keyword, teks, msgtype, file_id):
|
|
|
99 |
await m.reply_text(
|
100 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
101 |
)
|
|
|
136 |
& owner_filter,
|
137 |
)
|
138 |
async def rm_allfilters(_, m: Message):
|
139 |
+
if all_bls := db.get_all_filters(m.chat.id):
|
140 |
+
return await m.reply_text(
|
141 |
+
"Are you sure you want to clear all filters?",
|
142 |
+
reply_markup=ikb(
|
143 |
+
[[("⚠️ Confirm", "rm_allfilters"), ("❌ Cancel", "close_admin")]],
|
144 |
+
),
|
145 |
+
)
|
146 |
+
else:
|
147 |
return await m.reply_text("No filters to stop in this chat.")
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
@Gojo.on_callback_query(filters.regex("^rm_allfilters$"))
|
151 |
async def rm_allfilters_callback(_, q: CallbackQuery):
|
Powers/plugins/flood.py
CHANGED
@@ -21,35 +21,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 |
close_kb =InlineKeyboardMarkup(
|
55 |
[
|
@@ -152,15 +137,13 @@ 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}",
|
@@ -190,8 +173,7 @@ 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.")
|
@@ -207,7 +189,7 @@ async def flood_set(c: Gojo, m: Message):
|
|
207 |
swithin = is_flood[1]
|
208 |
return await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
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:
|
@@ -241,8 +223,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 +232,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 +260,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 +284,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 +305,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(
|
@@ -367,7 +343,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:
|
@@ -398,22 +374,22 @@ 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 : {u_id : [[],[]]}}
|
415 |
dic.update(z)
|
416 |
-
|
417 |
try:
|
418 |
dic[c_id] # access and check weather the c_id present or not
|
419 |
except KeyError:
|
@@ -425,18 +401,18 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
425 |
except KeyError:
|
426 |
z = {u_id : [[],[]]}
|
427 |
dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
|
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 : [[sec], ["x"]]})
|
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("_")
|
@@ -444,11 +420,11 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
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 +442,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 +464,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":
|
@@ -575,7 +529,7 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
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(seconds=31) #will automatically unban user after 31 seconds kind of fail safe if unban members doesn't work properly
|
|
|
21 |
off_key = ["off", "end", "enable", "stop"]
|
22 |
|
23 |
async def get_what_temp(what):
|
24 |
+
return InlineKeyboardMarkup(
|
25 |
[
|
26 |
[
|
27 |
+
InlineKeyboardButton("5 minutes", f"f_temp_{what}_5min"),
|
|
|
|
|
|
|
28 |
InlineKeyboardButton(
|
29 |
"10 minute",
|
30 |
f"f_temp_{what}_10min",
|
31 |
),
|
32 |
+
InlineKeyboardButton("30 minute", f"f_temp_{what}_30min"),
|
33 |
+
InlineKeyboardButton("1 hour", f"f_temp_{what}_60min"),
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
],
|
35 |
+
[InlineKeyboardButton("« Back", "f_temp_back")],
|
|
|
|
|
|
|
|
|
|
|
36 |
]
|
37 |
)
|
|
|
38 |
|
39 |
close_kb =InlineKeyboardMarkup(
|
40 |
[
|
|
|
137 |
Flood = Floods()
|
138 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
139 |
status = bot.status
|
140 |
+
if status not in [CMS.OWNER, CMS.ADMINISTRATOR] and not bot.privileges.can_restrict_members:
|
|
|
141 |
return await m.reply_text("Give me permission to restict member first")
|
142 |
if m.chat.type == CT.PRIVATE:
|
143 |
await m.reply_text("Use this command in group")
|
144 |
return
|
145 |
c_id = m.chat.id
|
146 |
+
if is_flood := Flood.is_chat(c_id):
|
|
|
147 |
saction = is_flood[2]
|
148 |
await m.reply_text(
|
149 |
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
|
|
173 |
bot = await c.get_chat_member(m.chat.id, c.me.id)
|
174 |
Flood = Floods()
|
175 |
status = bot.status
|
176 |
+
if status not in [CMS.OWNER, CMS.ADMINISTRATOR] and not bot.privileges.can_restrict_members:
|
|
|
177 |
return await m.reply_text("Give me permission to restict member first")
|
178 |
if m.chat.type == CT.PRIVATE:
|
179 |
return await m.reply_text("This command is ment to be used in groups.")
|
|
|
189 |
swithin = is_flood[1]
|
190 |
return await m.reply_text(f"Flood is on for this chat\n**Action**:{saction}\n**Messages**:{slimit} within {swithin} sec")
|
191 |
return await m.reply_text("Flood protection is off of this chat.")
|
192 |
+
|
193 |
if len(split) == 2:
|
194 |
c_id = m.chat.id
|
195 |
if split[1].lower() in on_key:
|
|
|
223 |
return
|
224 |
c_id = q.message.chat.id
|
225 |
Flood = Floods()
|
226 |
+
if is_flood := Flood.is_chat(c_id):
|
|
|
227 |
saction = is_flood[2]
|
228 |
slimit = is_flood[0]
|
229 |
swithin = is_flood[1]
|
|
|
232 |
if user in SUPPORT_STAFF or user_status in [CMS.OWNER, CMS.ADMINISTRATOR]:
|
233 |
if data in ["f_mute", "f_ban", "f_kick", "f_skip"]:
|
234 |
change = data.split("_")[1]
|
235 |
+
if change != saction:
|
236 |
Flood.save_flood(c_id, slimit, swithin, change)
|
237 |
await q.answer("Updated action", show_alert=True)
|
238 |
await q.edit_message_text(
|
|
|
260 |
kb = action_kb
|
261 |
await q.edit_message_text(
|
262 |
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
263 |
+
reply_markup=kb,
|
264 |
)
|
265 |
return
|
266 |
kb = await get_what_temp(to_do)
|
|
|
284 |
reply_markup=within_kb
|
285 |
)
|
286 |
return
|
287 |
+
if change != slimit:
|
288 |
Flood.save_flood(c_id, change, swithin, saction)
|
289 |
await q.answer("Updated limit", show_alert=True)
|
|
|
|
|
|
|
|
|
|
|
290 |
else:
|
291 |
await q.answer("Updated action", show_alert=True)
|
292 |
+
await q.edit_message_text(
|
293 |
+
f"Set the time with the number of message recived treated as flood\n **CUURENT TIME** {swithin}",
|
294 |
+
reply_markup=within_kb
|
295 |
+
)
|
296 |
+
return
|
297 |
elif data in ["f_f_5", "f_f_10", "f_f_15", "f_f_skip"]:
|
298 |
data = data.split("_")[-1]
|
299 |
try:
|
|
|
305 |
)
|
306 |
await q.answer("skip")
|
307 |
return
|
308 |
+
if change != swithin:
|
309 |
Flood.save_flood(c_id, slimit, change, saction)
|
310 |
await q.answer("Updated", show_alert=True)
|
311 |
await q.edit_message_text(
|
|
|
343 |
)
|
344 |
return
|
345 |
whoo = await c.get_chat(user_id)
|
346 |
+
doneto = whoo.first_name or whoo.title
|
347 |
try:
|
348 |
await q.message.chat.unban_member(user_id)
|
349 |
except RPCError as e:
|
|
|
374 |
@Gojo.on_message(flood_filter, 18)
|
375 |
async def flood_watcher(c: Gojo, m: Message):
|
376 |
c_id = m.chat.id
|
377 |
+
|
378 |
Flood = Floods()
|
379 |
+
|
380 |
u_id = m.from_user.id
|
381 |
+
|
382 |
is_flood = Flood.is_chat(c_id)
|
383 |
+
|
384 |
|
385 |
action = is_flood[2]
|
386 |
limit = int(is_flood[0])
|
387 |
within = int(is_flood[1])
|
388 |
+
|
389 |
if not len(dic):
|
390 |
z = {c_id : {u_id : [[],[]]}}
|
391 |
dic.update(z)
|
392 |
+
|
393 |
try:
|
394 |
dic[c_id] # access and check weather the c_id present or not
|
395 |
except KeyError:
|
|
|
401 |
except KeyError:
|
402 |
z = {u_id : [[],[]]}
|
403 |
dic[c_id].update(z) # make the dic something like {c_id : {u_id : [[for time],[for msg]]}}
|
404 |
+
|
405 |
sec = round(time.time())
|
406 |
+
|
407 |
try:
|
408 |
dic[c_id][u_id][0].append(sec)
|
409 |
dic[c_id][u_id][1].append("x")
|
410 |
except KeyError:
|
411 |
dic[c_id].update({u_id : [[sec], ["x"]]})
|
412 |
+
|
413 |
x = int(dic[c_id][u_id][0][0])
|
414 |
y = int(dic[c_id][u_id][0][-1])
|
415 |
+
|
416 |
if len(dic[c_id][u_id][1]) == limit:
|
417 |
if y-x <= within:
|
418 |
action = action.split("_")
|
|
|
420 |
try:
|
421 |
to_do = action[0]
|
422 |
for_tim = int(action[1].replace("min",""))
|
423 |
+
except Exception:
|
424 |
for_tim = 30
|
425 |
for_how_much = datetime.now() + timedelta(minutes=for_tim)
|
426 |
+
try:
|
427 |
+
if to_do == "ban":
|
428 |
await m.chat.ban_member(u_id, until_date=for_how_much)
|
429 |
keyboard = InlineKeyboardMarkup(
|
430 |
[
|
|
|
442 |
caption=txt,
|
443 |
reply_markup=keyboard,
|
444 |
)
|
445 |
+
else:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
await m.chat.restrict_member(
|
447 |
u_id,
|
448 |
ChatPermissions(),
|
|
|
464 |
caption=txt,
|
465 |
reply_markup=keyboard,
|
466 |
)
|
467 |
+
dic[c_id][u_id][1].clear()
|
468 |
+
dic[c_id][u_id][0].clear()
|
469 |
+
return
|
470 |
+
|
471 |
+
except UserAdminInvalid:
|
472 |
+
await m.reply_text(
|
473 |
+
"I can't protect this chat from this user",
|
474 |
)
|
475 |
+
dic[c_id][u_id][1].clear()
|
476 |
+
dic[c_id][u_id][0].clear()
|
477 |
+
return
|
478 |
+
except RPCError as ef:
|
479 |
+
await m.reply_text(
|
480 |
+
text=f"""Some error occured, report it using `/bug`
|
481 |
|
482 |
<b>Error:</b> <code>{ef}</code>"""
|
483 |
)
|
484 |
+
LOGGER.error(ef)
|
485 |
+
LOGGER.error(format_exc())
|
486 |
+
dic[c_id][u_id][1].clear()
|
487 |
+
dic[c_id][u_id][0].clear()
|
488 |
+
return
|
489 |
else:
|
490 |
action = action[0]
|
491 |
if action == "ban":
|
|
|
529 |
dic[c_id][u_id][1].clear()
|
530 |
dic[c_id][u_id][0].clear()
|
531 |
return
|
532 |
+
|
533 |
elif action == "kick":
|
534 |
try:
|
535 |
d = datetime.now()+timedelta(seconds=31) #will automatically unban user after 31 seconds kind of fail safe if unban members doesn't work properly
|
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
@@ -273,78 +273,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 +285,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 |
|
@@ -456,7 +451,7 @@ async def welcome(c: Gojo, m: Message):
|
|
456 |
reply_markup=button,
|
457 |
disable_web_page_preview=True,
|
458 |
)
|
459 |
-
|
460 |
await (await send_cmd(c,mtype))(
|
461 |
m.chat.id,
|
462 |
UwU,
|
@@ -518,7 +513,7 @@ async def goodbye(c: Gojo, m: Message):
|
|
518 |
reply_markup=button,
|
519 |
disable_web_page_preview=True,
|
520 |
)
|
521 |
-
|
522 |
await (await send_cmd(c,mtype))(
|
523 |
m.chat.id,
|
524 |
UwU,
|
|
|
273 |
"chatname",
|
274 |
]
|
275 |
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
276 |
+
if not status:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
tek, button = await parse_button(hmm)
|
279 |
button = await build_keyboard(button)
|
280 |
button = ikb(button) if button else None
|
|
|
285 |
else:
|
286 |
teks = tek
|
287 |
|
288 |
+
if not teks:
|
289 |
+
teks = f"A wild {user.mention} appeared in {m.chat.title}! Everyone be aware."
|
290 |
+
|
291 |
+
ifff = db.get_current_cleanwelcome_id()
|
292 |
+
gg = db.get_current_cleanwelcome_settings()
|
293 |
+
if ifff and gg:
|
294 |
try:
|
295 |
await c.delete_messages(m.chat.id, int(ifff))
|
296 |
except RPCError:
|
297 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
if not teks:
|
299 |
+
teks = "Hey {first}, welcome to {chatname}"
|
300 |
try:
|
301 |
if not UwU:
|
302 |
+
jj = await c.send_message(
|
303 |
m.chat.id,
|
304 |
text=teks,
|
305 |
reply_markup=button,
|
306 |
disable_web_page_preview=True,
|
307 |
)
|
308 |
+
else:
|
309 |
+
jj = await (await send_cmd(c,mtype))(
|
310 |
m.chat.id,
|
311 |
UwU,
|
312 |
caption=teks,
|
313 |
reply_markup=button,
|
314 |
)
|
315 |
|
316 |
+
if jj:
|
317 |
+
db.set_cleanwlcm_id(int(jj.id))
|
|
|
318 |
except ChannelPrivate:
|
319 |
+
continue
|
320 |
except RPCError as e:
|
321 |
LOGGER.error(e)
|
322 |
LOGGER.error(format_exc(e))
|
323 |
+
|
324 |
+
|
325 |
+
@Gojo.on_message(filters.group & filters.left_chat_member, group=99)
|
326 |
+
async def member_has_left(c: Gojo, m: Message):
|
327 |
+
db = Greetings(m.chat.id)
|
328 |
+
status = db.get_goodbye_status()
|
329 |
+
oo = db.get_goodbye_text()
|
330 |
+
UwU = db.get_goodbye_media()
|
331 |
+
mtype = db.get_goodbye_msgtype()
|
332 |
+
parse_words = [
|
333 |
+
"first",
|
334 |
+
"last",
|
335 |
+
"fullname",
|
336 |
+
"id",
|
337 |
+
"username",
|
338 |
+
"mention",
|
339 |
+
"chatname",
|
340 |
+
]
|
341 |
+
|
342 |
+
user = m.left_chat_member or m.from_user
|
343 |
+
|
344 |
+
hmm = await escape_mentions_using_curly_brackets_wl(user, m, oo, parse_words)
|
345 |
+
if not status:
|
346 |
+
return
|
347 |
+
tek, button = await parse_button(hmm)
|
348 |
+
button = await build_keyboard(button)
|
349 |
+
button = ikb(button) if button else None
|
350 |
+
|
351 |
+
if "%%%" in tek:
|
352 |
+
filter_reply = tek.split("%%%")
|
353 |
+
teks = choice(filter_reply)
|
354 |
else:
|
355 |
+
teks = tek
|
356 |
+
|
357 |
+
if not teks: #Just in case
|
358 |
+
teks = f"Thanks for being part of this group {user.mention}. But I don't like your arrogance and leaving the group {emoji.EYES}"
|
359 |
+
|
360 |
+
ifff = db.get_current_cleangoodbye_id()
|
361 |
+
iii = db.get_current_cleangoodbye_settings()
|
362 |
+
if ifff and iii:
|
363 |
+
try:
|
364 |
+
await c.delete_messages(m.chat.id, int(ifff))
|
365 |
+
except RPCError:
|
366 |
+
pass
|
367 |
+
if user.id in DEV_USERS:
|
368 |
+
await c.send_message(
|
369 |
+
m.chat.id,
|
370 |
+
f"Will miss you my master {user.mention} :(",
|
371 |
+
)
|
372 |
+
return
|
373 |
+
if not teks:
|
374 |
+
teks = "Sad to see you leaving {first}\nTake Care!"
|
375 |
+
try:
|
376 |
+
ooo = (
|
377 |
+
await (await send_cmd(c, mtype))(
|
378 |
+
m.chat.id,
|
379 |
+
UwU,
|
380 |
+
caption=teks,
|
381 |
+
reply_markup=button,
|
382 |
+
) if UwU else await c.send_message(
|
383 |
+
m.chat.id,
|
384 |
+
text=teks,
|
385 |
+
reply_markup=button,
|
386 |
+
disable_web_page_preview=True,
|
387 |
+
)
|
388 |
+
)
|
389 |
+
if ooo:
|
390 |
+
db.set_cleangoodbye_id(int(ooo.id))
|
391 |
+
return
|
392 |
+
except ChannelPrivate:
|
393 |
+
pass
|
394 |
+
except RPCError as e:
|
395 |
+
LOGGER.error(e)
|
396 |
+
LOGGER.error(format_exc(e))
|
397 |
return
|
398 |
|
399 |
|
|
|
451 |
reply_markup=button,
|
452 |
disable_web_page_preview=True,
|
453 |
)
|
454 |
+
else:
|
455 |
await (await send_cmd(c,mtype))(
|
456 |
m.chat.id,
|
457 |
UwU,
|
|
|
513 |
reply_markup=button,
|
514 |
disable_web_page_preview=True,
|
515 |
)
|
516 |
+
else:
|
517 |
await (await send_cmd(c,mtype))(
|
518 |
m.chat.id,
|
519 |
UwU,
|
Powers/plugins/info.py
CHANGED
@@ -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,7 +107,7 @@ 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
|
@@ -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:
|
@@ -287,7 +284,7 @@ async def info_func(c: Gojo, message: Message):
|
|
287 |
if e == "User not found ! Error: 'InputPeerChannel' object has no attribute 'user_id'":
|
288 |
await m.reply_text("Looks like you are trying to fetch info of a chat not an user. In that case please use /chinfo")
|
289 |
return
|
290 |
-
|
291 |
await message.reply_text(text=e)
|
292 |
LOGGER.error(e)
|
293 |
LOGGER.error(format_exc())
|
@@ -311,7 +308,7 @@ 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://"):
|
@@ -322,9 +319,9 @@ async def chat_info_func(c: Gojo, message: Message):
|
|
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"):
|
|
|
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 = bool(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
|
|
|
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:
|
|
|
284 |
if e == "User not found ! Error: 'InputPeerChannel' object has no attribute 'user_id'":
|
285 |
await m.reply_text("Looks like you are trying to fetch info of a chat not an user. In that case please use /chinfo")
|
286 |
return
|
287 |
+
|
288 |
await message.reply_text(text=e)
|
289 |
LOGGER.error(e)
|
290 |
LOGGER.error(format_exc())
|
|
|
308 |
|
309 |
try:
|
310 |
chat = int(chat)
|
311 |
+
except Exception as ef:
|
312 |
if "invalid literal for int() with base 10:" in str(ef):
|
313 |
chat = str(chat)
|
314 |
if chat.startswith("https://"):
|
|
|
319 |
)
|
320 |
|
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,9 +452,15 @@ 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 (m.from_user.id in ul or m.from_user.id in SUDO_LEVEL or m.from_user.id in admins_group or m.from_user.id == c.me.id):
|
468 |
return True
|
@@ -471,9 +469,12 @@ async def is_approved_user(c: Gojo, m: Message):
|
|
471 |
else:
|
472 |
return False
|
473 |
elif m.from_user:
|
474 |
-
|
475 |
-
|
476 |
-
|
|
|
|
|
|
|
477 |
else:
|
478 |
return False
|
479 |
|
@@ -504,7 +505,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 (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):
|
466 |
return True
|
|
|
469 |
else:
|
470 |
return False
|
471 |
elif m.from_user:
|
472 |
+
return (
|
473 |
+
m.from_user.id in ul
|
474 |
+
or m.from_user.id in SUDO_LEVEL
|
475 |
+
or m.from_user.id in admins_group
|
476 |
+
or m.from_user.id == c.me.id
|
477 |
+
)
|
478 |
else:
|
479 |
return False
|
480 |
|
|
|
505 |
if not chat_locks:
|
506 |
return
|
507 |
|
508 |
+
if (
|
509 |
+
chat_locks["anti_channel"]
|
510 |
+
and m.sender_chat
|
511 |
+
and not m.forward_from_chat
|
512 |
+
and not m.forward_from
|
513 |
+
):
|
514 |
if m.chat.is_admin:
|
515 |
return
|
516 |
await delete_messages(c, m)
|
Powers/plugins/muting.py
CHANGED
@@ -479,13 +479,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 |
|
|
|
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 = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
user_id = m.reply_to_message.from_user.id
|
484 |
user_first_name = m.reply_to_message.from_user.first_name
|
485 |
|
Powers/plugins/notes.py
CHANGED
@@ -323,9 +323,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 |
[
|
|
|
323 |
|
324 |
msg_id = m.reply_to_message.id if m.reply_to_message else m.id
|
325 |
|
326 |
+
if curr_pref := db_settings.get_privatenotes(m.chat.id):
|
|
|
|
|
327 |
pm_kb = ikb(
|
328 |
[
|
329 |
[
|
Powers/plugins/pin.py
CHANGED
@@ -18,15 +18,15 @@ 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
|
@@ -162,8 +162,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 +171,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,
|
|
|
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 |
|
31 |
if m.chat.username:
|
32 |
# If chat has a username, use this format
|
|
|
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 |
if chat.pinned_message:
|
166 |
pinned_id = chat.pinned_message.id
|
167 |
if m.chat.username:
|
|
|
171 |
link_chat_id = (str(m.chat.id)).replace("-100", "")
|
172 |
message_link = f"https://t.me/c/{link_chat_id}/{pinned_id}"
|
173 |
|
174 |
+
msg_id = m.reply_to_message.id if m.reply_to_message else m.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,
|
Powers/plugins/rules.py
CHANGED
@@ -25,9 +25,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 +74,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)
|
|
|
25 |
)
|
26 |
return
|
27 |
|
28 |
+
if priv_rules_status := db.get_privrules():
|
|
|
|
|
29 |
pm_kb = ikb(
|
30 |
[
|
31 |
[
|
|
|
74 |
return await m.reply_text("Provide some text to set as rules !!")
|
75 |
|
76 |
if len(rules) > 4000:
|
77 |
+
rules = rules[:3949]
|
78 |
await m.reply_text("Rules are truncated to 3950 characters!")
|
79 |
|
80 |
db.set_rules(rules)
|
Powers/plugins/scheduled_jobs.py
CHANGED
@@ -17,8 +17,7 @@ from Powers.utils.extras import birthday_wish
|
|
17 |
|
18 |
|
19 |
def give_date(date,form = "%d/%m/%Y"):
|
20 |
-
|
21 |
-
return datee
|
22 |
|
23 |
scheduler = AsyncIOScheduler()
|
24 |
scheduler.timezone = TIME_ZONE
|
@@ -38,10 +37,10 @@ async def send_wishish(JJK: Client):
|
|
38 |
agee = ""
|
39 |
if i["is_year"]:
|
40 |
agee = curr.year - dob.year
|
41 |
-
suffix = {1: 'st', 2: 'nd', 3: 'rd'}
|
42 |
if int(agee/10) == 1:
|
43 |
suf = "th"
|
44 |
else:
|
|
|
45 |
suffix.get((agee%10), "th")
|
46 |
agee = f"{agee}{suf}"
|
47 |
U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
|
|
|
17 |
|
18 |
|
19 |
def give_date(date,form = "%d/%m/%Y"):
|
20 |
+
return datetime.strptime(date,form).date()
|
|
|
21 |
|
22 |
scheduler = AsyncIOScheduler()
|
23 |
scheduler.timezone = TIME_ZONE
|
|
|
37 |
agee = ""
|
38 |
if i["is_year"]:
|
39 |
agee = curr.year - dob.year
|
|
|
40 |
if int(agee/10) == 1:
|
41 |
suf = "th"
|
42 |
else:
|
43 |
+
suffix = {1: 'st', 2: 'nd', 3: 'rd'}
|
44 |
suffix.get((agee%10), "th")
|
45 |
agee = f"{agee}{suf}"
|
46 |
U = await JJK.get_chat_member(chat_id=j,user_id=i["user_id"])
|
Powers/plugins/search.py
CHANGED
@@ -233,14 +233,11 @@ 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 |
@Gojo.on_message(command(["images","imgs"]))
|
@@ -258,9 +255,7 @@ 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()
|
|
|
233 |
text_to_return = message.text
|
234 |
if message.text is None:
|
235 |
return None
|
236 |
+
if " " not in text_to_return:
|
237 |
+
return None
|
238 |
+
try:
|
239 |
+
return message.text.split(None, 1)[1]
|
240 |
+
except Exception:
|
|
|
|
|
|
|
241 |
return None
|
242 |
|
243 |
@Gojo.on_message(command(["images","imgs"]))
|
|
|
255 |
return
|
256 |
image_urls = resp.get("image_urls", [])[:10]
|
257 |
ab = await m.reply_text("Getting Your Images... Wait A Min..\nCredits: @NovaXMod")
|
258 |
+
Ok = [InputMediaPhoto(a) for a in image_urls]
|
|
|
|
|
259 |
try:
|
260 |
await m.reply_media_group(media=Ok)
|
261 |
await ab.delete()
|
Powers/plugins/start.py
CHANGED
@@ -127,13 +127,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:
|
@@ -313,7 +313,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,23 +326,28 @@ 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]$"))
|
@@ -348,7 +356,7 @@ async def helppp_page_iter(c: Gojo, q: CallbackQuery):
|
|
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 +428,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:
|
|
|
127 |
]
|
128 |
]
|
129 |
)
|
130 |
+
except Exception:
|
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 Exception:
|
137 |
pass
|
138 |
return
|
139 |
except Exception:
|
|
|
313 |
new_msg += f"{i}\n"
|
314 |
kb = [
|
315 |
[
|
316 |
+
(
|
317 |
+
"Next page ▶️",
|
318 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page + 1}",
|
319 |
+
)
|
320 |
]
|
321 |
]
|
322 |
else:
|
|
|
326 |
new_msg += f"{i}\n"
|
327 |
kb = [
|
328 |
[
|
329 |
+
(
|
330 |
+
"◀️ Previous page",
|
331 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page - 1}",
|
332 |
+
)
|
333 |
]
|
334 |
]
|
335 |
else:
|
336 |
for i in msg[first:last]:
|
337 |
new_msg += f"{i}\n"
|
338 |
kb = [
|
339 |
+
[
|
340 |
+
(
|
341 |
+
"◀️ Previous page",
|
342 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page - 1}",
|
343 |
+
),
|
344 |
+
(
|
345 |
+
"Next page ▶️",
|
346 |
+
f"iter_page_{plugin_name}_{f'{back_to_do}_' if back_to_do else ''}{page + 1}",
|
347 |
+
),
|
348 |
]
|
349 |
+
]
|
350 |
+
kb = ikb(kb, True, back_to_do) if back_to_do else ikb(kb)
|
|
|
|
|
|
|
351 |
return new_msg, kb
|
352 |
|
353 |
@Gojo.on_callback_query(filters.regex(r"^iter_page_.*[0-9]$"))
|
|
|
356 |
plugin_ = data[2]
|
357 |
try:
|
358 |
back_to = data[-2]
|
359 |
+
except Exception:
|
360 |
back_to = None
|
361 |
curr_page = int(data[-1])
|
362 |
msg, kb = await get_divided_msg(plugin_, curr_page, back_to_do=back_to)
|
|
|
428 |
pass
|
429 |
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
430 |
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
431 |
+
if not true_sudo:
|
432 |
reply += "No Sudo Users\n"
|
433 |
else:
|
434 |
for each_user in true_sudo:
|
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
@@ -22,10 +22,7 @@ from Powers.utils.web_helpers import get_file_size
|
|
22 |
|
23 |
@Gojo.on_message(command(["stickerinfo","stinfo"]))
|
24 |
async def give_st_info(c: Gojo , m: Message):
|
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
|
@@ -49,10 +46,7 @@ Pack name : {st_in.set_name}
|
|
49 |
|
50 |
@Gojo.on_message(command(["stickerid","stid"]))
|
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
|
@@ -70,9 +64,8 @@ async def kang(c:Gojo, m: Message):
|
|
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 = False
|
73 |
-
if m.reply_to_message.sticker:
|
74 |
-
|
75 |
-
is_requ = True
|
76 |
# Find the proper emoji
|
77 |
args = m.text.split()
|
78 |
if len(args) > 1:
|
@@ -120,7 +113,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 +121,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,7 +144,7 @@ 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: # To prevent this loop from running forever
|
156 |
await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
|
157 |
return
|
@@ -225,16 +218,16 @@ async def remove_sticker_from_pack(c: Gojo, m: Message):
|
|
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(f"Successfully removed [sticker]({m.reply_to_message.link}) from {sticker_set.set.title}")
|
@@ -269,17 +262,12 @@ 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 |
-
if rep_to.sticker:
|
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)
|
@@ -299,12 +287,23 @@ async def get_sticker_from_file(c: Gojo, m: 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:
|
@@ -312,22 +311,18 @@ async def get_sticker_from_file(c: Gojo, m: Message):
|
|
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)
|
@@ -335,7 +330,7 @@ async def get_sticker_from_file(c: Gojo, m: Message):
|
|
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()
|
@@ -389,9 +384,7 @@ async def quote_the_msg(_, m: Message):
|
|
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...")
|
@@ -444,20 +437,19 @@ 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__ = [
|
|
|
22 |
|
23 |
@Gojo.on_message(command(["stickerinfo","stinfo"]))
|
24 |
async def give_st_info(c: Gojo , m: Message):
|
25 |
+
if not m.reply_to_message or not m.reply_to_message.sticker:
|
|
|
|
|
|
|
26 |
await m.reply_text("Reply to a sticker")
|
27 |
return
|
28 |
st_in = m.reply_to_message.sticker
|
|
|
46 |
|
47 |
@Gojo.on_message(command(["stickerid","stid"]))
|
48 |
async def sticker_id_gib(c: Gojo, m: Message):
|
49 |
+
if not m.reply_to_message or not m.reply_to_message.sticker:
|
|
|
|
|
|
|
50 |
await m.reply_text("Reply to a sticker")
|
51 |
return
|
52 |
st_in = m.reply_to_message.sticker
|
|
|
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 = False
|
67 |
+
if m.reply_to_message.sticker and (m.reply_to_message.sticker.is_animated or m.reply_to_message.sticker.is_video):
|
68 |
+
is_requ = True
|
|
|
69 |
# Find the proper emoji
|
70 |
args = m.text.split()
|
71 |
if len(args) > 1:
|
|
|
113 |
sticker_emoji
|
114 |
)
|
115 |
os.remove(path)
|
116 |
+
elif m.reply_to_message.sticker:
|
117 |
sticker = await create_sticker(
|
118 |
await get_document_from_file_id(
|
119 |
m.reply_to_message.sticker.file_id
|
|
|
121 |
sticker_emoji
|
122 |
)
|
123 |
else:
|
124 |
+
await m.reply_text("Unsupported media file...")
|
125 |
+
return
|
126 |
except ShortnameOccupyFailed:
|
127 |
await m.reply_text("Change Your Name Or Username")
|
128 |
return
|
|
|
144 |
try:
|
145 |
while not packname_found:
|
146 |
packname = f"CE{m.from_user.id}{packnum}_by_{c.me.username}"
|
147 |
+
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}"
|
148 |
if limit >= 50: # To prevent this loop from running forever
|
149 |
await m.reply_text("Failed to kang\nMay be you have made more than 50 sticker packs with me try deleting some")
|
150 |
return
|
|
|
218 |
return await m.reply_text(
|
219 |
"Reply to a sticker to remove it from the pack."
|
220 |
)
|
221 |
+
|
222 |
sticker = m.reply_to_message.sticker
|
223 |
|
224 |
+
to_modify = await m.reply_text("Removing the sticker from your pack")
|
225 |
sticker_set = await get_sticker_set_by_name(c, sticker.set_name)
|
226 |
|
227 |
if not sticker_set:
|
228 |
await to_modify.edit_text("This sticker is not part for your pack")
|
229 |
return
|
230 |
+
|
231 |
try:
|
232 |
await remove_sticker(c, sticker.file_id)
|
233 |
await to_modify.edit_text(f"Successfully removed [sticker]({m.reply_to_message.link}) from {sticker_set.set.title}")
|
|
|
262 |
await m.reply_text("Give me something to write")
|
263 |
return
|
264 |
filll = m.command[0][-1]
|
265 |
+
fiil = "black" if filll == "b" else "white"
|
|
|
|
|
|
|
266 |
x = await m.reply_text("Memifying...")
|
267 |
meme = m.text.split(None,1)[1].strip()
|
268 |
name = f"@memesofdank_{m.id}.png"
|
269 |
path = await rep_to.download(name)
|
270 |
+
is_sticker = bool(rep_to.sticker)
|
|
|
|
|
271 |
output = await draw_meme(path,meme,is_sticker,fiil)
|
272 |
await x.delete()
|
273 |
xNx = await m.reply_photo(output[0],reply_markup=kb)
|
|
|
287 |
if not repl:
|
288 |
await m.reply_text("Reply to a sticker or file")
|
289 |
return
|
290 |
+
if (
|
291 |
+
not repl.animation
|
292 |
+
and not repl.video
|
293 |
+
and not repl.sticker
|
294 |
+
and not repl.photo
|
295 |
+
and (
|
296 |
+
not repl.document
|
297 |
+
or repl.document.mime_type.split("/")[0] not in ["image", "video"]
|
298 |
+
)
|
299 |
+
):
|
300 |
await m.reply_text("I only support conversion of plain stickers, images, videos and animation for now")
|
301 |
return
|
302 |
+
to_vid = bool(
|
303 |
+
repl.animation
|
304 |
+
or repl.video
|
305 |
+
or (repl.document and repl.document.mime_type.split("/")[0] == "video")
|
306 |
+
)
|
307 |
x = await m.reply_text("Converting...")
|
308 |
if repl.sticker:
|
309 |
if repl.sticker.is_animated:
|
|
|
311 |
up = tgs_to_gif(upp,True)
|
312 |
await x.delete()
|
313 |
await m.reply_animation(up,caption=Caption)
|
|
|
|
|
314 |
elif repl.sticker.is_video:
|
315 |
upp = await repl.download()
|
316 |
up = await webm_to_gif(upp)
|
317 |
await x.delete()
|
318 |
await m.reply_animation(up,caption=Caption)
|
|
|
|
|
319 |
else:
|
320 |
upp = await repl.download()
|
321 |
up = toimage(upp,is_direc=True)
|
322 |
await x.delete()
|
323 |
await m.reply_document(up, caption=Caption)
|
324 |
+
os.remove(up)
|
325 |
+
return
|
326 |
elif repl.photo:
|
327 |
upp = await repl.download()
|
328 |
up = tosticker(upp,is_direc=True)
|
|
|
330 |
await m.reply_sticker(up)
|
331 |
os.remove(up)
|
332 |
return
|
333 |
+
|
334 |
elif to_vid:
|
335 |
up = await Vsticker(c,repl)
|
336 |
await x.delete()
|
|
|
384 |
msg_data = []
|
385 |
if len(m.command) > 1 and m.command[1].lower() == "r":
|
386 |
reply_msg = m.reply_to_message.reply_to_message
|
387 |
+
if not reply_msg or not reply_msg.text:
|
|
|
|
|
388 |
reply_message = {}
|
389 |
else:
|
390 |
to_edit = await to_edit.edit_text("Genrating quote with reply to the message...")
|
|
|
437 |
data = q.data.split("_")
|
438 |
decoded = await encode_decode(data[-1], "decode")
|
439 |
user = int(decoded.split("_")[-1])
|
|
|
|
|
440 |
if q.from_user.id != user:
|
441 |
await q.answer("This is not for you")
|
|
|
442 |
else:
|
443 |
+
offset = int(decoded.split("_")[0])
|
444 |
+
|
445 |
txt, kb = await get_all_sticker_packs(c, q.from_user.id, offset)
|
446 |
if not txt:
|
447 |
await q.answer("No sticker pack found....")
|
|
|
448 |
else:
|
449 |
+
await q.answer("Showing your sticker set")
|
450 |
await q.edit_message_text(txt, reply_markup=kb)
|
451 |
+
|
452 |
+
return
|
453 |
|
454 |
__PLUGIN__ = "sticker"
|
455 |
__alt_name__ = [
|
Powers/plugins/utils.py
CHANGED
@@ -109,15 +109,12 @@ async def get_lyrics(_, m: Message):
|
|
109 |
await em.delete()
|
110 |
await m.reply_text("Connection error try again after sometime")
|
111 |
return
|
112 |
-
|
113 |
if song:
|
114 |
if song.lyrics:
|
115 |
reply = song.lyrics
|
116 |
reply = reply.split("\n",1)[1]
|
117 |
-
|
118 |
-
artist = song.artist
|
119 |
-
else:
|
120 |
-
artist = artist
|
121 |
else:
|
122 |
reply = "Couldn't find any lyrics for that song!"
|
123 |
else:
|
@@ -221,9 +218,7 @@ async def github(_, m: Message):
|
|
221 |
if len(m.text.split()) == 2:
|
222 |
username = m.text.split(maxsplit=1)[1]
|
223 |
else:
|
224 |
-
await m.reply_text(
|
225 |
-
f"Usage: <code>/github username</code>",
|
226 |
-
)
|
227 |
return
|
228 |
username = username.split("/")[-1].strip("@")
|
229 |
URL = f"https://api.github.com/users/{username}"
|
@@ -350,13 +345,13 @@ async def paste_func(_, message: Message):
|
|
350 |
if not link:
|
351 |
await m.edit_text("Failed to post!")
|
352 |
return
|
353 |
-
kb = [[InlineKeyboardButton(text="📍 Paste 📍", url=
|
354 |
await m.delete()
|
355 |
try:
|
356 |
await message.reply_text("Here's your paste", reply_markup=InlineKeyboardMarkup(kb))
|
357 |
except Exception as e:
|
358 |
if link:
|
359 |
-
return await message.reply_text(f"Here's your paste:\n [link]({link
|
360 |
return await message.reply_text(f"Failed to post. Due to following error:\n{e}")
|
361 |
|
362 |
|
@@ -439,7 +434,7 @@ async def botstaff(c: Gojo, m: Message):
|
|
439 |
pass
|
440 |
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
441 |
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
442 |
-
if true_sudo
|
443 |
reply += "No Sudo Users\n"
|
444 |
else:
|
445 |
for each_user in true_sudo:
|
|
|
109 |
await em.delete()
|
110 |
await m.reply_text("Connection error try again after sometime")
|
111 |
return
|
112 |
+
|
113 |
if song:
|
114 |
if song.lyrics:
|
115 |
reply = song.lyrics
|
116 |
reply = reply.split("\n",1)[1]
|
117 |
+
artist = artist or song.artist
|
|
|
|
|
|
|
118 |
else:
|
119 |
reply = "Couldn't find any lyrics for that song!"
|
120 |
else:
|
|
|
218 |
if len(m.text.split()) == 2:
|
219 |
username = m.text.split(maxsplit=1)[1]
|
220 |
else:
|
221 |
+
await m.reply_text("Usage: <code>/github username</code>")
|
|
|
|
|
222 |
return
|
223 |
username = username.split("/")[-1].strip("@")
|
224 |
URL = f"https://api.github.com/users/{username}"
|
|
|
345 |
if not link:
|
346 |
await m.edit_text("Failed to post!")
|
347 |
return
|
348 |
+
kb = [[InlineKeyboardButton(text="📍 Paste 📍", url=f"{link}.{exe}")]]
|
349 |
await m.delete()
|
350 |
try:
|
351 |
await message.reply_text("Here's your paste", reply_markup=InlineKeyboardMarkup(kb))
|
352 |
except Exception as e:
|
353 |
if link:
|
354 |
+
return await message.reply_text(f"Here's your paste:\n [link]({link}.{exe})")
|
355 |
return await message.reply_text(f"Failed to post. Due to following error:\n{e}")
|
356 |
|
357 |
|
|
|
434 |
pass
|
435 |
true_sudo = list(set(SUDO_USERS) - set(DEV_USERS))
|
436 |
reply += "\n<b>Sudo Users 🐉:</b>\n"
|
437 |
+
if not true_sudo:
|
438 |
reply += "No Sudo Users\n"
|
439 |
else:
|
440 |
for each_user in true_sudo:
|
Powers/plugins/warns.py
CHANGED
@@ -23,19 +23,10 @@ from Powers.utils.parser import mention_html
|
|
23 |
async def warn(c: Gojo, m: Message):
|
24 |
if m.reply_to_message:
|
25 |
r_id = m.reply_to_message.id
|
26 |
-
if len(m.text.split()) >= 2
|
27 |
-
reason = m.text.split(None, 1)[1]
|
28 |
-
else:
|
29 |
-
reason = None
|
30 |
-
elif not m.reply_to_message:
|
31 |
-
r_id = m.id
|
32 |
-
if len(m.text.split()) >= 3:
|
33 |
-
reason = m.text.split(None, 2)[2]
|
34 |
-
else:
|
35 |
-
reason = None
|
36 |
else:
|
37 |
-
|
38 |
-
|
39 |
if not len(m.command) > 1 and not m.reply_to_message:
|
40 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
41 |
return
|
@@ -69,18 +60,17 @@ async def warn(c: Gojo, m: Message):
|
|
69 |
warn_settings = warn_settings_db.get_warnings_settings()
|
70 |
if num >= warn_settings["warn_limit"]:
|
71 |
timeee = datetime.now(TIME_ZONE) + timedelta(minutes=45)
|
72 |
-
if warn_settings["warn_mode"] == "kick"
|
|
|
|
|
73 |
await m.chat.ban_member(user_id, until_date=timeee)
|
74 |
action = "kicked"
|
75 |
elif warn_settings["warn_mode"] == "ban":
|
76 |
await m.chat.ban_member(user_id)
|
77 |
action = "banned"
|
78 |
-
|
79 |
await m.chat.restrict_member(user_id, ChatPermissions())
|
80 |
action = "muted"
|
81 |
-
else:
|
82 |
-
await m.chat.ban_member(user_id, until_date=timeee)
|
83 |
-
action = "kicked"
|
84 |
await m.reply_text(
|
85 |
(
|
86 |
f"Warnings {num}/{warn_settings['warn_limit']}!"
|
@@ -93,8 +83,7 @@ async def warn(c: Gojo, m: Message):
|
|
93 |
)
|
94 |
await m.stop_propagation()
|
95 |
|
96 |
-
rules
|
97 |
-
if rules:
|
98 |
kb = InlineKeyboardButton(
|
99 |
"Rules 📋",
|
100 |
url=f"https://t.me/{c.me.username}?start=rules_{m.chat.id}",
|
@@ -136,7 +125,7 @@ async def warn(c: Gojo, m: Message):
|
|
136 |
@Gojo.on_message(command("resetwarns") & restrict_filter)
|
137 |
async def reset_warn(c: Gojo, m: Message):
|
138 |
|
139 |
-
if
|
140 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
141 |
return
|
142 |
|
@@ -213,7 +202,7 @@ async def list_warns(c: Gojo, m: Message):
|
|
213 |
)
|
214 |
async def remove_warn(c: Gojo, m: Message):
|
215 |
|
216 |
-
if
|
217 |
await m.reply_text(
|
218 |
"I can't remove warns of nothing! Tell me user whose warn should be removed!",
|
219 |
)
|
@@ -273,20 +262,9 @@ async def remove_last_warn_btn(c: Gojo, q: CallbackQuery):
|
|
273 |
action = args[1]
|
274 |
user_id = int(args[2])
|
275 |
chat_id = int(q.message.chat.id)
|
276 |
-
user = Users.get_user_info(
|
277 |
user_first_name = user["name"]
|
278 |
|
279 |
-
if action == "remove":
|
280 |
-
warn_db = Warns(q.message.chat.id)
|
281 |
-
_, num_warns = warn_db.remove_warn(user_id)
|
282 |
-
await q.message.edit_text(
|
283 |
-
(
|
284 |
-
f"Admin {(await mention_html(q.from_user.first_name, q.from_user.id))} "
|
285 |
-
"removed last warn for "
|
286 |
-
f"{(await mention_html(user_first_name, user_id))}\n"
|
287 |
-
f"<b>Current Warnings:</b> {num_warns}"
|
288 |
-
),
|
289 |
-
)
|
290 |
if action == "kick":
|
291 |
try:
|
292 |
timee = datetime.now(TIME_ZONE) + timedelta(minutes=45)
|
@@ -305,6 +283,17 @@ async def remove_last_warn_btn(c: Gojo, q: CallbackQuery):
|
|
305 |
f"🛑 Failed to Kick\n<b>Error:</b>\n</code>{err}</code>",
|
306 |
)
|
307 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
await q.answer()
|
309 |
return
|
310 |
|
|
|
23 |
async def warn(c: Gojo, m: Message):
|
24 |
if m.reply_to_message:
|
25 |
r_id = m.reply_to_message.id
|
26 |
+
reason = m.text.split(None, 1)[1] if len(m.text.split()) >= 2 else None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
else:
|
28 |
+
r_id = m.id
|
29 |
+
reason = m.text.split(None, 2)[2] if len(m.text.split()) >= 3 else None
|
30 |
if not len(m.command) > 1 and not m.reply_to_message:
|
31 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
32 |
return
|
|
|
60 |
warn_settings = warn_settings_db.get_warnings_settings()
|
61 |
if num >= warn_settings["warn_limit"]:
|
62 |
timeee = datetime.now(TIME_ZONE) + timedelta(minutes=45)
|
63 |
+
if warn_settings["warn_mode"] == "kick" or warn_settings[
|
64 |
+
"warn_mode"
|
65 |
+
] not in ["ban", "mute"]:
|
66 |
await m.chat.ban_member(user_id, until_date=timeee)
|
67 |
action = "kicked"
|
68 |
elif warn_settings["warn_mode"] == "ban":
|
69 |
await m.chat.ban_member(user_id)
|
70 |
action = "banned"
|
71 |
+
else:
|
72 |
await m.chat.restrict_member(user_id, ChatPermissions())
|
73 |
action = "muted"
|
|
|
|
|
|
|
74 |
await m.reply_text(
|
75 |
(
|
76 |
f"Warnings {num}/{warn_settings['warn_limit']}!"
|
|
|
83 |
)
|
84 |
await m.stop_propagation()
|
85 |
|
86 |
+
if rules := Rules(m.chat.id).get_rules():
|
|
|
87 |
kb = InlineKeyboardButton(
|
88 |
"Rules 📋",
|
89 |
url=f"https://t.me/{c.me.username}?start=rules_{m.chat.id}",
|
|
|
125 |
@Gojo.on_message(command("resetwarns") & restrict_filter)
|
126 |
async def reset_warn(c: Gojo, m: Message):
|
127 |
|
128 |
+
if len(m.command) <= 1 and not m.reply_to_message:
|
129 |
await m.reply_text("I can't warn nothing! Tell me user whom I should warn")
|
130 |
return
|
131 |
|
|
|
202 |
)
|
203 |
async def remove_warn(c: Gojo, m: Message):
|
204 |
|
205 |
+
if len(m.command) <= 1 and not m.reply_to_message:
|
206 |
await m.reply_text(
|
207 |
"I can't remove warns of nothing! Tell me user whose warn should be removed!",
|
208 |
)
|
|
|
262 |
action = args[1]
|
263 |
user_id = int(args[2])
|
264 |
chat_id = int(q.message.chat.id)
|
265 |
+
user = Users.get_user_info(user_id)
|
266 |
user_first_name = user["name"]
|
267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
268 |
if action == "kick":
|
269 |
try:
|
270 |
timee = datetime.now(TIME_ZONE) + timedelta(minutes=45)
|
|
|
283 |
f"🛑 Failed to Kick\n<b>Error:</b>\n</code>{err}</code>",
|
284 |
)
|
285 |
|
286 |
+
elif action == "remove":
|
287 |
+
warn_db = Warns(q.message.chat.id)
|
288 |
+
_, num_warns = warn_db.remove_warn(user_id)
|
289 |
+
await q.message.edit_text(
|
290 |
+
(
|
291 |
+
f"Admin {(await mention_html(q.from_user.first_name, q.from_user.id))} "
|
292 |
+
"removed last warn for "
|
293 |
+
f"{(await mention_html(user_first_name, user_id))}\n"
|
294 |
+
f"<b>Current Warnings:</b> {num_warns}"
|
295 |
+
),
|
296 |
+
)
|
297 |
await q.answer()
|
298 |
return
|
299 |
|
Powers/plugins/web_con.py
CHANGED
@@ -105,7 +105,7 @@ from Powers.utils.web_scrapper import INSTAGRAM, SCRAP_DATA
|
|
105 |
# pass
|
106 |
# return
|
107 |
|
108 |
-
songs =
|
109 |
|
110 |
@Gojo.on_callback_query(filters.regex("^lyrics_"))
|
111 |
async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
@@ -117,7 +117,7 @@ async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
|
117 |
artist = None
|
118 |
if artist:
|
119 |
song = genius_lyrics.search_song(song,artist)
|
120 |
-
|
121 |
song = genius_lyrics.search_song(song)
|
122 |
artist = song.artist
|
123 |
if not song.lyrics:
|
@@ -128,10 +128,10 @@ async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
|
128 |
await q.answer("Fetching lyrics")
|
129 |
reply = song.lyrics.split("\n",1)[1]
|
130 |
if len(reply) >= 4096:
|
131 |
-
cap = f"{header}\n{reply[
|
132 |
if artist:
|
133 |
songs[f"{songe}"][f"{artist}"] = reply
|
134 |
-
art = '_'
|
135 |
else:
|
136 |
songs[f"{songe}"] = reply
|
137 |
art = ''
|
@@ -162,25 +162,19 @@ async def lyrics_for_song_next(c: Gojo, q: CallbackQuery):
|
|
162 |
try:
|
163 |
artist = split[3]
|
164 |
header = f"{song.capitalize()} by {artist}"
|
165 |
-
art = '_'
|
166 |
except IndexError:
|
167 |
artist = False
|
168 |
header = f"{song.capitalize()}"
|
169 |
art = ''
|
170 |
try:
|
171 |
-
if artist
|
172 |
-
songe = songs[song][artist]
|
173 |
-
else:
|
174 |
-
songe = songs[song]
|
175 |
except KeyError:
|
176 |
if artist:
|
177 |
songe = genius_lyrics.search_song(song,artist)
|
178 |
-
elif not artist:
|
179 |
-
songe = genius_lyrics.search_song(song)
|
180 |
-
if todo == "next":
|
181 |
-
next_part = songe[4080:]
|
182 |
else:
|
183 |
-
|
|
|
184 |
next_part = f"{header}\n{next_part}"
|
185 |
new_kb = [
|
186 |
[
|
@@ -198,7 +192,7 @@ async def remove_background(c: Gojo, m: Message):
|
|
198 |
if not is_rmbg:
|
199 |
await m.reply_text("Add rmbg api to use this command")
|
200 |
return
|
201 |
-
|
202 |
reply = m.reply_to_message
|
203 |
if not reply:
|
204 |
await m.reply_text("Reply to image/sticker to remove it's background")
|
@@ -231,10 +225,7 @@ async def remove_background(c: Gojo, m: Message):
|
|
231 |
os.remove(file)
|
232 |
return
|
233 |
to_path = "./downloads"
|
234 |
-
if reply.sticker
|
235 |
-
to_path = f'{to_path}/no-bg.webp'
|
236 |
-
else:
|
237 |
-
to_path = f'{to_path}/no-bg.png'
|
238 |
with open(to_path,'wb') as out:
|
239 |
out.write(result.content)
|
240 |
if reply.sticker:
|
@@ -256,17 +247,14 @@ async def song_down_up(c: Gojo, m: Message):
|
|
256 |
await m.reply_text("**USAGE**\n /song [song name | link]")
|
257 |
return
|
258 |
_id = get_video_id(splited)
|
259 |
-
|
260 |
-
query = splited
|
261 |
-
else:
|
262 |
-
query = _id
|
263 |
to_edit = await m.reply_text("⏳")
|
264 |
try:
|
265 |
await youtube_downloader(c,m,query, "a")
|
266 |
await to_edit.delete()
|
267 |
return
|
268 |
except KeyError:
|
269 |
-
await to_edit.edit_text(
|
270 |
return
|
271 |
except Exception as e:
|
272 |
await to_edit.edit_text(f"Got an error\n{e}")
|
@@ -282,17 +270,14 @@ async def video_down_up(c: Gojo, m: Message):
|
|
282 |
await m.reply_text("**USAGE**\n /vsong [song name | link]")
|
283 |
return
|
284 |
_id = get_video_id(splited)
|
285 |
-
|
286 |
-
query = splited
|
287 |
-
else:
|
288 |
-
query = _id
|
289 |
to_edit = await m.reply_text("⏳")
|
290 |
try:
|
291 |
await youtube_downloader(c,m,query,"v")
|
292 |
await to_edit.delete()
|
293 |
return
|
294 |
except KeyError:
|
295 |
-
await to_edit.edit_text(
|
296 |
return
|
297 |
except Exception as e:
|
298 |
await to_edit.edit_text(f"Got an error\n{e}")
|
|
|
105 |
# pass
|
106 |
# return
|
107 |
|
108 |
+
songs = {}
|
109 |
|
110 |
@Gojo.on_callback_query(filters.regex("^lyrics_"))
|
111 |
async def lyrics_for_song(c: Gojo, q: CallbackQuery):
|
|
|
117 |
artist = None
|
118 |
if artist:
|
119 |
song = genius_lyrics.search_song(song,artist)
|
120 |
+
else:
|
121 |
song = genius_lyrics.search_song(song)
|
122 |
artist = song.artist
|
123 |
if not song.lyrics:
|
|
|
128 |
await q.answer("Fetching lyrics")
|
129 |
reply = song.lyrics.split("\n",1)[1]
|
130 |
if len(reply) >= 4096:
|
131 |
+
cap = f"{header}\n{reply[:4080]}..."
|
132 |
if artist:
|
133 |
songs[f"{songe}"][f"{artist}"] = reply
|
134 |
+
art = f'_{artist}'
|
135 |
else:
|
136 |
songs[f"{songe}"] = reply
|
137 |
art = ''
|
|
|
162 |
try:
|
163 |
artist = split[3]
|
164 |
header = f"{song.capitalize()} by {artist}"
|
165 |
+
art = f'_{artist}'
|
166 |
except IndexError:
|
167 |
artist = False
|
168 |
header = f"{song.capitalize()}"
|
169 |
art = ''
|
170 |
try:
|
171 |
+
songe = songs[song][artist] if artist else songs[song]
|
|
|
|
|
|
|
172 |
except KeyError:
|
173 |
if artist:
|
174 |
songe = genius_lyrics.search_song(song,artist)
|
|
|
|
|
|
|
|
|
175 |
else:
|
176 |
+
songe = genius_lyrics.search_song(song)
|
177 |
+
next_part = songe[4080:] if todo == "next" else songe[:4080]
|
178 |
next_part = f"{header}\n{next_part}"
|
179 |
new_kb = [
|
180 |
[
|
|
|
192 |
if not is_rmbg:
|
193 |
await m.reply_text("Add rmbg api to use this command")
|
194 |
return
|
195 |
+
|
196 |
reply = m.reply_to_message
|
197 |
if not reply:
|
198 |
await m.reply_text("Reply to image/sticker to remove it's background")
|
|
|
225 |
os.remove(file)
|
226 |
return
|
227 |
to_path = "./downloads"
|
228 |
+
to_path = f'{to_path}/no-bg.webp' if reply.sticker else f'{to_path}/no-bg.png'
|
|
|
|
|
|
|
229 |
with open(to_path,'wb') as out:
|
230 |
out.write(result.content)
|
231 |
if reply.sticker:
|
|
|
247 |
await m.reply_text("**USAGE**\n /song [song name | link]")
|
248 |
return
|
249 |
_id = get_video_id(splited)
|
250 |
+
query = _id or splited
|
|
|
|
|
|
|
251 |
to_edit = await m.reply_text("⏳")
|
252 |
try:
|
253 |
await youtube_downloader(c,m,query, "a")
|
254 |
await to_edit.delete()
|
255 |
return
|
256 |
except KeyError:
|
257 |
+
await to_edit.edit_text("Failed to find any result")
|
258 |
return
|
259 |
except Exception as e:
|
260 |
await to_edit.edit_text(f"Got an error\n{e}")
|
|
|
270 |
await m.reply_text("**USAGE**\n /vsong [song name | link]")
|
271 |
return
|
272 |
_id = get_video_id(splited)
|
273 |
+
query = _id or splited
|
|
|
|
|
|
|
274 |
to_edit = await m.reply_text("⏳")
|
275 |
try:
|
276 |
await youtube_downloader(c,m,query,"v")
|
277 |
await to_edit.delete()
|
278 |
return
|
279 |
except KeyError:
|
280 |
+
await to_edit.edit_text("Failed to find any result")
|
281 |
return
|
282 |
except Exception as e:
|
283 |
await to_edit.edit_text(f"Got an error\n{e}")
|
Powers/supports.py
CHANGED
@@ -32,7 +32,7 @@ def get_support_staff(want="all"):
|
|
32 |
else:
|
33 |
wanted = list(set([int(OWNER_ID)] + devs + sudo + whitelist))
|
34 |
|
35 |
-
return wanted
|
36 |
|
37 |
async def cache_support():
|
38 |
dev = get_support_staff("dev")
|
|
|
32 |
else:
|
33 |
wanted = list(set([int(OWNER_ID)] + devs + sudo + whitelist))
|
34 |
|
35 |
+
return wanted or []
|
36 |
|
37 |
async def cache_support():
|
38 |
dev = get_support_staff("dev")
|
Powers/utils/captcha_helper.py
CHANGED
@@ -26,11 +26,7 @@ def genrator():
|
|
26 |
rand_alpha = choice(alpha)
|
27 |
if_ = randint(0, 1)
|
28 |
|
29 |
-
if if_
|
30 |
-
new_alpha = rand_alpha.upper()
|
31 |
-
else:
|
32 |
-
new_alpha = rand_alpha
|
33 |
-
|
34 |
list_ = [new_alpha]
|
35 |
while len(list_) != 4:
|
36 |
xXx = randrange(0, 9)
|
|
|
26 |
rand_alpha = choice(alpha)
|
27 |
if_ = randint(0, 1)
|
28 |
|
29 |
+
new_alpha = rand_alpha.upper() if if_ else rand_alpha
|
|
|
|
|
|
|
|
|
30 |
list_ = [new_alpha]
|
31 |
while len(list_) != 4:
|
32 |
xXx = randrange(0, 9)
|
Powers/utils/custom_filters.py
CHANGED
@@ -38,7 +38,7 @@ def command(
|
|
38 |
if m.chat and m.chat.type == ChatType.CHANNEL:
|
39 |
return False
|
40 |
|
41 |
-
if m and not
|
42 |
return False
|
43 |
|
44 |
if m.from_user.is_bot:
|
@@ -85,15 +85,13 @@ def command(
|
|
85 |
|
86 |
ddb = Disabling(m.chat.id)
|
87 |
if str(matches.group(1)) in ddb.get_disabled() and user_status not in (
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
pass
|
96 |
-
return False
|
97 |
if matches.group(3) == "":
|
98 |
return True
|
99 |
try:
|
@@ -313,10 +311,7 @@ async def auto_join_check_filter(_, __, j: ChatJoinRequest):
|
|
313 |
aj = AUTOJOIN()
|
314 |
join_type = aj.get_autojoin(chat)
|
315 |
|
316 |
-
|
317 |
-
return False
|
318 |
-
else:
|
319 |
-
return True
|
320 |
|
321 |
|
322 |
async def afk_check_filter(_, __, m: Message):
|
@@ -333,8 +328,7 @@ async def afk_check_filter(_, __, m: Message):
|
|
333 |
chat = m.chat.id
|
334 |
is_repl_afk = None
|
335 |
if m.reply_to_message:
|
336 |
-
repl_user
|
337 |
-
if repl_user:
|
338 |
repl_user = m.reply_to_message.from_user.id
|
339 |
is_repl_afk = afk.check_afk(chat, repl_user)
|
340 |
|
@@ -342,10 +336,7 @@ async def afk_check_filter(_, __, m: Message):
|
|
342 |
|
343 |
is_afk = afk.check_afk(chat, user)
|
344 |
|
345 |
-
|
346 |
-
return False
|
347 |
-
else:
|
348 |
-
return True
|
349 |
|
350 |
|
351 |
async def flood_check_filter(_, __, m: Message):
|
@@ -388,7 +379,7 @@ async def flood_check_filter(_, __, m: Message):
|
|
388 |
async def captcha_filt(_, __, m: Message):
|
389 |
try:
|
390 |
return CAPTCHA().is_captcha(m.chat.id)
|
391 |
-
except:
|
392 |
return False
|
393 |
|
394 |
captcha_filter = create(captcha_filt)
|
|
|
38 |
if m.chat and m.chat.type == ChatType.CHANNEL:
|
39 |
return False
|
40 |
|
41 |
+
if m and not m.from_user and not m.chat.is_admin:
|
42 |
return False
|
43 |
|
44 |
if m.from_user.is_bot:
|
|
|
85 |
|
86 |
ddb = Disabling(m.chat.id)
|
87 |
if str(matches.group(1)) in ddb.get_disabled() and user_status not in (
|
88 |
+
CMS.OWNER,
|
89 |
+
CMS.ADMINISTRATOR,
|
90 |
+
) and ddb.get_action() == "del":
|
91 |
+
try:
|
92 |
+
await m.delete()
|
93 |
+
except RPCError:
|
94 |
+
return False
|
|
|
|
|
95 |
if matches.group(3) == "":
|
96 |
return True
|
97 |
try:
|
|
|
311 |
aj = AUTOJOIN()
|
312 |
join_type = aj.get_autojoin(chat)
|
313 |
|
314 |
+
return bool(join_type)
|
|
|
|
|
|
|
315 |
|
316 |
|
317 |
async def afk_check_filter(_, __, m: Message):
|
|
|
328 |
chat = m.chat.id
|
329 |
is_repl_afk = None
|
330 |
if m.reply_to_message:
|
331 |
+
if repl_user := m.reply_to_message.from_user:
|
|
|
332 |
repl_user = m.reply_to_message.from_user.id
|
333 |
is_repl_afk = afk.check_afk(chat, repl_user)
|
334 |
|
|
|
336 |
|
337 |
is_afk = afk.check_afk(chat, user)
|
338 |
|
339 |
+
return bool((is_afk or is_repl_afk))
|
|
|
|
|
|
|
340 |
|
341 |
|
342 |
async def flood_check_filter(_, __, m: Message):
|
|
|
379 |
async def captcha_filt(_, __, m: Message):
|
380 |
try:
|
381 |
return CAPTCHA().is_captcha(m.chat.id)
|
382 |
+
except Exception:
|
383 |
return False
|
384 |
|
385 |
captcha_filter = create(captcha_filt)
|
Powers/utils/extract_user.py
CHANGED
@@ -37,7 +37,7 @@ async def extract_user(c: Gojo, m: Message) -> Tuple[int, str, str]:
|
|
37 |
|
38 |
try:
|
39 |
user_found = int(user_found)
|
40 |
-
except
|
41 |
if "invalid literal for int() with base 10:" in str(ef):
|
42 |
user_found = str(user_found)
|
43 |
else:
|
@@ -72,7 +72,7 @@ async def extract_user(c: Gojo, m: Message) -> Tuple[int, str, str]:
|
|
72 |
else:
|
73 |
try:
|
74 |
user_id = int(m.text.split()[1])
|
75 |
-
except
|
76 |
if "invalid literal for int() with base 10:" in str(ef):
|
77 |
user_id = (
|
78 |
str(m.text.split()[1])
|
|
|
37 |
|
38 |
try:
|
39 |
user_found = int(user_found)
|
40 |
+
except Exception as ef:
|
41 |
if "invalid literal for int() with base 10:" in str(ef):
|
42 |
user_found = str(user_found)
|
43 |
else:
|
|
|
72 |
else:
|
73 |
try:
|
74 |
user_id = int(m.text.split()[1])
|
75 |
+
except Exception as ef:
|
76 |
if "invalid literal for int() with base 10:" in str(ef):
|
77 |
user_id = (
|
78 |
str(m.text.split()[1])
|