Esempio n. 1
0
async def chat_unlock(unlock):
    # Admin or creator check
    chat = await unlock.get_chat()
    admin = chat.admin_rights
    creator = chat.creator

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

    await unlock.edit("`Unlocking...`")

    try:
        await unlock.client(
            EditChatDefaultBannedRightsRequest(unlock.chat_id,
                                               CHATUNLOCK_RIGHTS))
        await unlock.edit("`Unlocked!`")
    except ChatNotModifiedError:
        await unlock.edit("`Chat already unlocked`")

    if BOTLOG:
        await unlock.client.send_message(
            BOTLOG_CHATID, "#UNLOCK\n"
            f"CHAT: {unlock.chat.title}(`{unlock.chat_id}`)")
Esempio n. 2
0
async def lock(client: Client, event: Command) -> MDTeXDocument:
    """Set a chat to read only.

    Arguments:
        `-self`: Use to make other Kantek instances ignore your command

    Examples:
        {cmd}
    """
    chat: InputPeerChannel = await event.get_input_chat()
    try:
        await client(
            EditChatDefaultBannedRightsRequest(chat,
                                               banned_rights=ChatBannedRights(
                                                   until_date=None,
                                                   view_messages=None,
                                                   send_messages=True,
                                                   send_media=True,
                                                   send_stickers=True,
                                                   send_gifs=True,
                                                   send_games=True,
                                                   send_inline=True,
                                                   send_polls=True,
                                                   change_info=True,
                                                   invite_users=True,
                                                   pin_messages=True)))
        return MDTeXDocument('Chat locked.')
    except ChatNotModifiedError:
        return MDTeXDocument('Chat already locked.')
Esempio n. 3
0
async def emergency_lock(lock):
    """For emergency-locking a chat"""
    # Admin or creator check
    chat = await lock.get_chat()
    admin = chat.admin_rights
    creator = chat.creator

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

    await lock.edit("`Locking...`")

    try:
        await lock.client(
            EditChatDefaultBannedRightsRequest(lock.chat_id, CHATLOCK_RIGHTS))
        await lock.edit("`Locked!`")
    except ChatNotModifiedError:
        await lock.edit("`Chat has already been locked!`")

    if BOTLOG:
        await lock.client.send_message(
            BOTLOG_CHATID, "#LOCK\n"
            f"CHAT: {lock.chat.title}(`{lock.chat_id}`)")
Esempio n. 4
0
async def locks(event):
    if not event.text[0].isalpha() and event.text[0] not in ("/", "#", "@",
                                                             "!"):
        input_str = event.pattern_match.group(1)
        peer_id = event.chat_id
        msg = None
        media = None
        sticker = None
        gif = None
        gamee = None
        ainline = None
        gpoll = None
        adduser = None
        cpin = None
        changeinfo = None
        if "msg" in input_str:
            msg = True
        if "media" in input_str:
            media = True
        if "sticker" in input_str:
            sticker = True
        if "gif" in input_str:
            gif = True
        if "game" in input_str:
            gamee = True
        if "inline" in input_str:
            ainline = True
        if "poll" in input_str:
            gpoll = True
        if "invite" in input_str:
            adduser = True
        if "pin" in input_str:
            cpin = True
        if "info" in input_str:
            changeinfo = True
        banned_rights = ChatBannedRights(
            until_date=None,
            send_messages=msg,
            send_media=media,
            send_stickers=sticker,
            send_gifs=gif,
            send_games=gamee,
            send_inline=ainline,
            send_polls=gpoll,
            invite_users=adduser,
            pin_messages=cpin,
            change_info=changeinfo,
        )
        try:
            result = await event.client(
                EditChatDefaultBannedRightsRequest(peer=peer_id,
                                                   banned_rights=banned_rights)
            )
        except Exception as e:
            await event.edit(str(e))
        else:
            await sleep(5)
            await event.delete()
