Spaces:
Sleeping
Sleeping
File size: 25,136 Bytes
ca4eb6d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
from asyncio import sleep
from html import escape
from os import remove
from traceback import format_exc
from pyrogram import filters
from pyrogram.errors import (
ChatAdminInviteRequired,
ChatAdminRequired,
FloodWait,
RightForbidden,
RPCError,
UserAdminInvalid,
)
from pyrogram.types import Message
from Powers import DEV_USERS, LOGGER, OWNER_ID, SUPPORT_GROUP, SUPPORT_STAFF
from Powers.bot_class import Gojo
from Powers.database.approve_db import Approve
from Powers.database.reporting_db import Reporting
from Powers.tr_engine import tlang
from Powers.utils.caching import ADMIN_CACHE, TEMP_ADMIN_CACHE_BLOCK, admin_cache_reload
from Powers.utils.custom_filters import (
DEV_LEVEL,
admin_filter,
command,
owner_filter,
promote_filter,
)
from Powers.utils.extract_user import extract_user
from Powers.utils.parser import mention_html
from Powers.vars import Config
@Gojo.on_message(command("adminlist"))
async def adminlist_show(_, m: Message):
global ADMIN_CACHE
if m.chat.type != "supergroup":
return await m.reply_text(
"This command is made to be used in groups only!",
)
try:
try:
admin_list = ADMIN_CACHE[m.chat.id]
note = tlang(m, "admin.adminlist.note_cached")
except KeyError:
admin_list = await admin_cache_reload(m, "adminlist")
note = tlang(m, "admin.adminlist.note_updated")
adminstr = (tlang(m, "admin.adminlist.adminstr")).format(
chat_title=m.chat.title,
) + "\n\n"
bot_admins = [i for i in admin_list if (i[1].lower()).endswith("bot")]
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
# format is like: (user_id, username/name,anonyamous or not)
mention_users = [
(
admin[1]
if admin[1].startswith("@")
else (await mention_html(admin[1], admin[0]))
)
for admin in user_admins
if not admin[2] # if non-anonyamous admin
]
mention_users.sort(key=lambda x: x[1])
mention_bots = [
(
admin[1]
if admin[1].startswith("@")
else (await mention_html(admin[1], admin[0]))
)
for admin in bot_admins
]
mention_bots.sort(key=lambda x: x[1])
adminstr += "<b>User Admins:</b>\n"
adminstr += "\n".join(f"- {i}" for i in mention_users)
adminstr += "\n\n<b>Bots:</b>\n"
adminstr += "\n".join(f"- {i}" for i in mention_bots)
await m.reply_text(adminstr + "\n\n" + note)
LOGGER.info(f"Adminlist cmd use in {m.chat.id} by {m.from_user.id}")
except Exception as ef:
if str(ef) == str(m.chat.id):
await m.reply_text(tlang(m, "admin.adminlist.use_admin_cache"))
else:
ef = str(ef) + f"{admin_list}\n"
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=ef,
),
)
LOGGER.error(ef)
LOGGER.error(format_exc())
return
@Gojo.on_message(command("zombies") & owner_filter)
async def zombie_clean(c: Gojo, m: Message):
zombie = 0
wait = await m.reply_text("Searching ... and banning ...")
async for member in c.iter_chat_members(m.chat.id):
if member.user.is_deleted:
zombie += 1
try:
await c.kick_chat_member(m.chat.id, member.user.id)
except UserAdminInvalid:
zombie -= 1
except FloodWait as e:
await sleep(e.x)
if zombie == 0:
return await wait.edit_text("Group is clean!")
return await wait.edit_text(
f"<b>{zombie}</b> Zombies found and has been banned!",
)
@Gojo.on_message(command("admincache"))
async def reload_admins(_, m: Message):
global TEMP_ADMIN_CACHE_BLOCK
if m.chat.type != "supergroup":
return await m.reply_text(
"This command is made to be used in groups only!",
)
if (
(m.chat.id in set(TEMP_ADMIN_CACHE_BLOCK.keys()))
and (m.from_user.id not in SUPPORT_STAFF)
and TEMP_ADMIN_CACHE_BLOCK[m.chat.id] == "manualblock"
):
await m.reply_text("Can only reload admin cache once per 10 mins!")
return
try:
await admin_cache_reload(m, "admincache")
TEMP_ADMIN_CACHE_BLOCK[m.chat.id] = "manualblock"
await m.reply_text(tlang(m, "admin.adminlist.reloaded_admins"))
LOGGER.info(f"Admincache cmd use in {m.chat.id} by {m.from_user.id}")
except RPCError as ef:
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=ef,
),
)
LOGGER.error(ef)
LOGGER.error(format_exc())
return
@Gojo.on_message(filters.regex(r"^(?i)@admin(s)?") & filters.group)
async def tag_admins(_, m: Message):
db = Reporting(m.chat.id)
if not db.get_settings():
return
try:
admin_list = ADMIN_CACHE[m.chat.id]
except KeyError:
admin_list = await admin_cache_reload(m, "adminlist")
user_admins = [i for i in admin_list if not (i[1].lower()).endswith("bot")]
mention_users = [(await mention_html("\u2063", admin[0])) for admin in user_admins]
mention_users.sort(key=lambda x: x[1])
mention_str = "".join(mention_users)
await m.reply_text(
(
f"{(await mention_html(m.from_user.first_name, m.from_user.id))}"
f" reported the message to admins!{mention_str}"
),
)
@Gojo.on_message(command("fullpromote") & promote_filter)
async def fullpromote_usr(c: Gojo, m: Message):
global ADMIN_CACHE
if len(m.text.split()) == 1 and not m.reply_to_message:
await m.reply_text(tlang(m, "admin.promote.no_target"))
return
try:
user_id, user_first_name, user_name = await extract_user(c, m)
except Exception:
return
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
if user_id == Config.BOT_ID:
await m.reply_text("Huh, how can I even promote myself?")
return
if not bot.can_promote_members:
return await m.reply_text(
"I don't have enough permissions!",
) # This should be here
user = await c.get_chat_member(m.chat.id, m.from_user.id)
if m.from_user.id not in [DEV_USERS, OWNER_ID] and user.status != "creator":
return await m.reply_text("This command can only be used by chat owner.")
# If user is alreay admin
try:
admin_list = {i[0] for i in ADMIN_CACHE[m.chat.id]}
except KeyError:
admin_list = {
i[0] for i in (await admin_cache_reload(m, "promote_cache_update"))
}
if user_id in admin_list:
await m.reply_text(
"This user is already an admin, how am I supposed to re-promote them?",
)
return
try:
await m.chat.promote_member(
user_id=user_id,
can_change_info=bot.can_change_info,
can_invite_users=bot.can_invite_users,
can_delete_messages=bot.can_delete_messages,
can_restrict_members=bot.can_restrict_members,
can_pin_messages=bot.can_pin_messages,
can_promote_members=bot.can_promote_members,
can_manage_chat=bot.can_manage_chat,
can_manage_voice_chats=bot.can_manage_voice_chats,
)
title = ""
if len(m.text.split()) == 3 and not m.reply_to_message:
title = m.text.split()[2]
elif len(m.text.split()) == 2 and m.reply_to_message:
title = m.text.split()[1]
if title and len(title) > 16:
title = title[0:16] # trim title to 16 characters
try:
await c.set_administrator_title(m.chat.id, user_id, title)
except RPCError as e:
LOGGER.error(e)
LOGGER.info(
f"{m.from_user.id} fullpromoted {user_id} in {m.chat.id} with title '{title}'",
)
await m.reply_text(
(tlang(m, "admin.promote.promoted_user")).format(
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
promoted=(await mention_html(user_first_name, user_id)),
chat_title=f"{escape(m.chat.title)} title set to {title}"
if title
else f"{escape(m.chat.title)} title set to Admin",
),
)
# If user is approved, disapprove them as they willbe promoted and get even more rights
if Approve(m.chat.id).check_approve(user_id):
Approve(m.chat.id).remove_approve(user_id)
# ----- Add admin to temp cache -----
try:
inp1 = user_name or user_first_name
admins_group = ADMIN_CACHE[m.chat.id]
admins_group.append((user_id, inp1))
ADMIN_CACHE[m.chat.id] = admins_group
except KeyError:
await admin_cache_reload(m, "promote_key_error")
except ChatAdminRequired:
await m.reply_text(tlang(m, "admin.not_admin"))
except RightForbidden:
await m.reply_text(tlang(m, "admin.promote.bot_no_right"))
except UserAdminInvalid:
await m.reply_text(tlang(m, "admin.user_admin_invalid"))
except RPCError as e:
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=e,
),
)
LOGGER.error(e)
LOGGER.error(format_exc())
return
@Gojo.on_message(command("promote") & promote_filter)
async def promote_usr(c: Gojo, m: Message):
global ADMIN_CACHE
if len(m.text.split()) == 1 and not m.reply_to_message:
await m.reply_text(tlang(m, "admin.promote.no_target"))
return
try:
user_id, user_first_name, user_name = await extract_user(c, m)
except Exception:
return
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
if user_id == Config.BOT_ID:
await m.reply_text("Huh, how can I even promote myself?")
return
if not bot.can_promote_members:
return await m.reply_text(
"I don't have enough permissions",
) # This should be here
# If user is alreay admin
try:
admin_list = {i[0] for i in ADMIN_CACHE[m.chat.id]}
except KeyError:
admin_list = {
i[0] for i in (await admin_cache_reload(m, "promote_cache_update"))
}
if user_id in admin_list:
await m.reply_text(
"This user is already an admin, how am I supposed to re-promote them?",
)
return
try:
await m.chat.promote_member(
user_id=user_id,
can_change_info=bot.can_change_info,
can_invite_users=bot.can_invite_users,
can_delete_messages=bot.can_delete_messages,
can_restrict_members=bot.can_restrict_members,
can_pin_messages=bot.can_pin_messages,
# can_promote_members=bot.can_promote_members,
can_manage_chat=bot.can_manage_chat,
can_manage_voice_chats=bot.can_manage_voice_chats,
)
title = "Itadori" # Deafult title
if len(m.text.split()) == 3 and not m.reply_to_message:
title = m.text.split()[2]
elif len(m.text.split()) == 2 and m.reply_to_message:
title = m.text.split()[1]
if title and len(title) > 16:
title = title[0:16] # trim title to 16 characters
try:
await c.set_administrator_title(m.chat.id, user_id, title)
except RPCError as e:
LOGGER.error(e)
LOGGER.info(
f"{m.from_user.id} promoted {user_id} in {m.chat.id} with title '{title}'",
)
await m.reply_text(
(tlang(m, "admin.promote.promoted_user")).format(
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
promoted=(await mention_html(user_first_name, user_id)),
chat_title=f"{escape(m.chat.title)} title set to {title}"
if title
else f"{escape(m.chat.title)} title set to Admin",
),
)
# If user is approved, disapprove them as they willbe promoted and get even more rights
if Approve(m.chat.id).check_approve(user_id):
Approve(m.chat.id).remove_approve(user_id)
# ----- Add admin to temp cache -----
try:
inp1 = user_name or user_first_name
admins_group = ADMIN_CACHE[m.chat.id]
admins_group.append((user_id, inp1))
ADMIN_CACHE[m.chat.id] = admins_group
except KeyError:
await admin_cache_reload(m, "promote_key_error")
except ChatAdminRequired:
await m.reply_text(tlang(m, "admin.not_admin"))
except RightForbidden:
await m.reply_text(tlang(m, "admin.promote.bot_no_right"))
except UserAdminInvalid:
await m.reply_text(tlang(m, "admin.user_admin_invalid"))
except RPCError as e:
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=e,
),
)
LOGGER.error(e)
LOGGER.error(format_exc())
return
@Gojo.on_message(command("spromote") & promote_filter)
async def superpromote_usr(c: Gojo, m: Message):
global ADMIN_CACHE
if len(m.text.split()) == 1 and not m.reply_to_message:
await m.reply_text(tlang(m, "admin.promote.no_target"))
return
try:
user_id, user_first_name, user_name = await extract_user(c, m)
except Exception:
return
bot = await c.get_chat_member(m.chat.id, Config.BOT_ID)
if user_id == Config.BOT_ID:
await m.reply_text("Huh, how can I even promote myself?")
return
if not bot.can_promote_members:
return await m.reply_text(
"I don't have enough permissions",
) # This should be here
# If user is alreay admin
try:
admin_list = {i[0] for i in ADMIN_CACHE[m.chat.id]}
except KeyError:
admin_list = {
i[0] for i in (await admin_cache_reload(m, "promote_cache_update"))
}
if user_id in admin_list:
await m.reply_text(
"This user is already an admin, how am I supposed to re-promote them?",
)
return
try:
await m.chat.promote_member(
user_id=user_id,
can_change_info=bot.can_change_info,
can_invite_users=bot.can_invite_users,
can_delete_messages=bot.can_delete_messages,
can_restrict_members=bot.can_restrict_members,
can_pin_messages=bot.can_pin_messages,
can_promote_members=bot.can_promote_members,
can_manage_chat=bot.can_manage_chat,
can_manage_voice_chats=bot.can_manage_voice_chats,
)
title = "Gojo" # Deafult title
if len(m.text.split()) == 3 and not m.reply_to_message:
title = m.text.split()[2]
elif len(m.text.split()) == 2 and m.reply_to_message:
title = m.text.split()[1]
if title and len(title) > 16:
title = title[0:16] # trim title to 16 characters
try:
await c.set_administrator_title(m.chat.id, user_id, title)
except RPCError as e:
LOGGER.error(e)
LOGGER.info(
f"{m.from_user.id} super promoted {user_id} in {m.chat.id} with title '{title}'",
)
await m.reply_text(
(tlang(m, "admin.promote.promoted_user")).format(
promoter=(await mention_html(m.from_user.first_name, m.from_user.id)),
promoted=(await mention_html(user_first_name, user_id)),
chat_title=f"{escape(m.chat.title)} title set to {title}"
if title
else f"{escape(m.chat.title)} title set to Admin",
),
)
# If user is approved, disapprove them as they willbe promoted and get even more rights
if Approve(m.chat.id).check_approve(user_id):
Approve(m.chat.id).remove_approve(user_id)
# ----- Add admin to temp cache -----
try:
inp1 = user_name or user_first_name
admins_group = ADMIN_CACHE[m.chat.id]
admins_group.append((user_id, inp1))
ADMIN_CACHE[m.chat.id] = admins_group
except KeyError:
await admin_cache_reload(m, "promote_key_error")
except ChatAdminRequired:
await m.reply_text(tlang(m, "admin.not_admin"))
except RightForbidden:
await m.reply_text(tlang(m, "admin.promote.bot_no_right"))
except UserAdminInvalid:
await m.reply_text(tlang(m, "admin.user_admin_invalid"))
except RPCError as e:
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=e,
),
)
LOGGER.error(e)
LOGGER.error(format_exc())
return
@Gojo.on_message(command("demote") & promote_filter)
async def demote_usr(c: Gojo, m: Message):
global ADMIN_CACHE
if len(m.text.split()) == 1 and not m.reply_to_message:
await m.reply_text(tlang(m, "admin.demote.no_target"))
return
try:
user_id, user_first_name, _ = await extract_user(c, m)
except Exception:
return
if user_id == Config.BOT_ID:
await m.reply_text("Get an admin to demote me!")
return
# If user not alreay admin
try:
admin_list = {i[0] for i in ADMIN_CACHE[m.chat.id]}
except KeyError:
admin_list = {
i[0] for i in (await admin_cache_reload(m, "demote_cache_update"))
}
if user_id not in admin_list:
await m.reply_text(
"This user is not an admin, how am I supposed to re-demote them?",
)
return
try:
await m.chat.promote_member(
user_id=user_id,
can_change_info=False,
can_invite_users=False,
can_delete_messages=False,
can_restrict_members=False,
can_pin_messages=False,
can_promote_members=False,
can_manage_chat=False,
can_manage_voice_chats=False,
)
LOGGER.info(f"{m.from_user.id} demoted {user_id} in {m.chat.id}")
# ----- Remove admin from cache -----
try:
admin_list = ADMIN_CACHE[m.chat.id]
user = next(user for user in admin_list if user[0] == user_id)
admin_list.remove(user)
ADMIN_CACHE[m.chat.id] = admin_list
except (KeyError, StopIteration):
await admin_cache_reload(m, "demote_key_stopiter_error")
await m.reply_text(
(tlang(m, "admin.demote.demoted_user")).format(
demoter=(
await mention_html(
m.from_user.first_name,
m.from_user.id,
)
),
demoted=(await mention_html(user_first_name, user_id)),
chat_title=m.chat.title,
),
)
except ChatAdminRequired:
await m.reply_text(tlang(m, "admin.not_admin"))
except RightForbidden:
await m.reply_text(tlang(m, "admin.demote.bot_no_right"))
except UserAdminInvalid:
await m.reply_text(tlang(m, "admin.user_admin_invalid"))
except RPCError as ef:
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=ef,
),
)
LOGGER.error(ef)
LOGGER.error(format_exc())
return
@Gojo.on_message(command("invitelink"))
async def get_invitelink(c: Gojo, m: Message):
# Bypass the bot devs, sudos and owner
if m.from_user.id not in DEV_LEVEL:
user = await m.chat.get_member(m.from_user.id)
if not user.can_invite_users and user.status != "creator":
await m.reply_text(tlang(m, "admin.no_user_invite_perm"))
return False
try:
link = await c.export_chat_invite_link(m.chat.id)
await m.reply_text(
(tlang(m, "admin.invitelink")).format(
chat_name=m.chat.id,
link=link,
),
disable_web_page_preview=True,
)
LOGGER.info(f"{m.from_user.id} exported invite link in {m.chat.id}")
except ChatAdminRequired:
await m.reply_text(tlang(m, "admin.not_admin"))
except ChatAdminInviteRequired:
await m.reply_text(tlang(m, "admin.no_invite_perm"))
except RightForbidden:
await m.reply_text(tlang(m, "admin.no_user_invite_perm"))
except RPCError as ef:
await m.reply_text(
(tlang(m, "general.some_error")).format(
SUPPORT_GROUP=SUPPORT_GROUP,
ef=ef,
),
)
LOGGER.error(ef)
LOGGER.error(format_exc())
return
@Gojo.on_message(command("setgtitle") & admin_filter)
async def setgtitle(_, m: Message):
user = await m.chat.get_member(m.from_user.id)
if not user.can_change_info and user.status != "creator":
await m.reply_text(
"You don't have enough permission to use this command!",
)
return False
if len(m.command) < 1:
return await m.reply_text("Please read /help for using it!")
gtit = m.text.split(None, 1)[1]
try:
await m.chat.set_title(gtit)
except Exception as e:
return await m.reply_text(f"Error: {e}")
return await m.reply_text(
f"Successfully Changed Group Title From {m.chat.title} To {gtit}",
)
@Gojo.on_message(command("setgdes") & admin_filter)
async def setgdes(_, m: Message):
user = await m.chat.get_member(m.from_user.id)
if not user.can_change_info and user.status != "creator":
await m.reply_text(
"You don't have enough permission to use this command!",
)
return False
if len(m.command) < 1:
return await m.reply_text("Please read /help for using it!")
desp = m.text.split(None, 1)[1]
try:
await m.chat.set_description(desp)
except Exception as e:
return await m.reply_text(f"Error: {e}")
return await m.reply_text(
f"Successfully Changed Group description From {m.chat.description} To {desp}",
)
@Gojo.on_message(command("title") & admin_filter)
async def set_user_title(c: Gojo, m: Message):
user = await m.chat.get_member(m.from_user.id)
if not user.can_promote_members and user.status != "creator":
await m.reply_text(
"You don't have enough permission to use this command!",
)
return False
if len(m.text.split()) == 1 and not m.reply_to_message:
return await m.reply_text("To whom??")
if m.reply_to_message:
if len(m.text.split()) >= 2:
reason = m.text.split(None, 1)[1]
else:
if len(m.text.split()) >= 3:
reason = m.text.split(None, 2)[2]
try:
user_id, _, _ = await extract_user(c, m)
except Exception:
return
if not user_id:
return await m.reply_text("Cannot find user!")
if user_id == Config.BOT_ID:
return await m.reply_text("Huh, why ?")
if not reason:
return await m.reply_text("Read /help please!")
from_user = await c.get_users(user_id)
title = reason
try:
await c.set_administrator_title(m.chat.id, from_user.id, title)
except Exception as e:
return await m.reply_text(f"Error: {e}")
return await m.reply_text(
f"Successfully Changed {from_user.mention}'s Admin Title To {title}",
)
@Gojo.on_message(command("setgpic") & admin_filter)
async def setgpic(c: Gojo, m: Message):
user = await m.chat.get_member(m.from_user.id)
if not user.can_change_info and user.status != "creator":
await m.reply_text(
"You don't have enough permission to use this command!",
)
return False
if not m.reply_to_message:
return await m.reply_text("Reply to a photo to set it as chat photo")
if not m.reply_to_message.photo and not m.reply_to_message.document:
return await m.reply_text("Reply to a photo to set it as chat photo")
photo = await m.reply_to_message.download()
try:
await m.chat.set_photo(photo)
except Exception as e:
remove(photo)
return await m.reply_text(f"Error: {e}")
await m.reply_text("Successfully Changed Group Photo!")
remove(photo)
__PLUGIN__ = "admin"
__alt_name__ = [
"admins",
"promote",
"spromote",
"demote",
"adminlist",
"setgpic",
"title",
"setgtitle",
"fullpromote",
"invitelink",
"setgdes",
"zombies",
]
|