async def startmute(event): xx = await event.eor("`Muting...`") input_ = event.pattern_match.group(1).strip() if input_: try: userid = await event.client.parse_id(input_) except Exception as x: return await xx.edit(str(x)) elif event.reply_to_msg_id: userid = (await event.get_reply_message()).sender_id elif event.is_private: userid = event.chat_id else: return await xx.eor("`Reply to a user or add their userid.`", time=5) chat = await event.get_chat() if "admin_rights" in vars(chat) and vars(chat)["admin_rights"] is not None: if chat.admin_rights.delete_messages is not True: return await xx.eor("`No proper admin rights...`", time=5) elif "creator" not in vars(chat) and not event.is_private: return await xx.eor("`No proper admin rights...`", time=5) if is_muted(event.chat_id, userid): return await xx.eor("`This user is already muted in this chat.`", time=5) mute(event.chat_id, userid) await xx.eor("`Successfully muted...`", time=3)
async def endmute(event): xx = await eor(event, "`Unmuting...`") input = event.pattern_match.group(1) private = bool(event.is_private) if input: if input.isdigit(): try: userid = input except ValueError as x: return await xx.edit(str(x)) else: userid = (await event.client.get_entity(input)).id elif event.reply_to_msg_id: userid = (await event.get_reply_message()).sender_id elif private: userid = event.chat_id else: return await eor(xx, "`Reply to a user or add their userid.`", time=5) chat_id = event.chat_id if not is_muted(chat_id, userid): return await eor(xx, "`This user is not muted in this chat.`", time=3) try: unmute(chat_id, userid) await eor(xx, "`Successfully unmuted...`", time=3) except Exception as e: await eor(xx, "Error: " + f"`{e}`", time=5)
async def startmute(event): xx = await eor(event, "`Muting...`") input = event.pattern_match.group(1) private = bool(event.is_private) if input: if input.isdigit(): try: userid = input except ValueError as x: return await xx.edit(str(x)) else: userid = (await event.client.get_entity(input)).id elif event.reply_to_msg_id: userid = (await event.get_reply_message()).sender_id elif private: userid = event.chat_id else: return await eor(xx, "`Reply to a user or add their userid.`", time=5) chat_id = event.chat_id chat = await event.get_chat() if "admin_rights" in vars(chat) and vars(chat)["admin_rights"] is not None: if chat.admin_rights.delete_messages is not True: return await eor(xx, "`No proper admin rights...`", time=5) elif "creator" not in vars(chat) and not private: return await eor(xx, "`No proper admin rights...`", time=5) if is_muted(chat_id, userid): return await eor(xx, "`This user is already muted in this chat.`", time=5) try: mute(chat_id, userid) await eor(xx, "`Successfully muted...`", time=3) except Exception as e: await eor(xx, "Error: " + f"`{e}`", time=5)
async def endmute(event): xx = await event.eor("`Unmuting...`") input_ = event.pattern_match.group(1).strip() if input_: try: userid = await event.client.parse_id(input_) except Exception as x: return await xx.edit(str(x)) elif event.reply_to_msg_id: userid = (await event.get_reply_message()).sender_id elif event.is_private: userid = event.chat_id else: return await xx.eor("`Reply to a user or add their userid.`", time=5) if not is_muted(event.chat_id, userid): return await xx.eor("`This user is not muted in this chat.`", time=3) unmute(event.chat_id, userid) await xx.eor("`Successfully unmuted...`", time=3)
async def watcher(event): if is_muted(event.chat_id, event.sender_id): await event.delete() if event.via_bot and is_muted(event.chat_id, event.via_bot_id): await event.delete()