Esempio n. 5
0
async def unlckho(e):
    mat = e.pattern_match.group(1)
    if not mat:
        return await eor(e, "`Give some Proper Input..`", time=5)
    ml = unlucks(mat)
    if not ml:
        return await eor(e, "`Incorrect Input`", time=5)
    await e.client(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
    await eor(e, f"Unlocked - `{mat}` ! ")
Esempio n. 6
0
async def unlckho(e):
    mat = e.pattern_match.group(1)
    if not mat:
        return await eod(e, "`What to Lock  ?`")
    try:
        ml = unlucks(mat)
    except BaseException:
        return await eod(e, "`Incorrect Input`")
    await ultroid_bot(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
    await eor(e, f"Unlocked - `{mat}` ! ")
Esempio n. 7
0
async def lockho(e):
    mat = e.pattern_match.group(1)
    if not mat:
        return await eod(e, "`Give some Proper Input..`")
    try:
        ml = lucks(mat)
    except BaseException:
        return await eod(e, "`Incorrect Input`")
    await e.client(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
    await eor(e, f"Locked - `{mat}` ! ")
Esempio n. 8
0
async def un_lock(e):
    mat = e.pattern_match.group(2).strip()
    if not mat:
        return await e.eor("`Give some Proper Input..`", time=5)
    lock = e.pattern_match.group(1) == ""
    ml = lock_unlock(mat, lock)
    if not ml:
        return await e.eor("`Incorrect Input`", time=5)
    msg = "Locked" if lock else "Unlocked"
    try:
        await e.client(EditChatDefaultBannedRightsRequest(e.chat_id, ml))
    except Exception as er:
        return await e.eor(str(er))
    await e.eor(f"**{msg}** - `{mat}` ! ")
Esempio n. 9
0
async def close_grp():
    chats = night_grps()
    h1, m1, h2, m2 = 0, 0, 7, 0
    if udB.get("NIGHT_TIME"):
        h1, m1, h2, m2 = eval(udB["NIGHT_TIME"])
    for chat in chats:
        try:
            await ultroid_bot(
                EditChatDefaultBannedRightsRequest(
                    chat,
                    banned_rights=ChatBannedRights(
                        until_date=None,
                        send_messages=True,
                    ),
                )
            )
            await ultroid_bot.send_message(
                chat, f"**NightMode : Group Closed**\n\nGroup Will Open At `{h2}:{m2}`"
            )
        except Exception as er:
            LOGS.info(er)
Esempio n. 10
0
async def open_grp():
    chats = night_grps()
    for chat in chats:
        try:
            await ultroid_bot(
                EditChatDefaultBannedRightsRequest(
                    chat,
                    banned_rights=ChatBannedRights(
                        until_date=None,
                        send_messages=False,
                        send_media=False,
                        send_stickers=False,
                        send_gifs=False,
                        send_games=False,
                        send_inline=False,
                        send_polls=False,
                    ),
                )
            )
            await ultroid_bot.send_message(chat, "**NightMode Off**\n\nGroup Opened 🥳.")
        except Exception as er:
            LOGS.info(er)
Esempio n. 11
0
async def unlock(client: Client, db: Database, chat, event: Command, msg: Message) -> KanTeXDocument:
    """Restore a chats previous permissions

    Arguments:
        `-self`: Use to make other Kantek instances ignore your command

    Examples:
        {cmd}
    """
    participant = (await client(GetParticipantRequest(chat, msg.sender_id))).participant
    permitted = False
    if isinstance(participant, ChannelParticipantCreator):
        permitted = True
    elif isinstance(participant, ChannelParticipantAdmin):
        rights = participant.admin_rights
        permitted = rights.ban_users
    if not permitted:
        return KanTeXDocument('Insufficient permission.')
    dbchat = await db.chats.get(event.chat_id)
    permissions = chat.default_banned_rights.to_dict()
    del permissions['_']
    if dbchat.locked:
        new_rights = permissions.copy()

        for k, v in dbchat.permissions.items():
            new_rights[k] = v
        try:
            await client(EditChatDefaultBannedRightsRequest(
                chat,
                banned_rights=ChatBannedRights(**new_rights)))
        except ChatNotModifiedError:
            pass
        await db.chats.unlock(event.chat_id)
        return KanTeXDocument('Chat unlocked.')
    else:
        return KanTeXDocument('Chat not locked.')
Esempio n. 12
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    peer_id = event.chat_id
    if input_str in (("bots", "commands", "email", "forward", "url")):
        update_lock(peer_id, input_str, False)
        await edit_or_reply(event, "`UnLocked {}`".format(input_str))
    else:
        msg = None
        media = None
        sticker = None
        gif = None
        gamee = None
        ainline = None
        gpoll = None
        adduser = None
        cpin = None
        changeinfo = None
        if input_str == "msg":
            msg = False
            locktype = "messages"
        elif input_str == "media":
            media = False
            locktype = "media"
        elif input_str == "sticker":
            sticker = False
            locktype = "stickers"
        elif input_str == "gif":
            gif = False
            locktype = "GIFs"
        elif input_str == "game":
            gamee = False
            locktype = "games"
        elif input_str == "inline":
            ainline = False
            locktype = "inline bots"
        elif input_str == "poll":
            gpoll = False
            locktype = "polls"
        elif input_str == "invite":
            adduser = False
            locktype = "invites"
        elif input_str == "pin":
            cpin = False
            locktype = "pins"
        elif input_str == "info":
            changeinfo = False
            locktype = "chat info"
        elif input_str == "all":
            msg = False
            media = False
            sticker = False
            gif = False
            gamee = False
            ainline = False
            gpoll = False
            adduser = False
            cpin = False
            changeinfo = False
            locktype = "everything"
        else:
            if not input_str:
                return await edit_or_reply(event,
                                           "`I can't unlock nothing !!`")
            else:
                return await edit_delete(event,
                                         f"`Invalid unlock type:` {input_str}",
                                         time=5)

        unlock_rights = ChatBannedRights(
            until_date=None,
            send_messages=msg,
            send_media=media,
            send_stickers=sticker,
            send_gifs=gif,
            send_games=gamee,
            send_inline=ainline,
            send_polls=gpoll,
            invite_users=adduser,
            pin_messages=cpin,
            change_info=changeinfo,
        )
        try:
            await event.client(
                EditChatDefaultBannedRightsRequest(peer=peer_id,
                                                   banned_rights=unlock_rights)
            )
            await edit_or_reply(event,
                                f"`Unlocked {locktype} for this chat !!`")
        except BaseException as e:
            return await edit_delete(
                event,
                f"`Do I have proper rights for that ??`\n**Error:** {str(e)}",
                time=5,
            )
Esempio n. 13
0
async def rem_locks(event):
    if not event.is_group:
        return
    if event.is_group:
        if not await can_change_info(message=event):
            print("not enough perms")
            return
    input_str = event.pattern_match.group(1).lower()
    # print(input_str)
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    emlink = None
    changeinfo = None
    if input_str == "msg":
        msg = False
        what = "messages"
    elif input_str == "media":
        media = False
        what = "media"
    elif input_str == "sticker":
        sticker = False
        what = "stickers"
    elif input_str == "gif":
        gif = False
        what = "GIFs"
    elif input_str == "game":
        gamee = False
        what = "games"
    elif input_str == "inline":
        ainline = False
        what = "inline bots"
    elif input_str == "poll":
        gpoll = False
        what = "polls"
    elif input_str == "invite":
        adduser = False
        what = "invites"
    elif input_str == "pin":
        cpin = False
        what = "pins"
    elif input_str == "url":
        emlink = False
        what = "url links"
    elif input_str == "info":
        changeinfo = False
        what = "chat info"
    elif input_str == "all":
        msg = False
        media = False
        sticker = False
        gif = False
        gamee = False
        emlink = False
        ainline = False
        gpoll = False
        adduser = False
        cpin = False
        changeinfo = False
        what = "everything"
    else:
        if not input_str:
            await event.reply("I can't unlock nothing !!")
            return
        await event.reply(f"Invalid unlock type: {input_str}")
        return

    unlock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        embed_links=emlink,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )

    # print(input_str)
    # print (unlock_rights)
    try:
        await tbot(
            EditChatDefaultBannedRightsRequest(
                event.chat_id, banned_rights=unlock_rights
            )
        )
        await event.reply(f"Unlocked Successfully !")
    except Exception:
        await event.reply("Failed to unlock.")
        return
Esempio n. 14
0
async def rem_locks(event):
    input_str = event.text.split(" ")[1]
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = False
        what = "messages"
    elif input_str == "media":
        media = False
        what = "media"
    elif input_str == "sticker":
        sticker = False
        what = "stickers"
    elif input_str == "gif":
        gif = False
        what = "GIFs"
    elif input_str == "game":
        gamee = False
        what = "games"
    elif input_str == "inline":
        ainline = False
        what = "inline bots"
    elif input_str == "poll":
        gpoll = False
        what = "polls"
    elif input_str == "invite":
        adduser = False
        what = "invites"
    elif input_str == "pin":
        cpin = False
        what = "pins"
    elif input_str == "info":
        changeinfo = False
        what = "chat info"
    elif input_str == "all":
        msg = False
        media = False
        sticker = False
        gif = False
        gamee = False
        ainline = False
        gpoll = False
        adduser = False
        cpin = False
        changeinfo = False
        what = "everything"
    else:
        if not input_str:
            await event.edit("I can't unlock nothing!")
            return
        else:
            await event.edit(f"Invalid unlock type: `{input_str}`")
            return

    unlock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=unlock_rights))
        await event.edit(f"Unlocked {what} for this chat!")
    except BaseException as e:
        await event.edit(
            f"Do I have proper rights for that?\n**Error:** `{str(e)}`")
        return
