def member_ban(_, message): msg_id = message.message_id chat_id = message.chat.id can_ban = kingbot.get_chat_member(chat_id, "me").can_restrict_members chat_msg = message.text user_id = None if "@" in chat_msg: index = chat_msg.index("@") chat_msg = str(chat_msg) user_id = chat_msg[index + 1:len(chat_msg)] else: user_id = message.reply_to_message.from_user.id user_info = kingbot.get_users(user_id) can_user_ban = kingbot.get_chat_member(chat_id, user_id).can_restrict_members if (can_ban): if (can_user_ban): reply_string = "Can't kick another admin. LOL !" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: kingbot.kick_chat_member(chat_id, user_id) if (user_info.username): usercontact = user_info.username reply_string = "@" + usercontact + " has been kicked to hell 😈" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: usercontact = user_info.first_name reply_string = usercontact + " has been kicked to hell 😈" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: reply_string = "Noob,you can't kick members 😂 !" kingbot.edit_message_text(chat_id, msg_id, reply_string)
def member_unban(_, message): msg_id = message.message_id chat_msg = message.text username = None if "@" in chat_msg: index = chat_msg.index("@") chat_msg = str(chat_msg) username = chat_msg[index + 1:len(chat_msg)] else: username = message.reply_to_message.from_user.id chat_id = message.chat.id can_ban = kingbot.get_chat_member(chat_id, "me").can_restrict_members user_info = kingbot.get_users(username) if (can_ban): kingbot.unban_chat_member(chat_id, username) if (user_info.username): usercontact = user_info.username reply_string = "@" + usercontact + " has been picked up from hell 😈" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: usercontact = user_info.first_name reply_string = usercontact + " has been picked up from 😈" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: reply_string = "Noob,you can't unban members 😂 !" kingbot.edit_message_text(chat_id, msg_id, reply_string)
def unmute(_, message): msg_id = message.message_id chat_msg = message.text username = None if "@" in chat_msg: index = chat_msg.index("@") chat_msg = str(chat_msg) username = chat_msg[index + 1:len(chat_msg)] else: username = message.reply_to_message.from_user.id chat_id = message.chat.id can_unmute = kingbot.get_chat_member(chat_id, "me").can_restrict_members user_info = kingbot.get_users(username) if (can_unmute): kingbot.restrict_chat_member(chat_id, username, message.chat.permissions) if (user_info.username): usercontact = user_info.username reply_string = "@" + usercontact + " has been released 😈" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: usercontact = user_info.first_name reply_string = usercontact + " has been released 😈" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: reply_string = "Noob,you can't unmute members 😂 !" kingbot.edit_message_text(chat_id, msg_id, reply_string)
def set_chat_photo(_, message): msg_id=message.message_id chat_id=message.chat.id can_change_admin=kingbot.get_chat_member(chat_id , "me").can_change_info can_change_member=message.chat.permissions.can_change_info if not (can_change_admin or can_change_member): message.reply("You don't have enough permission") if message.reply_to_message: if message.reply_to_message.photo: kingbot.set_chat_photo(chat_id , photo=message.reply_to_message.photo.file_id) return else: message.reply("Reply to a photo to set it !")
def lock(_ , message): chat_id=message.chat.id can_lock=kingbot.get_chat_member(chat_id , "me").can_restrict_members if not can_lock: message.reply("Don't have enough permissions !!") else: message.reply("Chat has been locked for all non-admins !!") kingbot.set_chat_permissions( chat_id, ChatPermissions( can_send_messages=False, can_invite_users=True ) )
def mute(_, message): msg_id = message.message_id chat_id = message.chat.id can_mute = kingbot.get_chat_member(chat_id, "me").can_restrict_members chat_msg = message.text user_id = None if "@" in chat_msg: index = chat_msg.index("@") chat_msg = str(chat_msg) user_id = chat_msg[index + 1:len(chat_msg)] else: user_id = message.reply_to_message.from_user.id user_info = kingbot.get_users(user_id) can_user_ban = kingbot.get_chat_member(chat_id, user_id).can_restrict_members if (can_mute): if (can_user_ban): reply_string = "Can't mute another admin. LOL !" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: kingbot.restrict_chat_member(chat_id, user_id, ChatPermissions(), int(time() + 86400)) if (user_info.username): usercontact = user_info.username reply_string = "@" + usercontact + " has been muted for 24hrs !" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: usercontact = user_info.first_name reply_string = usercontact + " has been muted for 24hrs !" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: reply_string = "Noob,you can't mute members 😂 !" kingbot.edit_message_text(chat_id, msg_id, reply_string)
async def promotte(_, message): msg_id = message.message_id user_id = message.reply_to_message.from_user.id chat_id = message.chat.id can_promote = kingbot.get_chat_member(chat_id, message.user.id).can_promote_members user_info = kingbot.get_users(user_id) usercontact = None if (user_info.username): usercontact = user_info.username else: usercontact = user_info.first_name if (can_promote): chat_msg = message.text title = None if " " in chat_msg: space = chat_msg.index(" ") chat_msg = str(chat_msg) title = chat_msg[space + 1:len(chat_msg)] app.promote_chat_member(chat_id, user_id, can_manage_chat=True, can_delete_messages=True, can_restrict_members=True, can_pin_messages=True, can_manage_voice_chats=True, can_invite_users=True) if (title): kingbot.set_administrator_title(chat_id, user_id, title) if (user_info.username): usercontact = user_info.username reply_string = "@" + usercontact + " has been promoted due to bribe" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: usercontact = user_info.first_name reply_string = usercontact + " has been promoted due to bribe" kingbot.edit_message_text(chat_id, msg_id, reply_string) else: reply_string = "Noob,you are not an admin !" reply_len = len(reply_string) for i in range(reply_len): edit_string = reply_string[0:i + 2] try: kingbot.edit_message_text(chat_id, msg_id, edit_string) except: i = i + 1
def unpin_message(_, message): msg_id=message.message_id chat_id=message.chat.id if message.reply_to_message == None: kingbot.edit_message_text(chat_id , msg_id , "Shall I unpin your head from wall ?") else: if message.chat.type == "private": client.unpin_chat_message(chat_id , msg_id , both_sides=True) kingbot.edit_message_text(chat_id , msg_id , "Done the Job master !") else: can_pin=kingbot.get_chat_member(chat_id , "me").can_pin_messages if can_pin == None: kingbot.edit_message_text(chat_id , msg_id , "Can't pin messages bruh 🥱") else: reply_msg_id=message.reply_to_message.message_id client.unpin_chat_message(chat_id , reply_msg_id) kingbot.edit_message_text(chat_id , msg_id , "Done the Job master !")
def purge(_, message): chat_id=message.chat.id if message.reply_to_message: if message.chat.type == "group": reply_msg_id=message.reply_to_message.message_id current_msg_id=message.message_id can_delete=kingbot.get_chat_member(chat_id , "me").can_delete_messages if can_delete: for msg_id in range(reply_msg_id , current_msg_id ,1): client.delete_messages(chat_id , msg_id) message.reply("All messages purged , no hint left !") else: message.reply("Mistakes can't be deleted by everyone !") else: reply_msg_id=message.reply_to_message.message_id current_msg_id=message.message_id for msg_id in range(reply_msg_id , current_msg_id ,1): kingbot.delete_messages(chat_id , msg_id) message.reply("All messages purged , no hint left !") else: message.reply("Shall I delete your existence ?😌")
def pin_message(_, message): msg_id = message.message_id chat_id = message.chat.id if message.reply_to_message == None: kingbot.edit_message_text(chat_id, msg_id, "Shall I pin your head to wall ?") else: if message.chat.type == "private": reply_msg_id = message.reply_to_message.message_id kingbot.pin_chat_message(chat_id, reply_msg_id, both_sides=True) message.edit_text("Done the Job master !") else: can_pin = kingbot.get_chat_member(chat_id, "me").can_pin_messages if can_pin == None: kingbot.edit_message_text(chat_id, msg_id, "Not a admin bruh 🥱") else: reply_msg_id = message.reply_to_message.message_id kingbot.pin_chat_message(chat_id, reply_msg_id) kingbot.edit_message_text(chat_id, msg_id, "Done the Job master !")