Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
4884bdd
1
Parent(s):
ffd8e21
Looks good
Browse files- Powers/plugins/admin.py +32 -4
Powers/plugins/admin.py
CHANGED
|
@@ -5,11 +5,11 @@ from pyrogram import filters
|
|
| 5 |
from Powers.vars import Config
|
| 6 |
from traceback import format_exc
|
| 7 |
from Powers.bot_class import Gojo
|
| 8 |
-
from pyrogram.types import Message, ChatPrivileges
|
| 9 |
from Powers.utils.parser import mention_html
|
| 10 |
from Powers.database.approve_db import Approve
|
| 11 |
from Powers.database.reporting_db import Reporting
|
| 12 |
from Powers.utils.extract_user import extract_user
|
|
|
|
| 13 |
from pyrogram.enums import ChatType, ChatMemberStatus as CMS
|
| 14 |
from Powers import LOGGER, OWNER_ID, DEV_USERS, SUPPORT_GROUP, SUPPORT_STAFF
|
| 15 |
from Powers.utils.caching import (
|
|
@@ -19,6 +19,8 @@ from Powers.utils.custom_filters import (
|
|
| 19 |
from pyrogram.errors import (
|
| 20 |
RPCError, FloodWait, RightForbidden, UserAdminInvalid, ChatAdminRequired,
|
| 21 |
ChatAdminInviteRequired)
|
|
|
|
|
|
|
| 22 |
@Gojo.on_message(command("adminlist"))
|
| 23 |
async def adminlist_show(_, m: Message):
|
| 24 |
global ADMIN_CACHE
|
|
@@ -73,6 +75,8 @@ async def adminlist_show(_, m: Message):
|
|
| 73 |
LOGGER.error(ef)
|
| 74 |
LOGGER.error(format_exc())
|
| 75 |
return
|
|
|
|
|
|
|
| 76 |
@Gojo.on_message(command("zombies") & owner_filter)
|
| 77 |
async def zombie_clean(c: Gojo, m: Message):
|
| 78 |
zombie = 0
|
|
@@ -91,6 +95,8 @@ async def zombie_clean(c: Gojo, m: Message):
|
|
| 91 |
return await wait.edit_text(
|
| 92 |
text=f"<b>{zombie}</b> Zombies found and has been banned!",
|
| 93 |
)
|
|
|
|
|
|
|
| 94 |
@Gojo.on_message(command("admincache"))
|
| 95 |
async def reload_admins(_, m: Message):
|
| 96 |
global TEMP_ADMIN_CACHE_BLOCK
|
|
@@ -117,6 +123,8 @@ async def reload_admins(_, m: Message):
|
|
| 117 |
LOGGER.error(ef)
|
| 118 |
LOGGER.error(format_exc())
|
| 119 |
return
|
|
|
|
|
|
|
| 120 |
@Gojo.on_message(filters.regex(r"^(?i)@admin(s)?") & filters.group)
|
| 121 |
async def tag_admins(_, m: Message):
|
| 122 |
db = Reporting(m.chat.id)
|
|
@@ -136,6 +144,8 @@ async def tag_admins(_, m: Message):
|
|
| 136 |
f" reported the message to admins!{mention_str}"
|
| 137 |
),
|
| 138 |
)
|
|
|
|
|
|
|
| 139 |
@Gojo.on_message(command("fullpromote") & promote_filter)
|
| 140 |
async def fullpromote_usr(c: Gojo, m: Message):
|
| 141 |
global ADMIN_CACHE
|
|
@@ -174,7 +184,7 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 174 |
try:
|
| 175 |
await m.chat.promote_member(user_id=user_id, privileges=bot.privileges)
|
| 176 |
if not m.chat.type == ChatType.SUPERGROUP:
|
| 177 |
-
title = "Gojo"
|
| 178 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
| 179 |
title = m.text.split()[2]
|
| 180 |
elif len(m.text.split()) == 2 and m.reply_to_message:
|
|
@@ -190,7 +200,9 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 190 |
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
| 191 |
)
|
| 192 |
await m.reply_text(
|
| 193 |
-
(
|
|
|
|
|
|
|
| 194 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
| 195 |
promoted=(await mention_html(user_first_name, user_id)),
|
| 196 |
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
|
@@ -225,6 +237,8 @@ async def fullpromote_usr(c: Gojo, m: Message):
|
|
| 225 |
LOGGER.error(e)
|
| 226 |
LOGGER.error(format_exc())
|
| 227 |
return
|
|
|
|
|
|
|
| 228 |
@Gojo.on_message(command("promote") & promote_filter)
|
| 229 |
async def promote_usr(c: Gojo, m: Message):
|
| 230 |
global ADMIN_CACHE
|
|
@@ -278,7 +292,7 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 278 |
title = m.text.split()[1]
|
| 279 |
if title and len(title) > 16:
|
| 280 |
title = title[0:16] # trim title to 16 characters
|
| 281 |
-
|
| 282 |
try:
|
| 283 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
| 284 |
except RPCError as e:
|
|
@@ -322,6 +336,8 @@ async def promote_usr(c: Gojo, m: Message):
|
|
| 322 |
LOGGER.error(e)
|
| 323 |
LOGGER.error(format_exc())
|
| 324 |
return
|
|
|
|
|
|
|
| 325 |
@Gojo.on_message(command("demote") & promote_filter)
|
| 326 |
async def demote_usr(c: Gojo, m: Message):
|
| 327 |
global ADMIN_CACHE
|
|
@@ -388,6 +404,8 @@ async def demote_usr(c: Gojo, m: Message):
|
|
| 388 |
LOGGER.error(ef)
|
| 389 |
LOGGER.error(format_exc())
|
| 390 |
return
|
|
|
|
|
|
|
| 391 |
@Gojo.on_message(command("invitelink"))
|
| 392 |
async def get_invitelink(c: Gojo, m: Message):
|
| 393 |
# Bypass the bot devs, sudos and owner
|
|
@@ -416,6 +434,8 @@ async def get_invitelink(c: Gojo, m: Message):
|
|
| 416 |
LOGGER.error(ef)
|
| 417 |
LOGGER.error(format_exc())
|
| 418 |
return
|
|
|
|
|
|
|
| 419 |
@Gojo.on_message(command("setgtitle") & admin_filter)
|
| 420 |
async def setgtitle(_, m: Message):
|
| 421 |
user = await m.chat.get_member(m.from_user.id)
|
|
@@ -434,6 +454,8 @@ async def setgtitle(_, m: Message):
|
|
| 434 |
return await m.reply_text(
|
| 435 |
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
|
| 436 |
)
|
|
|
|
|
|
|
| 437 |
@Gojo.on_message(command("setgdes") & admin_filter)
|
| 438 |
async def setgdes(_, m: Message):
|
| 439 |
user = await m.chat.get_member(m.from_user.id)
|
|
@@ -452,6 +474,8 @@ async def setgdes(_, m: Message):
|
|
| 452 |
return await m.reply_text(
|
| 453 |
f"Successfully Changed Group description From {m.chat.description} To {desp}",
|
| 454 |
)
|
|
|
|
|
|
|
| 455 |
@Gojo.on_message(command("title") & admin_filter)
|
| 456 |
async def set_user_title(c: Gojo, m: Message):
|
| 457 |
user = await m.chat.get_member(m.from_user.id)
|
|
@@ -487,6 +511,8 @@ async def set_user_title(c: Gojo, m: Message):
|
|
| 487 |
return await m.reply_text(
|
| 488 |
f"Successfully Changed {from_user.mention}'s Admin Title To {title}",
|
| 489 |
)
|
|
|
|
|
|
|
| 490 |
@Gojo.on_message(command("setgpic") & admin_filter)
|
| 491 |
async def setgpic(c: Gojo, m: Message):
|
| 492 |
user = await m.chat.get_member(m.from_user.id)
|
|
@@ -507,6 +533,8 @@ async def setgpic(c: Gojo, m: Message):
|
|
| 507 |
return await m.reply_text(f"Error: {e}")
|
| 508 |
await m.reply_text("Successfully Changed Group Photo!")
|
| 509 |
remove(photo)
|
|
|
|
|
|
|
| 510 |
__PLUGIN__ = "admin"
|
| 511 |
__alt_name__ = [
|
| 512 |
"admins",
|
|
|
|
| 5 |
from Powers.vars import Config
|
| 6 |
from traceback import format_exc
|
| 7 |
from Powers.bot_class import Gojo
|
|
|
|
| 8 |
from Powers.utils.parser import mention_html
|
| 9 |
from Powers.database.approve_db import Approve
|
| 10 |
from Powers.database.reporting_db import Reporting
|
| 11 |
from Powers.utils.extract_user import extract_user
|
| 12 |
+
from pyrogram.types import Message, ChatPrivileges
|
| 13 |
from pyrogram.enums import ChatType, ChatMemberStatus as CMS
|
| 14 |
from Powers import LOGGER, OWNER_ID, DEV_USERS, SUPPORT_GROUP, SUPPORT_STAFF
|
| 15 |
from Powers.utils.caching import (
|
|
|
|
| 19 |
from pyrogram.errors import (
|
| 20 |
RPCError, FloodWait, RightForbidden, UserAdminInvalid, ChatAdminRequired,
|
| 21 |
ChatAdminInviteRequired)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
@Gojo.on_message(command("adminlist"))
|
| 25 |
async def adminlist_show(_, m: Message):
|
| 26 |
global ADMIN_CACHE
|
|
|
|
| 75 |
LOGGER.error(ef)
|
| 76 |
LOGGER.error(format_exc())
|
| 77 |
return
|
| 78 |
+
|
| 79 |
+
|
| 80 |
@Gojo.on_message(command("zombies") & owner_filter)
|
| 81 |
async def zombie_clean(c: Gojo, m: Message):
|
| 82 |
zombie = 0
|
|
|
|
| 95 |
return await wait.edit_text(
|
| 96 |
text=f"<b>{zombie}</b> Zombies found and has been banned!",
|
| 97 |
)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
@Gojo.on_message(command("admincache"))
|
| 101 |
async def reload_admins(_, m: Message):
|
| 102 |
global TEMP_ADMIN_CACHE_BLOCK
|
|
|
|
| 123 |
LOGGER.error(ef)
|
| 124 |
LOGGER.error(format_exc())
|
| 125 |
return
|
| 126 |
+
|
| 127 |
+
|
| 128 |
@Gojo.on_message(filters.regex(r"^(?i)@admin(s)?") & filters.group)
|
| 129 |
async def tag_admins(_, m: Message):
|
| 130 |
db = Reporting(m.chat.id)
|
|
|
|
| 144 |
f" reported the message to admins!{mention_str}"
|
| 145 |
),
|
| 146 |
)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
@Gojo.on_message(command("fullpromote") & promote_filter)
|
| 150 |
async def fullpromote_usr(c: Gojo, m: Message):
|
| 151 |
global ADMIN_CACHE
|
|
|
|
| 184 |
try:
|
| 185 |
await m.chat.promote_member(user_id=user_id, privileges=bot.privileges)
|
| 186 |
if not m.chat.type == ChatType.SUPERGROUP:
|
| 187 |
+
title = "Gojo" # Default fullpromote title
|
| 188 |
if len(m.text.split()) == 3 and not m.reply_to_message:
|
| 189 |
title = m.text.split()[2]
|
| 190 |
elif len(m.text.split()) == 2 and m.reply_to_message:
|
|
|
|
| 200 |
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
|
| 201 |
)
|
| 202 |
await m.reply_text(
|
| 203 |
+
(
|
| 204 |
+
"{promoter} promoted {promoted} in chat <b>{chat_title}</b> with full rights!"
|
| 205 |
+
).format(
|
| 206 |
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
|
| 207 |
promoted=(await mention_html(user_first_name, user_id)),
|
| 208 |
chat_title=f"{escape(m.chat.title)} title set to {title}"
|
|
|
|
| 237 |
LOGGER.error(e)
|
| 238 |
LOGGER.error(format_exc())
|
| 239 |
return
|
| 240 |
+
|
| 241 |
+
|
| 242 |
@Gojo.on_message(command("promote") & promote_filter)
|
| 243 |
async def promote_usr(c: Gojo, m: Message):
|
| 244 |
global ADMIN_CACHE
|
|
|
|
| 292 |
title = m.text.split()[1]
|
| 293 |
if title and len(title) > 16:
|
| 294 |
title = title[0:16] # trim title to 16 characters
|
| 295 |
+
|
| 296 |
try:
|
| 297 |
await c.set_administrator_title(m.chat.id, user_id, title)
|
| 298 |
except RPCError as e:
|
|
|
|
| 336 |
LOGGER.error(e)
|
| 337 |
LOGGER.error(format_exc())
|
| 338 |
return
|
| 339 |
+
|
| 340 |
+
|
| 341 |
@Gojo.on_message(command("demote") & promote_filter)
|
| 342 |
async def demote_usr(c: Gojo, m: Message):
|
| 343 |
global ADMIN_CACHE
|
|
|
|
| 404 |
LOGGER.error(ef)
|
| 405 |
LOGGER.error(format_exc())
|
| 406 |
return
|
| 407 |
+
|
| 408 |
+
|
| 409 |
@Gojo.on_message(command("invitelink"))
|
| 410 |
async def get_invitelink(c: Gojo, m: Message):
|
| 411 |
# Bypass the bot devs, sudos and owner
|
|
|
|
| 434 |
LOGGER.error(ef)
|
| 435 |
LOGGER.error(format_exc())
|
| 436 |
return
|
| 437 |
+
|
| 438 |
+
|
| 439 |
@Gojo.on_message(command("setgtitle") & admin_filter)
|
| 440 |
async def setgtitle(_, m: Message):
|
| 441 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
|
| 454 |
return await m.reply_text(
|
| 455 |
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
|
| 456 |
)
|
| 457 |
+
|
| 458 |
+
|
| 459 |
@Gojo.on_message(command("setgdes") & admin_filter)
|
| 460 |
async def setgdes(_, m: Message):
|
| 461 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
|
| 474 |
return await m.reply_text(
|
| 475 |
f"Successfully Changed Group description From {m.chat.description} To {desp}",
|
| 476 |
)
|
| 477 |
+
|
| 478 |
+
|
| 479 |
@Gojo.on_message(command("title") & admin_filter)
|
| 480 |
async def set_user_title(c: Gojo, m: Message):
|
| 481 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
|
| 511 |
return await m.reply_text(
|
| 512 |
f"Successfully Changed {from_user.mention}'s Admin Title To {title}",
|
| 513 |
)
|
| 514 |
+
|
| 515 |
+
|
| 516 |
@Gojo.on_message(command("setgpic") & admin_filter)
|
| 517 |
async def setgpic(c: Gojo, m: Message):
|
| 518 |
user = await m.chat.get_member(m.from_user.id)
|
|
|
|
| 533 |
return await m.reply_text(f"Error: {e}")
|
| 534 |
await m.reply_text("Successfully Changed Group Photo!")
|
| 535 |
remove(photo)
|
| 536 |
+
|
| 537 |
+
|
| 538 |
__PLUGIN__ = "admin"
|
| 539 |
__alt_name__ = [
|
| 540 |
"admins",
|