Esempio n. 15
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "messages"
    elif input_str == "media":
        media = True
        what = "media"
    elif input_str == "sticker":
        sticker = True
        what = "stickers"
    elif input_str == "gif":
        gif = True
        what = "GIFs"
    elif input_str == "game":
        gamee = True
        what = "games"
    elif input_str == "inline":
        ainline = True
        what = "inline bots"
    elif input_str == "poll":
        gpoll = True
        what = "polls"
    elif input_str == "invite":
        adduser = True
        what = "invites"
    elif input_str == "pin":
        cpin = True
        what = "pins"
    elif input_str == "info":
        changeinfo = True
        what = "chat info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "everything"
    else:
        if not input_str:
            await event.edit("`Hiçliği kilitleyemem dostum!`")
            return
        else:
            await event.edit(f"`Geçersiz medya tipi:` {input_str}")
            return

    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=lock_rights))
        await event.edit(f"`{what} bu sohbet için kilitlendi!`")
    except BaseException as e:
        await event.edit(
            f"`Bunun için gerekli haklara sahip olduğuna emin misin?`\n**Hata:** {str(e)}"
        )
        return
Esempio n. 16
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "Pesan"
    elif input_str == "media":
        media = True
        what = "Media"
    elif input_str == "sticker":
        sticker = True
        what = "Sticker"
    elif input_str == "gif":
        gif = True
        what = "GIF"
    elif input_str == "game":
        gamee = True
        what = "Game"
    elif input_str == "inline":
        ainline = True
        what = "Inline Bot"
    elif input_str == "poll":
        gpoll = True
        what = "Poll"
    elif input_str == "invite":
        adduser = True
        what = "Invite"
    elif input_str == "pin":
        cpin = True
        what = "Pin"
    elif input_str == "info":
        changeinfo = True
        what = "Info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "Semuanya"
    else:
        if not input_str:
            await event.edit("`Mohon Maaf, Apa Yang Harus Saya Kunci? ヅ`")
            return
        else:
            await event.edit(f"`Jenis Yang Mau Anda Kunci Tidak Valid` `{input_str}`")
            return

    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=lock_rights))
        await event.edit(f"`Lord Telah Mengunci {what} Untuk Obrolan Ini ヅ`")
    except BaseException as e:
        await event.edit(
            f"`Apakah Anda Mempunyai Izin Melakukan Itu Disini?`\n**Kesalahan:** {str(e)}")
        return
Esempio n. 17
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "messages"
    elif input_str == "media":
        media = True
        what = "media"
    elif input_str == "sticker":
        sticker = True
        what = "stickers"
    elif input_str == "gif":
        gif = True
        what = "GIFs"
    elif input_str == "game":
        gamee = True
        what = "games"
    elif input_str == "inline":
        ainline = True
        what = "inline bots"
    elif input_str == "poll":
        gpoll = True
        what = "polls"
    elif input_str == "invite":
        adduser = True
        what = "invites"
    elif input_str == "pin":
        cpin = True
        what = "pins"
    elif input_str == "info":
        changeinfo = True
        what = "chat info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "everything"
    else:
        if not input_str:
            await edit_or_reply(event, "`Need something to lock sur!!`🚶")
            return
        else:
            await edit_or_reply(event, f"🤐 `Invalid lock type:` {input_str}")
            return

    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id, banned_rights=lock_rights)
        )
        await edit_or_reply(event, f"[{DEFAULTUSER}](tg://user?id={kraken}) Locked `{what}` \n__Cause its Rest Time Nimba!!__")
    except BaseException as e:
        await edit_or_reply(event, f"`Do I have proper rights for that ??`\n**Error:** {str(e)}")
        return
