Spaces:
Sleeping
Sleeping
Captain Ezio
commited on
Commit
·
11170eb
1
Parent(s):
373cd34
Removed multi langs
Browse files- Powers/plugins/admin.py +37 -253
- Powers/plugins/antispam.py +27 -42
- Powers/plugins/bans.py +118 -138
- Powers/plugins/blacklist.py +12 -20
- Powers/plugins/dev.py +12 -33
- Powers/plugins/formatting.py +60 -8
- Powers/plugins/fun.py +4 -4
- Powers/plugins/initial.py +0 -3
- Powers/plugins/langs.py +0 -1
- Powers/plugins/locks.py +31 -25
- Powers/plugins/muting.py +62 -75
- Powers/plugins/pin.py +25 -33
- Powers/plugins/purge.py +13 -17
- Powers/plugins/rules.py +13 -18
- Powers/plugins/start.py +40 -19
- Powers/plugins/utils.py +41 -51
- Powers/plugins/warns.py +1 -2
- Powers/plugins/watchers.py +10 -14
Powers/plugins/admin.py
CHANGED
@@ -18,7 +18,6 @@ from Powers import DEV_USERS, LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
|
18 |
from Powers.bot_class import Gojo
|
19 |
from Powers.database.approve_db import Approve
|
20 |
from Powers.database.reporting_db import Reporting
|
21 |
-
from Powers.tr_engine import tlang
|
22 |
from Powers.utils.caching import ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload
|
23 |
from Powers.utils.custom_filters import (
|
24 |
DEV_LEVEL,
|
@@ -37,19 +36,17 @@ async def adminlist_show(_, m: Message):
|
|
37 |
global ADMIN_CACHE
|
38 |
if m.chat.type != "supergroup":
|
39 |
return await m.reply_text(
|
40 |
-
"This command is made to be used in groups only!",
|
41 |
)
|
42 |
try:
|
43 |
try:
|
44 |
admin_list = ADMIN_CACHE[m.chat.id]
|
45 |
-
note =
|
46 |
except KeyError:
|
47 |
admin_list = await admin_cache_reload(m, "adminlist")
|
48 |
-
note =
|
49 |
-
|
50 |
-
adminstr =
|
51 |
-
chat_title=m.chat.title,
|
52 |
-
) + "\n\n"
|
53 |
|
54 |
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
|
55 |
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
|
@@ -86,14 +83,11 @@ async def adminlist_show(_, m: Message):
|
|
86 |
|
87 |
except Exception as ef:
|
88 |
if str(ef) == str(m.chat.id):
|
89 |
-
await m.reply_text(
|
90 |
else:
|
91 |
ef = str(ef) + f"{admin_list}\n"
|
92 |
await m.reply_text(
|
93 |
-
|
94 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
95 |
-
ef=ef,
|
96 |
-
),
|
97 |
)
|
98 |
LOGGER.error(ef)
|
99 |
LOGGER.error(format_exc())
|
@@ -119,7 +113,7 @@ async def zombie_clean(c: Gojo, m: Message):
|
|
119 |
if zombie == 0:
|
120 |
return await wait.edit_text("Group is clean!")
|
121 |
return await wait.edit_text(
|
122 |
-
f"<b>{zombie}</b> Zombies found and has been banned!",
|
123 |
)
|
124 |
|
125 |
|
@@ -143,14 +137,11 @@ async def reload_admins(_, m: Message):
|
|
143 |
try:
|
144 |
await admin_cache_reload(m, "admincache")
|
145 |
TEMP_ADMIN_CACHE_BLOCK[m.chat.id] = "manualblock"
|
146 |
-
await m.reply_text(
|
147 |
LOGGER.info(f"Admincache cmd use in {m.chat.id} by {m.from_user.id}")
|
148 |
except RPCError as ef:
|
149 |
await m.reply_text(
|
150 |
-
|
151 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
152 |
-
ef=ef,
|
153 |
-
),
|
154 |
)
|
155 |
LOGGER.error(ef)
|
156 |
LOGGER.error(format_exc())
|
@@ -185,7 +176,7 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
185 |
global ADMIN_CACHE
|
186 |
|
187 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
188 |
-
await m.reply_text(
|
189 |
return
|
190 |
|
191 |
try:
|
@@ -241,6 +232,8 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
241 |
title = m.text.split()[1]
|
242 |
if title and len(title) > 16:
|
243 |
title = title[0:16] # trim title to 16 characters
|
|
|
|
|
244 |
|
245 |
try:
|
246 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
@@ -250,14 +243,15 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
250 |
LOGGER.info(
|
251 |
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
252 |
)
|
|
|
253 |
|
254 |
await m.reply_text(
|
255 |
-
(
|
256 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
257 |
promoted=(await mention_html(user_first_name, user_id)),
|
258 |
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
259 |
if title
|
260 |
-
else f"{escape(m.chat.title)} title set to
|
261 |
),
|
262 |
)
|
263 |
|
@@ -275,17 +269,14 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
275 |
await admin_cache_reload(m, "promote_key_error")
|
276 |
|
277 |
except ChatAdminRequired:
|
278 |
-
await m.reply_text(
|
279 |
except RightForbidden:
|
280 |
-
await m.reply_text(
|
281 |
except UserAdminInvalid:
|
282 |
-
await m.reply_text(
|
283 |
except RPCError as e:
|
284 |
await m.reply_text(
|
285 |
-
|
286 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
287 |
-
ef=e,
|
288 |
-
),
|
289 |
)
|
290 |
LOGGER.error(e)
|
291 |
LOGGER.error(format_exc())
|
@@ -298,7 +289,7 @@ async def promote_usr(c: Gojo, m: Message):
|
|
298 |
global ADMIN_CACHE
|
299 |
|
300 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
301 |
-
await m.reply_text(
|
302 |
return
|
303 |
|
304 |
try:
|
@@ -338,18 +329,19 @@ async def promote_usr(c: Gojo, m: Message):
|
|
338 |
can_delete_messages=bot.can_delete_messages,
|
339 |
can_restrict_members=bot.can_restrict_members,
|
340 |
can_pin_messages=bot.can_pin_messages,
|
341 |
-
# can_promote_members=bot.can_promote_members,
|
342 |
can_manage_chat=bot.can_manage_chat,
|
343 |
can_manage_voice_chats=bot.can_manage_voice_chats,
|
344 |
)
|
345 |
|
346 |
-
title = "
|
347 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
348 |
title = m.text.split()[2]
|
349 |
elif len(m.text.split()) == 2 and m.reply_to_message:
|
350 |
title = m.text.split()[1]
|
351 |
if title and len(title) > 16:
|
352 |
title = title[0:16] # trim title to 16 characters
|
|
|
|
|
353 |
|
354 |
try:
|
355 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
@@ -361,122 +353,12 @@ async def promote_usr(c: Gojo, m: Message):
|
|
361 |
)
|
362 |
|
363 |
await m.reply_text(
|
364 |
-
(
|
365 |
-
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
366 |
-
promoted=(await mention_html(user_first_name, user_id)),
|
367 |
-
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
368 |
-
if title
|
369 |
-
else f"{escape(m.chat.title)} title set to Admin",
|
370 |
-
),
|
371 |
-
)
|
372 |
-
|
373 |
-
# If user is approved, disapprove them as they willbe promoted and get even more rights
|
374 |
-
if Approve(m.chat.id).check_approve(user_id):
|
375 |
-
Approve(m.chat.id).remove_approve(user_id)
|
376 |
-
|
377 |
-
# ----- Add admin to temp cache -----
|
378 |
-
try:
|
379 |
-
inp1 = user_name or user_first_name
|
380 |
-
admins_group = ADMIN_CACHE[m.chat.id]
|
381 |
-
admins_group.append((user_id, inp1))
|
382 |
-
ADMIN_CACHE[m.chat.id] = admins_group
|
383 |
-
except KeyError:
|
384 |
-
await admin_cache_reload(m, "promote_key_error")
|
385 |
-
|
386 |
-
except ChatAdminRequired:
|
387 |
-
await m.reply_text(tlang(m, "admin.not_admin"))
|
388 |
-
except RightForbidden:
|
389 |
-
await m.reply_text(tlang(m, "admin.promote.bot_no_right"))
|
390 |
-
except UserAdminInvalid:
|
391 |
-
await m.reply_text(tlang(m, "admin.user_admin_invalid"))
|
392 |
-
except RPCError as e:
|
393 |
-
await m.reply_text(
|
394 |
-
(tlang(m, "general.some_error")).format(
|
395 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
396 |
-
ef=e,
|
397 |
-
),
|
398 |
-
)
|
399 |
-
LOGGER.error(e)
|
400 |
-
LOGGER.error(format_exc())
|
401 |
-
return
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
@Gojo.on_message(command("spromote") & promote_filter)
|
406 |
-
async def superpromote_usr(c: Gojo, m: Message):
|
407 |
-
|
408 |
-
global ADMIN_CACHE
|
409 |
-
|
410 |
-
if len(m.text.split()) == 1 and not m.reply_to_message:
|
411 |
-
await m.reply_text(tlang(m, "admin.promote.no_target"))
|
412 |
-
return
|
413 |
-
|
414 |
-
try:
|
415 |
-
user_id, user_first_name, user_name = await extract_user(c, m)
|
416 |
-
except Exception:
|
417 |
-
return
|
418 |
-
|
419 |
-
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
|
420 |
-
|
421 |
-
if user_id == Config.BOT_ID:
|
422 |
-
await m.reply_text("Huh, how can I even promote myself?")
|
423 |
-
return
|
424 |
-
|
425 |
-
if not bot.can_promote_members:
|
426 |
-
return await m.reply_text(
|
427 |
-
"I don't have enough permissions",
|
428 |
-
) # This should be here
|
429 |
-
# If user is alreay admin
|
430 |
-
try:
|
431 |
-
admin_list = {i[0] for i in ADMIN_CACHE[m.chat.id]}
|
432 |
-
except KeyError:
|
433 |
-
admin_list = {
|
434 |
-
i[0] for i in (await admin_cache_reload(m, "promote_cache_update"))
|
435 |
-
}
|
436 |
-
|
437 |
-
if user_id in admin_list:
|
438 |
-
await m.reply_text(
|
439 |
-
"This user is already an admin, how am I supposed to re-promote them?",
|
440 |
-
)
|
441 |
-
return
|
442 |
-
|
443 |
-
try:
|
444 |
-
await m.chat.promote_member(
|
445 |
-
user_id=user_id,
|
446 |
-
can_change_info=bot.can_change_info,
|
447 |
-
can_invite_users=bot.can_invite_users,
|
448 |
-
can_delete_messages=bot.can_delete_messages,
|
449 |
-
can_restrict_members=bot.can_restrict_members,
|
450 |
-
can_pin_messages=bot.can_pin_messages,
|
451 |
-
can_promote_members=bot.can_promote_members,
|
452 |
-
can_manage_chat=bot.can_manage_chat,
|
453 |
-
can_manage_voice_chats=bot.can_manage_voice_chats,
|
454 |
-
)
|
455 |
-
|
456 |
-
title = "Gojo" # Deafult title
|
457 |
-
if len(m.text.split()) == 3 and not m.reply_to_message:
|
458 |
-
title = m.text.split()[2]
|
459 |
-
elif len(m.text.split()) == 2 and m.reply_to_message:
|
460 |
-
title = m.text.split()[1]
|
461 |
-
if title and len(title) > 16:
|
462 |
-
title = title[0:16] # trim title to 16 characters
|
463 |
-
|
464 |
-
try:
|
465 |
-
await c.set_administrator_title(m.chat.id, user_id, title)
|
466 |
-
except RPCError as e:
|
467 |
-
LOGGER.error(e)
|
468 |
-
|
469 |
-
LOGGER.info(
|
470 |
-
f"{m.from_user.id} super promoted {user_id} in {m.chat.id} with title '{title}'",
|
471 |
-
)
|
472 |
-
|
473 |
-
await m.reply_text(
|
474 |
-
(tlang(m, "admin.promote.promoted_user")).format(
|
475 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
476 |
promoted=(await mention_html(user_first_name, user_id)),
|
477 |
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
478 |
if title
|
479 |
-
else f"{escape(m.chat.title)} title set to
|
480 |
),
|
481 |
)
|
482 |
|
@@ -494,112 +376,20 @@ async def superpromote_usr(c: Gojo, m: Message):
|
|
494 |
await admin_cache_reload(m, "promote_key_error")
|
495 |
|
496 |
except ChatAdminRequired:
|
497 |
-
await m.reply_text(
|
498 |
except RightForbidden:
|
499 |
-
await m.reply_text(
|
500 |
except UserAdminInvalid:
|
501 |
-
await m.reply_text(
|
502 |
except RPCError as e:
|
503 |
await m.reply_text(
|
504 |
-
|
505 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
506 |
-
ef=e,
|
507 |
-
),
|
508 |
)
|
509 |
LOGGER.error(e)
|
510 |
LOGGER.error(format_exc())
|
511 |
return
|
512 |
|
513 |
|
514 |
-
@Gojo.on_message(command("demote") & promote_filter)
|
515 |
-
async def demote_usr(c: Gojo, m: Message):
|
516 |
-
|
517 |
-
global ADMIN_CACHE
|
518 |
-
|
519 |
-
if len(m.text.split()) == 1 and not m.reply_to_message:
|
520 |
-
await m.reply_text(tlang(m, "admin.demote.no_target"))
|
521 |
-
return
|
522 |
-
|
523 |
-
try:
|
524 |
-
user_id, user_first_name, _ = await extract_user(c, m)
|
525 |
-
except Exception:
|
526 |
-
return
|
527 |
-
|
528 |
-
if user_id == Config.BOT_ID:
|
529 |
-
await m.reply_text("Get an admin to demote me!")
|
530 |
-
return
|
531 |
-
|
532 |
-
# If user not alreay admin
|
533 |
-
try:
|
534 |
-
admin_list = {i[0] for i in ADMIN_CACHE[m.chat.id]}
|
535 |
-
except KeyError:
|
536 |
-
admin_list = {
|
537 |
-
i[0] for i in (await admin_cache_reload(m, "demote_cache_update"))
|
538 |
-
}
|
539 |
-
|
540 |
-
if user_id not in admin_list:
|
541 |
-
await m.reply_text(
|
542 |
-
"This user is not an admin, how am I supposed to re-demote them?",
|
543 |
-
)
|
544 |
-
return
|
545 |
-
|
546 |
-
try:
|
547 |
-
await m.chat.promote_member(
|
548 |
-
user_id=user_id,
|
549 |
-
can_change_info=False,
|
550 |
-
can_invite_users=False,
|
551 |
-
can_delete_messages=False,
|
552 |
-
can_restrict_members=False,
|
553 |
-
can_pin_messages=False,
|
554 |
-
can_promote_members=False,
|
555 |
-
can_manage_chat=False,
|
556 |
-
can_manage_voice_chats=False,
|
557 |
-
)
|
558 |
-
LOGGER.info(f"{m.from_user.id} demoted {user_id} in {m.chat.id}")
|
559 |
-
|
560 |
-
# ----- Remove admin from cache -----
|
561 |
-
try:
|
562 |
-
admin_list = ADMIN_CACHE[m.chat.id]
|
563 |
-
user = next(user for user in admin_list if user[0] == user_id)
|
564 |
-
admin_list.remove(user)
|
565 |
-
ADMIN_CACHE[m.chat.id] = admin_list
|
566 |
-
except (KeyError, StopIteration):
|
567 |
-
await admin_cache_reload(m, "demote_key_stopiter_error")
|
568 |
-
|
569 |
-
await m.reply_text(
|
570 |
-
(tlang(m, "admin.demote.demoted_user")).format(
|
571 |
-
demoter=(
|
572 |
-
await mention_html(
|
573 |
-
m.from_user.first_name,
|
574 |
-
m.from_user.id,
|
575 |
-
)
|
576 |
-
),
|
577 |
-
demoted=(await mention_html(user_first_name, user_id)),
|
578 |
-
chat_title=m.chat.title,
|
579 |
-
),
|
580 |
-
)
|
581 |
-
|
582 |
-
except ChatAdminRequired:
|
583 |
-
await m.reply_text(tlang(m, "admin.not_admin"))
|
584 |
-
except RightForbidden:
|
585 |
-
await m.reply_text(tlang(m, "admin.demote.bot_no_right"))
|
586 |
-
except UserAdminInvalid:
|
587 |
-
await m.reply_text(tlang(m, "admin.user_admin_invalid"))
|
588 |
-
except RPCError as ef:
|
589 |
-
await m.reply_text(
|
590 |
-
(tlang(m, "general.some_error")).format(
|
591 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
592 |
-
ef=ef,
|
593 |
-
),
|
594 |
-
)
|
595 |
-
LOGGER.error(ef)
|
596 |
-
LOGGER.error(format_exc())
|
597 |
-
|
598 |
-
return
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
@Gojo.on_message(command("invitelink"))
|
604 |
async def get_invitelink(c: Gojo, m: Message):
|
605 |
# Bypass the bot devs, sudos and owner
|
@@ -607,31 +397,26 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
607 |
user = await m.chat.get_member(m.from_user.id)
|
608 |
|
609 |
if not user.can_invite_users and user.status != "creator":
|
610 |
-
await m.reply_text(
|
611 |
return False
|
612 |
|
613 |
try:
|
614 |
link = await c.export_chat_invite_link(m.chat.id)
|
615 |
await m.reply_text(
|
616 |
-
|
617 |
-
|
618 |
-
link=link,
|
619 |
-
),
|
620 |
disable_web_page_preview=True,
|
621 |
)
|
622 |
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
|
623 |
except ChatAdminRequired:
|
624 |
-
await m.reply_text(
|
625 |
except ChatAdminInviteRequired:
|
626 |
-
await m.reply_text(
|
627 |
except RightForbidden:
|
628 |
-
await m.reply_text(
|
629 |
except RPCError as ef:
|
630 |
await m.reply_text(
|
631 |
-
|
632 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
633 |
-
ef=ef,
|
634 |
-
),
|
635 |
)
|
636 |
LOGGER.error(ef)
|
637 |
LOGGER.error(format_exc())
|
@@ -756,7 +541,6 @@ __PLUGIN__ = "admin"
|
|
756 |
__alt_name__ = [
|
757 |
"admins",
|
758 |
"promote",
|
759 |
-
"spromote",
|
760 |
"demote",
|
761 |
"adminlist",
|
762 |
"setgpic",
|
|
|
18 |
from Powers.bot_class import Gojo
|
19 |
from Powers.database.approve_db import Approve
|
20 |
from Powers.database.reporting_db import Reporting
|
|
|
21 |
from Powers.utils.caching import ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload
|
22 |
from Powers.utils.custom_filters import (
|
23 |
DEV_LEVEL,
|
|
|
36 |
global ADMIN_CACHE
|
37 |
if m.chat.type != "supergroup":
|
38 |
return await m.reply_text(
|
39 |
+
text="This command is made to be used in groups only!",
|
40 |
)
|
41 |
try:
|
42 |
try:
|
43 |
admin_list = ADMIN_CACHE[m.chat.id]
|
44 |
+
note = "<i>Note:</i> These are cached values!"
|
45 |
except KeyError:
|
46 |
admin_list = await admin_cache_reload(m, "adminlist")
|
47 |
+
note = "<i>Note:</i> These are up-to-date values!"
|
48 |
+
|
49 |
+
adminstr = f"Admins in <b>{m.chat.title}</b>:"+ "\n\n"
|
|
|
|
|
50 |
|
51 |
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
|
52 |
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
|
|
|
83 |
|
84 |
except Exception as ef:
|
85 |
if str(ef) == str(m.chat.id):
|
86 |
+
await m.reply_text(text="Use /admincache to reload admins!")
|
87 |
else:
|
88 |
ef = str(ef) + f"{admin_list}\n"
|
89 |
await m.reply_text(
|
90 |
+
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{ef}</code>"
|
|
|
|
|
|
|
91 |
)
|
92 |
LOGGER.error(ef)
|
93 |
LOGGER.error(format_exc())
|
|
|
113 |
if zombie == 0:
|
114 |
return await wait.edit_text("Group is clean!")
|
115 |
return await wait.edit_text(
|
116 |
+
text=f"<b>{zombie}</b> Zombies found and has been banned!",
|
117 |
)
|
118 |
|
119 |
|
|
|
137 |
try:
|
138 |
await admin_cache_reload(m, "admincache")
|
139 |
TEMP_ADMIN_CACHE_BLOCK[m.chat.id] = "manualblock"
|
140 |
+
await m.reply_text(text="Reloaded all admins in this chat!")
|
141 |
LOGGER.info(f"Admincache cmd use in {m.chat.id} by {m.from_user.id}")
|
142 |
except RPCError as ef:
|
143 |
await m.reply_text(
|
144 |
+
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{ef}</code>"
|
|
|
|
|
|
|
145 |
)
|
146 |
LOGGER.error(ef)
|
147 |
LOGGER.error(format_exc())
|
|
|
176 |
global ADMIN_CACHE
|
177 |
|
178 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
179 |
+
await m.reply_text(text="I can't promote nothing! Give me an username or user id or atleast reply to that user")
|
180 |
return
|
181 |
|
182 |
try:
|
|
|
232 |
title = m.text.split()[1]
|
233 |
if title and len(title) > 16:
|
234 |
title = title[0:16] # trim title to 16 characters
|
235 |
+
elif not title:
|
236 |
+
title = "Gojo"
|
237 |
|
238 |
try:
|
239 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
|
243 |
LOGGER.info(
|
244 |
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
245 |
)
|
246 |
+
|
247 |
|
248 |
await m.reply_text(
|
249 |
+
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
250 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
251 |
promoted=(await mention_html(user_first_name, user_id)),
|
252 |
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
253 |
if title
|
254 |
+
else f"{escape(m.chat.title)} title set to Gojo",
|
255 |
),
|
256 |
)
|
257 |
|
|
|
269 |
await admin_cache_reload(m, "promote_key_error")
|
270 |
|
271 |
except ChatAdminRequired:
|
272 |
+
await m.reply_text(text="I'm not admin or I don't have rights......")
|
273 |
except RightForbidden:
|
274 |
+
await m.reply_text(text = "I don't have enough rights to promote this user.")
|
275 |
except UserAdminInvalid:
|
276 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
277 |
except RPCError as e:
|
278 |
await m.reply_text(
|
279 |
+
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{e}</code>"
|
|
|
|
|
|
|
280 |
)
|
281 |
LOGGER.error(e)
|
282 |
LOGGER.error(format_exc())
|
|
|
289 |
global ADMIN_CACHE
|
290 |
|
291 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
292 |
+
await m.reply_text(text="I can't promote nothing!......reply to user to promote him/her....")
|
293 |
return
|
294 |
|
295 |
try:
|
|
|
329 |
can_delete_messages=bot.can_delete_messages,
|
330 |
can_restrict_members=bot.can_restrict_members,
|
331 |
can_pin_messages=bot.can_pin_messages,
|
|
|
332 |
can_manage_chat=bot.can_manage_chat,
|
333 |
can_manage_voice_chats=bot.can_manage_voice_chats,
|
334 |
)
|
335 |
|
336 |
+
title = "" # Deafult title
|
337 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
338 |
title = m.text.split()[2]
|
339 |
elif len(m.text.split()) == 2 and m.reply_to_message:
|
340 |
title = m.text.split()[1]
|
341 |
if title and len(title) > 16:
|
342 |
title = title[0:16] # trim title to 16 characters
|
343 |
+
if not title:
|
344 |
+
title="Itadori"
|
345 |
|
346 |
try:
|
347 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
|
|
353 |
)
|
354 |
|
355 |
await m.reply_text(
|
356 |
+
("{promoter} promoted {promoted} in chat <b>{chat_title}</b>!").format(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
358 |
promoted=(await mention_html(user_first_name, user_id)),
|
359 |
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
360 |
if title
|
361 |
+
else f"{escape(m.chat.title)} title set to Itadori",
|
362 |
),
|
363 |
)
|
364 |
|
|
|
376 |
await admin_cache_reload(m, "promote_key_error")
|
377 |
|
378 |
except ChatAdminRequired:
|
379 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
380 |
except RightForbidden:
|
381 |
+
await m.reply_text(text="I don't have enough rights to promote this user.")
|
382 |
except UserAdminInvalid:
|
383 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
384 |
except RPCError as e:
|
385 |
await m.reply_text(
|
386 |
+
text=f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{e}</code>"
|
|
|
|
|
|
|
387 |
)
|
388 |
LOGGER.error(e)
|
389 |
LOGGER.error(format_exc())
|
390 |
return
|
391 |
|
392 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
@Gojo.on_message(command("invitelink"))
|
394 |
async def get_invitelink(c: Gojo, m: Message):
|
395 |
# Bypass the bot devs, sudos and owner
|
|
|
397 |
user = await m.chat.get_member(m.from_user.id)
|
398 |
|
399 |
if not user.can_invite_users and user.status != "creator":
|
400 |
+
await m.reply_text(text="You don't have rights to invite users....")
|
401 |
return False
|
402 |
|
403 |
try:
|
404 |
link = await c.export_chat_invite_link(m.chat.id)
|
405 |
await m.reply_text(
|
406 |
+
text=f"Invite Link for Chat <b>{m.chat.id}</b>: {link}",
|
407 |
+
|
|
|
|
|
408 |
disable_web_page_preview=True,
|
409 |
)
|
410 |
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
|
411 |
except ChatAdminRequired:
|
412 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
413 |
except ChatAdminInviteRequired:
|
414 |
+
await m.reply_text(text="I don't have permission for invite link!")
|
415 |
except RightForbidden:
|
416 |
+
await m.reply_text(text="You don't have permissions to invite users.")
|
417 |
except RPCError as ef:
|
418 |
await m.reply_text(
|
419 |
+
text = f"Some error occured, report to @{SUPPORT_GROUP} \n <b>Error:</b> <code>{ef}</code>"
|
|
|
|
|
|
|
420 |
)
|
421 |
LOGGER.error(ef)
|
422 |
LOGGER.error(format_exc())
|
|
|
541 |
__alt_name__ = [
|
542 |
"admins",
|
543 |
"promote",
|
|
|
544 |
"demote",
|
545 |
"adminlist",
|
546 |
"setgpic",
|
Powers/plugins/antispam.py
CHANGED
@@ -9,7 +9,6 @@ from Powers import LOGGER, MESSAGE_DUMP, SUPPORT_GROUP, SUPPORT_STAFF
|
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.antispam_db import GBan
|
11 |
from Powers.database.users_db import Users
|
12 |
-
from Powers.tr_engine import tlang
|
13 |
from Powers.utils.clean_file import remove_markdown_and_html
|
14 |
from Powers.utils.custom_filters import command
|
15 |
from Powers.utils.extract_user import extract_user
|
@@ -23,11 +22,11 @@ db = GBan()
|
|
23 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
24 |
async def gban(c: Gojo, m: Message):
|
25 |
if len(m.text.split()) == 1:
|
26 |
-
await m.reply_text(
|
27 |
return
|
28 |
|
29 |
if len(m.text.split()) == 2 and not m.reply_to_message:
|
30 |
-
await m.reply_text(
|
31 |
return
|
32 |
|
33 |
user_id, user_first_name, _ = await extract_user(c, m)
|
@@ -38,45 +37,33 @@ async def gban(c: Gojo, m: Message):
|
|
38 |
gban_reason = m.text.split(None, 2)[2]
|
39 |
|
40 |
if user_id in SUPPORT_STAFF:
|
41 |
-
await m.reply_text(
|
42 |
return
|
43 |
|
44 |
if user_id == Config.BOT_ID:
|
45 |
-
await m.reply_text(
|
46 |
return
|
47 |
|
48 |
if db.check_gban(user_id):
|
49 |
db.update_gban_reason(user_id, gban_reason)
|
50 |
await m.reply_text(
|
51 |
-
|
52 |
-
gban_reason=gban_reason,
|
53 |
-
),
|
54 |
)
|
55 |
return
|
56 |
|
57 |
db.add_gban(user_id, gban_reason, m.from_user.id)
|
58 |
await m.reply_text(
|
59 |
-
(
|
60 |
-
first_name=user_first_name,
|
61 |
-
),
|
62 |
)
|
63 |
LOGGER.info(f"{m.from_user.id} gbanned {user_id} from {m.chat.id}")
|
64 |
-
|
65 |
-
|
66 |
-
ban_admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
67 |
-
gbanned_user=(await mention_html(user_first_name, user_id)),
|
68 |
-
gban_user_id=user_id,
|
69 |
-
time=(datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),
|
70 |
-
)
|
71 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
72 |
try:
|
73 |
# Send message to user telling that he's gbanned
|
74 |
await c.send_message(
|
75 |
user_id,
|
76 |
-
|
77 |
-
gban_reason=gban_reason,
|
78 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
79 |
-
),
|
80 |
)
|
81 |
except UserIsBlocked:
|
82 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
@@ -95,47 +82,46 @@ async def gban(c: Gojo, m: Message):
|
|
95 |
)
|
96 |
async def ungban(c: Gojo, m: Message):
|
97 |
if len(m.text.split()) == 1:
|
98 |
-
await m.reply_text(
|
99 |
return
|
100 |
|
101 |
user_id, user_first_name, _ = await extract_user(c, m)
|
102 |
|
103 |
if user_id in SUPPORT_STAFF:
|
104 |
-
await m.reply_text(
|
105 |
return
|
106 |
|
107 |
if user_id == Config.BOT_ID:
|
108 |
-
await m.reply_text(
|
|
|
109 |
return
|
110 |
|
111 |
if db.check_gban(user_id):
|
112 |
db.remove_gban(user_id)
|
113 |
await m.reply_text(
|
114 |
-
|
115 |
-
first_name=user_first_name,
|
116 |
-
),
|
117 |
)
|
|
|
118 |
LOGGER.info(f"{m.from_user.id} ungbanned {user_id} from {m.chat.id}")
|
119 |
-
log_msg = (
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
)
|
126 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
127 |
try:
|
128 |
# Send message to user telling that he's ungbanned
|
129 |
await c.send_message(
|
130 |
user_id,
|
131 |
-
|
132 |
)
|
133 |
except Exception as ef: # TODO: Improve Error Detection
|
134 |
LOGGER.error(ef)
|
135 |
LOGGER.error(format_exc())
|
136 |
return
|
137 |
|
138 |
-
await m.reply_text(
|
139 |
return
|
140 |
|
141 |
|
@@ -144,8 +130,7 @@ async def ungban(c: Gojo, m: Message):
|
|
144 |
)
|
145 |
async def gban_count(_, m: Message):
|
146 |
await m.reply_text(
|
147 |
-
|
148 |
-
)
|
149 |
LOGGER.info(f"{m.from_user.id} counting gbans in {m.chat.id}")
|
150 |
return
|
151 |
|
@@ -157,10 +142,10 @@ async def gban_list(_, m: Message):
|
|
157 |
banned_users = db.load_from_db()
|
158 |
|
159 |
if not banned_users:
|
160 |
-
await m.reply_text(
|
161 |
return
|
162 |
|
163 |
-
banfile =
|
164 |
for user in banned_users:
|
165 |
banfile += f"[x] <b>{Users.get_user_info(user['_id'])['name']}</b> - <code>{user['_id']}</code>\n"
|
166 |
if user["reason"]:
|
@@ -173,7 +158,7 @@ async def gban_list(_, m: Message):
|
|
173 |
f.name = "gbanlist.txt"
|
174 |
await m.reply_document(
|
175 |
document=f,
|
176 |
-
caption=
|
177 |
)
|
178 |
|
179 |
LOGGER.info(f"{m.from_user.id} exported gbanlist in {m.chat.id}")
|
|
|
9 |
from Powers.bot_class import Gojo
|
10 |
from Powers.database.antispam_db import GBan
|
11 |
from Powers.database.users_db import Users
|
|
|
12 |
from Powers.utils.clean_file import remove_markdown_and_html
|
13 |
from Powers.utils.custom_filters import command
|
14 |
from Powers.utils.extract_user import extract_user
|
|
|
22 |
@Gojo.on_message(command(["gban", "globalban"], sudo_cmd=True))
|
23 |
async def gban(c: Gojo, m: Message):
|
24 |
if len(m.text.split()) == 1:
|
25 |
+
await m.reply_text(text ="<b>How to gban?</b> \n <b>Answer:</b> <code>/gban user_id reason</code>")
|
26 |
return
|
27 |
|
28 |
if len(m.text.split()) == 2 and not m.reply_to_message:
|
29 |
+
await m.reply_text(text="Please enter a reason to gban user!")
|
30 |
return
|
31 |
|
32 |
user_id, user_first_name, _ = await extract_user(c, m)
|
|
|
37 |
gban_reason = m.text.split(None, 2)[2]
|
38 |
|
39 |
if user_id in SUPPORT_STAFF:
|
40 |
+
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
|
41 |
return
|
42 |
|
43 |
if user_id == Config.BOT_ID:
|
44 |
+
await m.reply_text(text="You don't dare use that command on me again nigga! \n Go straight and fuck your self......")
|
45 |
return
|
46 |
|
47 |
if db.check_gban(user_id):
|
48 |
db.update_gban_reason(user_id, gban_reason)
|
49 |
await m.reply_text(
|
50 |
+
text="Updated Gban reason to: <code>{gban_reason}</code>."
|
|
|
|
|
51 |
)
|
52 |
return
|
53 |
|
54 |
db.add_gban(user_id, gban_reason, m.from_user.id)
|
55 |
await m.reply_text(
|
56 |
+
(f"Added {user_first_name} to GBan List. \n They will now be banned in all groups where I'm admin!")
|
|
|
|
|
57 |
)
|
58 |
LOGGER.info(f"{m.from_user.id} gbanned {user_id} from {m.chat.id}")
|
59 |
+
date = (datetime.utcnow().strftime("%H:%M - %d-%m-%Y"))
|
60 |
+
log_msg = f"#GBAN \n <b>Originated from:</b> {m.chat.id} \n <b>Admin:</b> {await mention_html(m.from_user.first_name, m.from_user.id)} \n <b>Gbanned User:</b> {await mention_html(user_first_name, user_id)} \n <b>Gbanned User ID:</b> {user_id} \ n<b>Event Stamp:</b> {date}"
|
|
|
|
|
|
|
|
|
|
|
61 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
62 |
try:
|
63 |
# Send message to user telling that he's gbanned
|
64 |
await c.send_message(
|
65 |
user_id,
|
66 |
+
f"You have been added to my global ban list! \n <b>Reason:</b> <code>{gban_reason}</code> \n <b>Appeal Chat:</b> @{SUPPORT_GROUP}"
|
|
|
|
|
|
|
67 |
)
|
68 |
except UserIsBlocked:
|
69 |
LOGGER.error("Could not send PM Message, user blocked bot")
|
|
|
82 |
)
|
83 |
async def ungban(c: Gojo, m: Message):
|
84 |
if len(m.text.split()) == 1:
|
85 |
+
await m.reply_text(text= "Pass a user id or username as an argument!")
|
86 |
return
|
87 |
|
88 |
user_id, user_first_name, _ = await extract_user(c, m)
|
89 |
|
90 |
if user_id in SUPPORT_STAFF:
|
91 |
+
await m.reply_text(text="This user is part of my Support!, Can't ban our own!")
|
92 |
return
|
93 |
|
94 |
if user_id == Config.BOT_ID:
|
95 |
+
await m.reply_text(text= """You can't gban me nigga!
|
96 |
+
Fuck yourself.......!""")
|
97 |
return
|
98 |
|
99 |
if db.check_gban(user_id):
|
100 |
db.remove_gban(user_id)
|
101 |
await m.reply_text(
|
102 |
+
text=f"Removed {user_first_name} from Global Ban List."
|
|
|
|
|
103 |
)
|
104 |
+
time=(datetime.utcnow().strftime("%H:%M - %d-%m-%Y")),
|
105 |
LOGGER.info(f"{m.from_user.id} ungbanned {user_id} from {m.chat.id}")
|
106 |
+
log_msg = (f"""#UNGBAN
|
107 |
+
<b>Originated from:</b> {m.chat.id}
|
108 |
+
<b>Admin:</b> {(await mention_html(m.from_user.first_name, m.from_user.id))}
|
109 |
+
<b>UnGbanned User:</b> {(await mention_html(user_first_name, user_id))}
|
110 |
+
<b>UnGbanned User ID:</b> {user_id}
|
111 |
+
<b>Event Stamp:</b> {time}""")
|
|
|
112 |
await c.send_message(MESSAGE_DUMP, log_msg)
|
113 |
try:
|
114 |
# Send message to user telling that he's ungbanned
|
115 |
await c.send_message(
|
116 |
user_id,
|
117 |
+
text="You have been removed from my global ban list!.....Be careful it takes few seconds to add you again..."
|
118 |
)
|
119 |
except Exception as ef: # TODO: Improve Error Detection
|
120 |
LOGGER.error(ef)
|
121 |
LOGGER.error(format_exc())
|
122 |
return
|
123 |
|
124 |
+
await m.reply_text(text="User is not gbanned!")
|
125 |
return
|
126 |
|
127 |
|
|
|
130 |
)
|
131 |
async def gban_count(_, m: Message):
|
132 |
await m.reply_text(
|
133 |
+
text=f"Number of people gbanned: <code>{(db.count_gbans())}</code>")
|
|
|
134 |
LOGGER.info(f"{m.from_user.id} counting gbans in {m.chat.id}")
|
135 |
return
|
136 |
|
|
|
142 |
banned_users = db.load_from_db()
|
143 |
|
144 |
if not banned_users:
|
145 |
+
await m.reply_text(text="There aren't any gbanned users...!")
|
146 |
return
|
147 |
|
148 |
+
banfile = "Here are all the globally banned geys!\n\n"
|
149 |
for user in banned_users:
|
150 |
banfile += f"[x] <b>{Users.get_user_info(user['_id'])['name']}</b> - <code>{user['_id']}</code>\n"
|
151 |
if user["reason"]:
|
|
|
158 |
f.name = "gbanlist.txt"
|
159 |
await m.reply_document(
|
160 |
document=f,
|
161 |
+
caption="Here are all the globally banned geys!\n\n"
|
162 |
)
|
163 |
|
164 |
LOGGER.info(f"{m.from_user.id} exported gbanlist in {m.chat.id}")
|
Powers/plugins/bans.py
CHANGED
@@ -19,7 +19,6 @@ from pyrogram.types import (
|
|
19 |
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
20 |
from Powers.bot_class import Gojo
|
21 |
from Powers.utils.fun_strings import BAN_GIFS, KICK_GIFS
|
22 |
-
from Powers.tr_engine import tlang
|
23 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
24 |
from Powers.utils.custom_filters import command, restrict_filter
|
25 |
from Powers.utils.extract_user import extract_user
|
@@ -34,7 +33,7 @@ KICK_MEDIA = random.choice(KICK_GIFS)
|
|
34 |
@Gojo.on_message(command("tban") & restrict_filter)
|
35 |
async def tban_usr(c: Gojo, m: Message):
|
36 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
37 |
-
await m.reply_text(
|
38 |
await m.stop_propagation()
|
39 |
|
40 |
try:
|
@@ -50,7 +49,7 @@ async def tban_usr(c: Gojo, m: Message):
|
|
50 |
await m.stop_propagation()
|
51 |
|
52 |
if user_id in SUPPORT_STAFF:
|
53 |
-
await m.reply_text(
|
54 |
LOGGER.info(
|
55 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
56 |
)
|
@@ -85,17 +84,18 @@ async def tban_usr(c: Gojo, m: Message):
|
|
85 |
admins_group = await admin_cache_reload(m, "ban")
|
86 |
|
87 |
if user_id in admins_group:
|
88 |
-
await m.reply_text(
|
89 |
await m.stop_propagation()
|
90 |
|
91 |
try:
|
|
|
|
|
|
|
92 |
LOGGER.info(f"{m.from_user.id} tbanned {user_id} in {m.chat.id}")
|
93 |
-
await m.chat.ban_member(user_id, until_date=int(bantime)
|
94 |
-
|
95 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
96 |
-
banned=(await mention_html(user_first_name, user_id)),
|
97 |
-
chat_title=m.chat.title,
|
98 |
)
|
|
|
99 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
100 |
keyboard = InlineKeyboardMarkup(
|
101 |
[
|
@@ -110,21 +110,20 @@ async def tban_usr(c: Gojo, m: Message):
|
|
110 |
await m.reply_animation(reply_to_message_id = r_id, animation = BAN_MEDIA, caption = txt, reply_markup=keyboard, parse_mode="html")
|
111 |
# await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
112 |
except ChatAdminRequired:
|
113 |
-
await m.reply_text(
|
114 |
except PeerIdInvalid:
|
115 |
await m.reply_text(
|
116 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
117 |
)
|
118 |
except UserAdminInvalid:
|
119 |
-
await m.reply_text(
|
120 |
except RightForbidden:
|
121 |
-
await m.reply_text(
|
122 |
except RPCError as ef:
|
123 |
await m.reply_text(
|
124 |
-
(
|
125 |
-
|
126 |
-
|
127 |
-
),
|
128 |
)
|
129 |
LOGGER.error(ef)
|
130 |
LOGGER.error(format_exc())
|
@@ -134,7 +133,7 @@ async def tban_usr(c: Gojo, m: Message):
|
|
134 |
@Gojo.on_message(command("stban") & restrict_filter)
|
135 |
async def stban_usr(c: Gojo, m: Message):
|
136 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
137 |
-
await m.reply_text(
|
138 |
await m.stop_propagation()
|
139 |
|
140 |
try:
|
@@ -150,7 +149,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
150 |
await m.stop_propagation()
|
151 |
|
152 |
if user_id in SUPPORT_STAFF:
|
153 |
-
await m.reply_text(
|
154 |
LOGGER.info(
|
155 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
156 |
)
|
@@ -183,7 +182,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
183 |
admins_group = await admin_cache_reload(m, "ban")
|
184 |
|
185 |
if user_id in admins_group:
|
186 |
-
await m.reply_text(
|
187 |
await m.stop_propagation()
|
188 |
|
189 |
try:
|
@@ -195,21 +194,20 @@ async def stban_usr(c: Gojo, m: Message):
|
|
195 |
return
|
196 |
return
|
197 |
except ChatAdminRequired:
|
198 |
-
await m.reply_text(
|
199 |
except PeerIdInvalid:
|
200 |
await m.reply_text(
|
201 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
202 |
)
|
203 |
except UserAdminInvalid:
|
204 |
-
await m.reply_text(
|
205 |
except RightForbidden:
|
206 |
-
await m.reply_text(
|
207 |
except RPCError as ef:
|
208 |
await m.reply_text(
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
),
|
213 |
)
|
214 |
LOGGER.error(ef)
|
215 |
LOGGER.error(format_exc())
|
@@ -219,7 +217,7 @@ async def stban_usr(c: Gojo, m: Message):
|
|
219 |
@Gojo.on_message(command("dtban") & restrict_filter)
|
220 |
async def dtban_usr(c: Gojo, m: Message):
|
221 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
222 |
-
await m.reply_text(
|
223 |
await m.stop_propagation()
|
224 |
|
225 |
if not m.reply_to_message:
|
@@ -239,7 +237,7 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
239 |
await m.stop_propagation()
|
240 |
|
241 |
if user_id in SUPPORT_STAFF:
|
242 |
-
await m.reply_text(
|
243 |
LOGGER.info(
|
244 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
245 |
)
|
@@ -272,18 +270,19 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
272 |
admins_group = await admin_cache_reload(m, "ban")
|
273 |
|
274 |
if user_id in admins_group:
|
275 |
-
await m.reply_text(
|
276 |
await m.stop_propagation()
|
277 |
|
278 |
try:
|
|
|
|
|
|
|
279 |
LOGGER.info(f"{m.from_user.id} dtbanned {user_id} in {m.chat.id}")
|
280 |
await m.chat.ban_member(user_id, until_date=int(bantime))
|
281 |
await m.reply_to_message.delete()
|
282 |
-
txt =
|
283 |
-
|
284 |
-
|
285 |
-
chat_title=m.chat.title,
|
286 |
-
)
|
287 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
288 |
keyboard = InlineKeyboardMarkup(
|
289 |
[
|
@@ -298,21 +297,20 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
298 |
await c.send_animation(chat_id = m.chat.id, animation = BAN_MEDIA, caption = txt, reply_markup=keyboard, parse_mode="html")
|
299 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
300 |
except ChatAdminRequired:
|
301 |
-
await m.reply_text(
|
302 |
except PeerIdInvalid:
|
303 |
await m.reply_text(
|
304 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
305 |
)
|
306 |
except UserAdminInvalid:
|
307 |
-
await m.reply_text(
|
308 |
except RightForbidden:
|
309 |
-
await m.reply_text(
|
310 |
except RPCError as ef:
|
311 |
await m.reply_text(
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
),
|
316 |
)
|
317 |
LOGGER.error(ef)
|
318 |
LOGGER.error(format_exc())
|
@@ -322,7 +320,7 @@ async def dtban_usr(c: Gojo, m: Message):
|
|
322 |
@Gojo.on_message(command("kick") & restrict_filter)
|
323 |
async def kick_usr(c: Gojo, m: Message):
|
324 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
325 |
-
await m.reply_text(
|
326 |
return
|
327 |
|
328 |
reason = None
|
@@ -349,7 +347,7 @@ async def kick_usr(c: Gojo, m: Message):
|
|
349 |
await m.stop_propagation()
|
350 |
|
351 |
if user_id in SUPPORT_STAFF:
|
352 |
-
await m.reply_text(
|
353 |
LOGGER.info(
|
354 |
f"{m.from_user.id} trying to kick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
355 |
)
|
@@ -361,37 +359,35 @@ async def kick_usr(c: Gojo, m: Message):
|
|
361 |
admins_group = await admin_cache_reload(m, "kick")
|
362 |
|
363 |
if user_id in admins_group:
|
364 |
-
await m.reply_text(
|
365 |
await m.stop_propagation()
|
366 |
|
367 |
try:
|
|
|
|
|
|
|
368 |
LOGGER.info(f"{m.from_user.id} kicked {user_id} in {m.chat.id}")
|
369 |
await m.chat.ban_member(user_id)
|
370 |
-
txt =
|
371 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
372 |
-
kicked=(await mention_html(user_first_name, user_id)),
|
373 |
-
chat_title=m.chat.title,
|
374 |
-
)
|
375 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
376 |
# await m.reply_text(txt, reply_to_message_id=r_id)
|
377 |
await m.reply_animation(reply_to_message_id = r_id, animation = KICK_MEDIA, caption = txt, parse_mode="html")
|
378 |
await m.chat.unban_member(user_id)
|
379 |
except ChatAdminRequired:
|
380 |
-
await m.reply_text(
|
381 |
except PeerIdInvalid:
|
382 |
await m.reply_text(
|
383 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
384 |
)
|
385 |
except UserAdminInvalid:
|
386 |
-
await m.reply_text(
|
387 |
except RightForbidden:
|
388 |
-
await m.reply_text(
|
389 |
except RPCError as ef:
|
390 |
await m.reply_text(
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
),
|
395 |
)
|
396 |
LOGGER.error(ef)
|
397 |
LOGGER.error(format_exc())
|
@@ -402,7 +398,7 @@ async def kick_usr(c: Gojo, m: Message):
|
|
402 |
@Gojo.on_message(command("skick") & restrict_filter)
|
403 |
async def skick_usr(c: Gojo, m: Message):
|
404 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
405 |
-
await m.reply_text(
|
406 |
return
|
407 |
|
408 |
try:
|
@@ -419,7 +415,7 @@ async def skick_usr(c: Gojo, m: Message):
|
|
419 |
await m.stop_propagation()
|
420 |
|
421 |
if user_id in SUPPORT_STAFF:
|
422 |
-
await m.reply_text(
|
423 |
LOGGER.info(
|
424 |
f"{m.from_user.id} trying to skick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
425 |
)
|
@@ -431,7 +427,7 @@ async def skick_usr(c: Gojo, m: Message):
|
|
431 |
admins_group = await admin_cache_reload(m, "kick")
|
432 |
|
433 |
if user_id in admins_group:
|
434 |
-
await m.reply_text(
|
435 |
await m.stop_propagation()
|
436 |
|
437 |
try:
|
@@ -442,21 +438,20 @@ async def skick_usr(c: Gojo, m: Message):
|
|
442 |
await m.reply_to_message.delete()
|
443 |
await m.chat.unban_member(user_id)
|
444 |
except ChatAdminRequired:
|
445 |
-
await m.reply_text(
|
446 |
except PeerIdInvalid:
|
447 |
await m.reply_text(
|
448 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
449 |
)
|
450 |
except UserAdminInvalid:
|
451 |
-
await m.reply_text(
|
452 |
except RightForbidden:
|
453 |
-
await m.reply_text(
|
454 |
except RPCError as ef:
|
455 |
await m.reply_text(
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
),
|
460 |
)
|
461 |
LOGGER.error(ef)
|
462 |
LOGGER.error(format_exc())
|
@@ -467,7 +462,7 @@ async def skick_usr(c: Gojo, m: Message):
|
|
467 |
@Gojo.on_message(command("dkick") & restrict_filter)
|
468 |
async def dkick_usr(c: Gojo, m: Message):
|
469 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
470 |
-
await m.reply_text(
|
471 |
return
|
472 |
if not m.reply_to_message:
|
473 |
return await m.reply_text("Reply to a message to delete it and kick the user!")
|
@@ -486,7 +481,7 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
486 |
await m.stop_propagation()
|
487 |
|
488 |
if user_id in SUPPORT_STAFF:
|
489 |
-
await m.reply_text(
|
490 |
LOGGER.info(
|
491 |
f"{m.from_user.id} trying to dkick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
492 |
)
|
@@ -498,38 +493,36 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
498 |
admins_group = await admin_cache_reload(m, "kick")
|
499 |
|
500 |
if user_id in admins_group:
|
501 |
-
await m.reply_text(
|
502 |
await m.stop_propagation()
|
503 |
|
504 |
try:
|
505 |
LOGGER.info(f"{m.from_user.id} dkicked {user_id} in {m.chat.id}")
|
506 |
await m.reply_to_message.delete()
|
507 |
await m.chat.ban_member(user_id)
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
)
|
513 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
514 |
await c.send_message(m.chat.id, txt)
|
515 |
await c.send_animation(chat_id = m.chat.id, animation = KICK_MEDIA, caption = txt, parse_mode="html")
|
516 |
await m.chat.unban_member(user_id)
|
517 |
except ChatAdminRequired:
|
518 |
-
await m.reply_text(
|
519 |
except PeerIdInvalid:
|
520 |
await m.reply_text(
|
521 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
522 |
)
|
523 |
except UserAdminInvalid:
|
524 |
-
await m.reply_text(
|
525 |
except RightForbidden:
|
526 |
-
await m.reply_text(
|
527 |
except RPCError as ef:
|
528 |
await m.reply_text(
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
),
|
533 |
)
|
534 |
LOGGER.error(ef)
|
535 |
LOGGER.error(format_exc())
|
@@ -540,7 +533,7 @@ async def dkick_usr(c: Gojo, m: Message):
|
|
540 |
@Gojo.on_message(command("unban") & restrict_filter)
|
541 |
async def unban_usr(c: Gojo, m: Message):
|
542 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
543 |
-
await m.reply_text(
|
544 |
await m.stop_propagation()
|
545 |
|
546 |
if m.reply_to_message and not m.reply_to_message.from_user:
|
@@ -563,23 +556,21 @@ async def unban_usr(c: Gojo, m: Message):
|
|
563 |
|
564 |
try:
|
565 |
await m.chat.unban_member(user_id)
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
)
|
571 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
572 |
await m.reply_text(txt)
|
573 |
except ChatAdminRequired:
|
574 |
-
await m.reply_text(
|
575 |
except RightForbidden:
|
576 |
-
await m.reply_text(
|
577 |
except RPCError as ef:
|
578 |
await m.reply_text(
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
),
|
583 |
)
|
584 |
LOGGER.error(ef)
|
585 |
LOGGER.error(format_exc())
|
@@ -590,7 +581,7 @@ async def unban_usr(c: Gojo, m: Message):
|
|
590 |
@Gojo.on_message(command("sban") & restrict_filter)
|
591 |
async def sban_usr(c: Gojo, m: Message):
|
592 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
593 |
-
await m.reply_text(
|
594 |
await m.stop_propagation()
|
595 |
|
596 |
if m.reply_to_message and not m.reply_to_message.from_user:
|
@@ -612,7 +603,7 @@ async def sban_usr(c: Gojo, m: Message):
|
|
612 |
await m.stop_propagation()
|
613 |
|
614 |
if user_id in SUPPORT_STAFF:
|
615 |
-
await m.reply_text(
|
616 |
LOGGER.info(
|
617 |
f"{m.from_user.id} trying to sban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
618 |
)
|
@@ -624,7 +615,7 @@ async def sban_usr(c: Gojo, m: Message):
|
|
624 |
admins_group = await admin_cache_reload(m, "ban")
|
625 |
|
626 |
if user_id in admins_group:
|
627 |
-
await m.reply_text(
|
628 |
await m.stop_propagation()
|
629 |
|
630 |
try:
|
@@ -634,21 +625,20 @@ async def sban_usr(c: Gojo, m: Message):
|
|
634 |
if m.reply_to_message:
|
635 |
await m.reply_to_message.delete()
|
636 |
except ChatAdminRequired:
|
637 |
-
await m.reply_text(
|
638 |
except PeerIdInvalid:
|
639 |
await m.reply_text(
|
640 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
641 |
)
|
642 |
except UserAdminInvalid:
|
643 |
-
await m.reply_text(
|
644 |
except RightForbidden:
|
645 |
-
await m.reply_text(
|
646 |
except RPCError as ef:
|
647 |
await m.reply_text(
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
),
|
652 |
)
|
653 |
LOGGER.error(ef)
|
654 |
LOGGER.error(format_exc())
|
@@ -658,7 +648,7 @@ async def sban_usr(c: Gojo, m: Message):
|
|
658 |
@Gojo.on_message(command("dban") & restrict_filter)
|
659 |
async def dban_usr(c: Gojo, m: Message):
|
660 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
661 |
-
await m.reply_text(
|
662 |
await m.stop_propagation()
|
663 |
|
664 |
if not m.reply_to_message:
|
@@ -686,7 +676,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
686 |
await m.stop_propagation()
|
687 |
|
688 |
if user_id in SUPPORT_STAFF:
|
689 |
-
await m.reply_text(
|
690 |
LOGGER.info(
|
691 |
f"{m.from_user.id} trying to dban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
692 |
)
|
@@ -698,7 +688,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
698 |
admins_group = await admin_cache_reload(m, "ban")
|
699 |
|
700 |
if user_id in admins_group:
|
701 |
-
await m.reply_text(
|
702 |
await m.stop_propagation()
|
703 |
|
704 |
reason = None
|
@@ -709,11 +699,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
709 |
LOGGER.info(f"{m.from_user.id} dbanned {user_id} in {m.chat.id}")
|
710 |
await m.reply_to_message.delete()
|
711 |
await m.chat.ban_member(user_id)
|
712 |
-
txt =
|
713 |
-
admin=m.from_user.mention,
|
714 |
-
banned=m.reply_to_message.from_user.mention,
|
715 |
-
chat_title=m.chat.title,
|
716 |
-
)
|
717 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
718 |
keyboard = InlineKeyboardMarkup(
|
719 |
[
|
@@ -727,21 +713,20 @@ async def dban_usr(c: Gojo, m: Message):
|
|
727 |
)
|
728 |
await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
729 |
except ChatAdminRequired:
|
730 |
-
await m.reply_text(
|
731 |
except PeerIdInvalid:
|
732 |
await m.reply_text(
|
733 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
734 |
)
|
735 |
except UserAdminInvalid:
|
736 |
-
await m.reply_text(
|
737 |
except RightForbidden:
|
738 |
-
await m.reply_text(
|
739 |
except RPCError as ef:
|
740 |
await m.reply_text(
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
),
|
745 |
)
|
746 |
LOGGER.error(ef)
|
747 |
LOGGER.error(format_exc())
|
@@ -751,7 +736,7 @@ async def dban_usr(c: Gojo, m: Message):
|
|
751 |
@Gojo.on_message(command("ban") & restrict_filter)
|
752 |
async def ban_usr(c: Gojo, m: Message):
|
753 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
754 |
-
await m.reply_text(
|
755 |
await m.stop_propagation()
|
756 |
|
757 |
if m.reply_to_message and not m.reply_to_message.from_user:
|
@@ -776,7 +761,7 @@ async def ban_usr(c: Gojo, m: Message):
|
|
776 |
await m.stop_propagation()
|
777 |
|
778 |
if user_id in SUPPORT_STAFF:
|
779 |
-
await m.reply_text(
|
780 |
LOGGER.info(
|
781 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
782 |
)
|
@@ -788,7 +773,7 @@ async def ban_usr(c: Gojo, m: Message):
|
|
788 |
admins_group = await admin_cache_reload(m, "ban")
|
789 |
|
790 |
if user_id in admins_group:
|
791 |
-
await m.reply_text(
|
792 |
await m.stop_propagation()
|
793 |
|
794 |
reason = None
|
@@ -804,11 +789,8 @@ async def ban_usr(c: Gojo, m: Message):
|
|
804 |
try:
|
805 |
LOGGER.info(f"{m.from_user.id} banned {user_id} in {m.chat.id}")
|
806 |
await m.chat.ban_member(user_id)
|
807 |
-
|
808 |
-
|
809 |
-
banned=(await mention_html(user_first_name, user_id)),
|
810 |
-
chat_title=m.chat.title,
|
811 |
-
)
|
812 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
813 |
keyboard = InlineKeyboardMarkup(
|
814 |
[
|
@@ -822,21 +804,20 @@ async def ban_usr(c: Gojo, m: Message):
|
|
822 |
)
|
823 |
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
824 |
except ChatAdminRequired:
|
825 |
-
await m.reply_text(
|
826 |
except PeerIdInvalid:
|
827 |
await m.reply_text(
|
828 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
829 |
)
|
830 |
except UserAdminInvalid:
|
831 |
-
await m.reply_text(
|
832 |
except RightForbidden:
|
833 |
-
await m.reply_text(
|
834 |
except RPCError as ef:
|
835 |
await m.reply_text(
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
),
|
840 |
)
|
841 |
LOGGER.error(ef)
|
842 |
LOGGER.error(format_exc())
|
@@ -876,14 +857,13 @@ async def kickme(_, m: Message):
|
|
876 |
await m.chat.ban_member(m.from_user.id)
|
877 |
txt = "Why not let me help you!"
|
878 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
879 |
-
await m.
|
880 |
await m.chat.unban_member(m.from_user.id)
|
881 |
except RPCError as ef:
|
882 |
await m.reply_text(
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
),
|
887 |
)
|
888 |
return
|
889 |
|
|
|
19 |
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
20 |
from Powers.bot_class import Gojo
|
21 |
from Powers.utils.fun_strings import BAN_GIFS, KICK_GIFS
|
|
|
22 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
23 |
from Powers.utils.custom_filters import command, restrict_filter
|
24 |
from Powers.utils.extract_user import extract_user
|
|
|
33 |
@Gojo.on_message(command("tban") & restrict_filter)
|
34 |
async def tban_usr(c: Gojo, m: Message):
|
35 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
36 |
+
await m.reply_text(text="I can't ban nothing!")
|
37 |
await m.stop_propagation()
|
38 |
|
39 |
try:
|
|
|
49 |
await m.stop_propagation()
|
50 |
|
51 |
if user_id in SUPPORT_STAFF:
|
52 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
53 |
LOGGER.info(
|
54 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
55 |
)
|
|
|
84 |
admins_group = await admin_cache_reload(m, "ban")
|
85 |
|
86 |
if user_id in admins_group:
|
87 |
+
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
88 |
await m.stop_propagation()
|
89 |
|
90 |
try:
|
91 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
92 |
+
banned=(await mention_html(user_first_name, user_id)),
|
93 |
+
chat_title=m.chat.title,
|
94 |
LOGGER.info(f"{m.from_user.id} tbanned {user_id} in {m.chat.id}")
|
95 |
+
await m.chat.ban_member(user_id, until_date=int(bantime),
|
96 |
+
text = f"{admin} banned {banned} in <b>{chat_title}</b>!"
|
|
|
|
|
|
|
97 |
)
|
98 |
+
|
99 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
100 |
keyboard = InlineKeyboardMarkup(
|
101 |
[
|
|
|
110 |
await m.reply_animation(reply_to_message_id = r_id, animation = BAN_MEDIA, caption = txt, reply_markup=keyboard, parse_mode="html")
|
111 |
# await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
112 |
except ChatAdminRequired:
|
113 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
114 |
except PeerIdInvalid:
|
115 |
await m.reply_text(
|
116 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
117 |
)
|
118 |
except UserAdminInvalid:
|
119 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
120 |
except RightForbidden:
|
121 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
122 |
except RPCError as ef:
|
123 |
await m.reply_text(
|
124 |
+
(f"""Some error occured, report to @{SUPPORT_GROUP}
|
125 |
+
|
126 |
+
<b>Error:</b> <code>{ef}</code>""")
|
|
|
127 |
)
|
128 |
LOGGER.error(ef)
|
129 |
LOGGER.error(format_exc())
|
|
|
133 |
@Gojo.on_message(command("stban") & restrict_filter)
|
134 |
async def stban_usr(c: Gojo, m: Message):
|
135 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
136 |
+
await m.reply_text(text="I can't ban nothing!")
|
137 |
await m.stop_propagation()
|
138 |
|
139 |
try:
|
|
|
149 |
await m.stop_propagation()
|
150 |
|
151 |
if user_id in SUPPORT_STAFF:
|
152 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
153 |
LOGGER.info(
|
154 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
155 |
)
|
|
|
182 |
admins_group = await admin_cache_reload(m, "ban")
|
183 |
|
184 |
if user_id in admins_group:
|
185 |
+
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
186 |
await m.stop_propagation()
|
187 |
|
188 |
try:
|
|
|
194 |
return
|
195 |
return
|
196 |
except ChatAdminRequired:
|
197 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
198 |
except PeerIdInvalid:
|
199 |
await m.reply_text(
|
200 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
201 |
)
|
202 |
except UserAdminInvalid:
|
203 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
204 |
except RightForbidden:
|
205 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
206 |
except RPCError as ef:
|
207 |
await m.reply_text(
|
208 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
209 |
+
|
210 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
211 |
)
|
212 |
LOGGER.error(ef)
|
213 |
LOGGER.error(format_exc())
|
|
|
217 |
@Gojo.on_message(command("dtban") & restrict_filter)
|
218 |
async def dtban_usr(c: Gojo, m: Message):
|
219 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
220 |
+
await m.reply_text(text="I can't ban nothing!")
|
221 |
await m.stop_propagation()
|
222 |
|
223 |
if not m.reply_to_message:
|
|
|
237 |
await m.stop_propagation()
|
238 |
|
239 |
if user_id in SUPPORT_STAFF:
|
240 |
+
await m.reply_text(text="I am not going to ban one of my support staff")
|
241 |
LOGGER.info(
|
242 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
243 |
)
|
|
|
270 |
admins_group = await admin_cache_reload(m, "ban")
|
271 |
|
272 |
if user_id in admins_group:
|
273 |
+
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
274 |
await m.stop_propagation()
|
275 |
|
276 |
try:
|
277 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
278 |
+
banned=(await mention_html(user_first_name, user_id)),
|
279 |
+
chat_title=m.chat.title,
|
280 |
LOGGER.info(f"{m.from_user.id} dtbanned {user_id} in {m.chat.id}")
|
281 |
await m.chat.ban_member(user_id, until_date=int(bantime))
|
282 |
await m.reply_to_message.delete()
|
283 |
+
txt = f"{admin} banned {banned} in <b>{chat_title}</b>!"
|
284 |
+
|
285 |
+
|
|
|
|
|
286 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
287 |
keyboard = InlineKeyboardMarkup(
|
288 |
[
|
|
|
297 |
await c.send_animation(chat_id = m.chat.id, animation = BAN_MEDIA, caption = txt, reply_markup=keyboard, parse_mode="html")
|
298 |
# await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
299 |
except ChatAdminRequired:
|
300 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
301 |
except PeerIdInvalid:
|
302 |
await m.reply_text(
|
303 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
304 |
)
|
305 |
except UserAdminInvalid:
|
306 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
307 |
except RightForbidden:
|
308 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
309 |
except RPCError as ef:
|
310 |
await m.reply_text(
|
311 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
312 |
+
|
313 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
314 |
)
|
315 |
LOGGER.error(ef)
|
316 |
LOGGER.error(format_exc())
|
|
|
320 |
@Gojo.on_message(command("kick") & restrict_filter)
|
321 |
async def kick_usr(c: Gojo, m: Message):
|
322 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
323 |
+
await m.reply_text(text="I can't kick nothing!")
|
324 |
return
|
325 |
|
326 |
reason = None
|
|
|
347 |
await m.stop_propagation()
|
348 |
|
349 |
if user_id in SUPPORT_STAFF:
|
350 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
351 |
LOGGER.info(
|
352 |
f"{m.from_user.id} trying to kick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
353 |
)
|
|
|
359 |
admins_group = await admin_cache_reload(m, "kick")
|
360 |
|
361 |
if user_id in admins_group:
|
362 |
+
await m.reply_text(text="This user is an admin, I cannot kick them!")
|
363 |
await m.stop_propagation()
|
364 |
|
365 |
try:
|
366 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
367 |
+
kicked=(await mention_html(user_first_name, user_id)),
|
368 |
+
chat_title=m.chat.title,
|
369 |
LOGGER.info(f"{m.from_user.id} kicked {user_id} in {m.chat.id}")
|
370 |
await m.chat.ban_member(user_id)
|
371 |
+
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
|
|
|
|
|
|
|
|
372 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
373 |
# await m.reply_text(txt, reply_to_message_id=r_id)
|
374 |
await m.reply_animation(reply_to_message_id = r_id, animation = KICK_MEDIA, caption = txt, parse_mode="html")
|
375 |
await m.chat.unban_member(user_id)
|
376 |
except ChatAdminRequired:
|
377 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
378 |
except PeerIdInvalid:
|
379 |
await m.reply_text(
|
380 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
381 |
)
|
382 |
except UserAdminInvalid:
|
383 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
384 |
except RightForbidden:
|
385 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
386 |
except RPCError as ef:
|
387 |
await m.reply_text(
|
388 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
389 |
+
|
390 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
391 |
)
|
392 |
LOGGER.error(ef)
|
393 |
LOGGER.error(format_exc())
|
|
|
398 |
@Gojo.on_message(command("skick") & restrict_filter)
|
399 |
async def skick_usr(c: Gojo, m: Message):
|
400 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
401 |
+
await m.reply_text(text="I can't kick nothing!")
|
402 |
return
|
403 |
|
404 |
try:
|
|
|
415 |
await m.stop_propagation()
|
416 |
|
417 |
if user_id in SUPPORT_STAFF:
|
418 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
419 |
LOGGER.info(
|
420 |
f"{m.from_user.id} trying to skick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
421 |
)
|
|
|
427 |
admins_group = await admin_cache_reload(m, "kick")
|
428 |
|
429 |
if user_id in admins_group:
|
430 |
+
await m.reply_text(text="This user is an admin, I cannot kick them!")
|
431 |
await m.stop_propagation()
|
432 |
|
433 |
try:
|
|
|
438 |
await m.reply_to_message.delete()
|
439 |
await m.chat.unban_member(user_id)
|
440 |
except ChatAdminRequired:
|
441 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
442 |
except PeerIdInvalid:
|
443 |
await m.reply_text(
|
444 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
445 |
)
|
446 |
except UserAdminInvalid:
|
447 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
448 |
except RightForbidden:
|
449 |
+
await m.reply_text(text="I don't have enough rights to kick this user.")
|
450 |
except RPCError as ef:
|
451 |
await m.reply_text(
|
452 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
453 |
+
|
454 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
455 |
)
|
456 |
LOGGER.error(ef)
|
457 |
LOGGER.error(format_exc())
|
|
|
462 |
@Gojo.on_message(command("dkick") & restrict_filter)
|
463 |
async def dkick_usr(c: Gojo, m: Message):
|
464 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
465 |
+
await m.reply_text(text="I can't ban nothing!")
|
466 |
return
|
467 |
if not m.reply_to_message:
|
468 |
return await m.reply_text("Reply to a message to delete it and kick the user!")
|
|
|
481 |
await m.stop_propagation()
|
482 |
|
483 |
if user_id in SUPPORT_STAFF:
|
484 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
485 |
LOGGER.info(
|
486 |
f"{m.from_user.id} trying to dkick {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
487 |
)
|
|
|
493 |
admins_group = await admin_cache_reload(m, "kick")
|
494 |
|
495 |
if user_id in admins_group:
|
496 |
+
await m.reply_text(text="This user is an admin, I cannot kick them!")
|
497 |
await m.stop_propagation()
|
498 |
|
499 |
try:
|
500 |
LOGGER.info(f"{m.from_user.id} dkicked {user_id} in {m.chat.id}")
|
501 |
await m.reply_to_message.delete()
|
502 |
await m.chat.ban_member(user_id)
|
503 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
504 |
+
kicked=(await mention_html(user_first_name, user_id)),
|
505 |
+
chat_title=m.chat.title,
|
506 |
+
txt = f"{admin} kicked {kicked} in <b>{chat_title}</b>!"
|
|
|
507 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
508 |
await c.send_message(m.chat.id, txt)
|
509 |
await c.send_animation(chat_id = m.chat.id, animation = KICK_MEDIA, caption = txt, parse_mode="html")
|
510 |
await m.chat.unban_member(user_id)
|
511 |
except ChatAdminRequired:
|
512 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
513 |
except PeerIdInvalid:
|
514 |
await m.reply_text(
|
515 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
516 |
)
|
517 |
except UserAdminInvalid:
|
518 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
519 |
except RightForbidden:
|
520 |
+
await m.reply_text(text="I don't have enough rights to kick this user.")
|
521 |
except RPCError as ef:
|
522 |
await m.reply_text(
|
523 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
524 |
+
|
525 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
526 |
)
|
527 |
LOGGER.error(ef)
|
528 |
LOGGER.error(format_exc())
|
|
|
533 |
@Gojo.on_message(command("unban") & restrict_filter)
|
534 |
async def unban_usr(c: Gojo, m: Message):
|
535 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
536 |
+
await m.reply_text(text="I can't unban nothing!")
|
537 |
await m.stop_propagation()
|
538 |
|
539 |
if m.reply_to_message and not m.reply_to_message.from_user:
|
|
|
556 |
|
557 |
try:
|
558 |
await m.chat.unban_member(user_id)
|
559 |
+
admin=m.from_user.mention,
|
560 |
+
unbanned=(await mention_html(user_first_name, user_id)),
|
561 |
+
chat_title=m.chat.title,
|
562 |
+
txt = f"{admin} unbanned {unbanned} in chat <b>{chat_title}</b>!"
|
|
|
563 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
564 |
await m.reply_text(txt)
|
565 |
except ChatAdminRequired:
|
566 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
567 |
except RightForbidden:
|
568 |
+
await m.reply_text(text="I don't have enough rights to unban this user.")
|
569 |
except RPCError as ef:
|
570 |
await m.reply_text(
|
571 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
572 |
+
|
573 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
574 |
)
|
575 |
LOGGER.error(ef)
|
576 |
LOGGER.error(format_exc())
|
|
|
581 |
@Gojo.on_message(command("sban") & restrict_filter)
|
582 |
async def sban_usr(c: Gojo, m: Message):
|
583 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
584 |
+
await m.reply_text(text="I can't ban nothing!")
|
585 |
await m.stop_propagation()
|
586 |
|
587 |
if m.reply_to_message and not m.reply_to_message.from_user:
|
|
|
603 |
await m.stop_propagation()
|
604 |
|
605 |
if user_id in SUPPORT_STAFF:
|
606 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
607 |
LOGGER.info(
|
608 |
f"{m.from_user.id} trying to sban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
609 |
)
|
|
|
615 |
admins_group = await admin_cache_reload(m, "ban")
|
616 |
|
617 |
if user_id in admins_group:
|
618 |
+
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
619 |
await m.stop_propagation()
|
620 |
|
621 |
try:
|
|
|
625 |
if m.reply_to_message:
|
626 |
await m.reply_to_message.delete()
|
627 |
except ChatAdminRequired:
|
628 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
629 |
except PeerIdInvalid:
|
630 |
await m.reply_text(
|
631 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
632 |
)
|
633 |
except UserAdminInvalid:
|
634 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
635 |
except RightForbidden:
|
636 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
637 |
except RPCError as ef:
|
638 |
await m.reply_text(
|
639 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
640 |
+
|
641 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
642 |
)
|
643 |
LOGGER.error(ef)
|
644 |
LOGGER.error(format_exc())
|
|
|
648 |
@Gojo.on_message(command("dban") & restrict_filter)
|
649 |
async def dban_usr(c: Gojo, m: Message):
|
650 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
651 |
+
await m.reply_text(text="I can't ban nothing!")
|
652 |
await m.stop_propagation()
|
653 |
|
654 |
if not m.reply_to_message:
|
|
|
676 |
await m.stop_propagation()
|
677 |
|
678 |
if user_id in SUPPORT_STAFF:
|
679 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
680 |
LOGGER.info(
|
681 |
f"{m.from_user.id} trying to dban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
682 |
)
|
|
|
688 |
admins_group = await admin_cache_reload(m, "ban")
|
689 |
|
690 |
if user_id in admins_group:
|
691 |
+
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
692 |
await m.stop_propagation()
|
693 |
|
694 |
reason = None
|
|
|
699 |
LOGGER.info(f"{m.from_user.id} dbanned {user_id} in {m.chat.id}")
|
700 |
await m.reply_to_message.delete()
|
701 |
await m.chat.ban_member(user_id)
|
702 |
+
txt =f"{m.from_user.mention} banned {m.reply_to_message.from_user.mention} in <b>{m.chat.title}</b>!"
|
|
|
|
|
|
|
|
|
703 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
704 |
keyboard = InlineKeyboardMarkup(
|
705 |
[
|
|
|
713 |
)
|
714 |
await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
715 |
except ChatAdminRequired:
|
716 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
717 |
except PeerIdInvalid:
|
718 |
await m.reply_text(
|
719 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
720 |
)
|
721 |
except UserAdminInvalid:
|
722 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
723 |
except RightForbidden:
|
724 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
725 |
except RPCError as ef:
|
726 |
await m.reply_text(
|
727 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
728 |
+
|
729 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
730 |
)
|
731 |
LOGGER.error(ef)
|
732 |
LOGGER.error(format_exc())
|
|
|
736 |
@Gojo.on_message(command("ban") & restrict_filter)
|
737 |
async def ban_usr(c: Gojo, m: Message):
|
738 |
if len(m.text.split()) == 1 and not m.reply_to_message:
|
739 |
+
await m.reply_text(text="I can't ban nothing!")
|
740 |
await m.stop_propagation()
|
741 |
|
742 |
if m.reply_to_message and not m.reply_to_message.from_user:
|
|
|
761 |
await m.stop_propagation()
|
762 |
|
763 |
if user_id in SUPPORT_STAFF:
|
764 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
765 |
LOGGER.info(
|
766 |
f"{m.from_user.id} trying to ban {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
767 |
)
|
|
|
773 |
admins_group = await admin_cache_reload(m, "ban")
|
774 |
|
775 |
if user_id in admins_group:
|
776 |
+
await m.reply_text(text="This user is an admin, I cannot ban them!")
|
777 |
await m.stop_propagation()
|
778 |
|
779 |
reason = None
|
|
|
789 |
try:
|
790 |
LOGGER.info(f"{m.from_user.id} banned {user_id} in {m.chat.id}")
|
791 |
await m.chat.ban_member(user_id)
|
792 |
+
banned=(await mention_html(user_first_name, user_id))
|
793 |
+
txt = f"{m.from_user.mention} banned {banned} in <b>{m.chat.title}</b>!"
|
|
|
|
|
|
|
794 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
795 |
keyboard = InlineKeyboardMarkup(
|
796 |
[
|
|
|
804 |
)
|
805 |
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
806 |
except ChatAdminRequired:
|
807 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
808 |
except PeerIdInvalid:
|
809 |
await m.reply_text(
|
810 |
"I have not seen this user yet...!\nMind forwarding one of their message so I can recognize them?",
|
811 |
)
|
812 |
except UserAdminInvalid:
|
813 |
+
await m.reply_text(text="Cannot act on this user, maybe I wasn't the one who changed their permissions.")
|
814 |
except RightForbidden:
|
815 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
816 |
except RPCError as ef:
|
817 |
await m.reply_text(
|
818 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
819 |
+
|
820 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
821 |
)
|
822 |
LOGGER.error(ef)
|
823 |
LOGGER.error(format_exc())
|
|
|
857 |
await m.chat.ban_member(m.from_user.id)
|
858 |
txt = "Why not let me help you!"
|
859 |
txt += f"\n<b>Reason</b>: {reason}" if reason else ""
|
860 |
+
await m.reply_animation(animation=KICK_MEDIA, caption=txt)
|
861 |
await m.chat.unban_member(m.from_user.id)
|
862 |
except RPCError as ef:
|
863 |
await m.reply_text(
|
864 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
865 |
+
|
866 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
867 |
)
|
868 |
return
|
869 |
|
Powers/plugins/blacklist.py
CHANGED
@@ -6,7 +6,6 @@ from pyrogram.types import CallbackQuery, Message
|
|
6 |
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.blacklist_db import Blacklist
|
9 |
-
from Powers.tr_engine import tlang
|
10 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
11 |
from Powers.utils.kbhelpers import ikb
|
12 |
|
@@ -18,16 +17,12 @@ async def view_blacklist(_, m: Message):
|
|
18 |
LOGGER.info(f"{m.from_user.id} checking blacklists in {m.chat.id}")
|
19 |
|
20 |
chat_title = m.chat.title
|
21 |
-
blacklists_chat =
|
22 |
-
chat_title=chat_title,
|
23 |
-
)
|
24 |
all_blacklisted = db.get_blacklists()
|
25 |
|
26 |
if not all_blacklisted:
|
27 |
await m.reply_text(
|
28 |
-
|
29 |
-
chat_title=chat_title,
|
30 |
-
),
|
31 |
)
|
32 |
return
|
33 |
|
@@ -44,7 +39,7 @@ async def add_blacklist(_, m: Message):
|
|
44 |
db = Blacklist(m.chat.id)
|
45 |
|
46 |
if len(m.text.split()) < 2:
|
47 |
-
await m.reply_text(
|
48 |
return
|
49 |
|
50 |
bl_words = ((m.text.split(None, 1)[1]).lower()).split()
|
@@ -63,11 +58,9 @@ async def add_blacklist(_, m: Message):
|
|
63 |
+ " already added in blacklist, skipped them!"
|
64 |
)
|
65 |
LOGGER.info(f"{m.from_user.id} added new blacklists ({bl_words}) in {m.chat.id}")
|
|
|
66 |
await m.reply_text(
|
67 |
-
(
|
68 |
-
trigger=", ".join(f"<code>{i}</code>" for i in bl_words),
|
69 |
-
)
|
70 |
-
+ (f"\n{rep_text}" if rep_text else ""),
|
71 |
)
|
72 |
|
73 |
await m.stop_propagation()
|
@@ -100,7 +93,7 @@ async def rm_blacklist(_, m: Message):
|
|
100 |
db = Blacklist(m.chat.id)
|
101 |
|
102 |
if len(m.text.split()) < 2:
|
103 |
-
await m.reply_text(
|
104 |
return
|
105 |
|
106 |
chat_bl = db.get_blacklists()
|
@@ -122,11 +115,9 @@ async def rm_blacklist(_, m: Message):
|
|
122 |
) + " in blcklisted words, skipped them."
|
123 |
|
124 |
LOGGER.info(f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
|
|
|
125 |
await m.reply_text(
|
126 |
-
(
|
127 |
-
bl_words=", ".join(f"<code>{i}</code>" for i in bl_words),
|
128 |
-
)
|
129 |
-
+ (f"\n{rep_text}" if rep_text else ""),
|
130 |
)
|
131 |
|
132 |
await m.stop_propagation()
|
@@ -155,16 +146,17 @@ async def set_bl_action(_, m: Message):
|
|
155 |
f"{m.from_user.id} set blacklist action to '{action}' in {m.chat.id}",
|
156 |
)
|
157 |
await m.reply_text(
|
158 |
-
|
159 |
)
|
160 |
elif len(m.text.split()) == 1:
|
161 |
action = db.get_action()
|
162 |
LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
|
163 |
await m.reply_text(
|
164 |
-
|
|
|
165 |
)
|
166 |
else:
|
167 |
-
await m.reply_text(
|
168 |
|
169 |
return
|
170 |
|
|
|
6 |
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.blacklist_db import Blacklist
|
|
|
9 |
from Powers.utils.custom_filters import command, owner_filter, restrict_filter
|
10 |
from Powers.utils.kbhelpers import ikb
|
11 |
|
|
|
17 |
LOGGER.info(f"{m.from_user.id} checking blacklists in {m.chat.id}")
|
18 |
|
19 |
chat_title = m.chat.title
|
20 |
+
blacklists_chat = f"Current Blacklisted words in <b>{chat_title}</b>:\n\n"
|
|
|
|
|
21 |
all_blacklisted = db.get_blacklists()
|
22 |
|
23 |
if not all_blacklisted:
|
24 |
await m.reply_text(
|
25 |
+
text=f"There are no blacklisted messages in <b>{chat_title}</b>!"
|
|
|
|
|
26 |
)
|
27 |
return
|
28 |
|
|
|
39 |
db = Blacklist(m.chat.id)
|
40 |
|
41 |
if len(m.text.split()) < 2:
|
42 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
43 |
return
|
44 |
|
45 |
bl_words = ((m.text.split(None, 1)[1]).lower()).split()
|
|
|
58 |
+ " already added in blacklist, skipped them!"
|
59 |
)
|
60 |
LOGGER.info(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!" + (f"\n{rep_text}" if rep_text else ""),
|
|
|
|
|
|
|
64 |
)
|
65 |
|
66 |
await m.stop_propagation()
|
|
|
93 |
db = Blacklist(m.chat.id)
|
94 |
|
95 |
if len(m.text.split()) < 2:
|
96 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
97 |
return
|
98 |
|
99 |
chat_bl = db.get_blacklists()
|
|
|
115 |
) + " in blcklisted words, skipped them."
|
116 |
|
117 |
LOGGER.info(f"{m.from_user.id} removed blacklists ({bl_words}) in {m.chat.id}")
|
118 |
+
bl_words=", ".join(f"<code>{i}</code>" for i in bl_words)
|
119 |
await m.reply_text(
|
120 |
+
text=f"Removed <b>{bl_words}</b> from blacklist words!" + (f"\n{rep_text}" if rep_text else ""),
|
|
|
|
|
|
|
121 |
)
|
122 |
|
123 |
await m.stop_propagation()
|
|
|
146 |
f"{m.from_user.id} set blacklist action to '{action}' in {m.chat.id}",
|
147 |
)
|
148 |
await m.reply_text(
|
149 |
+
text=f"Set action for blacklist for this to <b>{action}</b>"
|
150 |
)
|
151 |
elif len(m.text.split()) == 1:
|
152 |
action = db.get_action()
|
153 |
LOGGER.info(f"{m.from_user.id} checking blacklist action in {m.chat.id}")
|
154 |
await m.reply_text(
|
155 |
+
text= f"""The current action for blacklists in this chat is <i><b>{action}</b></i>
|
156 |
+
All blacklist modes delete the message containing blacklist word."""
|
157 |
)
|
158 |
else:
|
159 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
160 |
|
161 |
return
|
162 |
|
Powers/plugins/dev.py
CHANGED
@@ -14,12 +14,11 @@ from pyrogram.errors import (
|
|
14 |
RPCError,
|
15 |
)
|
16 |
from pyrogram.types import Message
|
17 |
-
|
18 |
|
19 |
from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
|
20 |
from Powers.bot_class import Gojo
|
21 |
from Powers.database.chats_db import Chats
|
22 |
-
from Powers.tr_engine import tlang
|
23 |
from Powers.utils.clean_file import remove_markdown_and_html
|
24 |
from Powers.utils.custom_filters import command
|
25 |
from Powers.utils.http_helper import HTTPx
|
@@ -32,7 +31,7 @@ from Powers.vars import Config
|
|
32 |
async def ping(_, m: Message):
|
33 |
LOGGER.info(f"{m.from_user.id} used ping cmd in {m.chat.id}")
|
34 |
start = time()
|
35 |
-
replymsg = await m.reply_text(
|
36 |
delta_ping = time() - start
|
37 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
38 |
return
|
@@ -78,29 +77,6 @@ async def group_info(c: Gojo, m: Message):
|
|
78 |
await replymsg.edit_text(msg)
|
79 |
return
|
80 |
|
81 |
-
|
82 |
-
@Gojo.on_message(command("speedtest", dev_cmd=True))
|
83 |
-
async def test_speed(c: Gojo, m: Message):
|
84 |
-
await c.send_message(
|
85 |
-
MESSAGE_DUMP,
|
86 |
-
f"#SPEEDTEST\n\n**User:** {(await mention_markdown(m.from_user.first_name, m.from_user.id))}",
|
87 |
-
)
|
88 |
-
sent = await m.reply_text(tlang(m, "dev.speedtest.start_speedtest"))
|
89 |
-
s = Speedtest()
|
90 |
-
bs = s.get_best_server()
|
91 |
-
dl = round(s.download() / 1024 / 1024, 2)
|
92 |
-
ul = round(s.upload() / 1024 / 1024, 2)
|
93 |
-
await sent.edit_text(
|
94 |
-
(tlang(m, "dev.speedtest.speedtest_txt")).format(
|
95 |
-
host=bs["sponsor"],
|
96 |
-
ping=int(bs["latency"]),
|
97 |
-
download=dl,
|
98 |
-
upload=ul,
|
99 |
-
),
|
100 |
-
)
|
101 |
-
return
|
102 |
-
|
103 |
-
|
104 |
@Gojo.on_message(command("neofetch", dev_cmd=True))
|
105 |
async def neofetch_stats(_, m: Message):
|
106 |
cmd = "neofetch --stdout"
|
@@ -131,7 +107,7 @@ async def neofetch_stats(_, m: Message):
|
|
131 |
@Gojo.on_message(command(["eval", "py"], dev_cmd=True))
|
132 |
async def evaluate_code(c: Gojo, m: Message):
|
133 |
if len(m.text.split()) == 1:
|
134 |
-
await m.reply_text(
|
135 |
return
|
136 |
sm = await m.reply_text("`Processing...`")
|
137 |
cmd = m.text.split(None, maxsplit=1)[1]
|
@@ -193,7 +169,7 @@ async def aexec(code, c, m):
|
|
193 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
194 |
async def execution(_, m: Message):
|
195 |
if len(m.text.split()) == 1:
|
196 |
-
await m.reply_text(
|
197 |
return
|
198 |
sm = await m.reply_text("`Processing...`")
|
199 |
cmd = m.text.split(maxsplit=1)[1]
|
@@ -243,7 +219,8 @@ async def public_ip(c: Gojo, m: Message):
|
|
243 |
f"#IP\n\n**User:** {(await mention_markdown(m.from_user.first_name, m.from_user.id))}",
|
244 |
)
|
245 |
await m.reply_text(
|
246 |
-
|
|
|
247 |
quote=True,
|
248 |
)
|
249 |
return
|
@@ -251,13 +228,15 @@ async def public_ip(c: Gojo, m: Message):
|
|
251 |
|
252 |
@Gojo.on_message(command("chatlist", dev_cmd=True))
|
253 |
async def chats(c: Gojo, m: Message):
|
254 |
-
exmsg = await m.reply_text(
|
255 |
await c.send_message(
|
256 |
MESSAGE_DUMP,
|
257 |
f"#CHATLIST\n\n**User:** {(await mention_markdown(m.from_user.first_name, m.from_user.id))}",
|
258 |
)
|
259 |
all_chats = (Chats.list_chats_full()) or {}
|
260 |
-
chatfile =
|
|
|
|
|
261 |
P = 1
|
262 |
for chat in all_chats:
|
263 |
try:
|
@@ -287,7 +266,7 @@ async def chats(c: Gojo, m: Message):
|
|
287 |
f.name = "chatlist.txt"
|
288 |
await m.reply_document(
|
289 |
document=f,
|
290 |
-
caption=
|
291 |
)
|
292 |
await exmsg.delete()
|
293 |
return
|
@@ -296,7 +275,7 @@ async def chats(c: Gojo, m: Message):
|
|
296 |
@Gojo.on_message(command("uptime", dev_cmd=True))
|
297 |
async def uptime(_, m: Message):
|
298 |
up = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
|
299 |
-
await m.reply_text(
|
300 |
return
|
301 |
|
302 |
|
|
|
14 |
RPCError,
|
15 |
)
|
16 |
from pyrogram.types import Message
|
17 |
+
|
18 |
|
19 |
from Powers import LOGFILE, LOGGER, MESSAGE_DUMP, UPTIME
|
20 |
from Powers.bot_class import Gojo
|
21 |
from Powers.database.chats_db import Chats
|
|
|
22 |
from Powers.utils.clean_file import remove_markdown_and_html
|
23 |
from Powers.utils.custom_filters import command
|
24 |
from Powers.utils.http_helper import HTTPx
|
|
|
31 |
async def ping(_, m: Message):
|
32 |
LOGGER.info(f"{m.from_user.id} used ping cmd in {m.chat.id}")
|
33 |
start = time()
|
34 |
+
replymsg = await m.reply_text(text="Pinging...", quote=True)
|
35 |
delta_ping = time() - start
|
36 |
await replymsg.edit_text(f"<b>Pong!</b>\n{delta_ping * 1000:.3f} ms")
|
37 |
return
|
|
|
77 |
await replymsg.edit_text(msg)
|
78 |
return
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
@Gojo.on_message(command("neofetch", dev_cmd=True))
|
81 |
async def neofetch_stats(_, m: Message):
|
82 |
cmd = "neofetch --stdout"
|
|
|
107 |
@Gojo.on_message(command(["eval", "py"], dev_cmd=True))
|
108 |
async def evaluate_code(c: Gojo, m: Message):
|
109 |
if len(m.text.split()) == 1:
|
110 |
+
await m.reply_text(text="Please execute the code correctly!")
|
111 |
return
|
112 |
sm = await m.reply_text("`Processing...`")
|
113 |
cmd = m.text.split(None, maxsplit=1)[1]
|
|
|
169 |
@Gojo.on_message(command(["exec", "sh"], dev_cmd=True))
|
170 |
async def execution(_, m: Message):
|
171 |
if len(m.text.split()) == 1:
|
172 |
+
await m.reply_text(text="Please execute the code correctly!")
|
173 |
return
|
174 |
sm = await m.reply_text("`Processing...`")
|
175 |
cmd = m.text.split(maxsplit=1)[1]
|
|
|
219 |
f"#IP\n\n**User:** {(await mention_markdown(m.from_user.first_name, m.from_user.id))}",
|
220 |
)
|
221 |
await m.reply_text(
|
222 |
+
text=f"""<b>Bot IP Address:</b>
|
223 |
+
<code>{ip.text}</code>""",
|
224 |
quote=True,
|
225 |
)
|
226 |
return
|
|
|
228 |
|
229 |
@Gojo.on_message(command("chatlist", dev_cmd=True))
|
230 |
async def chats(c: Gojo, m: Message):
|
231 |
+
exmsg = await m.reply_text(text="Exporting Charlist...")
|
232 |
await c.send_message(
|
233 |
MESSAGE_DUMP,
|
234 |
f"#CHATLIST\n\n**User:** {(await mention_markdown(m.from_user.first_name, m.from_user.id))}",
|
235 |
)
|
236 |
all_chats = (Chats.list_chats_full()) or {}
|
237 |
+
chatfile = """List of chats in my database.
|
238 |
+
|
239 |
+
<b>Chat name | Chat ID | Members count</b>"""
|
240 |
P = 1
|
241 |
for chat in all_chats:
|
242 |
try:
|
|
|
266 |
f.name = "chatlist.txt"
|
267 |
await m.reply_document(
|
268 |
document=f,
|
269 |
+
caption="Here is the list of chats in my Database.",
|
270 |
)
|
271 |
await exmsg.delete()
|
272 |
return
|
|
|
275 |
@Gojo.on_message(command("uptime", dev_cmd=True))
|
276 |
async def uptime(_, m: Message):
|
277 |
up = strftime("%Hh %Mm %Ss", gmtime(time() - UPTIME))
|
278 |
+
await m.reply_text(text=f"<b>Uptime:</b> <code>{up}</code>", quote=True)
|
279 |
return
|
280 |
|
281 |
|
Powers/plugins/formatting.py
CHANGED
@@ -3,7 +3,6 @@ from pyrogram.types import CallbackQuery, Message
|
|
3 |
|
4 |
from Powers import LOGGER
|
5 |
from Powers.bot_class import Gojo
|
6 |
-
from Powers.tr_engine import tlang
|
7 |
from Powers.utils.custom_filters import command
|
8 |
from Powers.utils.kbhelpers import ikb
|
9 |
|
@@ -16,7 +15,7 @@ async def gen_formatting_kb(m):
|
|
16 |
("Fillings", "formatting.fillings"),
|
17 |
],
|
18 |
[("Random Content", "formatting.random_content")],
|
19 |
-
[(
|
20 |
],
|
21 |
)
|
22 |
|
@@ -26,7 +25,7 @@ async def gen_formatting_kb(m):
|
|
26 |
)
|
27 |
async def markdownhelp(_, m: Message):
|
28 |
await m.reply_text(
|
29 |
-
|
30 |
quote=True,
|
31 |
reply_markup=(await gen_formatting_kb(m)),
|
32 |
)
|
@@ -37,23 +36,74 @@ async def markdownhelp(_, m: Message):
|
|
37 |
@Gojo.on_callback_query(filters.regex("^formatting."))
|
38 |
async def get_formatting_info(_, q: CallbackQuery):
|
39 |
cmd = q.data.split(".")[1]
|
40 |
-
kb = ikb([[(
|
41 |
|
42 |
if cmd == "md_formatting":
|
43 |
await q.message.edit_text(
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
reply_markup=kb,
|
46 |
parse_mode="html",
|
47 |
)
|
48 |
elif cmd == "fillings":
|
49 |
await q.message.edit_text(
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
reply_markup=kb,
|
52 |
parse_mode="html",
|
53 |
)
|
54 |
elif cmd == "random_content":
|
55 |
await q.message.edit_text(
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
reply_markup=kb,
|
58 |
parse_mode="html",
|
59 |
)
|
@@ -65,7 +115,9 @@ async def get_formatting_info(_, q: CallbackQuery):
|
|
65 |
@Gojo.on_callback_query(filters.regex("^back."))
|
66 |
async def send_mod_help(_, q: CallbackQuery):
|
67 |
await q.message.edit_text(
|
68 |
-
|
|
|
|
|
69 |
reply_markup=(await gen_formatting_kb(q.message)),
|
70 |
)
|
71 |
await q.answer()
|
|
|
3 |
|
4 |
from Powers import LOGGER
|
5 |
from Powers.bot_class import Gojo
|
|
|
6 |
from Powers.utils.custom_filters import command
|
7 |
from Powers.utils.kbhelpers import ikb
|
8 |
|
|
|
15 |
("Fillings", "formatting.fillings"),
|
16 |
],
|
17 |
[("Random Content", "formatting.random_content")],
|
18 |
+
[("« " + "Back", "commands")],
|
19 |
],
|
20 |
)
|
21 |
|
|
|
25 |
)
|
26 |
async def markdownhelp(_, m: Message):
|
27 |
await m.reply_text(
|
28 |
+
text=f"plugins.{__PLUGIN__}.help",
|
29 |
quote=True,
|
30 |
reply_markup=(await gen_formatting_kb(m)),
|
31 |
)
|
|
|
36 |
@Gojo.on_callback_query(filters.regex("^formatting."))
|
37 |
async def get_formatting_info(_, q: CallbackQuery):
|
38 |
cmd = q.data.split(".")[1]
|
39 |
+
kb = ikb([[("Back", "back.formatting")]])
|
40 |
|
41 |
if cmd == "md_formatting":
|
42 |
await q.message.edit_text(
|
43 |
+
text="""<b>Markdown Formatting</b>
|
44 |
+
You can format your message using <b>bold</b>, <i>italic</i>, <u>underline</u>, <strike>strike</strike> and much more. Go ahead and experiment!
|
45 |
+
|
46 |
+
**Note**: It supports telegram user based formatting as well as html and markdown formattings.
|
47 |
+
<b>Supported markdown</b>:
|
48 |
+
- <code>`code words`</code>: Backticks are used for monospace fonts. Shows as: <code>code words</code>.
|
49 |
+
- <code>__italic__</code>: Underscores are used for italic fonts. Shows as: <i>italic words</i>.
|
50 |
+
- <code>**bold**</code>: Asterisks are used for bold fonts. Shows as: <b>bold words</b>.
|
51 |
+
- <code>```pre```</code>: To make the formatter ignore other formatting characters inside the text formatted with '```', like: <code>**bold** | *bold*</code>.
|
52 |
+
- <code>--underline--</code>: To make text <u>underline</u>.
|
53 |
+
- <code>~~strike~~</code>: Tildes are used for strikethrough. Shows as: <strike>strike</strike>.
|
54 |
+
- <code>||spoiler||</code>: Double vertical bars are used for spoilers. Shows as: <spoiler>Spoiler</spoiler>.
|
55 |
+
- <code>[hyperlink](example.com)</code>: This is the formatting used for hyperlinks. Shows as: <a href="https://example.com/">hyperlink</a>.
|
56 |
+
- <code>[My Button](buttonurl://example.com)</code>: This is the formatting used for creating buttons. This example will create a button named "My button" which opens <code>example.com</code> when clicked.
|
57 |
+
If you would like to send buttons on the same row, use the <code>:same</code> formatting.
|
58 |
+
<b>Example:</b>
|
59 |
+
<code>[button 1](buttonurl:example.com)</code>
|
60 |
+
<code>[button 2](buttonurl://example.com:same)</code>
|
61 |
+
<code>[button 3](buttonurl://example.com)</code>
|
62 |
+
This will show button 1 and 2 on the same line, while 3 will be underneath.""",
|
63 |
reply_markup=kb,
|
64 |
parse_mode="html",
|
65 |
)
|
66 |
elif cmd == "fillings":
|
67 |
await q.message.edit_text(
|
68 |
+
text="""<b>Fillings</b>
|
69 |
+
|
70 |
+
You can also customise the contents of your message with contextual data. For example, you could mention a user by name in the welcome message, or mention them in a filter!
|
71 |
+
You can use these to mention a user in notes too!
|
72 |
+
|
73 |
+
<b>Supported fillings:</b>
|
74 |
+
- <code>{first}</code>: The user's first name.
|
75 |
+
- <code>{last}</code>: The user's last name.
|
76 |
+
- <code>{fullname}</code>: The user's full name.
|
77 |
+
- <code>{username}</code>: The user's username. If they don't have one, mentions the user instead.
|
78 |
+
- <code>{mention}</code>: Mentions the user with their firstname.
|
79 |
+
- <code>{id}</code>: The user's ID.
|
80 |
+
- <code>{chatname}</code>: The chat's name.""",
|
81 |
reply_markup=kb,
|
82 |
parse_mode="html",
|
83 |
)
|
84 |
elif cmd == "random_content":
|
85 |
await q.message.edit_text(
|
86 |
+
text="""<b>Random Content</b>
|
87 |
+
|
88 |
+
Another thing that can be fun, is to randomise the contents of a message. Make things a little more personal by changing welcome messages, or changing notes!
|
89 |
+
|
90 |
+
How to use random contents:
|
91 |
+
- %%%: This separator can be used to add "random" replies to the bot.
|
92 |
+
For example:
|
93 |
+
<code>hello
|
94 |
+
%%%
|
95 |
+
how are you</code>
|
96 |
+
This will randomly choose between sending the first message, "hello", or the second message, "how are you".
|
97 |
+
Use this to make Alita feel a bit more customised! (only works in filters/notes)
|
98 |
+
|
99 |
+
Example welcome message::
|
100 |
+
- Every time a new user joins, they'll be presented with one of the three messages shown here.
|
101 |
+
-> /filter "hey"
|
102 |
+
hello there <code>{first}</code>!
|
103 |
+
%%%
|
104 |
+
Ooooh, <code>{first}</code> how are you?
|
105 |
+
%%%
|
106 |
+
Sup? <code>{first}</code>""",
|
107 |
reply_markup=kb,
|
108 |
parse_mode="html",
|
109 |
)
|
|
|
115 |
@Gojo.on_callback_query(filters.regex("^back."))
|
116 |
async def send_mod_help(_, q: CallbackQuery):
|
117 |
await q.message.edit_text(
|
118 |
+
text="""Formatting
|
119 |
+
|
120 |
+
Alita supports a large number of formatting options to make your messages more expressive. Take a look by clicking the buttons below!""",
|
121 |
reply_markup=(await gen_formatting_kb(q.message)),
|
122 |
)
|
123 |
await q.answer()
|
Powers/plugins/fun.py
CHANGED
@@ -7,7 +7,6 @@ from pyrogram.types import Message
|
|
7 |
|
8 |
from Powers import LOGGER, DEV_USERS
|
9 |
from Powers.bot_class import Gojo
|
10 |
-
from Powers.tr_engine import tlang
|
11 |
from Powers.utils import fun_strings
|
12 |
from Powers.utils.custom_filters import command
|
13 |
from Powers.utils.extract_user import extract_user
|
@@ -18,7 +17,7 @@ from Powers.utils.extract_user import extract_user
|
|
18 |
async def fun_shout(_, m: Message):
|
19 |
if len(m.text.split()) == 1:
|
20 |
await m.reply_text(
|
21 |
-
|
22 |
quote=True,
|
23 |
)
|
24 |
return
|
@@ -157,7 +156,7 @@ async def weebify(_, m: Message):
|
|
157 |
)
|
158 |
return
|
159 |
if not args:
|
160 |
-
await m.reply_text(
|
161 |
return
|
162 |
|
163 |
# Use split to convert to list
|
@@ -172,7 +171,8 @@ async def weebify(_, m: Message):
|
|
172 |
string = string.replace(normiecharacter, weebycharacter)
|
173 |
|
174 |
await m.reply_text(
|
175 |
-
|
|
|
176 |
)
|
177 |
LOGGER.info(f"{m.from_user.id} weebified '{args}' in {m.chat.id}")
|
178 |
return
|
|
|
7 |
|
8 |
from Powers import LOGGER, DEV_USERS
|
9 |
from Powers.bot_class import Gojo
|
|
|
10 |
from Powers.utils import fun_strings
|
11 |
from Powers.utils.custom_filters import command
|
12 |
from Powers.utils.extract_user import extract_user
|
|
|
17 |
async def fun_shout(_, m: Message):
|
18 |
if len(m.text.split()) == 1:
|
19 |
await m.reply_text(
|
20 |
+
text="Please check help on how to use this this command.",
|
21 |
quote=True,
|
22 |
)
|
23 |
return
|
|
|
156 |
)
|
157 |
return
|
158 |
if not args:
|
159 |
+
await m.reply_text(text="What am I supposed to Weebify?")
|
160 |
return
|
161 |
|
162 |
# Use split to convert to list
|
|
|
171 |
string = string.replace(normiecharacter, weebycharacter)
|
172 |
|
173 |
await m.reply_text(
|
174 |
+
text=f"""<b>Weebified String:</b>
|
175 |
+
<code>{string}</code>"""
|
176 |
)
|
177 |
LOGGER.info(f"{m.from_user.id} weebified '{args}' in {m.chat.id}")
|
178 |
return
|
Powers/plugins/initial.py
CHANGED
@@ -10,7 +10,6 @@ from Powers.database.chats_db import Chats
|
|
10 |
from Powers.database.disable_db import Disabling
|
11 |
from Powers.database.filters_db import Filters
|
12 |
from Powers.database.greetings_db import Greetings
|
13 |
-
from Powers.database.lang_db import Langs
|
14 |
from Powers.database.notes_db import Notes, NotesSettings
|
15 |
from Powers.database.pins_db import Pins
|
16 |
from Powers.database.reporting_db import Reporting
|
@@ -85,7 +84,6 @@ async def initial_works(_, m: Message):
|
|
85 |
|
86 |
async def migrate_chat(m: Message, new_chat: int) -> None:
|
87 |
LOGGER.info(f"Migrating from {m.chat.id} to {new_chat}...")
|
88 |
-
langdb = Langs(m.chat.id)
|
89 |
notedb = Notes()
|
90 |
gdb = Greetings(m.chat.id)
|
91 |
ruledb = Rules(m.chat.id)
|
@@ -102,7 +100,6 @@ async def migrate_chat(m: Message, new_chat: int) -> None:
|
|
102 |
gdb.migrate_chat(new_chat)
|
103 |
chatdb.migrate_chat(new_chat)
|
104 |
userdb.migrate_chat(new_chat)
|
105 |
-
langdb.migrate_chat(new_chat)
|
106 |
ruledb.migrate_chat(new_chat)
|
107 |
bldb.migrate_chat(new_chat)
|
108 |
notedb.migrate_chat(m.chat.id, new_chat)
|
|
|
10 |
from Powers.database.disable_db import Disabling
|
11 |
from Powers.database.filters_db import Filters
|
12 |
from Powers.database.greetings_db import Greetings
|
|
|
13 |
from Powers.database.notes_db import Notes, NotesSettings
|
14 |
from Powers.database.pins_db import Pins
|
15 |
from Powers.database.reporting_db import Reporting
|
|
|
84 |
|
85 |
async def migrate_chat(m: Message, new_chat: int) -> None:
|
86 |
LOGGER.info(f"Migrating from {m.chat.id} to {new_chat}...")
|
|
|
87 |
notedb = Notes()
|
88 |
gdb = Greetings(m.chat.id)
|
89 |
ruledb = Rules(m.chat.id)
|
|
|
100 |
gdb.migrate_chat(new_chat)
|
101 |
chatdb.migrate_chat(new_chat)
|
102 |
userdb.migrate_chat(new_chat)
|
|
|
103 |
ruledb.migrate_chat(new_chat)
|
104 |
bldb.migrate_chat(new_chat)
|
105 |
notedb.migrate_chat(m.chat.id, new_chat)
|
Powers/plugins/langs.py
CHANGED
@@ -6,7 +6,6 @@ from pyrogram.types import CallbackQuery, Message
|
|
6 |
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.lang_db import Langs
|
9 |
-
from Powers.tr_engine import lang_dict, tlang
|
10 |
from Powers.utils.custom_filters import admin_filter, command
|
11 |
from Powers.utils.kbhelpers import ikb
|
12 |
|
|
|
6 |
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.lang_db import Langs
|
|
|
9 |
from Powers.utils.custom_filters import admin_filter, command
|
10 |
from Powers.utils.kbhelpers import ikb
|
11 |
|
Powers/plugins/locks.py
CHANGED
@@ -6,7 +6,6 @@ from pyrogram.types import ChatPermissions, Message
|
|
6 |
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.approve_db import Approve
|
9 |
-
from Powers.tr_engine import tlang
|
10 |
from Powers.utils.custom_filters import command, restrict_filter
|
11 |
|
12 |
|
@@ -41,7 +40,7 @@ async def lock_perm(c: Gojo, m: Message):
|
|
41 |
chat_id = m.chat.id
|
42 |
|
43 |
if not lock_type:
|
44 |
-
await m.reply_text(
|
45 |
return
|
46 |
|
47 |
get_perm = m.chat.permissions
|
@@ -62,8 +61,8 @@ async def lock_perm(c: Gojo, m: Message):
|
|
62 |
except ChatNotModified:
|
63 |
pass
|
64 |
except ChatAdminRequired:
|
65 |
-
await m.reply_text(
|
66 |
-
await m.reply_text("🔒 " +
|
67 |
await prevent_approved(m)
|
68 |
return
|
69 |
|
@@ -112,7 +111,9 @@ async def lock_perm(c: Gojo, m: Message):
|
|
112 |
perm = "pin"
|
113 |
|
114 |
else:
|
115 |
-
await m.reply_text(
|
|
|
|
|
116 |
return
|
117 |
|
118 |
try:
|
@@ -133,9 +134,9 @@ async def lock_perm(c: Gojo, m: Message):
|
|
133 |
except ChatNotModified:
|
134 |
pass
|
135 |
except ChatAdminRequired:
|
136 |
-
await m.reply_text(
|
137 |
await m.reply_text(
|
138 |
-
"🔒 " +
|
139 |
)
|
140 |
await prevent_approved(m)
|
141 |
return
|
@@ -143,7 +144,7 @@ async def lock_perm(c: Gojo, m: Message):
|
|
143 |
|
144 |
@Gojo.on_message(command("locks") & restrict_filter)
|
145 |
async def view_locks(_, m: Message):
|
146 |
-
chkmsg = await m.reply_text(
|
147 |
v_perm = m.chat.permissions
|
148 |
|
149 |
async def convert_to_emoji(val: bool):
|
@@ -162,21 +163,24 @@ async def view_locks(_, m: Message):
|
|
162 |
|
163 |
if v_perm is not None:
|
164 |
try:
|
165 |
-
permission_view_str =
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
|
|
|
|
|
|
175 |
LOGGER.info(f"{m.from_user.id} used locks cmd in {m.chat.id}")
|
176 |
await chkmsg.edit_text(permission_view_str)
|
177 |
|
178 |
except RPCError as e_f:
|
179 |
-
await chkmsg.edit_text(
|
180 |
await m.reply_text(e_f)
|
181 |
return
|
182 |
|
@@ -190,7 +194,7 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
190 |
chat_id = m.chat.id
|
191 |
|
192 |
if not unlock_type:
|
193 |
-
await m.reply_text(
|
194 |
return
|
195 |
|
196 |
if unlock_type == "all":
|
@@ -212,8 +216,8 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
212 |
except ChatNotModified:
|
213 |
pass
|
214 |
except ChatAdminRequired:
|
215 |
-
await m.reply_text(
|
216 |
-
await m.reply_text("🔓 " +
|
217 |
await prevent_approved(m)
|
218 |
return
|
219 |
|
@@ -273,7 +277,9 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
273 |
uperm = "pin"
|
274 |
|
275 |
else:
|
276 |
-
await m.reply_text(
|
|
|
|
|
277 |
return
|
278 |
|
279 |
try:
|
@@ -296,9 +302,9 @@ async def unlock_perm(c: Gojo, m: Message):
|
|
296 |
except ChatNotModified:
|
297 |
pass
|
298 |
except ChatAdminRequired:
|
299 |
-
await m.reply_text(
|
300 |
await m.reply_text(
|
301 |
-
"🔓 " +
|
302 |
)
|
303 |
await prevent_approved(m)
|
304 |
return
|
|
|
6 |
from Powers import LOGGER
|
7 |
from Powers.bot_class import Gojo
|
8 |
from Powers.database.approve_db import Approve
|
|
|
9 |
from Powers.utils.custom_filters import command, restrict_filter
|
10 |
|
11 |
|
|
|
40 |
chat_id = m.chat.id
|
41 |
|
42 |
if not lock_type:
|
43 |
+
await m.reply_text(text="Specify a permission to lock!")
|
44 |
return
|
45 |
|
46 |
get_perm = m.chat.permissions
|
|
|
61 |
except ChatNotModified:
|
62 |
pass
|
63 |
except ChatAdminRequired:
|
64 |
+
await m.reply_text(text="I don't have permission to do that")
|
65 |
+
await m.reply_text("🔒 " + "Locked <b>all</b> permission from this Chat!")
|
66 |
await prevent_approved(m)
|
67 |
return
|
68 |
|
|
|
111 |
perm = "pin"
|
112 |
|
113 |
else:
|
114 |
+
await m.reply_text(text=""" Invalid Lock Type!
|
115 |
+
|
116 |
+
Use /locktypes to get the lock types""")
|
117 |
return
|
118 |
|
119 |
try:
|
|
|
134 |
except ChatNotModified:
|
135 |
pass
|
136 |
except ChatAdminRequired:
|
137 |
+
await m.reply_text(text="I don't have permission to do that")
|
138 |
await m.reply_text(
|
139 |
+
"🔒 " + f"Locked <b>{perm}</b> for this Chat.",
|
140 |
)
|
141 |
await prevent_approved(m)
|
142 |
return
|
|
|
144 |
|
145 |
@Gojo.on_message(command("locks") & restrict_filter)
|
146 |
async def view_locks(_, m: Message):
|
147 |
+
chkmsg = await m.reply_text(text="Checking Chat permissions...")
|
148 |
v_perm = m.chat.permissions
|
149 |
|
150 |
async def convert_to_emoji(val: bool):
|
|
|
163 |
|
164 |
if v_perm is not None:
|
165 |
try:
|
166 |
+
permission_view_str = f"""<b>Chat Permissions:</b>
|
167 |
+
|
168 |
+
<b>Send Messages:</b> {vmsg}
|
169 |
+
<b>Send Media:</b> {vmedia}
|
170 |
+
<b>Send Stickers:</b> {vother}
|
171 |
+
<b>Send Animations:</b> {vother}
|
172 |
+
<b>Can Play Games:</b> {vother}
|
173 |
+
<b>Can Use Inline Bots:</b> {vother}
|
174 |
+
<b>Webpage Preview:</b> {vwebprev}
|
175 |
+
<b>Send Polls:</b> {vpolls}
|
176 |
+
<b>Change Info:</b> {vinfo}
|
177 |
+
<b>Invite Users:</b> {vinvite}
|
178 |
+
<b>Pin Messages:</b> {vpin}"""
|
179 |
LOGGER.info(f"{m.from_user.id} used locks cmd in {m.chat.id}")
|
180 |
await chkmsg.edit_text(permission_view_str)
|
181 |
|
182 |
except RPCError as e_f:
|
183 |
+
await chkmsg.edit_text(text="Something went wrong!")
|
184 |
await m.reply_text(e_f)
|
185 |
return
|
186 |
|
|
|
194 |
chat_id = m.chat.id
|
195 |
|
196 |
if not unlock_type:
|
197 |
+
await m.reply_text(text="Specify a permission to unlock!")
|
198 |
return
|
199 |
|
200 |
if unlock_type == "all":
|
|
|
216 |
except ChatNotModified:
|
217 |
pass
|
218 |
except ChatAdminRequired:
|
219 |
+
await m.reply_text(text="I don't have permission to do that")
|
220 |
+
await m.reply_text("🔓 " + "Unlocked <b>all</b> permission from this Chat!")
|
221 |
await prevent_approved(m)
|
222 |
return
|
223 |
|
|
|
277 |
uperm = "pin"
|
278 |
|
279 |
else:
|
280 |
+
await m.reply_text(text="""Invalid Lock Type!
|
281 |
+
|
282 |
+
Use /locktypes to get the lock types""")
|
283 |
return
|
284 |
|
285 |
try:
|
|
|
302 |
except ChatNotModified:
|
303 |
pass
|
304 |
except ChatAdminRequired:
|
305 |
+
await m.reply_text(text="I don't have permission to do that")
|
306 |
await m.reply_text(
|
307 |
+
"🔓 " + f"Unlocked <b>{uperm}</b> for this Chat.",
|
308 |
)
|
309 |
await prevent_approved(m)
|
310 |
return
|
Powers/plugins/muting.py
CHANGED
@@ -15,7 +15,6 @@ from pyrogram.types import (
|
|
15 |
|
16 |
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
17 |
from Powers.bot_class import Gojo
|
18 |
-
from Powers.tr_engine import tlang
|
19 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
20 |
from Powers.utils.custom_filters import command, restrict_filter
|
21 |
from Powers.utils.extract_user import extract_user
|
@@ -46,7 +45,7 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
46 |
LOGGER.info(
|
47 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
48 |
)
|
49 |
-
await m.reply_text(
|
50 |
return
|
51 |
|
52 |
try:
|
@@ -55,7 +54,7 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
55 |
admins_group = await admin_cache_reload(m, "mute")
|
56 |
|
57 |
if user_id in admins_group:
|
58 |
-
await m.reply_text(
|
59 |
return
|
60 |
|
61 |
r_id = m.reply_to_message.message_id if m.reply_to_message else m.message_id
|
@@ -89,10 +88,9 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
89 |
mutetime,
|
90 |
)
|
91 |
LOGGER.info(f"{m.from_user.id} tmuted {user_id} in {m.chat.id}")
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
)
|
96 |
if reason:
|
97 |
txt += f"\n<b>Reason</b>: {reason}"
|
98 |
keyboard = InlineKeyboardMarkup(
|
@@ -107,17 +105,16 @@ async def tmute_usr(c: Gojo, m: Message):
|
|
107 |
)
|
108 |
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
109 |
except ChatAdminRequired:
|
110 |
-
await m.reply_text(
|
111 |
except RightForbidden:
|
112 |
-
await m.reply_text(
|
113 |
except UserNotParticipant:
|
114 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
115 |
except RPCError as ef:
|
116 |
await m.reply_text(
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
),
|
121 |
)
|
122 |
LOGGER.error(ef)
|
123 |
|
@@ -148,7 +145,7 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
148 |
LOGGER.info(
|
149 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
150 |
)
|
151 |
-
await m.reply_text(
|
152 |
return
|
153 |
|
154 |
try:
|
@@ -157,7 +154,7 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
157 |
admins_group = await admin_cache_reload(m, "mute")
|
158 |
|
159 |
if user_id in admins_group:
|
160 |
-
await m.reply_text(
|
161 |
return
|
162 |
|
163 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
@@ -189,10 +186,9 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
189 |
)
|
190 |
LOGGER.info(f"{m.from_user.id} dtmuted {user_id} in {m.chat.id}")
|
191 |
await m.reply_to_message.delete()
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
)
|
196 |
if reason:
|
197 |
txt += f"\n<b>Reason</b>: {reason}"
|
198 |
keyboard = InlineKeyboardMarkup(
|
@@ -207,17 +203,16 @@ async def dtmute_usr(c: Gojo, m: Message):
|
|
207 |
)
|
208 |
await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
209 |
except ChatAdminRequired:
|
210 |
-
await m.reply_text(
|
211 |
except RightForbidden:
|
212 |
-
await m.reply_text(
|
213 |
except UserNotParticipant:
|
214 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
215 |
except RPCError as ef:
|
216 |
await m.reply_text(
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
),
|
221 |
)
|
222 |
LOGGER.error(ef)
|
223 |
|
@@ -246,7 +241,7 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
246 |
LOGGER.info(
|
247 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
248 |
)
|
249 |
-
await m.reply_text(
|
250 |
return
|
251 |
|
252 |
try:
|
@@ -255,7 +250,7 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
255 |
admins_group = await admin_cache_reload(m, "mute")
|
256 |
|
257 |
if user_id in admins_group:
|
258 |
-
await m.reply_text(
|
259 |
return
|
260 |
|
261 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
@@ -290,17 +285,16 @@ async def stmute_usr(c: Gojo, m: Message):
|
|
290 |
if m.reply_to_message:
|
291 |
await m.reply_to_message.delete()
|
292 |
except ChatAdminRequired:
|
293 |
-
await m.reply_text(
|
294 |
except RightForbidden:
|
295 |
-
await m.reply_text(
|
296 |
except UserNotParticipant:
|
297 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
298 |
except RPCError as ef:
|
299 |
await m.reply_text(
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
),
|
304 |
)
|
305 |
LOGGER.error(ef)
|
306 |
|
@@ -338,7 +332,7 @@ async def mute_usr(c: Gojo, m: Message):
|
|
338 |
LOGGER.info(
|
339 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
340 |
)
|
341 |
-
await m.reply_text(
|
342 |
return
|
343 |
|
344 |
try:
|
@@ -347,7 +341,7 @@ async def mute_usr(c: Gojo, m: Message):
|
|
347 |
admins_group = await admin_cache_reload(m, "mute")
|
348 |
|
349 |
if user_id in admins_group:
|
350 |
-
await m.reply_text(
|
351 |
return
|
352 |
|
353 |
try:
|
@@ -356,10 +350,9 @@ async def mute_usr(c: Gojo, m: Message):
|
|
356 |
ChatPermissions(),
|
357 |
)
|
358 |
LOGGER.info(f"{m.from_user.id} muted {user_id} in {m.chat.id}")
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
)
|
363 |
if reason:
|
364 |
txt += f"\n<b>Reason</b>: {reason}"
|
365 |
keyboard = InlineKeyboardMarkup(
|
@@ -374,17 +367,16 @@ async def mute_usr(c: Gojo, m: Message):
|
|
374 |
)
|
375 |
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
376 |
except ChatAdminRequired:
|
377 |
-
await m.reply_text(
|
378 |
except RightForbidden:
|
379 |
-
await m.reply_text(
|
380 |
except UserNotParticipant:
|
381 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
382 |
except RPCError as ef:
|
383 |
await m.reply_text(
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
),
|
388 |
)
|
389 |
LOGGER.error(ef)
|
390 |
|
@@ -413,7 +405,7 @@ async def smute_usr(c: Gojo, m: Message):
|
|
413 |
LOGGER.info(
|
414 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
415 |
)
|
416 |
-
await m.reply_text(
|
417 |
return
|
418 |
|
419 |
try:
|
@@ -422,7 +414,7 @@ async def smute_usr(c: Gojo, m: Message):
|
|
422 |
admins_group = await admin_cache_reload(m, "mute")
|
423 |
|
424 |
if user_id in admins_group:
|
425 |
-
await m.reply_text(
|
426 |
return
|
427 |
|
428 |
try:
|
@@ -437,17 +429,16 @@ async def smute_usr(c: Gojo, m: Message):
|
|
437 |
return
|
438 |
return
|
439 |
except ChatAdminRequired:
|
440 |
-
await m.reply_text(
|
441 |
except RightForbidden:
|
442 |
-
await m.reply_text(
|
443 |
except UserNotParticipant:
|
444 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
445 |
except RPCError as ef:
|
446 |
await m.reply_text(
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
),
|
451 |
)
|
452 |
LOGGER.error(ef)
|
453 |
|
@@ -483,7 +474,7 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
483 |
LOGGER.info(
|
484 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
485 |
)
|
486 |
-
await m.reply_text(
|
487 |
return
|
488 |
|
489 |
try:
|
@@ -492,7 +483,7 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
492 |
admins_group = await admin_cache_reload(m, "mute")
|
493 |
|
494 |
if user_id in admins_group:
|
495 |
-
await m.reply_text(
|
496 |
return
|
497 |
|
498 |
try:
|
@@ -502,10 +493,9 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
502 |
)
|
503 |
LOGGER.info(f"{m.from_user.id} dmuted {user_id} in {m.chat.id}")
|
504 |
await m.reply_to_message.delete()
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
)
|
509 |
if reason:
|
510 |
txt += f"\n<b>Reason</b>: {reason}"
|
511 |
keyboard = InlineKeyboardMarkup(
|
@@ -520,17 +510,16 @@ async def dmute_usr(c: Gojo, m: Message):
|
|
520 |
)
|
521 |
await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
522 |
except ChatAdminRequired:
|
523 |
-
await m.reply_text(
|
524 |
except RightForbidden:
|
525 |
-
await m.reply_text(
|
526 |
except UserNotParticipant:
|
527 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
528 |
except RPCError as ef:
|
529 |
await m.reply_text(
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
),
|
534 |
)
|
535 |
LOGGER.error(ef)
|
536 |
|
@@ -555,24 +544,22 @@ async def unmute_usr(c: Gojo, m: Message):
|
|
555 |
try:
|
556 |
await m.chat.unban_member(user_id)
|
557 |
LOGGER.info(f"{m.from_user.id} unmuted {user_id} in {m.chat.id}")
|
|
|
|
|
558 |
await m.reply_text(
|
559 |
-
|
560 |
-
admin=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
561 |
-
unmuted=(await mention_html(user_first_name, user_id)),
|
562 |
-
),
|
563 |
)
|
564 |
except ChatAdminRequired:
|
565 |
-
await m.reply_text(
|
566 |
except UserNotParticipant:
|
567 |
await m.reply_text("How can I unmute a user who is not a part of this chat?")
|
568 |
except RightForbidden:
|
569 |
-
await m.reply_text(
|
570 |
except RPCError as ef:
|
571 |
await m.reply_text(
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
),
|
576 |
)
|
577 |
LOGGER.error(ef)
|
578 |
return
|
|
|
15 |
|
16 |
from Powers import LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
|
17 |
from Powers.bot_class import Gojo
|
|
|
18 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
19 |
from Powers.utils.custom_filters import command, restrict_filter
|
20 |
from Powers.utils.extract_user import extract_user
|
|
|
45 |
LOGGER.info(
|
46 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
47 |
)
|
48 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
49 |
return
|
50 |
|
51 |
try:
|
|
|
54 |
admins_group = await admin_cache_reload(m, "mute")
|
55 |
|
56 |
if user_id in admins_group:
|
57 |
+
await m.reply_text(text="This user is an admin, I cannot mute them!")
|
58 |
return
|
59 |
|
60 |
r_id = m.reply_to_message.message_id if m.reply_to_message else m.message_id
|
|
|
88 |
mutetime,
|
89 |
)
|
90 |
LOGGER.info(f"{m.from_user.id} tmuted {user_id} in {m.chat.id}")
|
91 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id))
|
92 |
+
muted=(await mention_html(user_first_name, user_id))
|
93 |
+
txt =f"Admin {admin} muted {muted}!"
|
|
|
94 |
if reason:
|
95 |
txt += f"\n<b>Reason</b>: {reason}"
|
96 |
keyboard = InlineKeyboardMarkup(
|
|
|
105 |
)
|
106 |
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
107 |
except ChatAdminRequired:
|
108 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
109 |
except RightForbidden:
|
110 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
111 |
except UserNotParticipant:
|
112 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
113 |
except RPCError as ef:
|
114 |
await m.reply_text(
|
115 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
116 |
+
|
117 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
118 |
)
|
119 |
LOGGER.error(ef)
|
120 |
|
|
|
145 |
LOGGER.info(
|
146 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
147 |
)
|
148 |
+
await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
|
149 |
return
|
150 |
|
151 |
try:
|
|
|
154 |
admins_group = await admin_cache_reload(m, "mute")
|
155 |
|
156 |
if user_id in admins_group:
|
157 |
+
await m.reply_text(text = "This user is an admin, I cannot mute them!")
|
158 |
return
|
159 |
|
160 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
186 |
)
|
187 |
LOGGER.info(f"{m.from_user.id} dtmuted {user_id} in {m.chat.id}")
|
188 |
await m.reply_to_message.delete()
|
189 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id))
|
190 |
+
muted=(await mention_html(user_first_name, user_id))
|
191 |
+
txt = f"Admin {admin} muted {muted}!"
|
|
|
192 |
if reason:
|
193 |
txt += f"\n<b>Reason</b>: {reason}"
|
194 |
keyboard = InlineKeyboardMarkup(
|
|
|
203 |
)
|
204 |
await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
205 |
except ChatAdminRequired:
|
206 |
+
await m.reply_text(text = "I'm not admin or I don't have rights.")
|
207 |
except RightForbidden:
|
208 |
+
await m.reply_text(text = "I don't have enough rights to ban this user.")
|
209 |
except UserNotParticipant:
|
210 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
211 |
except RPCError as ef:
|
212 |
await m.reply_text(
|
213 |
+
text = f"""Some error occured, report to @{SUPPORT_GROUP}
|
214 |
+
|
215 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
216 |
)
|
217 |
LOGGER.error(ef)
|
218 |
|
|
|
241 |
LOGGER.info(
|
242 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
243 |
)
|
244 |
+
await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
|
245 |
return
|
246 |
|
247 |
try:
|
|
|
250 |
admins_group = await admin_cache_reload(m, "mute")
|
251 |
|
252 |
if user_id in admins_group:
|
253 |
+
await m.reply_text(text = "This user is an admin, I cannot mute them!")
|
254 |
return
|
255 |
|
256 |
if m.reply_to_message and len(m.text.split()) >= 2:
|
|
|
285 |
if m.reply_to_message:
|
286 |
await m.reply_to_message.delete()
|
287 |
except ChatAdminRequired:
|
288 |
+
await m.reply_text(text = "I'm not admin or I don't have rights.")
|
289 |
except RightForbidden:
|
290 |
+
await m.reply_text(text = "I don't have enough rights to ban this user.")
|
291 |
except UserNotParticipant:
|
292 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
293 |
except RPCError as ef:
|
294 |
await m.reply_text(
|
295 |
+
text = f"""Some error occured, report to @{SUPPORT_GROUP}
|
296 |
+
|
297 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
298 |
)
|
299 |
LOGGER.error(ef)
|
300 |
|
|
|
332 |
LOGGER.info(
|
333 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
334 |
)
|
335 |
+
await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
|
336 |
return
|
337 |
|
338 |
try:
|
|
|
341 |
admins_group = await admin_cache_reload(m, "mute")
|
342 |
|
343 |
if user_id in admins_group:
|
344 |
+
await m.reply_text(text = "This user is an admin, I cannot mute them!")
|
345 |
return
|
346 |
|
347 |
try:
|
|
|
350 |
ChatPermissions(),
|
351 |
)
|
352 |
LOGGER.info(f"{m.from_user.id} muted {user_id} in {m.chat.id}")
|
353 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id))
|
354 |
+
muted=(await mention_html(user_first_name, user_id))
|
355 |
+
txt = f"Admin {admin} muted {muted}!"
|
|
|
356 |
if reason:
|
357 |
txt += f"\n<b>Reason</b>: {reason}"
|
358 |
keyboard = InlineKeyboardMarkup(
|
|
|
367 |
)
|
368 |
await m.reply_text(txt, reply_markup=keyboard, reply_to_message_id=r_id)
|
369 |
except ChatAdminRequired:
|
370 |
+
await m.reply_text(text = "I'm not admin or I don't have rights.")
|
371 |
except RightForbidden:
|
372 |
+
await m.reply_text(text = "I don't have enough rights to ban this user.")
|
373 |
except UserNotParticipant:
|
374 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
375 |
except RPCError as ef:
|
376 |
await m.reply_text(
|
377 |
+
text = f"""Some error occured, report to @{SUPPORT_GROUP}
|
378 |
+
|
379 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
380 |
)
|
381 |
LOGGER.error(ef)
|
382 |
|
|
|
405 |
LOGGER.info(
|
406 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
407 |
)
|
408 |
+
await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
|
409 |
return
|
410 |
|
411 |
try:
|
|
|
414 |
admins_group = await admin_cache_reload(m, "mute")
|
415 |
|
416 |
if user_id in admins_group:
|
417 |
+
await m.reply_text(text = "This user is an admin, I cannot mute them!")
|
418 |
return
|
419 |
|
420 |
try:
|
|
|
429 |
return
|
430 |
return
|
431 |
except ChatAdminRequired:
|
432 |
+
await m.reply_text(text = "I'm not admin or I don't have rights.")
|
433 |
except RightForbidden:
|
434 |
+
await m.reply_text(text = "I don't have enough rights to ban this user.")
|
435 |
except UserNotParticipant:
|
436 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
437 |
except RPCError as ef:
|
438 |
await m.reply_text(
|
439 |
+
text = f"""Some error occured, report to @{SUPPORT_GROUP}
|
440 |
+
|
441 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
442 |
)
|
443 |
LOGGER.error(ef)
|
444 |
|
|
|
474 |
LOGGER.info(
|
475 |
f"{m.from_user.id} trying to mute {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
476 |
)
|
477 |
+
await m.reply_text(text = "This user is in my support staff, cannot restrict them.")
|
478 |
return
|
479 |
|
480 |
try:
|
|
|
483 |
admins_group = await admin_cache_reload(m, "mute")
|
484 |
|
485 |
if user_id in admins_group:
|
486 |
+
await m.reply_text(text = "This user is an admin, I cannot mute them!")
|
487 |
return
|
488 |
|
489 |
try:
|
|
|
493 |
)
|
494 |
LOGGER.info(f"{m.from_user.id} dmuted {user_id} in {m.chat.id}")
|
495 |
await m.reply_to_message.delete()
|
496 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id))
|
497 |
+
muted=(await mention_html(user_first_name, user_id))
|
498 |
+
txt = f"Admin {admin} muted {muted}!"
|
|
|
499 |
if reason:
|
500 |
txt += f"\n<b>Reason</b>: {reason}"
|
501 |
keyboard = InlineKeyboardMarkup(
|
|
|
510 |
)
|
511 |
await c.send_message(m.chat.id, txt, reply_markup=keyboard)
|
512 |
except ChatAdminRequired:
|
513 |
+
await m.reply_text(text = "I'm not admin or I don't have rights.")
|
514 |
except RightForbidden:
|
515 |
+
await m.reply_text(text = "I don't have enough rights to ban this user.")
|
516 |
except UserNotParticipant:
|
517 |
await m.reply_text("How can I mute a user who is not a part of this chat?")
|
518 |
except RPCError as ef:
|
519 |
await m.reply_text(
|
520 |
+
text = f"""Some error occured, report to @{SUPPORT_GROUP}
|
521 |
+
|
522 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
523 |
)
|
524 |
LOGGER.error(ef)
|
525 |
|
|
|
544 |
try:
|
545 |
await m.chat.unban_member(user_id)
|
546 |
LOGGER.info(f"{m.from_user.id} unmuted {user_id} in {m.chat.id}")
|
547 |
+
admin=(await mention_html(m.from_user.first_name, m.from_user.id))
|
548 |
+
unmuted=(await mention_html(user_first_name, user_id))
|
549 |
await m.reply_text(
|
550 |
+
text=f"Admin {admin} unmuted {unmuted}!"
|
|
|
|
|
|
|
551 |
)
|
552 |
except ChatAdminRequired:
|
553 |
+
await m.reply_text(text = "I'm not admin or I don't have rights.")
|
554 |
except UserNotParticipant:
|
555 |
await m.reply_text("How can I unmute a user who is not a part of this chat?")
|
556 |
except RightForbidden:
|
557 |
+
await m.reply_text(text="I don't have enough rights to ban this user.")
|
558 |
except RPCError as ef:
|
559 |
await m.reply_text(
|
560 |
+
text = f"""Some error occured, report to @{SUPPORT_GROUP}
|
561 |
+
|
562 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
563 |
)
|
564 |
LOGGER.error(ef)
|
565 |
return
|
Powers/plugins/pin.py
CHANGED
@@ -7,7 +7,6 @@ from pyrogram.types import CallbackQuery, Message
|
|
7 |
from Powers import LOGGER, SUPPORT_GROUP
|
8 |
from Powers.bot_class import Gojo
|
9 |
from Powers.database.pins_db import Pins
|
10 |
-
from Powers.tr_engine import tlang
|
11 |
from Powers.utils.custom_filters import admin_filter, command
|
12 |
from Powers.utils.kbhelpers import ikb
|
13 |
from Powers.utils.string import build_keyboard, parse_button
|
@@ -43,20 +42,19 @@ async def pin_message(_, m: Message):
|
|
43 |
f"https://t.me/c/{link_chat_id}/{m.reply_to_message.message_id}"
|
44 |
)
|
45 |
await m.reply_text(
|
46 |
-
|
47 |
disable_web_page_preview=True,
|
48 |
)
|
49 |
|
50 |
except ChatAdminRequired:
|
51 |
-
await m.reply_text(
|
52 |
except RightForbidden:
|
53 |
-
await m.reply_text(
|
54 |
except RPCError as ef:
|
55 |
await m.reply_text(
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
),
|
60 |
)
|
61 |
LOGGER.error(ef)
|
62 |
else:
|
@@ -73,20 +71,19 @@ async def unpin_message(c: Gojo, m: Message):
|
|
73 |
LOGGER.info(
|
74 |
f"{m.from_user.id} unpinned msgid: {m.reply_to_message.message_id} in {m.chat.id}",
|
75 |
)
|
76 |
-
await m.reply_text(
|
77 |
else:
|
78 |
await c.unpin_chat_message(m.chat.id)
|
79 |
-
await m.reply_text(
|
80 |
except ChatAdminRequired:
|
81 |
-
await m.reply_text(
|
82 |
except RightForbidden:
|
83 |
-
await m.reply_text(
|
84 |
except RPCError as ef:
|
85 |
await m.reply_text(
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
),
|
90 |
)
|
91 |
LOGGER.error(ef)
|
92 |
|
@@ -121,17 +118,16 @@ async def unpinall_calllback(c: Gojo, q: CallbackQuery):
|
|
121 |
try:
|
122 |
await c.unpin_all_chat_messages(q.message.chat.id)
|
123 |
LOGGER.info(f"{q.from_user.id} unpinned all messages in {q.message.chat.id}")
|
124 |
-
await q.message.edit_text(
|
125 |
except ChatAdminRequired:
|
126 |
-
await q.message.edit_text(
|
127 |
except RightForbidden:
|
128 |
-
await q.message.edit_text(
|
129 |
except RPCError as ef:
|
130 |
await q.message.edit_text(
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
),
|
135 |
)
|
136 |
LOGGER.error(ef)
|
137 |
return
|
@@ -144,9 +140,7 @@ async def anti_channel_pin(_, m: Message):
|
|
144 |
if len(m.text.split()) == 1:
|
145 |
status = pinsdb.get_settings()["antichannelpin"]
|
146 |
await m.reply_text(
|
147 |
-
|
148 |
-
status=status,
|
149 |
-
),
|
150 |
)
|
151 |
return
|
152 |
|
@@ -154,13 +148,13 @@ async def anti_channel_pin(_, m: Message):
|
|
154 |
if m.command[1] in ("yes", "on", "true"):
|
155 |
pinsdb.antichannelpin_on()
|
156 |
LOGGER.info(f"{m.from_user.id} enabled antichannelpin in {m.chat.id}")
|
157 |
-
msg =
|
158 |
elif m.command[1] in ("no", "off", "false"):
|
159 |
pinsdb.antichannelpin_off()
|
160 |
LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
|
161 |
-
msg =
|
162 |
else:
|
163 |
-
await m.reply_text(
|
164 |
return
|
165 |
|
166 |
await m.reply_text(msg)
|
@@ -198,9 +192,7 @@ async def clean_linked(_, m: Message):
|
|
198 |
if len(m.text.split()) == 1:
|
199 |
status = pinsdb.get_settings()["cleanlinked"]
|
200 |
await m.reply_text(
|
201 |
-
|
202 |
-
status=status,
|
203 |
-
),
|
204 |
)
|
205 |
return
|
206 |
|
@@ -214,7 +206,7 @@ async def clean_linked(_, m: Message):
|
|
214 |
LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
|
215 |
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
|
216 |
else:
|
217 |
-
await m.reply_text(
|
218 |
return
|
219 |
|
220 |
await m.reply_text(msg)
|
|
|
7 |
from Powers import LOGGER, SUPPORT_GROUP
|
8 |
from Powers.bot_class import Gojo
|
9 |
from Powers.database.pins_db import Pins
|
|
|
10 |
from Powers.utils.custom_filters import admin_filter, command
|
11 |
from Powers.utils.kbhelpers import ikb
|
12 |
from Powers.utils.string import build_keyboard, parse_button
|
|
|
42 |
f"https://t.me/c/{link_chat_id}/{m.reply_to_message.message_id}"
|
43 |
)
|
44 |
await m.reply_text(
|
45 |
+
text=f"I have Pinned [this message]({message_link})!",
|
46 |
disable_web_page_preview=True,
|
47 |
)
|
48 |
|
49 |
except ChatAdminRequired:
|
50 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
51 |
except RightForbidden:
|
52 |
+
await m.reply_text(text="I don't have enough rights to pin messages.")
|
53 |
except RPCError as ef:
|
54 |
await m.reply_text(
|
55 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
56 |
+
|
57 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
58 |
)
|
59 |
LOGGER.error(ef)
|
60 |
else:
|
|
|
71 |
LOGGER.info(
|
72 |
f"{m.from_user.id} unpinned msgid: {m.reply_to_message.message_id} in {m.chat.id}",
|
73 |
)
|
74 |
+
await m.reply_text(text="Unpinned last message.")
|
75 |
else:
|
76 |
await c.unpin_chat_message(m.chat.id)
|
77 |
+
await m.reply_text(text="Unpinned last pinned message!")
|
78 |
except ChatAdminRequired:
|
79 |
+
await m.reply_text(text="I'm not admin or I don't have rights.")
|
80 |
except RightForbidden:
|
81 |
+
await m.reply_text(text="I don't have enough rights to unpin messages.")
|
82 |
except RPCError as ef:
|
83 |
await m.reply_text(
|
84 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
85 |
+
|
86 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
87 |
)
|
88 |
LOGGER.error(ef)
|
89 |
|
|
|
118 |
try:
|
119 |
await c.unpin_all_chat_messages(q.message.chat.id)
|
120 |
LOGGER.info(f"{q.from_user.id} unpinned all messages in {q.message.chat.id}")
|
121 |
+
await q.message.edit_text(text="Unpinned all messages in this chat.")
|
122 |
except ChatAdminRequired:
|
123 |
+
await q.message.edit_text(text="I'm not admin or I don't have rights.")
|
124 |
except RightForbidden:
|
125 |
+
await q.message.edit_text(text="I don't have enough rights to unpin messages.")
|
126 |
except RPCError as ef:
|
127 |
await q.message.edit_text(
|
128 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
129 |
+
|
130 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
131 |
)
|
132 |
LOGGER.error(ef)
|
133 |
return
|
|
|
140 |
if len(m.text.split()) == 1:
|
141 |
status = pinsdb.get_settings()["antichannelpin"]
|
142 |
await m.reply_text(
|
143 |
+
text=f"Current AntiChannelPin status: {status}"
|
|
|
|
|
144 |
)
|
145 |
return
|
146 |
|
|
|
148 |
if m.command[1] in ("yes", "on", "true"):
|
149 |
pinsdb.antichannelpin_on()
|
150 |
LOGGER.info(f"{m.from_user.id} enabled antichannelpin in {m.chat.id}")
|
151 |
+
msg = "Turned on AntiChannelPin, now all message pinned by channel will be unpinned automtically!"
|
152 |
elif m.command[1] in ("no", "off", "false"):
|
153 |
pinsdb.antichannelpin_off()
|
154 |
LOGGER.info(f"{m.from_user.id} disabled antichannelpin in {m.chat.id}")
|
155 |
+
msg = "Turned off AntiChannelPin, now all message pinned by channel will stay pinned!"
|
156 |
else:
|
157 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
158 |
return
|
159 |
|
160 |
await m.reply_text(msg)
|
|
|
192 |
if len(m.text.split()) == 1:
|
193 |
status = pinsdb.get_settings()["cleanlinked"]
|
194 |
await m.reply_text(
|
195 |
+
text=f"Current AntiChannelPin status: {status}"
|
|
|
|
|
196 |
)
|
197 |
return
|
198 |
|
|
|
206 |
LOGGER.info(f"{m.from_user.id} disabled CleanLinked in {m.chat.id}")
|
207 |
msg = "Turned off CleanLinked! Messages from linked channel will not be deleted!"
|
208 |
else:
|
209 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
210 |
return
|
211 |
|
212 |
await m.reply_text(msg)
|
Powers/plugins/purge.py
CHANGED
@@ -5,14 +5,13 @@ from pyrogram.types import Message
|
|
5 |
|
6 |
from Powers import SUPPORT_GROUP
|
7 |
from Powers.bot_class import Gojo
|
8 |
-
from Powers.tr_engine import tlang
|
9 |
from Powers.utils.custom_filters import admin_filter, command
|
10 |
|
11 |
|
12 |
@Gojo.on_message(command("purge") & admin_filter)
|
13 |
async def purge(c: Gojo, m: Message):
|
14 |
if m.chat.type != "supergroup":
|
15 |
-
await m.reply_text(
|
16 |
return
|
17 |
|
18 |
if m.reply_to_message:
|
@@ -34,22 +33,20 @@ async def purge(c: Gojo, m: Message):
|
|
34 |
)
|
35 |
await m.delete()
|
36 |
except MessageDeleteForbidden:
|
37 |
-
await m.reply_text(
|
38 |
return
|
39 |
except RPCError as ef:
|
40 |
await m.reply_text(
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
),
|
45 |
)
|
46 |
|
47 |
count_del_msg = len(message_ids)
|
48 |
|
49 |
z = await m.reply_text(
|
50 |
-
|
51 |
-
|
52 |
-
),
|
53 |
)
|
54 |
await sleep(3)
|
55 |
await z.delete()
|
@@ -61,7 +58,7 @@ async def purge(c: Gojo, m: Message):
|
|
61 |
@Gojo.on_message(command("spurge") & admin_filter)
|
62 |
async def spurge(c: Gojo, m: Message):
|
63 |
if m.chat.type != "supergroup":
|
64 |
-
await m.reply_text(
|
65 |
return
|
66 |
|
67 |
if m.reply_to_message:
|
@@ -83,14 +80,13 @@ async def spurge(c: Gojo, m: Message):
|
|
83 |
)
|
84 |
await m.delete()
|
85 |
except MessageDeleteForbidden:
|
86 |
-
await m.reply_text(
|
87 |
return
|
88 |
except RPCError as ef:
|
89 |
await m.reply_text(
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
),
|
94 |
)
|
95 |
return
|
96 |
await m.reply_text("Reply to a message to start spurge !")
|
@@ -112,7 +108,7 @@ async def del_msg(c: Gojo, m: Message):
|
|
112 |
message_ids=m.reply_to_message.message_id,
|
113 |
)
|
114 |
else:
|
115 |
-
await m.reply_text(
|
116 |
return
|
117 |
|
118 |
|
|
|
5 |
|
6 |
from Powers import SUPPORT_GROUP
|
7 |
from Powers.bot_class import Gojo
|
|
|
8 |
from Powers.utils.custom_filters import admin_filter, command
|
9 |
|
10 |
|
11 |
@Gojo.on_message(command("purge") & admin_filter)
|
12 |
async def purge(c: Gojo, m: Message):
|
13 |
if m.chat.type != "supergroup":
|
14 |
+
await m.reply_text(text="Cannot purge messages in a basic group")
|
15 |
return
|
16 |
|
17 |
if m.reply_to_message:
|
|
|
33 |
)
|
34 |
await m.delete()
|
35 |
except MessageDeleteForbidden:
|
36 |
+
await m.reply_text(text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup.")
|
37 |
return
|
38 |
except RPCError as ef:
|
39 |
await m.reply_text(
|
40 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
41 |
+
|
42 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
43 |
)
|
44 |
|
45 |
count_del_msg = len(message_ids)
|
46 |
|
47 |
z = await m.reply_text(
|
48 |
+
text=f"Deleted <i>{count_del_msg}</i> messages"
|
49 |
+
|
|
|
50 |
)
|
51 |
await sleep(3)
|
52 |
await z.delete()
|
|
|
58 |
@Gojo.on_message(command("spurge") & admin_filter)
|
59 |
async def spurge(c: Gojo, m: Message):
|
60 |
if m.chat.type != "supergroup":
|
61 |
+
await m.reply_text(text="Cannot purge messages in a basic group")
|
62 |
return
|
63 |
|
64 |
if m.reply_to_message:
|
|
|
80 |
)
|
81 |
await m.delete()
|
82 |
except MessageDeleteForbidden:
|
83 |
+
await m.reply_text(text="Cannot delete all messages. The messages may be too old, I might not have delete rights, or this might not be a supergroup.")
|
84 |
return
|
85 |
except RPCError as ef:
|
86 |
await m.reply_text(
|
87 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
88 |
+
|
89 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
90 |
)
|
91 |
return
|
92 |
await m.reply_text("Reply to a message to start spurge !")
|
|
|
108 |
message_ids=m.reply_to_message.message_id,
|
109 |
)
|
110 |
else:
|
111 |
+
await m.reply_text(text="What do you wanna delete?")
|
112 |
return
|
113 |
|
114 |
|
Powers/plugins/rules.py
CHANGED
@@ -4,7 +4,6 @@ from pyrogram.types import CallbackQuery, Message
|
|
4 |
from Powers import LOGGER
|
5 |
from Powers.bot_class import Gojo
|
6 |
from Powers.database.rules_db import Rules
|
7 |
-
from Powers.tr_engine import tlang
|
8 |
from Powers.utils.custom_filters import admin_filter, command
|
9 |
from Powers.utils.kbhelpers import ikb
|
10 |
from Powers.vars import Config
|
@@ -22,7 +21,7 @@ async def get_rules(_, m: Message):
|
|
22 |
|
23 |
if not rules:
|
24 |
await m.reply_text(
|
25 |
-
|
26 |
quote=True,
|
27 |
)
|
28 |
return
|
@@ -42,7 +41,7 @@ async def get_rules(_, m: Message):
|
|
42 |
],
|
43 |
)
|
44 |
await m.reply_text(
|
45 |
-
|
46 |
quote=True,
|
47 |
reply_markup=pm_kb,
|
48 |
reply_to_message_id=msg_id,
|
@@ -52,10 +51,8 @@ async def get_rules(_, m: Message):
|
|
52 |
formated = rules
|
53 |
|
54 |
await m.reply_text(
|
55 |
-
|
56 |
-
|
57 |
-
rules=formated,
|
58 |
-
),
|
59 |
disable_web_page_preview=True,
|
60 |
reply_to_message_id=msg_id,
|
61 |
)
|
@@ -81,7 +78,7 @@ async def set_rules(_, m: Message):
|
|
81 |
|
82 |
db.set_rules(rules)
|
83 |
LOGGER.info(f"{m.from_user.id} set rules in {m.chat.id}")
|
84 |
-
await m.reply_text(
|
85 |
return
|
86 |
|
87 |
|
@@ -98,23 +95,21 @@ async def priv_rules(_, m: Message):
|
|
98 |
if option in ("on", "yes"):
|
99 |
db.set_privrules(True)
|
100 |
LOGGER.info(f"{m.from_user.id} enabled privaterules in {m.chat.id}")
|
101 |
-
msg =
|
102 |
elif option in ("off", "no"):
|
103 |
db.set_privrules(False)
|
104 |
LOGGER.info(f"{m.from_user.id} disbaled privaterules in {m.chat.id}")
|
105 |
-
msg =
|
106 |
else:
|
107 |
-
msg =
|
108 |
await m.reply_text(msg)
|
109 |
elif len(m.text.split()) == 1:
|
110 |
curr_pref = db.get_privrules()
|
111 |
-
msg =
|
112 |
-
current_option=curr_pref,
|
113 |
-
)
|
114 |
LOGGER.info(f"{m.from_user.id} fetched privaterules preference in {m.chat.id}")
|
115 |
await m.reply_text(msg)
|
116 |
else:
|
117 |
-
await m.
|
118 |
|
119 |
return
|
120 |
|
@@ -127,11 +122,11 @@ async def clear_rules(_, m: Message):
|
|
127 |
|
128 |
rules = db.get_rules()
|
129 |
if not rules:
|
130 |
-
await m.reply_text(
|
131 |
return
|
132 |
|
133 |
await m.reply_text(
|
134 |
-
|
135 |
reply_markup=ikb(
|
136 |
[[("⚠️ Confirm", "clear_rules"), ("❌ Cancel", "close_admin")]],
|
137 |
),
|
@@ -142,7 +137,7 @@ async def clear_rules(_, m: Message):
|
|
142 |
@Gojo.on_callback_query(filters.regex("^clear_rules$"))
|
143 |
async def clearrules_callback(_, q: CallbackQuery):
|
144 |
Rules(q.message.chat.id).clear_rules()
|
145 |
-
await q.message.edit_text(
|
146 |
LOGGER.info(f"{q.from_user.id} cleared rules in {q.message.chat.id}")
|
147 |
await q.answer("Rules for the chat have been cleared!", show_alert=True)
|
148 |
return
|
|
|
4 |
from Powers import LOGGER
|
5 |
from Powers.bot_class import Gojo
|
6 |
from Powers.database.rules_db import Rules
|
|
|
7 |
from Powers.utils.custom_filters import admin_filter, command
|
8 |
from Powers.utils.kbhelpers import ikb
|
9 |
from Powers.vars import Config
|
|
|
21 |
|
22 |
if not rules:
|
23 |
await m.reply_text(
|
24 |
+
text="The Admins for this group have not setup rules! That doesn't mean you can break the DECORUM of this group !",
|
25 |
quote=True,
|
26 |
)
|
27 |
return
|
|
|
41 |
],
|
42 |
)
|
43 |
await m.reply_text(
|
44 |
+
text="Click on the below button to see this group rules!",
|
45 |
quote=True,
|
46 |
reply_markup=pm_kb,
|
47 |
reply_to_message_id=msg_id,
|
|
|
51 |
formated = rules
|
52 |
|
53 |
await m.reply_text(
|
54 |
+
text=f"""The rules for <b>{m.chat.title} are:</b>
|
55 |
+
{formated}""",
|
|
|
|
|
56 |
disable_web_page_preview=True,
|
57 |
reply_to_message_id=msg_id,
|
58 |
)
|
|
|
78 |
|
79 |
db.set_rules(rules)
|
80 |
LOGGER.info(f"{m.from_user.id} set rules in {m.chat.id}")
|
81 |
+
await m.reply_text(text="Successfully set rules for this group.")
|
82 |
return
|
83 |
|
84 |
|
|
|
95 |
if option in ("on", "yes"):
|
96 |
db.set_privrules(True)
|
97 |
LOGGER.info(f"{m.from_user.id} enabled privaterules in {m.chat.id}")
|
98 |
+
msg = f"Private Rules have been turned <b>on</b> for chat <b>{m.chat.title}</b>"
|
99 |
elif option in ("off", "no"):
|
100 |
db.set_privrules(False)
|
101 |
LOGGER.info(f"{m.from_user.id} disbaled privaterules in {m.chat.id}")
|
102 |
+
msg = f"Private Rules have been turned <b>off</b> for chat <b>{m.chat.title}</b>"
|
103 |
else:
|
104 |
+
msg = "Option not valid, choose from <code>on</code>, <code>yes</code>, <code>off</code>, <code>no</code>"
|
105 |
await m.reply_text(msg)
|
106 |
elif len(m.text.split()) == 1:
|
107 |
curr_pref = db.get_privrules()
|
108 |
+
msg = f"Current Preference for Private rules in this chat is: <b>{curr_pref}</b>"
|
|
|
|
|
109 |
LOGGER.info(f"{m.from_user.id} fetched privaterules preference in {m.chat.id}")
|
110 |
await m.reply_text(msg)
|
111 |
else:
|
112 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
113 |
|
114 |
return
|
115 |
|
|
|
122 |
|
123 |
rules = db.get_rules()
|
124 |
if not rules:
|
125 |
+
await m.reply_text(text="The Admins for this group have not setup rules! That doesn't mean you can break the DECORUM of this group !")
|
126 |
return
|
127 |
|
128 |
await m.reply_text(
|
129 |
+
text="Are you sure you want to clear rules?",
|
130 |
reply_markup=ikb(
|
131 |
[[("⚠️ Confirm", "clear_rules"), ("❌ Cancel", "close_admin")]],
|
132 |
),
|
|
|
137 |
@Gojo.on_callback_query(filters.regex("^clear_rules$"))
|
138 |
async def clearrules_callback(_, q: CallbackQuery):
|
139 |
Rules(q.message.chat.id).clear_rules()
|
140 |
+
await q.message.edit_text(text="Successfully cleared rules for this group!")
|
141 |
LOGGER.info(f"{q.from_user.id} cleared rules in {q.message.chat.id}")
|
142 |
await q.answer("Rules for the chat have been cleared!", show_alert=True)
|
143 |
return
|
Powers/plugins/start.py
CHANGED
@@ -4,7 +4,6 @@ from pyrogram.types import CallbackQuery, Message
|
|
4 |
|
5 |
from Powers import HELP_COMMANDS, LOGGER
|
6 |
from Powers.bot_class import Gojo
|
7 |
-
from Powers.tr_engine import tlang
|
8 |
from Powers.utils.custom_filters import command
|
9 |
from Powers.utils.kbhelpers import ikb
|
10 |
from Powers.utils.start_utils import (
|
@@ -22,7 +21,13 @@ from Powers.vars import Config
|
|
22 |
)
|
23 |
async def donate(_, m: Message):
|
24 |
LOGGER.info(f"{m.from_user.id} fetched donation text in {m.chat.id}")
|
25 |
-
await m.reply_text(
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
return
|
27 |
|
28 |
|
@@ -80,7 +85,11 @@ async def start(c: Gojo, m: Message):
|
|
80 |
return
|
81 |
try:
|
82 |
await m.reply_text(
|
83 |
-
|
|
|
|
|
|
|
|
|
84 |
reply_markup=(await gen_start_kb(m)),
|
85 |
quote=True,
|
86 |
disable_web_page_preview=True,
|
@@ -89,7 +98,7 @@ async def start(c: Gojo, m: Message):
|
|
89 |
LOGGER.warning(f"Bot blocked by {m.from_user.id}")
|
90 |
else:
|
91 |
await m.reply_text(
|
92 |
-
|
93 |
quote=True,
|
94 |
)
|
95 |
return
|
@@ -99,7 +108,11 @@ async def start(c: Gojo, m: Message):
|
|
99 |
async def start_back(_, q: CallbackQuery):
|
100 |
try:
|
101 |
await q.message.edit_text(
|
102 |
-
|
|
|
|
|
|
|
|
|
103 |
reply_markup=(await gen_start_kb(q.message)),
|
104 |
disable_web_page_preview=True,
|
105 |
)
|
@@ -114,19 +127,27 @@ async def commands_menu(_, q: CallbackQuery):
|
|
114 |
keyboard = ikb(
|
115 |
[
|
116 |
*(await gen_cmds_kb(q)),
|
117 |
-
[(f"«
|
118 |
],
|
119 |
)
|
120 |
try:
|
121 |
await q.message.edit_text(
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
124 |
)
|
125 |
except MessageNotModified:
|
126 |
pass
|
127 |
except QueryIdInvalid:
|
128 |
await q.message.reply_text(
|
129 |
-
|
|
|
|
|
|
|
|
|
130 |
reply_markup=keyboard,
|
131 |
)
|
132 |
await q.answer()
|
@@ -156,7 +177,7 @@ async def help_menu(_, m: Message):
|
|
156 |
)
|
157 |
else:
|
158 |
await m.reply_text(
|
159 |
-
|
160 |
reply_markup=ikb(
|
161 |
[
|
162 |
[
|
@@ -174,16 +195,19 @@ async def help_menu(_, m: Message):
|
|
174 |
keyboard = ikb(
|
175 |
[
|
176 |
*(await gen_cmds_kb(m)),
|
177 |
-
[(
|
178 |
],
|
179 |
)
|
180 |
-
msg =
|
|
|
|
|
|
|
|
|
181 |
else:
|
182 |
keyboard = ikb(
|
183 |
[[("Help", f"t.me/{Config.BOT_USERNAME}?start=help", "url")]],
|
184 |
)
|
185 |
-
msg =
|
186 |
-
|
187 |
await m.reply_text(
|
188 |
msg,
|
189 |
reply_markup=keyboard,
|
@@ -196,13 +220,10 @@ async def help_menu(_, m: Message):
|
|
196 |
async def get_module_info(_, q: CallbackQuery):
|
197 |
module = q.data.split(".", 1)[1]
|
198 |
|
199 |
-
help_msg = f"**{
|
200 |
-
q,
|
201 |
-
HELP_COMMANDS[module]["help_msg"],
|
202 |
-
)
|
203 |
|
204 |
help_kb = HELP_COMMANDS[module]["buttons"] + [
|
205 |
-
[("« " +
|
206 |
]
|
207 |
await q.message.edit_text(
|
208 |
help_msg,
|
|
|
4 |
|
5 |
from Powers import HELP_COMMANDS, LOGGER
|
6 |
from Powers.bot_class import Gojo
|
|
|
7 |
from Powers.utils.custom_filters import command
|
8 |
from Powers.utils.kbhelpers import ikb
|
9 |
from Powers.utils.start_utils import (
|
|
|
21 |
)
|
22 |
async def donate(_, m: Message):
|
23 |
LOGGER.info(f"{m.from_user.id} fetched donation text in {m.chat.id}")
|
24 |
+
await m.reply_text(text="""Hey Thanks for your thought of donating me!
|
25 |
+
When you donate, all the fund goes towards my development which makes on fast and responsive.
|
26 |
+
Your donation might also me get me a new feature or two, which I wasn't able to get due to server limitations.
|
27 |
+
|
28 |
+
All the fund would be put into my services such as database, storage and hosting!
|
29 |
+
|
30 |
+
You can donate by contacting my owner: @iamgojoof6eyes""")
|
31 |
return
|
32 |
|
33 |
|
|
|
85 |
return
|
86 |
try:
|
87 |
await m.reply_text(
|
88 |
+
text="""Hey there! My name is Alita ✨.
|
89 |
+
I'm here to help you manage your groups!
|
90 |
+
Hit /help to find out more about how to use me in my full potential!
|
91 |
+
|
92 |
+
Join my [News Channel](https://t.me/gojo_updates) to get information on all the latest updates.""",
|
93 |
reply_markup=(await gen_start_kb(m)),
|
94 |
quote=True,
|
95 |
disable_web_page_preview=True,
|
|
|
98 |
LOGGER.warning(f"Bot blocked by {m.from_user.id}")
|
99 |
else:
|
100 |
await m.reply_text(
|
101 |
+
text="I'm alive :3",
|
102 |
quote=True,
|
103 |
)
|
104 |
return
|
|
|
108 |
async def start_back(_, q: CallbackQuery):
|
109 |
try:
|
110 |
await q.message.edit_text(
|
111 |
+
text="""Hey there! My name is Alita ✨.
|
112 |
+
I'm here to help you manage your groups!
|
113 |
+
Hit /help to find out more about how to use me in my full potential!
|
114 |
+
|
115 |
+
Join my [News Channel](http://t.me/gojo_updates) to get information on all the latest updates.""",
|
116 |
reply_markup=(await gen_start_kb(q.message)),
|
117 |
disable_web_page_preview=True,
|
118 |
)
|
|
|
127 |
keyboard = ikb(
|
128 |
[
|
129 |
*(await gen_cmds_kb(q)),
|
130 |
+
[(f"« Back", "start_back")],
|
131 |
],
|
132 |
)
|
133 |
try:
|
134 |
await q.message.edit_text(
|
135 |
+
text="""Hey There! My name is Alita.
|
136 |
+
I'm here to help you manage your groups!
|
137 |
+
Commands available:
|
138 |
+
× /start: Start the bot
|
139 |
+
× /help: Give's you this message.""",
|
140 |
+
reply_markup=keyboard,
|
141 |
)
|
142 |
except MessageNotModified:
|
143 |
pass
|
144 |
except QueryIdInvalid:
|
145 |
await q.message.reply_text(
|
146 |
+
text="""Hey There! My name is Alita.
|
147 |
+
I'm here to help you manage your groups!
|
148 |
+
Commands available:
|
149 |
+
× /start: Start the bot
|
150 |
+
× /help: Give's you this message.""",
|
151 |
reply_markup=keyboard,
|
152 |
)
|
153 |
await q.answer()
|
|
|
177 |
)
|
178 |
else:
|
179 |
await m.reply_text(
|
180 |
+
text=f"Press the button below to get help for <i>{help_option}</i>",
|
181 |
reply_markup=ikb(
|
182 |
[
|
183 |
[
|
|
|
195 |
keyboard = ikb(
|
196 |
[
|
197 |
*(await gen_cmds_kb(m)),
|
198 |
+
[("« Back", "start_back")],
|
199 |
],
|
200 |
)
|
201 |
+
msg = """Hey There! My name is Alita.
|
202 |
+
I'm here to help you manage your groups!
|
203 |
+
Commands available:
|
204 |
+
× /start: Start the bot
|
205 |
+
× /help: Give's you this message."""
|
206 |
else:
|
207 |
keyboard = ikb(
|
208 |
[[("Help", f"t.me/{Config.BOT_USERNAME}?start=help", "url")]],
|
209 |
)
|
210 |
+
msg = "Contact me in PM to get the list of possible commands."
|
|
|
211 |
await m.reply_text(
|
212 |
msg,
|
213 |
reply_markup=keyboard,
|
|
|
220 |
async def get_module_info(_, q: CallbackQuery):
|
221 |
module = q.data.split(".", 1)[1]
|
222 |
|
223 |
+
help_msg = f"**{str(module)}:**\n\n" + HELP_COMMANDS[module]["help_msg"],
|
|
|
|
|
|
|
224 |
|
225 |
help_kb = HELP_COMMANDS[module]["buttons"] + [
|
226 |
+
[("« " + "Back", "commands")],
|
227 |
]
|
228 |
await q.message.edit_text(
|
229 |
help_msg,
|
Powers/plugins/utils.py
CHANGED
@@ -22,7 +22,6 @@ from Powers import (
|
|
22 |
from Powers.bot_class import Gojo
|
23 |
from Powers.database.antispam_db import GBan
|
24 |
from Powers.database.users_db import Users
|
25 |
-
from Powers.tr_engine import tlang
|
26 |
from Powers.utils.clean_file import remove_markdown_and_html
|
27 |
from Powers.utils.custom_filters import command
|
28 |
from Powers.utils.extract_user import extract_user
|
@@ -39,7 +38,7 @@ async def wiki(_, m: Message):
|
|
39 |
LOGGER.info(f"{m.from_user.id} used wiki cmd in {m.chat.id}")
|
40 |
|
41 |
if len(m.text.split()) <= 1:
|
42 |
-
return await m.reply_text(
|
43 |
|
44 |
search = m.text.split(None, 1)[1]
|
45 |
try:
|
@@ -98,27 +97,26 @@ async def gdpr_remove(_, m: Message):
|
|
98 |
)
|
99 |
async def get_lyrics(_, m: Message):
|
100 |
if len(m.text.split()) <= 1:
|
101 |
-
await m.reply_text(
|
102 |
return
|
103 |
|
104 |
query = m.text.split(None, 1)[1]
|
105 |
LOGGER.info(f"{m.from_user.id} used lyrics cmd in {m.chat.id}")
|
106 |
song = ""
|
107 |
if not query:
|
108 |
-
await m.edit_text(
|
109 |
return
|
110 |
-
|
111 |
em = await m.reply_text(
|
112 |
-
|
113 |
-
)
|
114 |
song = Song.find_song(query)
|
115 |
if song:
|
116 |
if song.lyrics:
|
117 |
reply = song.format()
|
118 |
else:
|
119 |
-
reply =
|
120 |
else:
|
121 |
-
reply =
|
122 |
try:
|
123 |
await em.edit_text(reply)
|
124 |
except MessageTooLong:
|
@@ -138,11 +136,11 @@ async def id_info(c: Gojo, m: Message):
|
|
138 |
LOGGER.info(f"{m.from_user.id} used id cmd in {m.chat.id}")
|
139 |
|
140 |
if m.chat.type == "supergroup" and not m.reply_to_message:
|
141 |
-
await m.reply_text(
|
142 |
return
|
143 |
|
144 |
if m.chat.type == "private" and not m.reply_to_message:
|
145 |
-
await m.reply_text(
|
146 |
return
|
147 |
|
148 |
user_id, _, _ = await extract_user(c, m)
|
@@ -150,20 +148,21 @@ async def id_info(c: Gojo, m: Message):
|
|
150 |
if m.reply_to_message and m.reply_to_message.forward_from:
|
151 |
user1 = m.reply_to_message.from_user
|
152 |
user2 = m.reply_to_message.forward_from
|
|
|
|
|
|
|
|
|
153 |
await m.reply_text(
|
154 |
-
|
155 |
-
|
156 |
-
orig_id=f"<code>{user2.id}</code>",
|
157 |
-
fwd_sender=(await mention_html(user1.first_name, user1.id)),
|
158 |
-
fwd_id=f"<code>{user1.id}</code>",
|
159 |
-
),
|
160 |
parse_mode="HTML",
|
161 |
)
|
162 |
else:
|
163 |
try:
|
164 |
user = await c.get_users(user_id)
|
165 |
except PeerIdInvalid:
|
166 |
-
await m.reply_text(
|
|
|
167 |
return
|
168 |
|
169 |
await m.reply_text(
|
@@ -172,15 +171,11 @@ async def id_info(c: Gojo, m: Message):
|
|
172 |
)
|
173 |
elif m.chat.type == "private":
|
174 |
await m.reply_text(
|
175 |
-
|
176 |
-
my_id=f"<code>{m.chat.id}</code>",
|
177 |
-
),
|
178 |
)
|
179 |
else:
|
180 |
await m.reply_text(
|
181 |
-
|
182 |
-
group_id=f"<code>{m.chat.id}</code>",
|
183 |
-
),
|
184 |
)
|
185 |
return
|
186 |
|
@@ -196,7 +191,7 @@ async def get_gifid(_, m: Message):
|
|
196 |
parse_mode="html",
|
197 |
)
|
198 |
else:
|
199 |
-
await m.reply_text(
|
200 |
return
|
201 |
|
202 |
|
@@ -252,11 +247,11 @@ async def my_info(c: Gojo, m: Message):
|
|
252 |
try:
|
253 |
user_id, name, user_name = await extract_user(c, m)
|
254 |
except PeerIdInvalid:
|
255 |
-
await m.reply_text(
|
256 |
return
|
257 |
except ValueError as ef:
|
258 |
if "Peer id invalid" in str(ef):
|
259 |
-
await m.reply_text(
|
260 |
return
|
261 |
try:
|
262 |
user = Users.get_user_info(int(user_id))
|
@@ -274,45 +269,40 @@ async def my_info(c: Gojo, m: Message):
|
|
274 |
user_name = user["username"]
|
275 |
user_id = user["id"]
|
276 |
except PeerIdInvalid:
|
277 |
-
await m.reply_text(
|
|
|
278 |
return
|
279 |
except (RPCError, Exception) as ef:
|
280 |
await m.reply_text(
|
281 |
-
|
282 |
-
|
283 |
-
ef=ef,
|
284 |
-
),
|
285 |
)
|
286 |
return
|
287 |
|
288 |
gbanned, reason_gban = gban_db.get_gban(user_id)
|
289 |
LOGGER.info(f"{m.from_user.id} used info cmd for {user_id} in {m.chat.id}")
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
|
296 |
if user_name:
|
297 |
-
text +=
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
text += (tlang(m, "utils.user_info.info_text.perma_link")).format(
|
302 |
-
perma_link=(await mention_html("Click Here", user_id)),
|
303 |
-
)
|
304 |
|
305 |
if gbanned:
|
306 |
text += f"\nThis user is Globally banned beacuse: {reason_gban}\n"
|
307 |
|
308 |
if user_id == OWNER_ID:
|
309 |
-
text +=
|
310 |
elif user_id in DEV_USERS:
|
311 |
-
text +=
|
312 |
elif user_id in SUDO_USERS:
|
313 |
-
text +=
|
314 |
elif user_id in WHITELIST_USERS:
|
315 |
-
text +=
|
316 |
|
317 |
await m.reply_text(text, parse_mode="html", disable_web_page_preview=True)
|
318 |
return
|
@@ -320,7 +310,7 @@ async def my_info(c: Gojo, m: Message):
|
|
320 |
|
321 |
@Gojo.on_message(command("paste"))
|
322 |
async def paste_it(_, m: Message):
|
323 |
-
replymsg = await m.reply_text(
|
324 |
try:
|
325 |
if m.reply_to_message:
|
326 |
if m.reply_to_message.document:
|
@@ -336,8 +326,8 @@ async def paste_it(_, m: Message):
|
|
336 |
r = await http.post(ur, json={"content": txt})
|
337 |
url = f"https://hastebin.com/{r.json().get('key')}"
|
338 |
await replymsg.edit_text(
|
339 |
-
|
340 |
-
reply_markup=ikb([[(
|
341 |
)
|
342 |
LOGGER.info(f"{m.from_user.id} used paste cmd in {m.chat.id}")
|
343 |
except Exception as e:
|
|
|
22 |
from Powers.bot_class import Gojo
|
23 |
from Powers.database.antispam_db import GBan
|
24 |
from Powers.database.users_db import Users
|
|
|
25 |
from Powers.utils.clean_file import remove_markdown_and_html
|
26 |
from Powers.utils.custom_filters import command
|
27 |
from Powers.utils.extract_user import extract_user
|
|
|
38 |
LOGGER.info(f"{m.from_user.id} used wiki cmd in {m.chat.id}")
|
39 |
|
40 |
if len(m.text.split()) <= 1:
|
41 |
+
return await m.reply_text(text="Please check help on how to use this this command.")
|
42 |
|
43 |
search = m.text.split(None, 1)[1]
|
44 |
try:
|
|
|
97 |
)
|
98 |
async def get_lyrics(_, m: Message):
|
99 |
if len(m.text.split()) <= 1:
|
100 |
+
await m.reply_text(text="Please check help on how to use this this command.")
|
101 |
return
|
102 |
|
103 |
query = m.text.split(None, 1)[1]
|
104 |
LOGGER.info(f"{m.from_user.id} used lyrics cmd in {m.chat.id}")
|
105 |
song = ""
|
106 |
if not query:
|
107 |
+
await m.edit_text(text="You haven't specified which song to look for!")
|
108 |
return
|
109 |
+
song_name=query
|
110 |
em = await m.reply_text(
|
111 |
+
text=f"Finding lyrics for <code>{song_name}<code>...")
|
|
|
112 |
song = Song.find_song(query)
|
113 |
if song:
|
114 |
if song.lyrics:
|
115 |
reply = song.format()
|
116 |
else:
|
117 |
+
reply = "Couldn't find any lyrics for that song!"
|
118 |
else:
|
119 |
+
reply = "Song not found!"
|
120 |
try:
|
121 |
await em.edit_text(reply)
|
122 |
except MessageTooLong:
|
|
|
136 |
LOGGER.info(f"{m.from_user.id} used id cmd in {m.chat.id}")
|
137 |
|
138 |
if m.chat.type == "supergroup" and not m.reply_to_message:
|
139 |
+
await m.reply_text(text=f"This Group's ID is <code>{m.chat.id}</code>")
|
140 |
return
|
141 |
|
142 |
if m.chat.type == "private" and not m.reply_to_message:
|
143 |
+
await m.reply_text(text=f"Your ID is <code>{m.chat.id}</code>.")
|
144 |
return
|
145 |
|
146 |
user_id, _, _ = await extract_user(c, m)
|
|
|
148 |
if m.reply_to_message and m.reply_to_message.forward_from:
|
149 |
user1 = m.reply_to_message.from_user
|
150 |
user2 = m.reply_to_message.forward_from
|
151 |
+
orig_sender=(await mention_html(user2.first_name, user2.id)),
|
152 |
+
orig_id=f"<code>{user2.id}</code>",
|
153 |
+
fwd_sender=(await mention_html(user1.first_name, user1.id)),
|
154 |
+
fwd_id=f"<code>{user1.id}</code>",
|
155 |
await m.reply_text(
|
156 |
+
text=f"""Original Sender - {orig_sender} (<code>{orig_id}</code>)
|
157 |
+
Forwarder - {fwd_sender} (<code>{fwd_id}</code>)""",
|
|
|
|
|
|
|
|
|
158 |
parse_mode="HTML",
|
159 |
)
|
160 |
else:
|
161 |
try:
|
162 |
user = await c.get_users(user_id)
|
163 |
except PeerIdInvalid:
|
164 |
+
await m.reply_text(text="""Failed to get user
|
165 |
+
Peer ID invalid, I haven't seen this user anywhere earlier, maybe username would help to know them!""")
|
166 |
return
|
167 |
|
168 |
await m.reply_text(
|
|
|
171 |
)
|
172 |
elif m.chat.type == "private":
|
173 |
await m.reply_text(
|
174 |
+
text=f"Your ID is <code>{m.chat.id}</code>."
|
|
|
|
|
175 |
)
|
176 |
else:
|
177 |
await m.reply_text(
|
178 |
+
text=f"This Group's ID is <code>{m.chat.id}</code>"
|
|
|
|
|
179 |
)
|
180 |
return
|
181 |
|
|
|
191 |
parse_mode="html",
|
192 |
)
|
193 |
else:
|
194 |
+
await m.reply_text(text="Please reply to a gif to get it's ID.")
|
195 |
return
|
196 |
|
197 |
|
|
|
247 |
try:
|
248 |
user_id, name, user_name = await extract_user(c, m)
|
249 |
except PeerIdInvalid:
|
250 |
+
await m.reply_text(text="I haven't seen this user, mind forwarding one of their messages so I can recognize them?")
|
251 |
return
|
252 |
except ValueError as ef:
|
253 |
if "Peer id invalid" in str(ef):
|
254 |
+
await m.reply_text(text="User not found, please check the ID again")
|
255 |
return
|
256 |
try:
|
257 |
user = Users.get_user_info(int(user_id))
|
|
|
269 |
user_name = user["username"]
|
270 |
user_id = user["id"]
|
271 |
except PeerIdInvalid:
|
272 |
+
await m.reply_text(text="""Failed to get user
|
273 |
+
Peer ID invalid, I haven't seen this user anywhere earlier, maybe username would help to know them!""")
|
274 |
return
|
275 |
except (RPCError, Exception) as ef:
|
276 |
await m.reply_text(
|
277 |
+
text=f"""Some error occured, report to @{SUPPORT_GROUP}
|
278 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
|
|
279 |
)
|
280 |
return
|
281 |
|
282 |
gbanned, reason_gban = gban_db.get_gban(user_id)
|
283 |
LOGGER.info(f"{m.from_user.id} used info cmd for {user_id} in {m.chat.id}")
|
284 |
+
user_id=user_id,
|
285 |
+
user_name=name,
|
286 |
+
text = f"""<b>Characteristics:</b>
|
287 |
+
<b>ID:</b> <code>{user_id}</code>
|
288 |
+
<b>First Name:</b> {user_name}"""
|
289 |
|
290 |
if user_name:
|
291 |
+
text += f"<b>Username:</b> @{user_name}"
|
292 |
+
perma_link=(await mention_html("Click Here", user_id))
|
293 |
+
text += f"<b>Permanent User Link:</b> {perma_link}"
|
|
|
|
|
|
|
|
|
294 |
|
295 |
if gbanned:
|
296 |
text += f"\nThis user is Globally banned beacuse: {reason_gban}\n"
|
297 |
|
298 |
if user_id == OWNER_ID:
|
299 |
+
text += "This person is my Owner, I would never do anything against them!"
|
300 |
elif user_id in DEV_USERS:
|
301 |
+
text += "This member is one of my Developers ⚡️"
|
302 |
elif user_id in SUDO_USERS:
|
303 |
+
text += "This user is one of my Sudos, he has powers which are approximately same to owner!"
|
304 |
elif user_id in WHITELIST_USERS:
|
305 |
+
text += "This person is 'Whitelist User', they cannot be banned!"
|
306 |
|
307 |
await m.reply_text(text, parse_mode="html", disable_web_page_preview=True)
|
308 |
return
|
|
|
310 |
|
311 |
@Gojo.on_message(command("paste"))
|
312 |
async def paste_it(_, m: Message):
|
313 |
+
replymsg = await m.reply_text(text="Pasting...", quote=True)
|
314 |
try:
|
315 |
if m.reply_to_message:
|
316 |
if m.reply_to_message.document:
|
|
|
326 |
r = await http.post(ur, json={"content": txt})
|
327 |
url = f"https://hastebin.com/{r.json().get('key')}"
|
328 |
await replymsg.edit_text(
|
329 |
+
text="Pasted to NekoBin!",
|
330 |
+
reply_markup=ikb([[("NekoBin"), url, "url"]]),
|
331 |
)
|
332 |
LOGGER.info(f"{m.from_user.id} used paste cmd in {m.chat.id}")
|
333 |
except Exception as e:
|
Powers/plugins/warns.py
CHANGED
@@ -15,7 +15,6 @@ from Powers.bot_class import Gojo
|
|
15 |
from Powers.database.rules_db import Rules
|
16 |
from Powers.database.users_db import Users
|
17 |
from Powers.database.warns_db import Warns, WarnSettings
|
18 |
-
from Powers.tr_engine import tlang
|
19 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
20 |
from Powers.utils.custom_filters import admin_filter, command, restrict_filter
|
21 |
from Powers.utils.extract_user import extract_user
|
@@ -53,7 +52,7 @@ async def warn(c: Gojo, m: Message):
|
|
53 |
return
|
54 |
|
55 |
if user_id in SUPPORT_STAFF:
|
56 |
-
await m.reply_text(
|
57 |
LOGGER.info(
|
58 |
f"{m.from_user.id} trying to warn {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
59 |
)
|
|
|
15 |
from Powers.database.rules_db import Rules
|
16 |
from Powers.database.users_db import Users
|
17 |
from Powers.database.warns_db import Warns, WarnSettings
|
|
|
18 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
19 |
from Powers.utils.custom_filters import admin_filter, command, restrict_filter
|
20 |
from Powers.utils.extract_user import extract_user
|
|
|
52 |
return
|
53 |
|
54 |
if user_id in SUPPORT_STAFF:
|
55 |
+
await m.reply_text(text="This user is in my support staff, cannot restrict them.")
|
56 |
LOGGER.info(
|
57 |
f"{m.from_user.id} trying to warn {user_id} (SUPPORT_STAFF) in {m.chat.id}",
|
58 |
)
|
Powers/plugins/watchers.py
CHANGED
@@ -14,7 +14,6 @@ from Powers.database.blacklist_db import Blacklist
|
|
14 |
from Powers.database.group_blacklist import BLACKLIST_CHATS
|
15 |
from Powers.database.pins_db import Pins
|
16 |
from Powers.database.warns_db import Warns, WarnSettings
|
17 |
-
from Powers.tr_engine import tlang
|
18 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
19 |
from Powers.utils.parser import mention_html
|
20 |
from Powers.utils.regex_utils import regex_searcher
|
@@ -59,7 +58,7 @@ async def bl_watcher(_, m: Message):
|
|
59 |
if action == "kick":
|
60 |
await m.chat.kick_member(m.from_user.id, int(time() + 45))
|
61 |
await m.reply_text(
|
62 |
-
|
63 |
user=m.from_user.username or f"<b>{m.from_user.first_name}</b>",
|
64 |
),
|
65 |
)
|
@@ -71,7 +70,7 @@ async def bl_watcher(_, m: Message):
|
|
71 |
)
|
72 |
)
|
73 |
await m.reply_text(
|
74 |
-
|
75 |
user=m.from_user.username or f"<b>{m.from_user.first_name}</b>",
|
76 |
),
|
77 |
)
|
@@ -83,7 +82,7 @@ async def bl_watcher(_, m: Message):
|
|
83 |
)
|
84 |
|
85 |
await m.reply_text(
|
86 |
-
|
87 |
user=m.from_user.username or f"<b>{m.from_user.first_name}</b>",
|
88 |
),
|
89 |
)
|
@@ -185,13 +184,11 @@ async def gban_watcher(c: Gojo, m: Message):
|
|
185 |
try:
|
186 |
await m.chat.ban_member(m.from_user.id)
|
187 |
await m.delete(m.message_id) # Delete users message!
|
|
|
188 |
await m.reply_text(
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
),
|
193 |
-
SUPPORT_GROUP=SUPPORT_GROUP,
|
194 |
-
),
|
195 |
)
|
196 |
LOGGER.info(f"Banned user {m.from_user.id} in {m.chat.id} due to antispam")
|
197 |
return
|
@@ -204,10 +201,9 @@ async def gban_watcher(c: Gojo, m: Message):
|
|
204 |
except RPCError as ef:
|
205 |
await c.send_message(
|
206 |
MESSAGE_DUMP,
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
),
|
211 |
)
|
212 |
return
|
213 |
|
|
|
14 |
from Powers.database.group_blacklist import BLACKLIST_CHATS
|
15 |
from Powers.database.pins_db import Pins
|
16 |
from Powers.database.warns_db import Warns, WarnSettings
|
|
|
17 |
from Powers.utils.caching import ADMIN_CACHE, admin_cache_reload
|
18 |
from Powers.utils.parser import mention_html
|
19 |
from Powers.utils.regex_utils import regex_searcher
|
|
|
58 |
if action == "kick":
|
59 |
await m.chat.kick_member(m.from_user.id, int(time() + 45))
|
60 |
await m.reply_text(
|
61 |
+
text="Kicked {user} for sending a blacklisted word!".format(
|
62 |
user=m.from_user.username or f"<b>{m.from_user.first_name}</b>",
|
63 |
),
|
64 |
)
|
|
|
70 |
)
|
71 |
)
|
72 |
await m.reply_text(
|
73 |
+
text="Banned {user} for sending a blacklisted word!".format(
|
74 |
user=m.from_user.username or f"<b>{m.from_user.first_name}</b>",
|
75 |
),
|
76 |
)
|
|
|
82 |
)
|
83 |
|
84 |
await m.reply_text(
|
85 |
+
text="Muted {user} for sending a blacklisted word!".format(
|
86 |
user=m.from_user.username or f"<b>{m.from_user.first_name}</b>",
|
87 |
),
|
88 |
)
|
|
|
184 |
try:
|
185 |
await m.chat.ban_member(m.from_user.id)
|
186 |
await m.delete(m.message_id) # Delete users message!
|
187 |
+
user_gbanned=(await mention_html(m.from_user.first_name, m.from_user.id))
|
188 |
await m.reply_text(
|
189 |
+
text=f"""This user ({user_gbanned}) has been banned globally!
|
190 |
+
|
191 |
+
To get unbanned, appeal at @{SUPPORT_GROUP}"""
|
|
|
|
|
|
|
192 |
)
|
193 |
LOGGER.info(f"Banned user {m.from_user.id} in {m.chat.id} due to antispam")
|
194 |
return
|
|
|
201 |
except RPCError as ef:
|
202 |
await c.send_message(
|
203 |
MESSAGE_DUMP,
|
204 |
+
text=f"""<b>Gban Watcher Error!</b>
|
205 |
+
<b>Chat:</b> <code>{m.chat.id}</code>
|
206 |
+
<b>Error:</b> <code>{ef}</code>"""
|
|
|
207 |
)
|
208 |
return
|
209 |
|