Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
5bc27d3
1
Parent(s):
c15d499
Changed according to `new pyrogram version`
Browse files- Powers/plugins/admin.py +9 -7
- Powers/plugins/approve.py +4 -3
- Powers/plugins/blacklist.py +11 -6
- Powers/plugins/disable.py +5 -3
- Powers/plugins/filters.py +9 -5
- Powers/plugins/greetings.py +3 -2
- Powers/plugins/notes.py +11 -6
- Powers/plugins/pin.py +3 -2
- Powers/plugins/start.py +7 -4
- Powers/utils/admin_check.py +6 -5
- Powers/utils/custom_filters.py +11 -10
Powers/plugins/admin.py
CHANGED
@@ -2,6 +2,7 @@ from os import remove
|
|
2 |
from html import escape
|
3 |
from asyncio import sleep
|
4 |
from pyrogram import filters
|
|
|
5 |
from Powers.vars import Config
|
6 |
from traceback import format_exc
|
7 |
from Powers.bot_class import Gojo
|
@@ -40,7 +41,8 @@ async def adminlist_show(_, m: Message):
|
|
40 |
adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
|
41 |
|
42 |
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
|
43 |
-
user_admins = [i for i in admin_list if not (
|
|
|
44 |
|
45 |
# format is like: (user_id, username/name,anonyamous or not)
|
46 |
mention_users = [
|
@@ -189,7 +191,7 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
189 |
) # This should be here
|
190 |
|
191 |
user = await c.get_chat_member(m.chat.id, m.from_user.id)
|
192 |
-
if m.from_user.id
|
193 |
return await m.reply_text("This command can only be used by chat owner.")
|
194 |
# If user is alreay admin
|
195 |
try:
|
@@ -396,7 +398,7 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
396 |
if m.from_user.id not in DEV_LEVEL:
|
397 |
user = await m.chat.get_member(m.from_user.id)
|
398 |
|
399 |
-
if not user.can_invite_users and user.status !=
|
400 |
await m.reply_text(text="You don't have rights to invite users....")
|
401 |
return False
|
402 |
|
@@ -427,7 +429,7 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
427 |
async def setgtitle(_, m: Message):
|
428 |
user = await m.chat.get_member(m.from_user.id)
|
429 |
|
430 |
-
if not user.can_change_info and user.status !=
|
431 |
await m.reply_text(
|
432 |
"You don't have enough permission to use this command!",
|
433 |
)
|
@@ -450,7 +452,7 @@ async def setgtitle(_, m: Message):
|
|
450 |
async def setgdes(_, m: Message):
|
451 |
|
452 |
user = await m.chat.get_member(m.from_user.id)
|
453 |
-
if not user.can_change_info and user.status !=
|
454 |
await m.reply_text(
|
455 |
"You don't have enough permission to use this command!",
|
456 |
)
|
@@ -473,7 +475,7 @@ async def setgdes(_, m: Message):
|
|
473 |
async def set_user_title(c: Gojo, m: Message):
|
474 |
|
475 |
user = await m.chat.get_member(m.from_user.id)
|
476 |
-
if not user.can_promote_members and user.status !=
|
477 |
await m.reply_text(
|
478 |
"You don't have enough permission to use this command!",
|
479 |
)
|
@@ -516,7 +518,7 @@ async def set_user_title(c: Gojo, m: Message):
|
|
516 |
@Gojo.on_message(command("setgpic") & admin_filter)
|
517 |
async def setgpic(c: Gojo, m: Message):
|
518 |
user = await m.chat.get_member(m.from_user.id)
|
519 |
-
if not user.can_change_info and user.status !=
|
520 |
await m.reply_text(
|
521 |
"You don't have enough permission to use this command!",
|
522 |
)
|
|
|
2 |
from html import escape
|
3 |
from asyncio import sleep
|
4 |
from pyrogram import filters
|
5 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
6 |
from Powers.vars import Config
|
7 |
from traceback import format_exc
|
8 |
from Powers.bot_class import Gojo
|
|
|
41 |
adminstr = f"Admins in <b>{m.chat.title}</b>:" + "\n\n"
|
42 |
|
43 |
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
|
44 |
+
user_admins = [i for i in admin_list if not (
|
45 |
+
i[1].lower()).endswith("bot")]
|
46 |
|
47 |
# format is like: (user_id, username/name,anonyamous or not)
|
48 |
mention_users = [
|
|
|
191 |
) # This should be here
|
192 |
|
193 |
user = await c.get_chat_member(m.chat.id, m.from_user.id)
|
194 |
+
if m.from_user.id != OWNER_ID and user.status != CMS.OWNER:
|
195 |
return await m.reply_text("This command can only be used by chat owner.")
|
196 |
# If user is alreay admin
|
197 |
try:
|
|
|
398 |
if m.from_user.id not in DEV_LEVEL:
|
399 |
user = await m.chat.get_member(m.from_user.id)
|
400 |
|
401 |
+
if not user.can_invite_users and user.status != CMS.OWNER:
|
402 |
await m.reply_text(text="You don't have rights to invite users....")
|
403 |
return False
|
404 |
|
|
|
429 |
async def setgtitle(_, m: Message):
|
430 |
user = await m.chat.get_member(m.from_user.id)
|
431 |
|
432 |
+
if not user.can_change_info and user.status != CMS.OWNER:
|
433 |
await m.reply_text(
|
434 |
"You don't have enough permission to use this command!",
|
435 |
)
|
|
|
452 |
async def setgdes(_, m: Message):
|
453 |
|
454 |
user = await m.chat.get_member(m.from_user.id)
|
455 |
+
if not user.can_change_info and user.status != CMS.OWNER:
|
456 |
await m.reply_text(
|
457 |
"You don't have enough permission to use this command!",
|
458 |
)
|
|
|
475 |
async def set_user_title(c: Gojo, m: Message):
|
476 |
|
477 |
user = await m.chat.get_member(m.from_user.id)
|
478 |
+
if not user.can_promote_members and user.status != CMS.OWNER:
|
479 |
await m.reply_text(
|
480 |
"You don't have enough permission to use this command!",
|
481 |
)
|
|
|
518 |
@Gojo.on_message(command("setgpic") & admin_filter)
|
519 |
async def setgpic(c: Gojo, m: Message):
|
520 |
user = await m.chat.get_member(m.from_user.id)
|
521 |
+
if not user.can_change_info and user.status != CMS.OWNER:
|
522 |
await m.reply_text(
|
523 |
"You don't have enough permission to use this command!",
|
524 |
)
|
Powers/plugins/approve.py
CHANGED
@@ -7,6 +7,7 @@ from Powers.database.approve_db import Approve
|
|
7 |
from pyrogram.types import Message, CallbackQuery
|
8 |
from Powers.utils.extract_user import extract_user
|
9 |
from pyrogram.errors import RPCError, PeerIdInvalid, UserNotParticipant
|
|
|
10 |
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
11 |
|
12 |
|
@@ -37,7 +38,7 @@ async def approve_user(c: Gojo, m: Message):
|
|
37 |
f"<b>Error</b>: <code>{ef}</code>\nReport it to @{SUPPORT_GROUP}",
|
38 |
)
|
39 |
return
|
40 |
-
if member.status in (
|
41 |
await m.reply_text(
|
42 |
"User is already admin - blacklists and locks already don't apply to them.",
|
43 |
)
|
@@ -97,7 +98,7 @@ async def disapprove_user(c: Gojo, m: Message):
|
|
97 |
)
|
98 |
return
|
99 |
|
100 |
-
if member.status in (
|
101 |
await m.reply_text("This user is an admin, they can't be disapproved.")
|
102 |
return
|
103 |
|
@@ -202,7 +203,7 @@ async def unapproveall_callback(_, q: CallbackQuery):
|
|
202 |
db = Approve(q.message.chat.id)
|
203 |
approved_people = db.list_approved()
|
204 |
user_status = (await q.message.chat.get_member(user_id)).status
|
205 |
-
if user_status not in {
|
206 |
await q.answer(
|
207 |
"You're not even an admin, don't try this explosive shit!",
|
208 |
show_alert=True,
|
|
|
7 |
from pyrogram.types import Message, CallbackQuery
|
8 |
from Powers.utils.extract_user import extract_user
|
9 |
from pyrogram.errors import RPCError, PeerIdInvalid, UserNotParticipant
|
10 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
11 |
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
12 |
|
13 |
|
|
|
38 |
f"<b>Error</b>: <code>{ef}</code>\nReport it to @{SUPPORT_GROUP}",
|
39 |
)
|
40 |
return
|
41 |
+
if member.status in (CMS.ADMINISTRATOR, CMS.OWNER):
|
42 |
await m.reply_text(
|
43 |
"User is already admin - blacklists and locks already don't apply to them.",
|
44 |
)
|
|
|
98 |
)
|
99 |
return
|
100 |
|
101 |
+
if member.status in (CMS.OWNER, CMS.ADMINISTRATOR):
|
102 |
await m.reply_text("This user is an admin, they can't be disapproved.")
|
103 |
return
|
104 |
|
|
|
203 |
db = Approve(q.message.chat.id)
|
204 |
approved_people = db.list_approved()
|
205 |
user_status = (await q.message.chat.get_member(user_id)).status
|
206 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
207 |
await q.answer(
|
208 |
"You're not even an admin, don't try this explosive shit!",
|
209 |
show_alert=True,
|
Powers/plugins/blacklist.py
CHANGED
@@ -4,6 +4,7 @@ from pyrogram import filters
|
|
4 |
from Powers.bot_class import Gojo
|
5 |
from Powers.utils.kbhelpers import ikb
|
6 |
from pyrogram.types import Message, CallbackQuery
|
|
|
7 |
from Powers.database.blacklist_db import Blacklist
|
8 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
9 |
|
@@ -55,7 +56,8 @@ async def add_blacklist(_, m: Message):
|
|
55 |
", ".join([f"<code>{i}</code>" for i in bl_words])
|
56 |
+ " already added in blacklist, skipped them!"
|
57 |
)
|
58 |
-
LOGGER.info(
|
|
|
59 |
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
60 |
await m.reply_text(
|
61 |
text=f"Added <code>{trigger}</code> in blacklist words!"
|
@@ -110,10 +112,12 @@ async def rm_blacklist(_, m: Message):
|
|
110 |
|
111 |
if non_found_words:
|
112 |
rep_text = (
|
113 |
-
"Could not find " +
|
|
|
114 |
) + " in blcklisted words, skipped them."
|
115 |
|
116 |
-
LOGGER.info(
|
|
|
117 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
118 |
await m.reply_text(
|
119 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
@@ -148,7 +152,8 @@ async def set_bl_action(_, m: Message):
|
|
148 |
await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
|
149 |
elif len(m.text.split()) == 1:
|
150 |
action = db.get_action()
|
151 |
-
LOGGER.info(
|
|
|
152 |
await m.reply_text(
|
153 |
text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
|
154 |
All blacklist modes delete the message containing blacklist word."""
|
@@ -184,13 +189,13 @@ async def rm_allbl_callback(_, q: CallbackQuery):
|
|
184 |
user_id = q.from_user.id
|
185 |
db = Blacklist(q.message.chat.id)
|
186 |
user_status = (await q.message.chat.get_member(user_id)).status
|
187 |
-
if user_status not in {
|
188 |
await q.answer(
|
189 |
"You're not even an admin, don't try this explosive shit!",
|
190 |
show_alert=True,
|
191 |
)
|
192 |
return
|
193 |
-
if user_status !=
|
194 |
await q.answer(
|
195 |
"You're just an admin, not owner\nStay in your limits!",
|
196 |
show_alert=True,
|
|
|
4 |
from Powers.bot_class import Gojo
|
5 |
from Powers.utils.kbhelpers import ikb
|
6 |
from pyrogram.types import Message, CallbackQuery
|
7 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
8 |
from Powers.database.blacklist_db import Blacklist
|
9 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
10 |
|
|
|
56 |
", ".join([f"<code>{i}</code>" for i in bl_words])
|
57 |
+ " already added in blacklist, skipped them!"
|
58 |
)
|
59 |
+
LOGGER.info(
|
60 |
+
f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
|
61 |
trigger = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
62 |
await m.reply_text(
|
63 |
text=f"Added <code>{trigger}</code> in blacklist words!"
|
|
|
112 |
|
113 |
if non_found_words:
|
114 |
rep_text = (
|
115 |
+
"Could not find " +
|
116 |
+
", ".join(f"<code>{i}</code>" for i in non_found_words)
|
117 |
) + " in blcklisted words, skipped them."
|
118 |
|
119 |
+
LOGGER.info(
|
120 |
+
f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
|
121 |
bl_words = ", ".join(f"<code>{i}</code>" for i in bl_words)
|
122 |
await m.reply_text(
|
123 |
text=f"Removed <b>{bl_words}</b> from blacklist words!"
|
|
|
152 |
await m.reply_text(text=f"Set action for blacklist for this to <b>{action}</b>")
|
153 |
elif len(m.text.split()) == 1:
|
154 |
action = db.get_action()
|
155 |
+
LOGGER.info(
|
156 |
+
f"{m.from_user.id} checking blacklist action in {m.chat.id}")
|
157 |
await m.reply_text(
|
158 |
text=f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
|
159 |
All blacklist modes delete the message containing blacklist word."""
|
|
|
189 |
user_id = q.from_user.id
|
190 |
db = Blacklist(q.message.chat.id)
|
191 |
user_status = (await q.message.chat.get_member(user_id)).status
|
192 |
+
if user_status not in {CMS.ADMINISTRATOR, CMS.OWNER}:
|
193 |
await q.answer(
|
194 |
"You're not even an admin, don't try this explosive shit!",
|
195 |
show_alert=True,
|
196 |
)
|
197 |
return
|
198 |
+
if user_status != CMS.OWNER:
|
199 |
await q.answer(
|
200 |
"You're just an admin, not owner\nStay in your limits!",
|
201 |
show_alert=True,
|
Powers/plugins/disable.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from html import escape
|
2 |
from pyrogram import filters
|
|
|
3 |
from Powers.bot_class import Gojo
|
4 |
from Powers import LOGGER, HELP_COMMANDS
|
5 |
from Powers.database.disable_db import Disabling
|
@@ -116,7 +117,8 @@ async def rm_alldisbl(_, m: Message):
|
|
116 |
"Confirm",
|
117 |
callback_data="enableallcmds",
|
118 |
),
|
119 |
-
InlineKeyboardButton(
|
|
|
120 |
],
|
121 |
],
|
122 |
),
|
@@ -128,13 +130,13 @@ async def rm_alldisbl(_, m: Message):
|
|
128 |
async def enablealll(_, q: CallbackQuery):
|
129 |
user_id = q.from_user.id
|
130 |
user_status = (await q.message.chat.get_member(user_id)).status
|
131 |
-
if user_status not in {
|
132 |
await q.answer(
|
133 |
"You're not even an admin, don't try this explosive shit!",
|
134 |
show_alert=True,
|
135 |
)
|
136 |
return
|
137 |
-
if user_status !=
|
138 |
await q.answer(
|
139 |
"You're just an admin, not owner\nStay in your limits!",
|
140 |
show_alert=True,
|
|
|
1 |
from html import escape
|
2 |
from pyrogram import filters
|
3 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
4 |
from Powers.bot_class import Gojo
|
5 |
from Powers import LOGGER, HELP_COMMANDS
|
6 |
from Powers.database.disable_db import Disabling
|
|
|
117 |
"Confirm",
|
118 |
callback_data="enableallcmds",
|
119 |
),
|
120 |
+
InlineKeyboardButton(
|
121 |
+
"Cancel", callback_data="close_admin"),
|
122 |
],
|
123 |
],
|
124 |
),
|
|
|
130 |
async def enablealll(_, q: CallbackQuery):
|
131 |
user_id = q.from_user.id
|
132 |
user_status = (await q.message.chat.get_member(user_id)).status
|
133 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
134 |
await q.answer(
|
135 |
"You're not even an admin, don't try this explosive shit!",
|
136 |
show_alert=True,
|
137 |
)
|
138 |
return
|
139 |
+
if user_status != CMS.OWNER:
|
140 |
await q.answer(
|
141 |
"You're just an admin, not owner\nStay in your limits!",
|
142 |
show_alert=True,
|
Powers/plugins/filters.py
CHANGED
@@ -10,6 +10,7 @@ from Powers.database.filters_db import Filters
|
|
10 |
from Powers.utils.regex_utils import regex_searcher
|
11 |
from Powers.utils.msg_types import Types, get_filter_type
|
12 |
from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
|
|
|
13 |
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
14 |
from Powers.utils.string import (
|
15 |
parse_button, split_quotes, build_keyboard,
|
@@ -95,7 +96,8 @@ async def add_filter(_, m: Message):
|
|
95 |
)
|
96 |
|
97 |
add = db.save_filter(m.chat.id, keyword, teks, msgtype, file_id)
|
98 |
-
LOGGER.info(
|
|
|
99 |
if add:
|
100 |
await m.reply_text(
|
101 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
@@ -119,7 +121,8 @@ async def stop_filter(_, m: Message):
|
|
119 |
for keyword in act_filters:
|
120 |
if keyword == m.text.split(None, 1)[1].lower():
|
121 |
db.rm_filter(m.chat.id, m.text.split(None, 1)[1].lower())
|
122 |
-
LOGGER.info(
|
|
|
123 |
await m.reply_text(
|
124 |
f"Okay, I'll stop replying to that filter and it's aliases in <b>{m.chat.title}</b>.",
|
125 |
)
|
@@ -154,13 +157,13 @@ async def rm_allfilters(_, m: Message):
|
|
154 |
async def rm_allfilters_callback(_, q: CallbackQuery):
|
155 |
user_id = q.from_user.id
|
156 |
user_status = (await q.message.chat.get_member(user_id)).status
|
157 |
-
if user_status not in {
|
158 |
await q.answer(
|
159 |
"You're not even an admin, don't try this explosive shit!",
|
160 |
show_alert=True,
|
161 |
)
|
162 |
return
|
163 |
-
if user_status !=
|
164 |
await q.answer(
|
165 |
"You're just an admin, not owner\nStay in your limits!",
|
166 |
show_alert=True,
|
@@ -280,7 +283,8 @@ async def filters_watcher(c: Gojo, m: Message):
|
|
280 |
if match:
|
281 |
try:
|
282 |
msgtype = await send_filter_reply(c, m, trigger)
|
283 |
-
LOGGER.info(
|
|
|
284 |
except Exception as ef:
|
285 |
await m.reply_text(f"Error: {ef}")
|
286 |
LOGGER.error(ef)
|
|
|
10 |
from Powers.utils.regex_utils import regex_searcher
|
11 |
from Powers.utils.msg_types import Types, get_filter_type
|
12 |
from pyrogram.types import Message, CallbackQuery, InlineKeyboardMarkup
|
13 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
14 |
from Powers.utils.custom_filters import command, admin_filter, owner_filter
|
15 |
from Powers.utils.string import (
|
16 |
parse_button, split_quotes, build_keyboard,
|
|
|
96 |
)
|
97 |
|
98 |
add = db.save_filter(m.chat.id, keyword, teks, msgtype, file_id)
|
99 |
+
LOGGER.info(
|
100 |
+
f"{m.from_user.id} added new filter ({keyword}) in {m.chat.id}")
|
101 |
if add:
|
102 |
await m.reply_text(
|
103 |
f"Saved filter for '<code>{', '.join(keyword.split('|'))}</code>' in <b>{m.chat.title}</b>!",
|
|
|
121 |
for keyword in act_filters:
|
122 |
if keyword == m.text.split(None, 1)[1].lower():
|
123 |
db.rm_filter(m.chat.id, m.text.split(None, 1)[1].lower())
|
124 |
+
LOGGER.info(
|
125 |
+
f"{m.from_user.id} removed filter ({keyword}) in {m.chat.id}")
|
126 |
await m.reply_text(
|
127 |
f"Okay, I'll stop replying to that filter and it's aliases in <b>{m.chat.title}</b>.",
|
128 |
)
|
|
|
157 |
async def rm_allfilters_callback(_, q: CallbackQuery):
|
158 |
user_id = q.from_user.id
|
159 |
user_status = (await q.message.chat.get_member(user_id)).status
|
160 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
161 |
await q.answer(
|
162 |
"You're not even an admin, don't try this explosive shit!",
|
163 |
show_alert=True,
|
164 |
)
|
165 |
return
|
166 |
+
if user_status != CMS.OWNER:
|
167 |
await q.answer(
|
168 |
"You're just an admin, not owner\nStay in your limits!",
|
169 |
show_alert=True,
|
|
|
283 |
if match:
|
284 |
try:
|
285 |
msgtype = await send_filter_reply(c, m, trigger)
|
286 |
+
LOGGER.info(
|
287 |
+
f"Replied with {msgtype} to {trigger} in {m.chat.id}")
|
288 |
except Exception as ef:
|
289 |
await m.reply_text(f"Error: {ef}")
|
290 |
LOGGER.error(ef)
|
Powers/plugins/greetings.py
CHANGED
@@ -9,6 +9,7 @@ from Powers.database.antispam_db import GBan
|
|
9 |
from Powers.database.greetings_db import Greetings
|
10 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
11 |
from pyrogram.errors import RPCError, ChatAdminRequired
|
|
|
12 |
from Powers.utils.parser import mention_html, escape_markdown
|
13 |
from pyrogram.types import Message, ChatMemberUpdated, InlineKeyboardMarkup
|
14 |
from Powers.utils.custom_filters import command, admin_filter, bot_admin_filter
|
@@ -238,7 +239,7 @@ async def member_has_joined(c: Gojo, member: ChatMemberUpdated):
|
|
238 |
|
239 |
if (
|
240 |
member.new_chat_member
|
241 |
-
and member.new_chat_member.status not in {
|
242 |
and not member.old_chat_member
|
243 |
):
|
244 |
pass
|
@@ -321,7 +322,7 @@ async def member_has_left(c: Gojo, member: ChatMemberUpdated):
|
|
321 |
|
322 |
if (
|
323 |
not member.new_chat_member
|
324 |
-
and member.old_chat_member.status not in {
|
325 |
and member.old_chat_member
|
326 |
):
|
327 |
pass
|
|
|
9 |
from Powers.database.greetings_db import Greetings
|
10 |
from Powers.utils.msg_types import Types, get_wlcm_type
|
11 |
from pyrogram.errors import RPCError, ChatAdminRequired
|
12 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
13 |
from Powers.utils.parser import mention_html, escape_markdown
|
14 |
from pyrogram.types import Message, ChatMemberUpdated, InlineKeyboardMarkup
|
15 |
from Powers.utils.custom_filters import command, admin_filter, bot_admin_filter
|
|
|
239 |
|
240 |
if (
|
241 |
member.new_chat_member
|
242 |
+
and member.new_chat_member.status not in {CMS.BANNED, CMS.LEFT, CMS.RESTRICTED}
|
243 |
and not member.old_chat_member
|
244 |
):
|
245 |
pass
|
|
|
322 |
|
323 |
if (
|
324 |
not member.new_chat_member
|
325 |
+
and member.old_chat_member.status not in {CMS.BANNED, CMS.RESTRICTED}
|
326 |
and member.old_chat_member
|
327 |
):
|
328 |
pass
|
Powers/plugins/notes.py
CHANGED
@@ -5,6 +5,7 @@ from traceback import format_exc
|
|
5 |
from Powers.bot_class import Gojo
|
6 |
from pyrogram import enums, filters
|
7 |
from pyrogram.errors import RPCError
|
|
|
8 |
from Powers.utils.kbhelpers import ikb
|
9 |
from Powers.utils.cmd_senders import send_cmd
|
10 |
from Powers.utils.msg_types import Types, get_note_type
|
@@ -73,7 +74,8 @@ async def get_note_func(c: Gojo, m: Message, note_name, priv_notes_status):
|
|
73 |
|
74 |
if priv_notes_status:
|
75 |
|
76 |
-
note_hash = next(i[1] for i in db.get_all_notes(
|
|
|
77 |
await reply_text(
|
78 |
f"Click on the button to get the note <code>{note_name}</code>",
|
79 |
reply_markup=ikb(
|
@@ -299,11 +301,13 @@ async def priv_notes(_, m: Message):
|
|
299 |
option = (m.text.split())[1]
|
300 |
if option in ("on", "yes"):
|
301 |
db_settings.set_privatenotes(chat_id, True)
|
302 |
-
LOGGER.info(
|
|
|
303 |
msg = "Set private notes to On"
|
304 |
elif option in ("off", "no"):
|
305 |
db_settings.set_privatenotes(chat_id, False)
|
306 |
-
LOGGER.info(
|
|
|
307 |
msg = "Set private notes to Off"
|
308 |
else:
|
309 |
msg = "Enter correct option"
|
@@ -311,7 +315,8 @@ async def priv_notes(_, m: Message):
|
|
311 |
elif len(m.text.split()) == 1:
|
312 |
curr_pref = db_settings.get_privatenotes(m.chat.id)
|
313 |
msg = msg = f"Private Notes: {curr_pref}"
|
314 |
-
LOGGER.info(
|
|
|
315 |
await m.reply_text(msg)
|
316 |
else:
|
317 |
await m.replt_text("Check help on how to use this command!")
|
@@ -399,13 +404,13 @@ async def clear_allnote(_, m: Message):
|
|
399 |
async def clearallnotes_callback(_, q: CallbackQuery):
|
400 |
user_id = q.from_user.id
|
401 |
user_status = (await q.message.chat.get_member(user_id)).status
|
402 |
-
if user_status not in {
|
403 |
await q.answer(
|
404 |
"You're not even an admin, don't try this explosive shit!",
|
405 |
show_alert=True,
|
406 |
)
|
407 |
return
|
408 |
-
if user_status !=
|
409 |
await q.answer(
|
410 |
"You're just an admin, not owner\nStay in your limits!",
|
411 |
show_alert=True,
|
|
|
5 |
from Powers.bot_class import Gojo
|
6 |
from pyrogram import enums, filters
|
7 |
from pyrogram.errors import RPCError
|
8 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
9 |
from Powers.utils.kbhelpers import ikb
|
10 |
from Powers.utils.cmd_senders import send_cmd
|
11 |
from Powers.utils.msg_types import Types, get_note_type
|
|
|
74 |
|
75 |
if priv_notes_status:
|
76 |
|
77 |
+
note_hash = next(i[1] for i in db.get_all_notes(
|
78 |
+
m.chat.id) if i[0] == note_name)
|
79 |
await reply_text(
|
80 |
f"Click on the button to get the note <code>{note_name}</code>",
|
81 |
reply_markup=ikb(
|
|
|
301 |
option = (m.text.split())[1]
|
302 |
if option in ("on", "yes"):
|
303 |
db_settings.set_privatenotes(chat_id, True)
|
304 |
+
LOGGER.info(
|
305 |
+
f"{m.from_user.id} enabled privatenotes in {m.chat.id}")
|
306 |
msg = "Set private notes to On"
|
307 |
elif option in ("off", "no"):
|
308 |
db_settings.set_privatenotes(chat_id, False)
|
309 |
+
LOGGER.info(
|
310 |
+
f"{m.from_user.id} disabled privatenotes in {m.chat.id}")
|
311 |
msg = "Set private notes to Off"
|
312 |
else:
|
313 |
msg = "Enter correct option"
|
|
|
315 |
elif len(m.text.split()) == 1:
|
316 |
curr_pref = db_settings.get_privatenotes(m.chat.id)
|
317 |
msg = msg = f"Private Notes: {curr_pref}"
|
318 |
+
LOGGER.info(
|
319 |
+
f"{m.from_user.id} fetched privatenotes preference in {m.chat.id}")
|
320 |
await m.reply_text(msg)
|
321 |
else:
|
322 |
await m.replt_text("Check help on how to use this command!")
|
|
|
404 |
async def clearallnotes_callback(_, q: CallbackQuery):
|
405 |
user_id = q.from_user.id
|
406 |
user_status = (await q.message.chat.get_member(user_id)).status
|
407 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
408 |
await q.answer(
|
409 |
"You're not even an admin, don't try this explosive shit!",
|
410 |
show_alert=True,
|
411 |
)
|
412 |
return
|
413 |
+
if user_status != CMS.OWNER:
|
414 |
await q.answer(
|
415 |
"You're just an admin, not owner\nStay in your limits!",
|
416 |
show_alert=True,
|
Powers/plugins/pin.py
CHANGED
@@ -5,6 +5,7 @@ from html import escape as escape_html
|
|
5 |
from Powers import LOGGER, SUPPORT_GROUP
|
6 |
from Powers.database.pins_db import Pins
|
7 |
from pyrogram.types import Message, CallbackQuery
|
|
|
8 |
from Powers.utils.string import parse_button, build_keyboard
|
9 |
from Powers.utils.custom_filters import command, admin_filter
|
10 |
from pyrogram.errors import RPCError, RightForbidden, ChatAdminRequired
|
@@ -101,13 +102,13 @@ async def unpinall_message(_, m: Message):
|
|
101 |
async def unpinall_calllback(c: Gojo, q: CallbackQuery):
|
102 |
user_id = q.from_user.id
|
103 |
user_status = (await q.message.chat.get_member(user_id)).status
|
104 |
-
if user_status not in {
|
105 |
await q.answer(
|
106 |
"You're not even an admin, don't try this explosive shit!",
|
107 |
show_alert=True,
|
108 |
)
|
109 |
return
|
110 |
-
if user_status !=
|
111 |
await q.answer(
|
112 |
"You're just an admin, not owner\nStay in your limits!",
|
113 |
show_alert=True,
|
|
|
5 |
from Powers import LOGGER, SUPPORT_GROUP
|
6 |
from Powers.database.pins_db import Pins
|
7 |
from pyrogram.types import Message, CallbackQuery
|
8 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
9 |
from Powers.utils.string import parse_button, build_keyboard
|
10 |
from Powers.utils.custom_filters import command, admin_filter
|
11 |
from pyrogram.errors import RPCError, RightForbidden, ChatAdminRequired
|
|
|
102 |
async def unpinall_calllback(c: Gojo, q: CallbackQuery):
|
103 |
user_id = q.from_user.id
|
104 |
user_status = (await q.message.chat.get_member(user_id)).status
|
105 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
106 |
await q.answer(
|
107 |
"You're not even an admin, don't try this explosive shit!",
|
108 |
show_alert=True,
|
109 |
)
|
110 |
return
|
111 |
+
if user_status != CMS.OWNER:
|
112 |
await q.answer(
|
113 |
"You're just an admin, not owner\nStay in your limits!",
|
114 |
show_alert=True,
|
Powers/plugins/start.py
CHANGED
@@ -9,6 +9,7 @@ from Powers.utils.chat_type import chattype
|
|
9 |
from Powers.utils.custom_filters import command
|
10 |
from pyrogram.types import Message, CallbackQuery
|
11 |
from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
|
|
|
12 |
from Powers.utils.start_utils import (
|
13 |
gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
|
14 |
get_private_rules)
|
@@ -37,13 +38,13 @@ You can donate by contacting my owner: [Captain Ezio](http://t.me/iamgojoof6eyes
|
|
37 |
async def close_admin_callback(_, q: CallbackQuery):
|
38 |
user_id = q.from_user.id
|
39 |
user_status = (await q.message.chat.get_member(user_id)).status
|
40 |
-
if user_status not in {
|
41 |
await q.answer(
|
42 |
"You're not even an admin, don't try this explosive shit!",
|
43 |
show_alert=True,
|
44 |
)
|
45 |
return
|
46 |
-
if user_status !=
|
47 |
await q.answer(
|
48 |
"You're just an admin, not owner\nStay in your limits!",
|
49 |
show_alert=True,
|
@@ -69,7 +70,8 @@ async def start(c: Gojo, m: Message):
|
|
69 |
await get_private_note(c, m, help_option)
|
70 |
return
|
71 |
if help_option.startswith("rules"):
|
72 |
-
LOGGER.info(
|
|
|
73 |
await get_private_rules(c, m, help_option)
|
74 |
return
|
75 |
|
@@ -181,7 +183,8 @@ async def help_menu(_, m: Message):
|
|
181 |
help_msg, help_kb = await get_help_msg(m, help_option)
|
182 |
|
183 |
if not help_msg:
|
184 |
-
LOGGER.error(
|
|
|
185 |
return
|
186 |
|
187 |
LOGGER.info(
|
|
|
9 |
from Powers.utils.custom_filters import command
|
10 |
from pyrogram.types import Message, CallbackQuery
|
11 |
from pyrogram.errors import UserIsBlocked, QueryIdInvalid, MessageNotModified
|
12 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
13 |
from Powers.utils.start_utils import (
|
14 |
gen_cmds_kb, gen_start_kb, get_help_msg, get_private_note,
|
15 |
get_private_rules)
|
|
|
38 |
async def close_admin_callback(_, q: CallbackQuery):
|
39 |
user_id = q.from_user.id
|
40 |
user_status = (await q.message.chat.get_member(user_id)).status
|
41 |
+
if user_status not in {CMS.OWNER, CMS.ADMINISTRATOR}:
|
42 |
await q.answer(
|
43 |
"You're not even an admin, don't try this explosive shit!",
|
44 |
show_alert=True,
|
45 |
)
|
46 |
return
|
47 |
+
if user_status != CMS.OWNER:
|
48 |
await q.answer(
|
49 |
"You're just an admin, not owner\nStay in your limits!",
|
50 |
show_alert=True,
|
|
|
70 |
await get_private_note(c, m, help_option)
|
71 |
return
|
72 |
if help_option.startswith("rules"):
|
73 |
+
LOGGER.info(
|
74 |
+
f"{m.from_user.id} fetched privaterules in {m.chat.id}")
|
75 |
await get_private_rules(c, m, help_option)
|
76 |
return
|
77 |
|
|
|
183 |
help_msg, help_kb = await get_help_msg(m, help_option)
|
184 |
|
185 |
if not help_msg:
|
186 |
+
LOGGER.error(
|
187 |
+
f"No help_msg found for help_option - {help_option}!!")
|
188 |
return
|
189 |
|
190 |
LOGGER.info(
|
Powers/utils/admin_check.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
from traceback import format_exc
|
2 |
from pyrogram.types import Message, CallbackQuery
|
|
|
3 |
from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS
|
4 |
|
5 |
|
@@ -21,7 +22,7 @@ async def admin_check(m: Message or CallbackQuery) -> bool:
|
|
21 |
LOGGER.error(format_exc())
|
22 |
|
23 |
user = await m.chat.get_member(user_id)
|
24 |
-
admin_strings = (
|
25 |
|
26 |
if user.status not in admin_strings:
|
27 |
reply = "Nigga, you're not admin, don't try this explosive shit."
|
@@ -48,9 +49,9 @@ async def check_rights(m: Message or CallbackQuery, rights) -> bool:
|
|
48 |
app = m.message._client
|
49 |
|
50 |
user = await app.get_chat_member(chat_id, user_id)
|
51 |
-
if user.status ==
|
52 |
return False
|
53 |
-
admin_strings = (
|
54 |
if user.status in admin_strings:
|
55 |
return bool(getattr(user, rights, None))
|
56 |
return False
|
@@ -73,8 +74,8 @@ async def owner_check(m: Message or CallbackQuery) -> bool:
|
|
73 |
|
74 |
user = await m.chat.get_member(user_id)
|
75 |
|
76 |
-
if user.status !=
|
77 |
-
if user.status ==
|
78 |
reply = "Stay in your limits, or lose adminship too."
|
79 |
else:
|
80 |
reply = "You ain't even admin, what are you trying to do?"
|
|
|
1 |
from traceback import format_exc
|
2 |
from pyrogram.types import Message, CallbackQuery
|
3 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
4 |
from Powers import LOGGER, OWNER_ID, DEV_USERS, SUDO_USERS
|
5 |
|
6 |
|
|
|
22 |
LOGGER.error(format_exc())
|
23 |
|
24 |
user = await m.chat.get_member(user_id)
|
25 |
+
admin_strings = (CMS.OWNER, CMS.ADMINISTRATOR)
|
26 |
|
27 |
if user.status not in admin_strings:
|
28 |
reply = "Nigga, you're not admin, don't try this explosive shit."
|
|
|
49 |
app = m.message._client
|
50 |
|
51 |
user = await app.get_chat_member(chat_id, user_id)
|
52 |
+
if user.status == CMS.MEMBER:
|
53 |
return False
|
54 |
+
admin_strings = (CMS.OWNER, CMS.ADMINISTRATOR)
|
55 |
if user.status in admin_strings:
|
56 |
return bool(getattr(user, rights, None))
|
57 |
return False
|
|
|
74 |
|
75 |
user = await m.chat.get_member(user_id)
|
76 |
|
77 |
+
if user.status != CMS.OWNER:
|
78 |
+
if user.status == CMS.ADMINISTRATOR:
|
79 |
reply = "Stay in your limits, or lose adminship too."
|
80 |
else:
|
81 |
reply = "You ain't even admin, what are you trying to do?"
|
Powers/utils/custom_filters.py
CHANGED
@@ -3,6 +3,7 @@ from pyrogram import enums
|
|
3 |
from Powers.vars import Config
|
4 |
from typing import List, Union
|
5 |
from pyrogram.filters import create
|
|
|
6 |
from Powers.utils.chat_type import chattype
|
7 |
from re import escape, compile as compile_re
|
8 |
from Powers.database.disable_db import Disabling
|
@@ -73,14 +74,14 @@ def command(
|
|
73 |
user_status = (await m.chat.get_member(m.from_user.id)).status
|
74 |
except UserNotParticipant:
|
75 |
# i.e anon admin
|
76 |
-
user_status =
|
77 |
except ValueError:
|
78 |
# i.e. PM
|
79 |
-
user_status =
|
80 |
ddb = Disabling(m.chat.id)
|
81 |
if str(matches.group(1)) in ddb.get_disabled() and user_status not in (
|
82 |
-
|
83 |
-
|
84 |
):
|
85 |
if bool(ddb.get_action() == "del"):
|
86 |
try:
|
@@ -194,11 +195,11 @@ async def owner_check_func(_, __, m: Message or CallbackQuery):
|
|
194 |
|
195 |
user = await m.chat.get_member(m.from_user.id)
|
196 |
|
197 |
-
if user.status ==
|
198 |
status = True
|
199 |
else:
|
200 |
status = False
|
201 |
-
if user.status ==
|
202 |
msg = "You're an admin only, stay in your limits!"
|
203 |
else:
|
204 |
msg = "Do you think that you can execute owner commands?"
|
@@ -222,7 +223,7 @@ async def restrict_check_func(_, __, m: Message or CallbackQuery):
|
|
222 |
|
223 |
user = await m.chat.get_member(m.from_user.id)
|
224 |
|
225 |
-
if user.can_restrict_members or user.status ==
|
226 |
status = True
|
227 |
else:
|
228 |
status = False
|
@@ -245,7 +246,7 @@ async def promote_check_func(_, __, m):
|
|
245 |
|
246 |
user = await m.chat.get_member(m.from_user.id)
|
247 |
|
248 |
-
if user.can_promote_members or user.status ==
|
249 |
status = True
|
250 |
else:
|
251 |
status = False
|
@@ -274,7 +275,7 @@ async def changeinfo_check_func(_, __, m):
|
|
274 |
|
275 |
user = await m.chat.get_member(m.from_user.id)
|
276 |
|
277 |
-
if user.can_change_info or user.status ==
|
278 |
status = True
|
279 |
else:
|
280 |
status = False
|
@@ -302,7 +303,7 @@ async def can_pin_message_func(_, __, m):
|
|
302 |
|
303 |
user = await m.chat.get_member(m.from_user.id)
|
304 |
|
305 |
-
if user.can_pin_messages or user.status ==
|
306 |
status = True
|
307 |
else:
|
308 |
status = False
|
|
|
3 |
from Powers.vars import Config
|
4 |
from typing import List, Union
|
5 |
from pyrogram.filters import create
|
6 |
+
from pyrogram.enums import ChatMemberStatus as CMS
|
7 |
from Powers.utils.chat_type import chattype
|
8 |
from re import escape, compile as compile_re
|
9 |
from Powers.database.disable_db import Disabling
|
|
|
74 |
user_status = (await m.chat.get_member(m.from_user.id)).status
|
75 |
except UserNotParticipant:
|
76 |
# i.e anon admin
|
77 |
+
user_status = CMS.ADMINISTRATOR
|
78 |
except ValueError:
|
79 |
# i.e. PM
|
80 |
+
user_status = CMS.OWNER
|
81 |
ddb = Disabling(m.chat.id)
|
82 |
if str(matches.group(1)) in ddb.get_disabled() and user_status not in (
|
83 |
+
CMS.OWNER,
|
84 |
+
CMS.ADMINISTRATOR,
|
85 |
):
|
86 |
if bool(ddb.get_action() == "del"):
|
87 |
try:
|
|
|
195 |
|
196 |
user = await m.chat.get_member(m.from_user.id)
|
197 |
|
198 |
+
if user.status == CMS.OWNER:
|
199 |
status = True
|
200 |
else:
|
201 |
status = False
|
202 |
+
if user.status == CMS.ADMINISTRATOR:
|
203 |
msg = "You're an admin only, stay in your limits!"
|
204 |
else:
|
205 |
msg = "Do you think that you can execute owner commands?"
|
|
|
223 |
|
224 |
user = await m.chat.get_member(m.from_user.id)
|
225 |
|
226 |
+
if user.can_restrict_members or user.status == CMS.OWNER:
|
227 |
status = True
|
228 |
else:
|
229 |
status = False
|
|
|
246 |
|
247 |
user = await m.chat.get_member(m.from_user.id)
|
248 |
|
249 |
+
if user.can_promote_members or user.status == CMS.OWNER:
|
250 |
status = True
|
251 |
else:
|
252 |
status = False
|
|
|
275 |
|
276 |
user = await m.chat.get_member(m.from_user.id)
|
277 |
|
278 |
+
if user.can_change_info or user.status == CMS.OWNER:
|
279 |
status = True
|
280 |
else:
|
281 |
status = False
|
|
|
303 |
|
304 |
user = await m.chat.get_member(m.from_user.id)
|
305 |
|
306 |
+
if user.can_pin_messages or user.status == CMS.OWNER:
|
307 |
status = True
|
308 |
else:
|
309 |
status = False
|