Esempio n. 18
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "Pesan"
    elif input_str == "media":
        media = True
        what = "Media"
    elif input_str == "sticker":
        sticker = True
        what = "Sticker"
    elif input_str == "gif":
        gif = True
        what = "GIF"
    elif input_str == "game":
        gamee = True
        what = "Game"
    elif input_str == "inline":
        ainline = True
        what = "Inline Bot"
    elif input_str == "poll":
        gpoll = True
        what = "Poll"
    elif input_str == "invite":
        adduser = True
        what = "Invite"
    elif input_str == "pin":
        cpin = True
        what = "Pin"
    elif input_str == "info":
        changeinfo = True
        what = "Info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "Semuanya"
    else:
        if not input_str:
            await edit_or_reply(event, "**Apa Yang Harus Saya Kunci?**")
        else:
            await edit_or_reply(
                event, f"**Jenis Yang Mau Anda Kunci Tidak Valid** `{input_str}`"
            )
        return
    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    me = await event.client.get_me()
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id, banned_rights=lock_rights)
        )
        await edit_or_reply(
            event, f"**{me.first_name} Telah Mengunci {what} Untuk Obrolan Ini!!**"
        )
    except BaseException as e:
        await edit_or_reply(event, f"**ERROR:** {e}")

        return
Esempio n. 19
0
async def lk(event):
 input_str = event.pattern_match.group(1)
 msg = None
 media = None
 sticker = None
 gif = None
 gamee = None
 ainline = None
 gpoll = None
 adduser = None
 cpin = None
 emlink = None
 changeinfo = None
 if input_str == "message" or input_str == "msg":
    msg = True
 elif input_str == "media":
    media = True
 elif input_str == "sticker":
    sticker = True
 elif input_str == "gif" or input_str == "gifs":
    gif = True
 elif input_str == "game" or input_str == "games":
    gamee = True
 elif input_str == "inline":
    ainline = True
 elif input_str == "poll":
    gpoll = True
 elif input_str == "invite":
    adduser = True
 elif input_str == "pin":
    cpin = True   
 elif input_str == "url":
    emlink = True
 elif input_str == "info":
    changeinfo = True
 elif input_str == "all":
    msg = True
    media = True
    sticker = True
    gif = True
    gamee = True
    ainline = True
    emlink = True
    gpoll = True
    adduser = True
    cpin = True
    changeinfo = True
 elif input_str in addon:
  forward = False
  command = False
  audio = False
  video = False
  phone = False
  location = False
  email = False
  comment = False
  if input_str == "forward":
     forward = True
  elif input_str == "command":
     command = True
  elif input_str == "phone":
     phone = True
  elif input_str == "audio":
     audio = True
  elif input_str == "video":
     video = True
  elif input_str == "location":
     location = True
  elif input_str == "email":
     email = True
  elif input_str == "comment":
     comment = True
  chats = lock.find({})
  cid = None
  for c in chats:
     if event.chat_id == c["id"]:
        cid = c["id"]
  if cid:
    to_check = get_chat(id=event.chat_id)
    lock.update_one(
                {
                    "_id": to_check["_id"],
                    "id": to_check["id"],
                    "forward": to_check["forward"],
                    "command": to_check["command"],
                    "phone": to_check["phone"],
                    "video": to_check["video"],
                    "audio": to_check["audio"],
                    "location": to_check["location"],
                    "email": to_check["email"],
                    "comment": to_check["comment"],
                },
                {"$set": {"forward": forward, "command": command, "phone": phone, "video": video, "audio": audio, "location": location, "email": email, "comment": comment}},
            )
    return await event.reply(f"Locked `{input_str}`")
  lock.insert_one(
        {"id": event.chat_id, "forward": forward, "command": command, "phone": phone, "video": video, "audio": audio, "location": location, "email": email, "comment": comment}
     )
  return await event.reply(f"Locked `{input_str}`")
 elif input_str == None:
   return await event.reply("You haven't specified a type to lock.")
 else:
   return await event.reply(f"Unknown lock types:\n- {input_str}\nCheck /locktypes!")
 lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        embed_links=emlink,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
 if await is_admin(event, BOT_ID):
  await event.reply(f"Locked `{input_str}`.")
  await tbot(
            EditChatDefaultBannedRightsRequest(event.chat_id, banned_rights=lock_rights)
        )
