azils3/bash
0
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available -9 10• `{i}mute <reply to msg/ user id>`11 Mute user in current chat.12 13• `{i}unmute <reply to msg/ user id>`14 Unmute user in current chat.15 16• `{i}dmute <reply to msg/ user id>`17 Mute user in current chat by deleting msgs.18 19• `{i}undmute <reply to msg/ use id>`20 Unmute dmuted user in current chat.21 22• `{i}tmute <time> <reply to msg/ use id>`23 s- seconds24 m- minutes25 h- hours26 d- days27 Mute user in current chat with time.28"""29from telethon import events30from telethon.utils import get_display_name31 32from pyUltroid.dB.mute_db import is_muted, mute, unmute33from pyUltroid.fns.admins import ban_time34 35from . import asst, eod, get_string, inline_mention, ultroid_bot, ultroid_cmd36 37 38@ultroid_bot.on(events.NewMessage(incoming=True))39async def watcher(event):40 if is_muted(event.chat_id, event.sender_id):41 await event.delete()42 if event.via_bot and is_muted(event.chat_id, event.via_bot_id):43 await event.delete()44 45 46@ultroid_cmd(47 pattern="dmute( (.*)|$)",48)49async def startmute(event):50 xx = await event.eor("`Muting...`")51 if input_ := event.pattern_match.group(1).strip():52 try:53 userid = await event.client.parse_id(input_)54 except Exception as x:55 return await xx.edit(str(x))56 elif event.reply_to_msg_id:57 reply = await event.get_reply_message()58 userid = reply.sender_id59 if reply.out or userid in [ultroid_bot.me.id, asst.me.id]:60 return await xx.eor("`You cannot mute yourself or your assistant bot.`")61 elif event.is_private:62 userid = event.chat_id63 else:64 return await xx.eor("`Reply to a user or add their userid.`", time=5)65 chat = await event.get_chat()66 if "admin_rights" in vars(chat) and vars(chat)["admin_rights"] is not None:67 if not chat.admin_rights.delete_messages:68 return await xx.eor("`No proper admin rights...`", time=5)69 elif "creator" not in vars(chat) and not event.is_private:70 return await xx.eor("`No proper admin rights...`", time=5)71 if is_muted(event.chat_id, userid):72 return await xx.eor("`This user is already muted in this chat.`", time=5)73 mute(event.chat_id, userid)74 await xx.eor("`Successfully muted...`", time=3)75 76 77@ultroid_cmd(78 pattern="undmute( (.*)|$)",79)80async def endmute(event):81 xx = await event.eor("`Unmuting...`")82 if input_ := event.pattern_match.group(1).strip():83 try:84 userid = await event.client.parse_id(input_)85 except Exception as x:86 return await xx.edit(str(x))87 elif event.reply_to_msg_id:88 userid = (await event.get_reply_message()).sender_id89 elif event.is_private:90 userid = event.chat_id91 else:92 return await xx.eor("`Reply to a user or add their userid.`", time=5)93 if not is_muted(event.chat_id, userid):94 return await xx.eor("`This user is not muted in this chat.`", time=3)95 unmute(event.chat_id, userid)96 await xx.eor("`Successfully unmuted...`", time=3)97 98 99@ultroid_cmd(100 pattern="tmute",101 groups_only=True,102 manager=True,103)104async def _(e):105 xx = await e.eor("`Muting...`")106 huh = e.text.split()107 try:108 tme = huh[1]109 except IndexError:110 return await xx.eor("`Time till mute?`", time=5)111 try:112 input_ = huh[2]113 except IndexError:114 input_ = ""115 chat = await e.get_chat()116 if e.reply_to_msg_id:117 reply = await e.get_reply_message()118 userid = reply.sender_id119 name = (await reply.get_sender()).first_name120 elif input_:121 userid = await e.client.parse_id(input_)122 name = (await e.client.get_entity(userid)).first_name123 else:124 return await xx.eor(get_string("tban_1"), time=3)125 if userid == ultroid_bot.uid:126 return await xx.eor("`I can't mute myself.`", time=3)127 try:128 bun = ban_time(tme)129 await e.client.edit_permissions(130 chat.id,131 userid,132 until_date=bun,133 send_messages=False,134 )135 await eod(136 xx,137 f"`Successfully Muted` [{name}](tg://user?id={userid}) `in {chat.title} for {tme}`",138 time=5,139 )140 except BaseException as m:141 await xx.eor(f"`{m}`", time=5)142 143 144@ultroid_cmd(145 pattern="unmute( (.*)|$)",146 admins_only=True,147 manager=True,148)149async def _(e):150 xx = await e.eor("`Unmuting...`")151 input = e.pattern_match.group(1).strip()152 chat = await e.get_chat()153 if e.reply_to_msg_id:154 reply = await e.get_reply_message()155 userid = reply.sender_id156 name = (await reply.get_sender()).first_name157 elif input:158 userid = await e.client.parse_id(input)159 name = (await e.client.get_entity(userid)).first_name160 else:161 return await xx.eor(get_string("tban_1"), time=3)162 try:163 await e.client.edit_permissions(164 chat.id,165 userid,166 until_date=None,167 send_messages=True,168 )169 await eod(170 xx,171 f"`Successfully Unmuted` [{name}](tg://user?id={userid}) `in {chat.title}`",172 time=5,173 )174 except BaseException as m:175 await xx.eor(f"`{m}`", time=5)176 177 178@ultroid_cmd(179 pattern="mute( (.*)|$)", admins_only=True, manager=True, require="ban_users"180)181async def _(e):182 xx = await e.eor("`Muting...`")183 input = e.pattern_match.group(1).strip()184 chat = await e.get_chat()185 if e.reply_to_msg_id:186 userid = (await e.get_reply_message()).sender_id187 name = get_display_name(await e.client.get_entity(userid))188 elif input:189 try:190 userid = await e.client.parse_id(input)191 name = inline_mention(await e.client.get_entity(userid))192 except Exception as x:193 return await xx.edit(str(x))194 else:195 return await xx.eor(get_string("tban_1"), time=3)196 if userid == ultroid_bot.uid:197 return await xx.eor("`I can't mute myself.`", time=3)198 try:199 await e.client.edit_permissions(200 chat.id,201 userid,202 until_date=None,203 send_messages=False,204 )205 await eod(206 xx,207 f"`Successfully Muted` {name} `in {chat.title}`",208 )209 except BaseException as m:210 await xx.eor(f"`{m}`", time=5)211 