Ejemplo n.º 1
0
async def disapprove_user(_, m: Message):

    chat_title = m.chat.title
    chat_id = m.chat.id
    user_id, user_first_name = await extract_user(m)
    if not user_id:
        await m.reply_text(
            "I don't know who you're talking about, you're going to need to specify a user!",
        )
        return
    try:
        member = await m.get_member(user_id)
    except UserNotParticipant:
        if db.is_approved(chat_id, user_id):
            db.disapprove(chat_id, user_id)
        await m.reply_text("This user is not in this chat!")
        return
    except RPCError as ef:
        await m.reply_text(
            f"<b>Error</b>: <code>{ef}</code>\nReport it to @{SUPPORT_GROUP}",
        )
        return
    if member.status in ["administrator", "creator"]:
        await m.reply_text("This user is an admin, they can't be unapproved.")
        return
    if not db.is_approved(chat_id, user_id):
        await m.reply_text(
            f"{(await mention_html(user_first_name, user_id))} isn't approved yet!",
        )
        return
    db.disapprove(chat_id, user_id)
    await m.reply_text(
        f"{(await mention_html(user_first_name, user_id))} is no longer approved in {chat_title}.",
    )
    return
Ejemplo n.º 2
0
async def approve_user(_, m: Message):

    chat_title = m.chat.title
    chat_id = m.chat.id
    user_id, user_first_name = await extract_user(m)
    if not user_id:
        await m.reply_text(
            "I don't know who you're talking about, you're going to need to specify a user!",
        )
        return
    try:
        member = await m.get_member(user_id)
    except UserNotParticipant:
        await m.reply_text("This user is not in this chat!")
        return
    except RPCError as ef:
        await m.reply_text(
            f"<b>Error</b>: <code>{ef}</code>\nReport it to @{SUPPORT_GROUP}",
        )
        return
    if member.status in ("administrator", "creator"):
        await m.reply_text(
            "User is already admin - blocklists already don't apply to them.",
        )
        return
    if db.is_approved(chat_id, user_id):
        await m.reply_text(
            f"{(await mention_html(user_first_name, user_id))} is already approved in {chat_title}",
        )
        return
    db.approve(chat_id, user_id)
    await m.reply_text(
        f"{(await mention_html(user_first_name, user_id))} has been approved in {chat_title}! They will now be ignored by blocklists.",
    )
    return
Ejemplo n.º 3
0
async def disapprove_user(c: Alita, m: Message):

    res = await owner_check(c, m)
    if not res:
        return

    chat_title = m.chat.title
    chat_id = m.chat.id
    user_id, user_first_name = await extract_user(c, m)
    if not user_id:
        await m.reply_text(
            "I don't know who you're talking about, you're going to need to specify a user!"
        )
        return
    member = await c.get_chat_member(chat_id=chat_id, user_id=user_id)
    if member.status in ["administrator", "creator"]:
        await m.reply_text("This user is an admin, they can't be unapproved.")
        return
    if not db.is_approved(chat_id, user_id):
        await m.reply_text(
            f"{mention_html(user_first_name, user_id)} isn't approved yet!"
        )
        return
    db.disapprove(chat_id, user_id)
    await m.reply_text(
        f"{mention_html(user_first_name, user_id)} is no longer approved in {chat_title}."
    )
    return
Ejemplo n.º 4
0
async def approve_user(c: Alita, m: Message):

    res = await owner_check(c, m)
    if not res:
        return

    chat_title = m.chat.title
    chat_id = m.chat.id
    user_id, user_first_name = await extract_user(c, m)
    if not user_id:
        await m.reply_text(
            "I don't know who you're talking about, you're going to need to specify a user!"
        )
        return
    member = await c.get_chat_member(chat_id=chat_id, user_id=user_id)
    if member.status in ["administrator", "creator"]:
        await m.reply_text(
            f"User is already admin - blocklists already don't apply to them."
        )
        return
    if db.is_approved(chat_id, user_id):
        await m.reply_text(
            f"{mention_html(user_first_name, user_id)} is already approved in {chat_title}"
        )
        return
    db.approve(chat_id, user_id)
    await m.reply_text(
        f"{mention_html(user_first_name, user_id)} has been approved in {chat_title}! They will now be ignored by blocklists."
    )
    return
Ejemplo n.º 5
0
async def check_approval(_, m: Message):

    user_id, user_first_name = await extract_user(m)
    if not user_id:
        await m.reply_text(
            "I don't know who you're talking about, you're going to need to specify a user!",
        )
        return
    if db.is_approved(m.chat.id, user_id):
        await m.reply_text(
            f"{(await mention_html(user_first_name, user_id))} is an approved user. Locks, antiflood, and blocklists won't apply to them.",
        )
    else:
        await m.reply_text(
            f"{(await mention_html(user_first_name, user_id))} is not an approved user. They are affected by normal commands.",
        )
    return