Esempio n. 20
0
async def rem_locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = False
        what = "Pesan"
    elif input_str == "media":
        media = False
        what = "Media"
    elif input_str == "sticker":
        sticker = False
        what = "Stiker"
    elif input_str == "gif":
        gif = False
        what = "GIF"
    elif input_str == "game":
        gamee = False
        what = "Game"
    elif input_str == "inline":
        ainline = False
        what = "Inline bots"
    elif input_str == "poll":
        gpoll = False
        what = "Jajak pendapat"
    elif input_str == "invite":
        adduser = False
        what = "Mengundang"
    elif input_str == "pin":
        cpin = False
        what = "Sematkan"
    elif input_str == "info":
        changeinfo = False
        what = "Info obrolan"
    elif input_str == "all":
        msg = False
        media = False
        sticker = False
        gif = False
        gamee = False
        ainline = False
        gpoll = False
        adduser = False
        cpin = False
        changeinfo = False
        what = "Semua"
    else:
        if not input_str:
            return await event.edit("`Saya tidak bisa membuka kunci apa pun!`")
        else:
            return await event.edit(
                f"`Jenis buka kunci tidak valid :` {input_str}")

    unlock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=unlock_rights))
        await event.edit(f"**{what}**  `tidak lagi dikunci untuk obrolan ini!`"
                         )
    except BaseException as e:
        return await event.edit(
            f"`Apakah saya memiliki hak yang layak untuk itu?`\n**Kesalahan** : {str(e)}"
        )
Esempio n. 21
0
async def locks(event):
    if not event.text[0].isalpha() and event.text[0] not in ("/", "#", "@",
                                                             "!"):
        input_str = event.pattern_match.group(1)
        peer_id = event.chat_id
        msg = None
        media = None
        sticker = None
        gif = None
        gamee = None
        ainline = None
        gpoll = None
        adduser = None
        cpin = None
        changeinfo = None
        if input_str.lower() == "msg":
            msg = True
            what = "messages"
        elif input_str.lower() == "media":
            media = True
            what = "media"
        elif input_str.lower() == "sticker":
            sticker = True
            what = "stickers"
        elif input_str.lower() == "gif":
            gif = True
            what = "GIFs"
        elif input_str.lower() == "game":
            gamee = True
            what = "games"
        elif input_str.lower() == "inline":
            ainline = True
            what = "inline bots"
        elif input_str.lower() == "poll":
            gpoll = True
            what = "polls"
        elif input_str.lower() == "invite":
            adduser = True
            what = "invites"
        elif input_str.lower() == "pin":
            cpin = True
            what = "pins"
        elif input_str.lower() == "info":
            changeinfo = True
            what = "chat info"
        elif input_str.lower() == "all":
            msg = True
            media = True
            sticker = True
            gif = True
            gamee = True
            ainline = True
            gpoll = True
            adduser = True
            cpin = True
            changeinfo = True
            what = "everything"
        else:
            if not input_str:
                await event.edit("`I can't lock nothing !!`")
                return
            else:
                await event.edit(f"`Invalid lock type:` {input_str}")
                return

        lock_rights = ChatBannedRights(
            until_date=None,
            send_messages=msg,
            send_media=media,
            send_stickers=sticker,
            send_gifs=gif,
            send_games=gamee,
            send_inline=ainline,
            send_polls=gpoll,
            invite_users=adduser,
            pin_messages=cpin,
            change_info=changeinfo,
        )
        try:
            await event.client(
                EditChatDefaultBannedRightsRequest(peer=peer_id,
                                                   banned_rights=lock_rights))
            await event.edit(f"`Locked {what} for this chat !!`")
        except BaseException as e:
            await event.edit(
                f"`Do I have proper rights for that ??`\n**Error:** {str(e)}")
            return
Esempio n. 22
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "messages"
    elif input_str == "media":
        media = True
        what = "media"
    elif input_str == "sticker":
        sticker = True
        what = "stickers"
    elif input_str == "gif":
        gif = True
        what = "GIFs"
    elif input_str == "game":
        gamee = True
        what = "games"
    elif input_str == "inline":
        ainline = True
        what = "inline bots"
    elif input_str == "poll":
        gpoll = True
        what = "polls"
    elif input_str == "invite":
        adduser = True
        what = "invites"
    elif input_str == "pin":
        cpin = True
        what = "pins"
    elif input_str == "info":
        changeinfo = True
        what = "chat info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "everything"
    else:
        if not input_str:
            await event.edit("`Saya tidak bisa mengunci apa pun !!`")
            return
        else:
            await event.edit(f"`Jenis kunci tidak valid:` {input_str}")
            return

    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id, banned_rights=lock_rights)
        )
        await event.edit(f"`Mengunci {what} untuk obrolan ini !!`")
    except BaseException as e:
        await event.edit(f"`Apakah saya memiliki hak yang tepat untuk itu??`\n**Error:** {str(e)}")
        return
Esempio n. 23
0
async def rem_locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = False
        what = "Pesan"
    elif input_str == "media":
        media = False
        what = "Media"
    elif input_str == "sticker":
        sticker = False
        what = "Sticker"
    elif input_str == "gif":
        gif = False
        what = "GIF"
    elif input_str == "game":
        gamee = False
        what = "Game"
    elif input_str == "inline":
        ainline = False
        what = "Inline"
    elif input_str == "poll":
        gpoll = False
        what = "Poll"
    elif input_str == "invite":
        adduser = False
        what = "Invite"
    elif input_str == "pin":
        cpin = False
        what = "Pin"
    elif input_str == "info":
        changeinfo = False
        what = "Info"
    elif input_str == "all":
        msg = False
        media = False
        sticker = False
        gif = False
        gamee = False
        ainline = False
        gpoll = False
        adduser = False
        cpin = False
        changeinfo = False
        what = "Semuanya"
    else:
        if not input_str:
            await event.edit("`Apa Yang Harus Saya Buka?`")
        else:
            await event.edit(
                f"`Jenis Kunci Yang Mau Anda Buka Tidak Valid` `{input_str}`")
        return
    unlock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=unlock_rights))
        await event.edit(
            f"`{ALIVE_NAME} Telah Membuka Kunci {what} Untuk Obrolan Ini!!`")
    except BaseException as e:
        await event.edit(
            f"`Apakah {ALIVE_NAME} Mempunyai Izin Melakukan Itu Disini?`\n**ERROR:** {str(e)}"
        )
        return
