async def unmoot(unmot): if unmot.fwd_from: return # """ For .unmute command, unmute the replied/tagged person """ # Admin or creator check chat = await unmot.get_chat() admin = chat.admin_rights creator = chat.creator # If not admin and not creator, return if not admin and not creator: await unmot.edit(NO_ADMIN) return # Check if the function running under SQL mode try: from userbot.plugins.sql_helper.spam_mute_sql import unmute except AttributeError: await unmot.edit(NO_SQL) return # If admin or creator, inform the user and start unmuting await unmot.edit("```Unmuting...```") user = await get_user_from_event(unmot) user = user[0] if user: pass else: return if unmute(unmot.chat_id, user.id) is False: return await unmot.edit("`Error! User probably already unmuted.`") else: try: await unmot.client( EditBannedRequest(unmot.chat_id, user.id, UNBAN_RIGHTS)) await unmot.edit("```Unmuted Successfully```") except UserIdInvalidError: await unmot.edit("`Uh oh my unmute logic broke!`") return if BOTLOG: await unmot.client.send_message( BOTLOG_CHATID, "#UNMUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {unmot.chat.title}(`{unmot.chat_id}`)", )
async def unmute(eventUnMute): if not eventUnMute.text[0].isalpha() and eventUnMute.text[0] \ not in ("/", "#", "@", "!"): chat = await eventUnMute.get_chat() admin = chat.admin_rights creator = chat.creator if not admin and not creator: await eventUnMute.edit("`I am not an admin!`") return try: from userbot.plugins.sql_helper.spam_mute_sql import unmute except AttributeError: await eventUnMute.edit("`Running on Non-SQL mode!`") return await eventUnMute.edit('```Unmuting...```') user = await get_user_from_event(eventUnMute) if user: pass else: return if unmute(eventUnMute.chat_id, user.id) is False: return await eventUnMute.edit( "`Error! User probably already unmuted.`") else: try: await eventUnMute.client( EditBannedRequest(eventUnMute.chat_id, user.id, UNBAN_RIGHTS)) await eventUnMute.edit("```Unmuted Successfully```") except UserIdInvalidError: await eventUnMute.edit("`Uh oh my unmute logic broke!`") return if ENABLE_LOG: await eventUnMute.client.send_message( LOGGING_CHATID, "#UNMUTE\n" f"USER: [{user.first_name}](tg://user?id={user.id})\n" f"CHAT: {eventUnMute.chat.title}(`{eventUnMute.chat_id}`)")