Пример #1
0
async def startmute(event):
    xx = await eor(event, "`Muting...`")
    private = False
    if event.is_private:
        private = True
    if event.pattern_match.group(1):
        userid = int(event.pattern_match.group(1))
    elif event.reply_to_msg_id:
        userid = (await event.get_reply_message()).sender_id
    elif private is True:
        userid = event.chat_id
    else:
        return await eod(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 True:
            pass
        else:
            return await eor(xx, "`No proper admin rights...`", time=5)
    elif "creator" in vars(chat):
        pass
    elif private == True:
        pass
    else:
        return await eod(xx, "`No proper admin rights...`", time=5)
    if is_muted(f"{userid}_{chat_id}"):
        return await eod(xx,
                         "`This user is already muted in this chat.`",
                         time=5)
    try:
        mute(f"{userid}_{chat_id}")
        await eod(xx, "`Successfully muted...`", time=3)
    except Exception as e:
        await eod(xx, "Error: " + f"`{str(e)}`")
Пример #2
0
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)