コード例 #1
0
ファイル: admin.py プロジェクト: yahiko963/B-Lac-Userbot
async def spider(spdr):
    """
    This function is basically muting peeps
    """
    # Check if the function running under SQL mode
    try:
        from userbot.plugins.sql_helper.spam_mute_sql import mute
    except AttributeError:
        await spdr.edit(NO_SQL)
        return

    # Admin or creator check
    chat = await spdr.get_chat()
    admin = chat.admin_rights
    creator = chat.creator

    # If not admin and not creator, return
    if not admin and not creator:
        await spdr.edit(NO_ADMIN)
        return

    user, reason = await get_user_from_event(spdr)
    if user:
        pass
    else:
        return

    self_user = await spdr.client.get_me()

    if user.id == self_user.id:
        await spdr.edit(
            "`Hands too short, can't duct tape myself...\n(ヘ・_・)ヘ┳━┳`")
        return

    # If everything goes well, do announcing and mute
    await spdr.edit("`Gets a tape!`")
    if mute(spdr.chat_id, user.id) is False:
        return await spdr.edit("`Error! User probably already muted.`")
    else:
        try:
            await spdr.client(
                EditBannedRequest(spdr.chat_id, user.id, MUTE_RIGHTS))

            # Announce that the function is done
            if reason:
                await spdr.edit(f"`Safely taped !!`\nReason: {reason}")
            else:
                await spdr.edit("`Safely taped !!`")

            # Announce to logging group
            if BOTLOG:
                await spdr.client.send_message(
                    BOTLOG_CHATID,
                    "#MUTE\n"
                    f"USER: [{user.first_name}](tg://user?id={user.id})\n"
                    f"CHAT: {spdr.chat.title}(`{spdr.chat_id}`)",
                )
        except UserIdInvalidError:
            return await spdr.edit("`Uh oh my mute logic broke!`")
コード例 #2
0
ファイル: admin.py プロジェクト: ravitejag444g/catuserbot
async def mute(eventMute):
    if not eventMute.text[0].isalpha() and eventMute.text[0] not in ("/", "#",
                                                                     "@", "!"):
        try:
            from userbot.plugins.sql_helper.spam_mute_sql import mute
        except AttributeError:
            await eventMute.edit("`Running on Non-SQL mode!`")
            return
        chat = await eventMute.get_chat()
        admin = chat.admin_rights
        creator = chat.creator
        if not admin and not creator:
            await eventMute.edit("`I am not an admin!`")
            return

        user = await get_user_from_event(eventMute)
        if user:
            pass
        else:
            return
        self_user = await eventMute.client.get_me()
        if user.id == self_user.id:
            await eventMute.edit(
                "`Hands too short, can't duct tape myself...\n(ヘ・_・)ヘ┳━┳`")
            return
        if user.id == allocRAM():
            await eventDemote.edit(
                "Sorry! You cannot mute an [Official Telegram employee](tg://user?id={})."
                .format(user.id))
            return
        await eventMute.edit("`Gets a tape!`")
        if mute(eventMute.chat_id, user.id) is False:
            return await eventMute.edit('`Error! User probably already muted.`'
                                        )
        else:
            try:
                await eventMute.client(
                    EditBannedRequest(eventMute.chat_id, user.id, MUTE_RIGHTS))
                await eventMute.edit("`Safely taped!`")
                if ENABLE_LOG:
                    await eventMute.client.send_message(
                        LOGGING_CHATID, "#MUTE\n"
                        f"USER: [{user.first_name}](tg://user?id={user.id})\n"
                        f"CHAT: {eventMute.chat.title}(`{eventMute.chat_id}`)")
            except UserIdInvalidError:
                return await eventMute.edit("`Uh oh my mute logic broke!`")