Esempio n. 24
0
async def lock(client: Client, db: Database, chat: Chat, event: Command,
               msg: Message, args) -> KanTeXDocument:
    """Set a chat to read only.

    Arguments:
        `duration`: How long the chat should be locked
        `-self`: Use to make other Kantek instances ignore your command

    Examples:
        {cmd} 2h
        {cmd} 1d
        {cmd}
    """
    participant = (await
                   client(GetParticipantRequest(chat,
                                                msg.from_id))).participant
    permitted = False
    if isinstance(participant, ChannelParticipantCreator):
        permitted = True
    elif isinstance(participant, ChannelParticipantAdmin):
        rights = participant.admin_rights
        permitted = rights.ban_users
    if not permitted:
        return KanTeXDocument('Insufficient permission.')

    duration = None
    if args:
        try:
            duration = parsers.time(args[0])
        except MissingExpression as err:
            return KanTeXDocument(Italic(err))

    if duration and duration < 10:
        return KanTeXDocument('Duration too short.')

    permissions = chat.default_banned_rights.to_dict()
    del permissions['_']
    del permissions['until_date']
    del permissions['view_messages']
    await db.chats.lock(event.chat_id,
                        {k: v
                         for k, v in permissions.items() if not v})
    try:
        await client(
            EditChatDefaultBannedRightsRequest(chat,
                                               banned_rights=ChatBannedRights(
                                                   until_date=None,
                                                   view_messages=None,
                                                   send_messages=True,
                                                   send_media=True,
                                                   send_stickers=True,
                                                   send_gifs=True,
                                                   send_games=True,
                                                   send_inline=True,
                                                   send_polls=True,
                                                   change_info=True,
                                                   invite_users=True,
                                                   pin_messages=True)))
        if duration:
            config = Config()
            await client.send_message(chat,
                                      f'{config.prefix}unlock',
                                      schedule=msg.date +
                                      timedelta(seconds=duration))
        return KanTeXDocument('Chat locked.')
    except ChatNotModifiedError:
        return KanTeXDocument('Chat already locked.')
Esempio n. 25
0
async def rem_locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = False
        what = "messages"
    elif input_str == "media":
        media = False
        what = "media"
    elif input_str == "sticker":
        sticker = False
        what = "stickers"
    elif input_str == "gif":
        gif = False
        what = "GIFs"
    elif input_str == "game":
        gamee = False
        what = "games"
    elif input_str == "inline":
        ainline = False
        what = "inline bots"
    elif input_str == "poll":
        gpoll = False
        what = "polls"
    elif input_str == "invite":
        adduser = False
        what = "invites"
    elif input_str == "pin":
        cpin = False
        what = "pins"
    elif input_str == "info":
        changeinfo = False
        what = "chat info"
    elif input_str == "all":
        msg = False
        media = False
        sticker = False
        gif = False
        gamee = False
        ainline = False
        gpoll = False
        adduser = False
        cpin = False
        changeinfo = False
        what = "everything"
    else:
        if not input_str:
            await event.edit("`I can't unlock nothing !!`")
            return
        else:
            await event.edit(f"`Invalid unlock type:` {input_str}")
            return

    unlock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=unlock_rights))
        await event.edit(
            f"{DEFAULTUSER} `Unlocked {what} now Start Chit Chat but dont spam else you gey !!`"
        )
    except BaseException as e:
        await event.edit(
            f"`Do I have proper rights for that ??`\n**Error:** {str(e)}")
        return
Esempio n. 26
0
async def rem_locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = False
        what = "messages"
    elif input_str == "media":
        media = False
        what = "media"
    elif input_str == "sticker":
        sticker = False
        what = "stickers"
    elif input_str == "gif":
        gif = False
        what = "GIFs"
    elif input_str == "game":
        gamee = False
        what = "games"
    elif input_str == "inline":
        ainline = False
        what = "inline bots"
    elif input_str == "poll":
        gpoll = False
        what = "polls"
    elif input_str == "invite":
        adduser = False
        what = "invites"
    elif input_str == "pin":
        cpin = False
        what = "pins"
    elif input_str == "info":
        changeinfo = False
        what = "chat info"
    elif input_str == "all":
        msg = False
        media = False
        sticker = False
        gif = False
        gamee = False
        ainline = False
        gpoll = False
        adduser = False
        cpin = False
        changeinfo = False
        what = "everything"
    else:
        if not input_str:
            await eod(event, "`I need something to unlock sur!!`🚶")
            return
        else:
            await eod(event, f"🤐 `Invalid unlock type:` {input_str}")
            return

    unlock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=unlock_rights))
        if Config.ABUSE == "ON":
            await event.delete()
            await bot.send_file(
                event.chat_id,
                shuru,
                caption=f"**{hell_mention} unlocked** `{what}`",
            )
        else:
            await eor(
                event,
                f"{hell_mention} Unlocked `{what}` \n__Now Start Chit Chat !!__"
            )
    except BaseException as e:
        await eod(
            event,
            f"`Do I have proper rights for that ??`\n**Error:** {str(e)}")
        return
