async def demote(dmod): if dmod.fwd_from: return chat = await dmod.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply(dmod, NO_ADMIN) return catevent = await edit_or_reply(dmod, "↮") rank = "مشرف" user = await get_user_from_event(dmod) user = user[0] if not user: return newrights = ChatAdminRights( add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None, ) try: await dmod.client( EditAdminRequest(dmod.chat_id, user.id, newrights, rank)) except BadRequestError: await catevent.edit(NO_PERM) return await catevent.edit("**- ❝ ⌊ تم تنزلـيه من الاشـرف بنجـاح 𓆰.**") if BOTLOG: await dmod.client.send_message( BOTLOG_CHATID, "#تنزيل_مشرف\n" f"المستخدم: [{user.first_name}](tg://user?id={user.id})\n" f"الدردشه: {dmod.chat.title}(`{dmod.chat_id}`)", )
async def promote(promt): """ For .promote command, do promote targeted person """ if not promt.text[0].isalpha() \ and promt.text[0] not in ("/", "#", "@", "!"): chats = await promt.get_chat() admin = chats.admin_rights creator = chats.creator new_rights = ChatAdminRights(add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True) # Self explanatory if not await promt.get_reply_message(): await promt.edit("`Give a reply message`") elif not admin and creator: rights = new_rights elif not admin and not creator: rights = None await promt.edit("`Promoting...`") # Try to promote if current user is admin or creator try: await promt.client( EditAdminRequest(promt.chat_id, (await promt.get_reply_message()).sender_id, rights, "admin")) await promt.edit("**Promoted Successfully!**") # If Telethon spit BadRequestError, assume # we don't have Promote permission except BadRequestError: await promt.edit( "`You Don't have sufficient permissions to parmod`") return
async def demote(dmod): if dmod.fwd_from: return chat = await dmod.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply(dmod, NO_ADMIN) return AuraXevent = await edit_or_reply(dmod, "Demoting...") rank = "??????" user = await get_user_from_event(dmod) user = user[0] if not user: return newrights = ChatAdminRights( add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None, ) try: await dmod.client( EditAdminRequest(dmod.chat_id, user.id, newrights, rank)) except BadRequestError: await AuraXevent.edit(NO_PERM) return await AuraXevent.edit("𝘿𝙀𝙈𝙊𝙏𝙀𝘿 𝙎𝙐𝘾𝘾𝙀𝙎𝙎𝙁𝙐𝙇𝙇𝙔..!!") if BOTLOG: await dmod.client.send_message( BOTLOG_CHATID, "#DEMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {dmod.chat.title}(`{dmod.chat_id}`)", )
async def demote(dmod): if dmod.fwd_from: return chat = await dmod.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply(dmod, NO_ADMIN) return catevent = await edit_or_reply(dmod, "`Demoting...`") rank = "admeme" user = await get_user_from_event(dmod) user = user[0] if not user: return newrights = ChatAdminRights( add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None, ) try: await dmod.client( EditAdminRequest(dmod.chat_id, user.id, newrights, rank)) except BadRequestError: await catevent.edit(NO_PERM) return await catevent.edit("`Demoted Successfully! Betterluck next time👍`") if BOTLOG: await dmod.client.send_message( BOTLOG_CHATID, "#DEMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {dmod.chat.title}(`{dmod.chat_id}`)", )
async def promote(promt): if promt.fwd_from: return chat = await promt.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply(promt, NO_ADMIN) return new_rights = ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ) catevent = await edit_or_reply(promt, "`Promoting...`") user, rank = await get_user_from_event(promt) if not rank: rank = "Admin" if not user: return try: await promt.client( EditAdminRequest(promt.chat_id, user.id, new_rights, rank)) await catevent.edit("`Promoted Successfully! Now gib Party🙂😏😁`") except BadRequestError: await catevent.edit(NO_PERM) return if BOTLOG: await promt.client.send_message( BOTLOG_CHATID, "#PROMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {promt.chat.title}(`{promt.chat_id}`)", )
async def promote(promt): if promt.fwd_from: return chat = await promt.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply(promt, NO_ADMIN) return new_rights = ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ) LEGENDevent = await edit_or_reply(promt, "Promoting...") user, rank = await get_user_from_event(promt) if not rank: rank = "ℓєgєи∂" if not user: return try: await promt.client(EditAdminRequest(promt.chat_id, user.id, new_rights, rank)) await LEGENDevent.edit( f"**🔥Promoted ~** [{user.first_name}](tg://user?id={user.id}) **Successfully In** ~ `{promt.chat.title}`!! \n**Admin Tag ~** `{rank}`" ) except BadRequestError: await LEGENDevent.edit(NO_PERM) return await promt.client.send_message( lg_id, "#PROMOTE\n" f"\nUSER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {promt.chat.title}(`{promt.chat_id}`)", )
async def promote(promt): if promt.fwd_from: return chat = await promt.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await edit_or_reply(promt, NO_ADMIN) return new_rights = ChatAdminRights( add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True, ) catevent = await edit_or_reply(promt, "**╮ ❐ جـاري ࢪفعه مالك ❏╰**") user, rank = await get_user_from_event(promt) if not rank: rank = "مالك" if not user: return try: await promt.client( EditAdminRequest(promt.chat_id, user.id, new_rights, rank)) await catevent.edit("**- ❝ ⌊ تم تـرقيتـه مالك 𓆰.**") except BadRequestError: await catevent.edit(NO_PERM) return if BOTLOG: await promt.client.send_message( BOTLOG_CHATID, "#مالك\n" f"المستخدم: [{user.first_name}](tg://user?id={user.id})\n" f"الدردشه: {promt.chat.title}(`{promt.chat_id}`)", )
async def promote(eventPromote): if not eventPromote.text[0].isalpha() \ and eventPromote.text[0] not in ("/", "#", "@", "!"): chat = await eventPromote.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await eventPromote.edit("`I am not an admin!`") return newAdminRights = ChatAdminRights(add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True) await eventPromote.edit("`Promoting this gey...`") user = await get_user_from_event(eventPromote) if user: pass else: return try: await eventPromote.client( EditAdminRequest(eventPromote.chat_id, user.id, newAdminRights, rank="")) await eventPromote.edit("`Promoted Successfully! Gib Party!`") except BadRequestError: await eventPromote.edit("`I don't have sufficient permissions!`") return if ENABLE_LOG: await eventPromote.client.send_message( LOGGING_CHATID, "#PROMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {eventPromote.chat.title}(`{eventPromote.chat_id}`)")
async def middemote(dmod): if dmod.is_group: if not await can_promote_users(message=dmod): return else: return user = await get_user_from_event(dmod) if not dmod.is_group: return if not await is_register_admin(dmod.input_chat, user.id): await dmod.reply("**Hehe, i cant demote non-admin**") return if not user: return # New rights after demotion newrights = ChatAdminRights( add_admins=False, invite_users=True, change_info=True, ban_users=False, delete_messages=True, pin_messages=True, ) # Edit Admin Permission try: await bot(EditAdminRequest(dmod.chat_id, user.id, newrights, "Admin")) await dmod.reply("**Demoted Successfully!**") # If we catch BadRequestError from Telethon # Assume we don't have permission to demote except Exception: await dmod.reply("**Failed to demote.**") return
async def highpromote(promt): if (promt.is_group and promt.sender_id != OWNER_ID and not await can_promote_users(message=promt) or not promt.is_group): return user = await get_user_from_event(promt) if not promt.is_group: return if await is_register_admin(promt.input_chat, user.id): await promt.reply( "**Well! i cant promote user who is already an admin**") return new_rights = ChatAdminRights( add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True, ) if not user: return quew = promt.pattern_match.group(1) title = quew or "Admin" # Try to promote if current user is admin or creator try: await bot(EditAdminRequest(promt.chat_id, user.id, new_rights, title)) await promt.reply("**Successfully promoted!**") # If Telethon spit BadRequestError, assume # we don't have Promote permission except Exception: await promt.reply("Failed to promote.") return
async def dmote(ult): xx = await eor(ult, "`Processing...`") chat = await ult.get_chat() isAdmin = chat.admin_rights isCreator = chat.creator if not isAdmin and not isCreator: return await xx.edit("`Hmm, I'm not an admin here...`") await xx.edit("`Demoting...`") user, rank = await get_user_info(ult) if not rank: rank = "Not Admin" if not user: return await xx.edit("`Reply to a user to demote him!`") try: await ultroid_bot( EditAdminRequest( ult.chat_id, user.id, ChatAdminRights( add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None, ), rank, ) ) await xx.edit( f"[{user.first_name}](tg://user?id={user.id}) `is no longer an admin in {ult.chat.title}`" ) except BadRequestError: return await xx.edit("`I don't have the right to demote you.`") await asyncio.sleep(5) await xx.delete()
async def promote(event, perm): if event.is_private: await event.reply("This cmd is made to be used in groups, not in PM!") return if not perm.add_admins: await event.reply( "You are missing the following rights to use this command:CanAddAdmins!" ) return input_str = event.pattern_match.group(1) user = await event.get_reply_message() if not input_str and not user: await event.reply( "Reply to a user or give its username to promote him!") return sed = await Stark(GetFullUserRequest(id=user.sender_id or input_str)) await Stark( EditAdminRequest(event.chat_id, user.sender_id or input_str, ChatAdminRights(add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True), rank="Admin")) if not input_str: await event.reply( f"Successfully Promoted [{sed.user.first_name}](tg://user?id={user.sender_id}) in {event.chat.title}!" ) return await event.reply(f"Succesfully Promoted {input_str} in {event.chat.title}" )
async def demote(eventDemote): if not eventDemote.text[0].isalpha() and eventDemote.text[0] not in ( "/", "#", "@", "!"): chat = await eventDemote.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await eventDemote.edit("`I am not an admin!`") return await eventDemote.edit("`Demoting...`") user = await get_user_from_event(eventDemote) if user: pass else: return newAdminRights = ChatAdminRights(add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None) try: await eventDemote.client( EditAdminRequest(eventDemote.chat_id, user.id, newAdminRights, rank="")) except BadRequestError: await eventDemote.edit("`I don't have sufficient permissions!`") return await eventDemote.edit("`Yetkileri başarıyla kaldırıldı!`") if ENABLE_LOG: await eventDemote.client.send_message( LOGGING_CHATID, "#DEMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {eventDemote.chat.title}(`{eventDemote.chat_id}`)")
async def dmote(ult): xx = await eor(ult, "`Work is on the way...`") chat = await ult.get_chat() isAdmin = chat.admin_rights isCreator = chat.creator if not isAdmin and not isCreator: return await xx.edit("`umm, sur jii admadminin bnao...`") await xx.edit("`Demoting...`") user, rank = await get_user_info(ult) if not rank: rank = "Not Admin" if not user: return await xx.edit("`sur ek user ko reply krke bolo !`") try: await ultroid_bot( EditAdminRequest( ult.chat_id, user.id, ChatAdminRights( add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None, ), rank, )) await xx.edit( f"[{user.first_name}](tg://user?id={user.id}) `is no longer an admin in {ult.chat.title}`" ) except BadRequestError: return await xx.edit( "`Sur jiii sryy mere paas rights noii h demote krne ka.`") await asyncio.sleep(5) await xx.delete()
async def promote(eventPromote): if not eventPromote.text[0].isalpha() \ and eventPromote.text[0] not in ("/", "#", "@", "!"): chat = await eventPromote.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await eventPromote.edit("`I am not an admin!`") return newAdminRights = ChatAdminRights(add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True) await eventPromote.edit("`Bu kişiyi yetkilendiriyorum...`") user = await get_user_from_event(eventPromote) if user: pass else: return try: await eventPromote.client( EditAdminRequest(eventPromote.chat_id, user.id, newAdminRights, rank="")) await eventPromote.edit("`Başarıyla yetkilendirildi!`") except BadRequestError: await eventPromote.edit("`Yeterli yetkilerim yok!`") return if ENABLE_LOG: await eventPromote.client.send_message( LOGGING_CHATID, "#PROMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {eventPromote.chat.title}(`{eventPromote.chat_id}`)")
async def prmte(ult): xx = await eor(ult, "`On the way wait...`") chat = await ult.get_chat() isAdmin = chat.admin_rights isCreator = chat.creator if not isAdmin and not isCreator: return await xx.edit("`umm, sur jii admadminin bnao...`") await xx.edit("`Promoting...`") user, rank = await get_user_info(ult) if not rank: rank = "Admin" if not user: return await xx.edit("`Reply to a user to promote him!`") try: await ultroid_bot( EditAdminRequest( ult.chat_id, user.id, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, )) await xx.edit( f"[{user.first_name}](tg://user?id={user.id}) `is now an admin in {ult.chat.title} with title {rank}.`" ) except BadRequestError: return await xx.edit( "`Sur jii mere paas admin bnane ka right noii hai.`") await asyncio.sleep(5) await xx.delete()
async def gben(userbot): ultrax = legend = userbot i = 0 await legend.get_sender() me = await userbot.client.get_me() await ultrax.edit("`Pʀᴏᴍᴏᴛɪɴɢ...`") my_mention = "[{}](tg://user?id={})".format(me.first_name, me.id) # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA f"@{me.username}" if me.username else my_mention await userbot.get_chat() if userbot.is_private: user = userbot.chat rank = userbot.pattern_match.group(1) else: userbot.chat.title try: user, rank = await get_full_user(userbot) except: pass if me == user: # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA await ultrax.edit("`Aʀᴇ ʏᴏᴜ ᴀ ɴᴏᴏʙ ᴡʜᴏ ᴡᴀɴᴛ ᴛᴏ ᴘʀᴏᴍᴏᴛᴇ ʏᴏᴜʀsᴇʟғ ㋛ !!`") return try: if not rank: rank = "ㅤㅤ" # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA # Reserved, Copyrighted by ULTRA-X, only for ULTRA-X UserBot, If found in any other repo, be ready for DMCA except: return await legend.edit(f"**Sᴏᴍᴇᴛʜɪɴɢ W3ɴᴛ Wʀᴏɴɢ 🧐 !!**") if user: telchanel = [ d.entity.id for d in await userbot.client.get_dialogs() if (d.is_group or d.is_channel) ] rgt = ChatAdminRights( add_admins=True, invite_users=True, change_info=True, ban_users=True, # ot, If found in any other repo, be ready for DMCA delete_messages=True, pin_messages=True, ) for x in telchanel: try: await userbot.client(EditAdminRequest(x, user, rgt, rank)) i += 1 await legend.edit( f"**Nᴇᴡ Gᴘʀᴏᴍᴏᴛɪᴏɴ !!**\n\n**Usᴇʀ** :- __[{user.first_name}](tg://user?id={user.id})__\n**Aғғᴇᴄᴛᴇᴅ Cʜᴀᴛs** :- `{i}`" ) except: pass else: await ultrax.edit(f"`Rᴇᴘʟʏ ᴛᴏ ᴀ ᴜsᴇʀ ᴛᴏ Gᴘʀᴏᴍᴏᴛᴇ ᴛʜᴇᴍ...`") return await ultrax.edit( f"**Nᴇᴡ Gᴘʀᴏᴍᴏᴛɪᴏɴ !!**\n\n**Usᴇʀ** :- __[{user.first_name}](tg://user?id={user.id})__\n**Aғғᴇᴄᴛᴇᴅ Cʜᴀᴛs** :- `{i}`" # )
message_id = event.message.reply_to_msg_id try: await client( UpdatePinnedMessageRequest(event.chat_id, message_id, silent)) except Exception as e: await event.edit(str(e)) else: await event.delete() else: await event.edit("Reply to a message to pin it.") admin_rights = ChatAdminRights(change_info=True, post_messages=True, edit_messages=True, delete_messages=True, ban_users=False, invite_users=True, pin_messages=True, add_admins=False) @client.on(register(pattern="promote ?(.*)")) async def handler(event): if event.fwd_from: return input_str = event.pattern_match.group(1) if input_str != "": admin_rank = input_str else: admin_rank = "admeme" start = datetime.now()
async def _(event): "To create a private group/channel with userbot" type_of_group = event.pattern_match.group(1) group_name = event.pattern_match.group(2) if type_of_group == "c": descript = "This is a Test Channel created using catuserbot" else: descript = "This is a Test Group created using catuserbot" event = await edit_or_reply(event, "creating......") flag = False if type_of_group == "b": try: new_rights = ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ) result = await event.client( functions.messages.CreateChatRequest( users=[Config.TG_BOT_USERNAME], title=group_name, ) ) created_chat_id = result.chats[0].id result = await event.client( functions.messages.ExportChatInviteRequest( peer=created_chat_id, ) ) await event.edit( "Group `{}` created successfully. Join {}".format( group_name, result.link ) ) flag = True try: rank = "admin" p = await event.client.get_entity(Config.TG_BOT_USERNAME) result = await event.client( EditAdminRequest(created_chat_id, p.id, new_rights, rank) ) except BadRequestError: pass except Exception as e: if not flag: await event.edit(str(e)) else: LOGS.error(e) elif type_of_group in ["g", "c"]: try: r = await event.client( functions.channels.CreateChannelRequest( title=group_name, about=descript, megagroup=type_of_group != "c", ) ) created_chat_id = r.chats[0].id result = await event.client( functions.messages.ExportChatInviteRequest( peer=created_chat_id, ) ) await event.edit( "Channel `{}` created successfully. Join {}".format( group_name, result.link ) ) except Exception as e: await event.edit(str(e)) else: await event.edit("Read `.help create` to know how to use me")
async def promote(event): if event.reply_to_msg_id: msg = await event.get_reply_message() try: if isinstance(msg.from_id, PeerUser): user = await event.client.get_entity(msg.from_id.user_id) elif isinstance(msg.from_id, PeerChannel): await event.edit(msgRep.CANNOT_PROMOTE_CHANNEL) return else: await event.edit(msgRep.PERSON_ANONYMOUS) return except ValueError as e: await event.edit(f"`{msgRep.GET_ENTITY_FAILED}: {e}`") return arg = event.pattern_match.group(1) title = arg if len(arg) <= 16 else "" else: args_from_event = event.pattern_match.group(1).split(" ", 1) if len(args_from_event) == 2: sec_arg = args_from_event[1] title = sec_arg if len(sec_arg) <= 16 else "" else: title = "" if args_from_event[0]: try: user = await event.client.get_entity(args_from_event[0]) except ValueError as e: await event.edit(f"`{msgRep.GET_ENTITY_FAILED}: {e}`") return else: user = None if not user: await event.edit(msgRep.NO_ONE_TO_PROMOTE) return if not type(user) is User: await event.edit(msgRep.NOT_USER) return if user.is_self: await event.edit(msgRep.CANNOT_PROMOTE_SELF) return chat = await event.get_chat() if type(chat) is User: await event.edit(msgRep.NO_GROUP_CHAN) return try: async for member in event.client.iter_participants(chat.id, filter=ChannelParticipantsAdmins): if user.id == member.id: if user.is_self: await event.edit(msgRep.ADMIN_ALREADY_SELF) else: await event.edit(msgRep.ADMIN_ALREADY) return except: pass try: if chat.creator: admin_perms = ChatAdminRights(add_admins=False, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True) else: # get our own admin rights but set add_admin perm to False. If we aren't admin set empty permissions admin_perms = chat.admin_rights if chat.admin_rights else ChatAdminRights() if admin_perms.add_admins is not None and not admin_perms.add_admins: await event.edit(msgRep.ADD_ADMINS_REQUIRED) return if admin_perms.add_admins: admin_perms.add_admins = False if all(getattr(admin_perms, perm) is False for perm in vars(admin_perms)): await event.edit(msgRep.ADMIN_NOT_ENOUGH_PERMS) return await event.client(EditAdminRequest(chat.id, user.id, admin_perms, title)) name = f"[{user.first_name}](tg://user?id={user.id})" if user.first_name else msgRep.DELETED_ACCOUNT await event.edit(msgRep.PROMOTE_SUCCESS.format(name)) if LOGGING: await event_log(event, "PROMOTE", user_name=user.first_name, username=user.username, user_id=user.id, chat_title=chat.title, chat_link=chat.username if hasattr(chat, "username") else None, chat_id=event.chat_id) except AdminsTooMuchError: await event.edit(msgRep.TOO_MANY_ADMINS) except AdminRankEmojiNotAllowedError: await event.edit(msgRep.EMOJI_NOT_ALLOWED) except ChatAdminRequiredError: await event.edit(msgRep.NO_ADMIN) except Exception as e: log.warning(e) await event.edit(msgRep.PROMOTE_FAILED) return
async def demote(event): if event.reply_to_msg_id: msg = await event.get_reply_message() try: if isinstance(msg.from_id, PeerUser): user = await event.client.get_entity(msg.from_id.user_id) elif isinstance(msg.from_id, PeerChannel): await event.edit(msgRep.CANNOT_DEMOTE_CHANNEL) return else: await event.edit(msgRep.PERSON_ANONYMOUS) return except ValueError as e: await event.edit(f"`{msgRep.GET_ENTITY_FAILED}: {e}`") return else: arg_from_event = event.pattern_match.group(1) if arg_from_event: try: user = await event.client.get_entity(arg_from_event) except ValueError as e: await event.edit(f"`{msgRep.GET_ENTITY_FAILED}: {e}`") return else: user = None if not user: await event.edit(msgRep.NO_ONE_TO_DEMOTE) return if not type(user) is User: await event.edit(msgRep.NOT_USER) return if user.is_self: await event.edit(msgRep.CANNOT_DEMOTE_SELF) return chat = await event.get_chat() if type(chat) is User: await event.edit(msgRep.NO_GROUP_CHAN) return try: admins = [] async for member in event.client.iter_participants(chat.id, filter=ChannelParticipantsAdmins): admins.append(member.id) if not user.id in admins: await event.edit(msgRep.DEMOTED_ALREADY) return user_is_admin = True if user.id in admins else False except: pass try: rm_admin_perms = ChatAdminRights(add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None) if chat.admin_rights and not chat.admin_rights.add_admins: await event.edit(msgRep.ADD_ADMINS_REQUIRED) return await event.client(EditAdminRequest(chat.id, user.id, rm_admin_perms, "")) name = f"[{user.first_name}](tg://user?id={user.id})" if user.first_name else msgRep.DELETED_ACCOUNT await event.edit(msgRep.DEMOTE_SUCCESS.format(name)) if LOGGING: await event_log(event, "DEMOTE", user_name=user.first_name, username=user.username, user_id=user.id, chat_title=chat.title, chat_link=chat.username if hasattr(chat, "username") else None, chat_id=event.chat_id) except ChatAdminRequiredError: if user_is_admin: await event.edit(msgRep.CANNOT_DEMOTE_ADMIN) else: await event.edit(msgRep.NO_ADMIN) except Exception as e: log.warning(e) await event.edit(msgRep.DEMOTE_FAILED) return
async def demote(dmod): """ For .demote command, demotes the replied/tagged person """ # Admin right check chat = await dmod.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await dmod.edit(NO_ADMIN) return # If passing, declare that we're going to demote await dmod.edit("`Demoting...`") rank = "Noob" # dummy rank, lol. user = await get_user_from_event(dmod) user = user[0] if user: pass else: return # New rights after demotion newrights = ChatAdminRights(add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None) # Edit Admin Permission try: await dmod.client( EditAdminRequest(dmod.chat_id, user.id, newrights, rank)) # If we catch BadRequestError from Telethon # Assume we don't have permission to demote except BadRequestError: await dmod.edit(NO_PERM) return await dmod.edit("`Demoted this retard Successfully!`") # Announce to the logging group if we have demoted successfully if BOTLOG: await dmod.client.send_message( BOTLOG_CHATID, "#DEMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {dmod.chat.title}(`{dmod.chat_id}`)")
async def promote(promt): """ For .promote command, promotes the replied/tagged person """ # Get targeted chat chat = await promt.get_chat() # Grab admin status or creator in a chat admin = chat.admin_rights creator = chat.creator # If not admin and not creator, also return if not admin and not creator: await promt.edit(NO_ADMIN) return new_rights = ChatAdminRights(add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True) await promt.edit("`Promoting...`") user, rank = await get_user_from_event(promt) if not rank: rank = "DARK COBRA" # Just in case. if user: pass else: return # Try to promote if current user is admin or creator try: await promt.client( EditAdminRequest(promt.chat_id, user.id, new_rights, rank)) await promt.edit("`Promoted Successfully! Now gib Party 🥳`") # If Telethon spit BadRequestError, assume # we don't have Promote permission except BadRequestError: await promt.edit(NO_PERM) return # Announce to the logging group if we have promoted successfully if BOTLOG: await promt.client.send_message( BOTLOG_CHATID, "#PROMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {promt.chat.title}(`{promt.chat_id}`)")
async def demote(dmod): if dmod.text[0].isalpha() or dmod.text[0] not in ("."): return chat = await dmod.get_chat() if isinstance(chat, User): await dmod.edit("`Yooo, this is not a channel or a group!`") return admin = chat.admin_rights creator = chat.creator if not admin and not creator: await dmod.edit(NO_ADMIN) return get_user = await get_user_from_event(dmod) if isinstance(get_user, tuple): user, rank = get_user else: user = get_user rank = "" if not rank: rank = "" if user: pass else: return if not isinstance(user, User): await dmod.edit("`I can't demote a channel or a group!`") return try: admins_list = [] async for member in dmod.client.iter_participants( dmod.chat_id, filter=ChannelParticipantsAdmins): admins_list.append(member.id) if user.id not in admins_list: await dmod.edit("`This user is mortal already`") return except ChatAdminRequiredError as cadre: await dmod.edit("`Admin privileges are required`") print("ChatAdminRequiredError:".cadre) return if user.is_self: await dmod.edit("`I can't demote myself!`") return await dmod.edit("`Demoting...`") newrights = ChatAdminRights(add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None) try: await dmod.client( EditAdminRequest(dmod.chat_id, user.id, newrights, rank)) await dmod.edit("`Demoted to a mortal user lmao`") except BadRequestError as bre: await dmod.edit(NO_PERM) print("BadRequestError:", bre) return except (TypeError, ValueError) as e: await dmod.edit(str(e)) return if BOTLOG: await dmod.client.send_message( BOTLOG_CHATID, "#DEMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {dmod.chat.title}(`{dmod.chat_id}`)")
async def promote(promt): if promt.text[0].isalpha() or promt.text[0] not in ("."): return chat = await promt.get_chat() if isinstance(chat, User): await promt.edit("`Yooo, this is not a channel or a group!`") return admin = chat.admin_rights creator = chat.creator if not admin and not creator: await promt.edit(NO_ADMIN) return new_rights = ChatAdminRights(add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True) get_user = await get_user_from_event(promt) if isinstance(get_user, tuple): user, rank = get_user else: user = get_user rank = "" if not rank: rank = "" if user: pass else: return if not isinstance(user, User): await promt.edit("`I can't promote a channel or a group!`") return try: async for member in promt.client.iter_participants( promt.chat_id, filter=ChannelParticipantsAdmins): if user.id == member.id: if user.is_self: await promt.edit("`I am immortal already`") else: await promt.edit("`This user is immortal already`") return except ChatAdminRequiredError as cadre: await promt.edit("`Admin privileges are required`") print("ChatAdminRequiredError:".cadre) return await promt.edit("`Promoting...`") try: if creator: await promt.client( EditAdminRequest(promt.chat_id, user.id, new_rights, rank)) else: admin.add_admins = False if all(getattr(admin, right) is False for right in vars(admin)): return await promt.edit( "`I don't have enough admin rights to promote this user`") await promt.client( EditAdminRequest(promt.chat_id, user.id, admin, rank)) if user.id in HOMIES: await promt.edit("`Promoted my homie with immortal power!`") else: await promt.edit("`Promoted with immortal power!`") except AdminsTooMuchError as atme: await promt.edit("`There are too many admins in this chat already`") print("AdminsTooMuchError:", atme) return except BadRequestError as bre: await promt.edit(NO_PERM) print("BadRequestError:", bre) return except (TypeError, ValueError) as e: await promt.edit(str(e)) return if BOTLOG: await promt.client.send_message( BOTLOG_CHATID, "#PROMOTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {promt.chat.title}(`{promt.chat_id}`)")
UNBAN_RIGHTS = ChatBannedRights( until_date=None, view_messages=None, send_messages=None, send_media=None, send_stickers=None, send_gifs=None, send_games=None, send_inline=None, embed_links=None, ) ADMIN_RIGHTS = ChatAdminRights(add_admins=True, invite_users=True, change_info=True, ban_users=True, delete_messages=True, pin_messages=True) UNADMIN_RIGHTS = ChatAdminRights(add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None) KICK_RIGHTS = ChatBannedRights(until_date=None, view_messages=True) MUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=True) UNMUTE_RIGHTS = ChatBannedRights(until_date=None, send_messages=False) # ================================================
async def gben(userbot): dc = dark = userbot i = 0 sender = await dc.get_sender() me = await userbot.client.get_me() await dark.edit("`demoting...`") my_mention = "[{}](tg://user?id={})".format(me.first_name, me.id) f"@{me.username}" if me.username else my_mention await userbot.get_chat() if userbot.is_private: user = userbot.chat rank = userbot.pattern_match.group(1) else: userbot.chat.title try: user, rank = await get_full_user(userbot) except: pass if me == user: k = await dark.edit("U want to demote urself 😑😑 waao..") return try: if not rank: rank = "ㅤㅤ" except: return await dark.edit(f"**Something W3NT Wrong 🤔**") if user: telchanel = [ d.entity.id for d in await userbot.client.get_dialogs() if (d.is_group or d.is_channel) ] rgt = ChatAdminRights(add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None) for x in telchanel: try: await userbot.client(EditAdminRequest(x, user, rgt, rank)) i += 1 await dark.edit(f"**Demoted in Chats **: `{i}`") except: pass else: await dark.edit(f"**Reply to a user you dumbo !!**") return await dark.edit( f"**Globally Demoted [{user.first_name}](tg://user?id={user.id})\n On Chats😏 : {i} **" )
async def _(e): if not e.out and not is_fullsudo(e.sender_id): return await eod(e, "`This Command Is Sudo Restricted.`") x = e.pattern_match.group(1) if not x: return await eod(e, "`Incorrect Format`") user = await e.get_reply_message() if user: ev = await eor(e, "`Promoting Replied User Globally`") ok = e.text.split() key = "all" if len(ok) > 1: if ("group" in ok[1]) or ("channel" in ok[1]): key = ok[1] rank = "AdMin" if len(ok) > 2: rank = ok[2] c = 0 if e.is_private: user.id = user.peer_id.user_id else: user.id = user.from_id.user_id async for x in ultroid_bot.iter_dialogs(): if "group" in key.lower(): if x.is_group: try: await ultroid_bot( EditAdminRequest( x.id, user.id, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, ), ) c += 1 except BaseException: pass elif "channel" in key.lower(): if x.is_channel: try: await ultroid_bot( EditAdminRequest( x.id, user.id, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, ), ) c += 1 except BaseException: pass else: if x.is_group or x.is_channel: try: await ultroid_bot( EditAdminRequest( x.id, user.id, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, ), ) c += 1 except Exception as er: LOGS.info(er) return await eor( ev, f"Promoted The Replied Users in Total : {c} {key} chats") else: k = e.text.split() if not k[1]: return await eod( e, "`Give someone's username/id or replied to user.") user = k[1] if user.isdigit(): user = int(user) try: name = await ultroid_bot.get_entity(user) except BaseException: return await eod(e, f"`No User Found Regarding {user}`") ev = await eor(e, f"`Promoting {name.first_name} globally.`") key = "all" if len(k) > 2: if ("group" in k[2]) or ("channel" in k[2]): key = k[2] rank = "AdMin" if len(k) > 3: rank = k[3] c = 0 async for x in ultroid_bot.iter_dialogs(): if "group" in key.lower(): if x.is_group: try: await ultroid_bot( EditAdminRequest( x.id, user, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, ), ) c += 1 except BaseException: pass elif "channel" in key.lower(): if x.is_channel: try: await ultroid_bot( EditAdminRequest( x.id, user, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, ), ) c += 1 except BaseException: pass else: if x.is_group or x.is_channel: try: await ultroid_bot( EditAdminRequest( x.id, user, ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ), rank, ), ) c += 1 except BaseException: pass return await eor( ev, f"Promoted {name.first_name} in Total : {c} {key} chats.")
Same function as gpromote. """ import os from pyUltroid.functions.gban_mute_db import * from pyUltroid.functions.gcast_blacklist_db import * from telethon.tl.functions.channels import EditAdminRequest from telethon.tl.functions.contacts import BlockRequest, UnblockRequest from telethon.tl.types import ChatAdminRights from . import * _gpromote_rights = ChatAdminRights( add_admins=False, invite_users=True, change_info=False, ban_users=True, delete_messages=True, pin_messages=True, ) _gdemote_rights = ChatAdminRights( add_admins=False, invite_users=False, change_info=False, ban_users=False, delete_messages=False, pin_messages=False, ) @ultroid_cmd(
from asyncio import sleep from telethon.errors import ChatAdminRequiredError, UserAdminInvalidError from telethon.tl.types import (ChatAdminRights, ChatBannedRights) from telethon.tl.functions.channels import (EditAdminRequest, EditBannedRequest) from telethon.tl.functions.messages import (UpdatePinnedMessageRequest, EditChatAdminRequest) logger = logging.getLogger(__name__) #================== КОНСТАНТЫ ======================== PROMOTE_RIGHTS = ChatAdminRights(post_messages=True, add_admins=None, invite_users=True, change_info=None, ban_users=True, delete_messages=True, pin_messages=True, edit_messages=True) DEMOTE_RIGHTS = ChatAdminRights(post_messages=None, add_admins=None, invite_users=None, change_info=None, ban_users=None, delete_messages=None, pin_messages=None, edit_messages=None) UNMUTE_RIGHTS = ChatBannedRights(until_date=None, view_messages=None,