Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
6b5947b
1
Parent(s):
c26bbaf
few updates
Browse files- Powers/plugins/admin.py +5 -3
- Powers/plugins/birthday.py +5 -3
- Powers/plugins/flood.py +157 -3
Powers/plugins/admin.py
CHANGED
@@ -6,9 +6,9 @@ from traceback import format_exc
|
|
6 |
from pyrogram import filters
|
7 |
from pyrogram.enums import ChatMemberStatus as CMS
|
8 |
from pyrogram.enums import ChatType
|
9 |
-
from pyrogram.errors import (
|
10 |
-
FloodWait, RightForbidden,
|
11 |
-
UserAdminInvalid)
|
12 |
from pyrogram.types import ChatPrivileges, Message
|
13 |
|
14 |
from Powers import LOGGER, OWNER_ID
|
@@ -407,6 +407,8 @@ async def demote_usr(c: Gojo, m: Message):
|
|
407 |
await m.reply_text(
|
408 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
409 |
)
|
|
|
|
|
410 |
except RPCError as ef:
|
411 |
await m.reply_text(
|
412 |
f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
|
|
6 |
from pyrogram import filters
|
7 |
from pyrogram.enums import ChatMemberStatus as CMS
|
8 |
from pyrogram.enums import ChatType
|
9 |
+
from pyrogram.errors import (BotChannelsNa, ChatAdminInviteRequired,
|
10 |
+
ChatAdminRequired, FloodWait, RightForbidden,
|
11 |
+
RPCError, UserAdminInvalid)
|
12 |
from pyrogram.types import ChatPrivileges, Message
|
13 |
|
14 |
from Powers import LOGGER, OWNER_ID
|
|
|
407 |
await m.reply_text(
|
408 |
"Cannot act on this user, maybe I wasn't the one who changed their permissions."
|
409 |
)
|
410 |
+
except BotChannelsNa:
|
411 |
+
await m.reply_text("May be the user is bot and due to telegram restrictions I can't demote them. Please do it manually")
|
412 |
except RPCError as ef:
|
413 |
await m.reply_text(
|
414 |
f"Some error occured, report it using `/bug` \n <b>Error:</b> <code>{ef}</code>"
|
Powers/plugins/birthday.py
CHANGED
@@ -147,8 +147,8 @@ async def who_is_next(c: Gojo, m: Message):
|
|
147 |
for i in users:
|
148 |
DOB = give_date(i["dob"])
|
149 |
dete = date(curr.year, DOB.month, DOB.day)
|
150 |
-
leff = (dete - curr).days
|
151 |
-
txt += f"`{i['user_id']}` : {leff} days left"
|
152 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
153 |
await xx.delete()
|
154 |
await m.reply_text(txt)
|
@@ -179,12 +179,14 @@ async def cant_recall_it(c: Gojo, m: Message):
|
|
179 |
day = int(result["dob"].split('/')[0])
|
180 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
|
181 |
bday_on = f"{day}{suffix} {formatted}"
|
182 |
-
if u_dob.month < curr.month:
|
183 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
184 |
days_left = (next_b - curr).days
|
185 |
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {days_left}"
|
186 |
txt += f"\nBirthday on: {bday_on}"
|
187 |
txt += f"\n\nDate of birth: {result['dob']}"
|
|
|
|
|
188 |
else:
|
189 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
190 |
days_left = (u_dobm - curr).days
|
|
|
147 |
for i in users:
|
148 |
DOB = give_date(i["dob"])
|
149 |
dete = date(curr.year, DOB.month, DOB.day)
|
150 |
+
leff = (dete - curr).days
|
151 |
+
txt += f"`{i['user_id']}` : {leff} days left\n"
|
152 |
txt += "\n\nYou can use /info [user id] to get info about the user"
|
153 |
await xx.delete()
|
154 |
await m.reply_text(txt)
|
|
|
179 |
day = int(result["dob"].split('/')[0])
|
180 |
suffix = {1: 'st', 2: 'nd', 3: 'rd'}.get(day % 10, 'th')
|
181 |
bday_on = f"{day}{suffix} {formatted}"
|
182 |
+
if (u_dob.day,u_dob.month) < (curr.day,curr.month):
|
183 |
next_b = date(curr.year + 1, u_dob.month, u_dob.day)
|
184 |
days_left = (next_b - curr).days
|
185 |
txt = f"{men} 's birthday is passed 🫤\nDays left until next one {days_left}"
|
186 |
txt += f"\nBirthday on: {bday_on}"
|
187 |
txt += f"\n\nDate of birth: {result['dob']}"
|
188 |
+
elif (u_dob.day,u_dob.month) == (curr.day,curr.month):
|
189 |
+
txt = f"Today is {men}'s birthday."
|
190 |
else:
|
191 |
u_dobm = date(curr.year, u_dob.month, u_dob.day)
|
192 |
days_left = (u_dobm - curr).days
|
Powers/plugins/flood.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import time
|
|
|
2 |
from random import choice
|
3 |
from traceback import format_exc
|
4 |
|
@@ -10,19 +11,48 @@ from pyrogram.types import (CallbackQuery, ChatPermissions,
|
|
10 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
11 |
Message)
|
12 |
|
13 |
-
from Powers import LOGGER
|
14 |
from Powers.bot_class import Gojo
|
15 |
-
from Powers.database.approve_db import Approve
|
16 |
from Powers.database.flood_db import Floods
|
17 |
from Powers.supports import get_support_staff
|
18 |
from Powers.utils.custom_filters import admin_filter, command, flood_filter
|
19 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
20 |
-
from Powers.utils.kbhelpers import ikb
|
21 |
from Powers.vars import Config
|
22 |
|
23 |
on_key = ["on", "start", "disable"]
|
24 |
off_key = ["off", "end", "enable", "stop"]
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
close_kb =InlineKeyboardMarkup(
|
27 |
[
|
28 |
[
|
@@ -50,6 +80,16 @@ action_kb = InlineKeyboardMarkup(
|
|
50 |
callback_data="f_kick"
|
51 |
)
|
52 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
[
|
54 |
InlineKeyboardButton(
|
55 |
"➡️ Skip",
|
@@ -228,6 +268,28 @@ async def callbacks(c: Gojo, q: CallbackQuery):
|
|
228 |
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
229 |
reply_markup=limit_kb
|
230 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
elif data in ["f_5", "f_10", "f_15", "f_f_f_skip"]:
|
232 |
try:
|
233 |
change = int(data.split("_")[-1])
|
@@ -374,6 +436,98 @@ async def flood_watcher(c: Gojo, m: Message):
|
|
374 |
|
375 |
if len(dic[c_id][u_id][1]) == limit:
|
376 |
if y-x <= within:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
if action == "ban":
|
378 |
try:
|
379 |
await m.chat.ban_member(u_id)
|
|
|
1 |
import time
|
2 |
+
from datetime import datetime, timedelta
|
3 |
from random import choice
|
4 |
from traceback import format_exc
|
5 |
|
|
|
11 |
InlineKeyboardButton, InlineKeyboardMarkup,
|
12 |
Message)
|
13 |
|
14 |
+
from Powers import LOGGER
|
15 |
from Powers.bot_class import Gojo
|
|
|
16 |
from Powers.database.flood_db import Floods
|
17 |
from Powers.supports import get_support_staff
|
18 |
from Powers.utils.custom_filters import admin_filter, command, flood_filter
|
19 |
from Powers.utils.extras import BAN_GIFS, KICK_GIFS, MUTE_GIFS
|
|
|
20 |
from Powers.vars import Config
|
21 |
|
22 |
on_key = ["on", "start", "disable"]
|
23 |
off_key = ["off", "end", "enable", "stop"]
|
24 |
|
25 |
+
async def get_what_temp(what):
|
26 |
+
temp_duration = InlineKeyboardMarkup(
|
27 |
+
[
|
28 |
+
[
|
29 |
+
InlineKeyboardButton(
|
30 |
+
"5 minutes",
|
31 |
+
f"f_temp_{what}_5min"
|
32 |
+
),
|
33 |
+
InlineKeyboardButton(
|
34 |
+
"10 minute",
|
35 |
+
f"f_temp_{what}_10min",
|
36 |
+
),
|
37 |
+
InlineKeyboardButton(
|
38 |
+
"30 minute",
|
39 |
+
f"f_temp_{what}_30min"
|
40 |
+
),
|
41 |
+
InlineKeyboardButton(
|
42 |
+
"1 hour",
|
43 |
+
f"f_temp_{what}_60min"
|
44 |
+
)
|
45 |
+
],
|
46 |
+
[
|
47 |
+
InlineKeyboardButton(
|
48 |
+
"« Back",
|
49 |
+
"f_temp_back"
|
50 |
+
)
|
51 |
+
]
|
52 |
+
]
|
53 |
+
)
|
54 |
+
return temp_duration
|
55 |
+
|
56 |
close_kb =InlineKeyboardMarkup(
|
57 |
[
|
58 |
[
|
|
|
80 |
callback_data="f_kick"
|
81 |
)
|
82 |
],
|
83 |
+
[
|
84 |
+
InlineKeyboardButton(
|
85 |
+
"Temp Mute 🔇",
|
86 |
+
"f_temp_mute"
|
87 |
+
),
|
88 |
+
InlineKeyboardButton(
|
89 |
+
"Temp Ban 🚷",
|
90 |
+
"f_temp_ban"
|
91 |
+
)
|
92 |
+
],
|
93 |
[
|
94 |
InlineKeyboardButton(
|
95 |
"➡️ Skip",
|
|
|
268 |
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
269 |
reply_markup=limit_kb
|
270 |
)
|
271 |
+
elif data.startswith("f_temp_"):
|
272 |
+
splited = data.split("_")
|
273 |
+
if len(splited) == 3:
|
274 |
+
to_do = splited[-1]
|
275 |
+
if to_do == "back":
|
276 |
+
kb = action_kb
|
277 |
+
await q.edit_message_text(
|
278 |
+
f"Choose a action given bellow to do when flood happens.\n **CURRENT ACTION** is {saction}",
|
279 |
+
reply_markup=action_kb
|
280 |
+
)
|
281 |
+
return
|
282 |
+
kb = await get_what_temp(to_do)
|
283 |
+
await q.answer(f"Choose temp {to_do} time", True)
|
284 |
+
await q.edit_message_text(f"What shoud be temp {to_do} time?", reply_markup=kb)
|
285 |
+
else:
|
286 |
+
change = f"{splited[-2]}_{splited[-1]}"
|
287 |
+
Flood.save_flood(c_id, slimit, swithin, change)
|
288 |
+
await q.edit_message_text(
|
289 |
+
f"Set the limit of message after the flood protection will be activated\n **CURRENT LIMIT** {slimit} messages",
|
290 |
+
reply_markup=limit_kb
|
291 |
+
)
|
292 |
+
return
|
293 |
elif data in ["f_5", "f_10", "f_15", "f_f_f_skip"]:
|
294 |
try:
|
295 |
change = int(data.split("_")[-1])
|
|
|
436 |
|
437 |
if len(dic[c_id][u_id][1]) == limit:
|
438 |
if y-x <= within:
|
439 |
+
action = action.split("_")
|
440 |
+
if len(action) == 2:
|
441 |
+
to_do = action[0]
|
442 |
+
for_tim = int(action[1].replace("min",""))
|
443 |
+
for_how_much = datetime.now() + timedelta(minutes=for_tim)
|
444 |
+
if to_do == "ban":
|
445 |
+
try:
|
446 |
+
await m.chat.ban_member(u_id, until_date=for_how_much)
|
447 |
+
keyboard = InlineKeyboardMarkup(
|
448 |
+
[
|
449 |
+
[
|
450 |
+
InlineKeyboardButton(
|
451 |
+
"Unban",
|
452 |
+
callback_data=f"un_ban_={u_id}",
|
453 |
+
),
|
454 |
+
],
|
455 |
+
],
|
456 |
+
)
|
457 |
+
txt = "Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: Baned\nReason: Spaming"
|
458 |
+
await m.reply_animation(
|
459 |
+
animation=str(choice(BAN_GIFS)),
|
460 |
+
caption=txt,
|
461 |
+
reply_markup=keyboard,
|
462 |
+
)
|
463 |
+
dic[c_id][u_id][1].clear()
|
464 |
+
dic[c_id][u_id][0].clear()
|
465 |
+
return
|
466 |
+
|
467 |
+
except UserAdminInvalid:
|
468 |
+
await m.reply_text(
|
469 |
+
"I can't protect this chat from this user",
|
470 |
+
)
|
471 |
+
dic[c_id][u_id][1].clear()
|
472 |
+
dic[c_id][u_id][0].clear()
|
473 |
+
return
|
474 |
+
except RPCError as ef:
|
475 |
+
await m.reply_text(
|
476 |
+
text=f"""Some error occured, report it using `/bug`
|
477 |
+
|
478 |
+
<b>Error:</b> <code>{ef}</code>"""
|
479 |
+
)
|
480 |
+
LOGGER.error(ef)
|
481 |
+
LOGGER.error(format_exc())
|
482 |
+
dic[c_id][u_id][1].clear()
|
483 |
+
dic[c_id][u_id][0].clear()
|
484 |
+
return
|
485 |
+
else:
|
486 |
+
try:
|
487 |
+
await m.chat.restrict_member(
|
488 |
+
u_id,
|
489 |
+
ChatPermissions(),
|
490 |
+
until_date=for_how_much
|
491 |
+
)
|
492 |
+
keyboard = InlineKeyboardMarkup(
|
493 |
+
[
|
494 |
+
[
|
495 |
+
InlineKeyboardButton(
|
496 |
+
"Unmute",
|
497 |
+
callback_data=f"un_mute_={u_id}",
|
498 |
+
),
|
499 |
+
],
|
500 |
+
],
|
501 |
+
)
|
502 |
+
txt = "Don't dare to spam here if I am around! Nothing can escape my 6 eyes\nAction: Muted\nReason: Spaming"
|
503 |
+
await m.reply_animation(
|
504 |
+
animation=str(choice(MUTE_GIFS)),
|
505 |
+
caption=txt,
|
506 |
+
reply_markup=keyboard,
|
507 |
+
)
|
508 |
+
dic[c_id][u_id][1].clear()
|
509 |
+
dic[c_id][u_id][0].clear()
|
510 |
+
return
|
511 |
+
except UserAdminInvalid:
|
512 |
+
await m.reply_text(
|
513 |
+
"I can't protect this chat from this user",
|
514 |
+
)
|
515 |
+
dic[c_id][u_id][1].clear()
|
516 |
+
dic[c_id][u_id][0].clear()
|
517 |
+
return
|
518 |
+
except RPCError as ef:
|
519 |
+
await m.reply_text(
|
520 |
+
text=f"""Some error occured, report it using `/bug`
|
521 |
+
|
522 |
+
<b>Error:</b> <code>{ef}</code>"""
|
523 |
+
)
|
524 |
+
LOGGER.error(ef)
|
525 |
+
LOGGER.error(format_exc())
|
526 |
+
dic[c_id][u_id][1].clear()
|
527 |
+
dic[c_id][u_id][0].clear()
|
528 |
+
return
|
529 |
+
else:
|
530 |
+
action = action[0]
|
531 |
if action == "ban":
|
532 |
try:
|
533 |
await m.chat.ban_member(u_id)
|