Esempio n. 27
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    peer_id = event.chat_id
    if not event.is_group:
        return await edit_delete(event, "`Idiot! ,This is not a group to lock things `")
    cat = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
    chat_per = (await event.get_chat()).default_banned_rights
    if input_str in (("bots", "commands", "email", "forward", "url")):
        update_lock(peer_id, input_str, False)
        await edit_or_reply(event, "`UnLocked {}`".format(input_str))
    else:
        msg = chat_per.send_messages
        media = chat_per.send_media
        sticker = chat_per.send_stickers
        gif = chat_per.send_gifs
        gamee = chat_per.send_games
        ainline = chat_per.send_inline
        gpoll = chat_per.send_polls
        embed_link = chat_per.embed_links
        adduser = chat_per.invite_users
        cpin = chat_per.pin_messages
        changeinfo = chat_per.change_info
        if input_str == "msg":
            if not msg:
                return await edit_delete(
                    event, "`This group is already unlocked with messaging permission`"
                )
            msg = False
            locktype = "messages"
        elif input_str == "media":
            if not media:
                return await edit_delete(
                    event, "`This group is already unlocked with sending media`"
                )
            media = False
            locktype = "media"
        elif input_str == "sticker":
            if not sticker:
                return await edit_delete(
                    event, "`This group is already unlocked with sending stickers`"
                )
            sticker = False
            locktype = "stickers"
        elif input_str == "preview":
            if not embed_link:
                return await edit_delete(
                    event, "`This group is already unlocked with preview links`"
                )
            embed_link = False
            locktype = "preview links"
        elif input_str == "gif":
            if not gif:
                return await edit_delete(
                    event, "`This group is already unlocked with sending GIFs`"
                )
            gif = False
            locktype = "GIFs"
        elif input_str == "game":
            if not gamee:
                return await edit_delete(
                    event, "`This group is already unlocked with sending games`"
                )
            gamee = False
            locktype = "games"
        elif input_str == "inline":
            if not ainline:
                return await edit_delete(
                    event, "`This group is already unlocked with using inline bots`"
                )
            ainline = False
            locktype = "inline bots"
        elif input_str == "poll":
            if not gpoll:
                return await edit_delete(
                    event, "`This group is already unlocked with sending polls`"
                )
            gpoll = False
            locktype = "polls"
        elif input_str == "invite":
            if not adduser:
                return await edit_delete(
                    event, "`This group is already unlocked with adding members`"
                )
            adduser = False
            locktype = "invites"
        elif input_str == "pin":
            if not cpin:
                return await edit_delete(
                    event,
                    "`This group is already unlocked with pinning messages by users`",
                )
            cpin = False
            locktype = "pins"
        elif input_str == "info":
            if not changeinfo:
                return await edit_delete(
                    event,
                    "`This group is already unlocked with Changing grup info by users`",
                )
            changeinfo = False
            locktype = "chat info"
        elif input_str == "all":
            msg = False
            media = False
            sticker = False
            gif = False
            gamee = False
            ainline = False
            gpoll = False
            embed_link = False
            adduser = False
            cpin = False
            changeinfo = False
            locktype = "everything"
        else:
            if input_str:
                return await edit_delete(
                    event, f"**Invalid unlock type :** `{input_str}`", time=5
                )

            return await edit_or_reply(event, "`I can't unlock nothing !!`")
        try:
            cat = Get(cat)
            await event.client(cat)
        except BaseException:
            pass
        unlock_rights = ChatBannedRights(
            until_date=None,
            send_messages=msg,
            send_media=media,
            send_stickers=sticker,
            send_gifs=gif,
            send_games=gamee,
            send_inline=ainline,
            send_polls=gpoll,
            embed_links=embed_link,
            invite_users=adduser,
            pin_messages=cpin,
            change_info=changeinfo,
        )
        try:
            await event.client(
                EditChatDefaultBannedRightsRequest(
                    peer=peer_id, banned_rights=unlock_rights
                )
            )
            await edit_or_reply(event, f"`Unlocked {locktype} for this chat !!`")
        except BaseException as e:
            return await edit_delete(
                event,
                f"`Do I have proper rights for that ??`\n\n**Error:** `{str(e)}`",
                time=5,
            )
Esempio n. 28
0
async def _(event):
    if event.fwd_from:
        return
    input_str = event.pattern_match.group(1)
    peer_id = event.chat_id
    if not event.is_group:
        return await edit_delete(event, "`Idiot! ,This is not a group to lock things `")
    chat_per = (await event.get_chat()).default_banned_rights
    if input_str in (("bots", "commands", "email", "forward", "url")):
        update_lock(peer_id, input_str, True)
        await edit_or_reply(event, "`Locked {}`".format(input_str))
    else:
        msg = chat_per.send_messages
        media = chat_per.send_media
        sticker = chat_per.send_stickers
        gif = chat_per.send_gifs
        gamee = chat_per.send_games
        ainline = chat_per.send_inline
        embed_link = chat_per.embed_links
        gpoll = chat_per.send_polls
        adduser = chat_per.invite_users
        cpin = chat_per.pin_messages
        changeinfo = chat_per.change_info
        if input_str == "msg":
            if msg:
                return await edit_delete(
                    event, "`This group is already locked with messaging permission`"
                )
            else:
                msg = True
            locktype = "messages"
        elif input_str == "media":
            if media:
                return await edit_delete(
                    event, "`This group is already locked with sending media`"
                )
            else:
                media = True
            locktype = "media"
        elif input_str == "sticker":
            if sticker:
                return await edit_delete(
                    event, "`This group is already locked with sending stickers`"
                )
            else:
                sticker = True
            locktype = "stickers"
        elif input_str == "preview":
            if embed_link:
                return await edit_delete(
                    event, "`This group is already locked with previewing links`"
                )
            else:
                embed_link = True
            locktype = "preview links"
        elif input_str == "gif":
            if gif:
                return await edit_delete(
                    event, "`This group is already locked with sending GIFs`"
                )
            else:
                gif = True
            locktype = "GIFs"
        elif input_str == "game":
            if gamee:
                return await edit_delete(
                    event, "`This group is already locked with sending games`"
                )
            else:
                gamee = True
            locktype = "games"
        elif input_str == "inline":
            if ainline:
                return await edit_delete(
                    event, "`This group is already locked with using inline bots`"
                )
            else:
                ainline = True
            locktype = "inline bots"
        elif input_str == "poll":
            if gpoll:
                return await edit_delete(
                    event, "`This group is already locked with sending polls`"
                )
            else:
                gpoll = True
            locktype = "polls"
        elif input_str == "invite":
            if adduser:
                return await edit_delete(
                    event, "`This group is already locked with adding members`"
                )
            else:
                adduser = True
            locktype = "invites"
        elif input_str == "pin":
            if cpin:
                return await edit_delete(
                    event,
                    "`This group is already locked with pinning messages by users`",
                )
            else:
                cpin = True
            locktype = "pins"
        elif input_str == "info":
            if changeinfo:
                return await edit_delete(
                    event,
                    "`This group is already locked with Changing group info by users`",
                )
            else:
                changeinfo = True
            locktype = "chat info"
        elif input_str == "all":
            msg = True
            media = True
            sticker = True
            gif = True
            gamee = True
            ainline = True
            embed_link = True
            gpoll = True
            adduser = True
            cpin = True
            changeinfo = True
            locktype = "everything"
        else:
            if input_str:
                return await edit_delete(
                    event, f"**Invalid lock type :** `{input_str}`", time=5
                )

            else:
                return await edit_or_reply(event, "`I can't lock nothing !!`")
        lock_rights = ChatBannedRights(
            until_date=None,
            send_messages=msg,
            send_media=media,
            send_stickers=sticker,
            send_gifs=gif,
            send_games=gamee,
            send_inline=ainline,
            embed_links=embed_link,
            send_polls=gpoll,
            invite_users=adduser,
            pin_messages=cpin,
            change_info=changeinfo,
        )
        try:
            await event.client(
                EditChatDefaultBannedRightsRequest(
                    peer=peer_id, banned_rights=lock_rights
                )
            )
            await edit_or_reply(event, f"`Locked {locktype} for this chat !!`")
        except BaseException as e:
            await edit_delete(
                event,
                f"`Do I have proper rights for that ??`\n\n**Error:** `{str(e)}`",
                time=5,
            )
Esempio n. 29
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "messages"
    elif input_str == "media":
        media = True
        what = "media"
    elif input_str == "sticker":
        sticker = True
        what = "stickers"
    elif input_str == "gif":
        gif = True
        what = "GIFs"
    elif input_str == "game":
        gamee = True
        what = "games"
    elif input_str == "inline":
        ainline = True
        what = "inline bots"
    elif input_str == "poll":
        gpoll = True
        what = "polls"
    elif input_str == "invite":
        adduser = True
        what = "invites"
    elif input_str == "pin":
        cpin = True
        what = "pins"
    elif input_str == "info":
        changeinfo = True
        what = "chat info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "everything"
    else:
        if not input_str:
            await event.edit(LANG['EVERYTHING_LOCK'])
            return
        else:
            await event.edit(LANG['INVALID_MEDIA_TYPE'] % input_str)
            return

    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=lock_rights))
        await event.edit(LANG['LOCK'] % what)
    except BaseException as e:
        await event.edit(
            f"{LANG['INVALID_AUTHORITY']} {str(e)}")
        return
Esempio n. 30
0
async def locks(event):
    input_str = event.pattern_match.group(1).lower()
    peer_id = event.chat_id
    msg = None
    media = None
    sticker = None
    gif = None
    gamee = None
    ainline = None
    gpoll = None
    adduser = None
    cpin = None
    changeinfo = None
    if input_str == "msg":
        msg = True
        what = "messages"
    elif input_str == "media":
        media = True
        what = "media"
    elif input_str == "sticker":
        sticker = True
        what = "stickers"
    elif input_str == "gif":
        gif = True
        what = "GIFs"
    elif input_str == "game":
        gamee = True
        what = "games"
    elif input_str == "inline":
        ainline = True
        what = "inline bots"
    elif input_str == "poll":
        gpoll = True
        what = "polls"
    elif input_str == "invite":
        adduser = True
        what = "invites"
    elif input_str == "pin":
        cpin = True
        what = "pins"
    elif input_str == "info":
        changeinfo = True
        what = "chat info"
    elif input_str == "all":
        msg = True
        media = True
        sticker = True
        gif = True
        gamee = True
        ainline = True
        gpoll = True
        adduser = True
        cpin = True
        changeinfo = True
        what = "everything"
    else:
        if not input_str:
            await event.edit("`I can't lock nothing !!`")
            return
        else:
            await event.edit(f"`Invalid lock type:` {input_str}")
            return

    lock_rights = ChatBannedRights(
        until_date=None,
        send_messages=msg,
        send_media=media,
        send_stickers=sticker,
        send_gifs=gif,
        send_games=gamee,
        send_inline=ainline,
        send_polls=gpoll,
        invite_users=adduser,
        pin_messages=cpin,
        change_info=changeinfo,
    )
    try:
        await event.client(
            EditChatDefaultBannedRightsRequest(peer=peer_id,
                                               banned_rights=lock_rights))
        await event.edit(f"{DEFAULTUSER} `Telah mengunci izin {what} Untuk semua non admin!!`")
    except BaseException as e:
        await event.edit(
            f"`Maaf Kamu Bukan Admin di Group Ini!`\n**Error:** {str(e)}")
        return