Beispiel #1
0
def gbanlist(update: Update, context: CallbackContext):
    banned_users = sql.get_gban_list()

    if not banned_users:
        update.effective_message.reply_text(
            "There aren't any gbanned users! You're kinder than I expected...")
        return

    banfile = 'Screw these guys.\n'
    for user in banned_users:
        banfile += f"[x] {user['name']} - {user['user_id']}\n"
        if user["reason"]:
            banfile += f"Reason: {user['reason']}\n"

    with BytesIO(str.encode(banfile)) as output:
        output.name = "gbanlist.txt"
        update.effective_message.reply_document(
            document=output,
            filename="gbanlist.txt",
            caption="Here is the list of currently gbanned users.")

    if sql.is_user_gbanned(user_id):
        update.effective_chat.kick_member(user_id)
        if should_message:
            text = f"<b>Alert</b>: this user is globally banned.\n" \
                   f"<code>*bans them from here*</code>.\n" \
                   f"<b>Appeal chat</b>: {SUPPORT_CHAT}\n" \
                   f"<b>User ID</b>: <code>{user_id}</code>"
            user = sql.get_gbanned_user(user_id)
            if user.reason:
                text += f"\n<b>Ban Reason:</b> <code>{html.escape(user.reason)}</code>"
            update.effective_message.reply_text(text,
                                                parse_mode=ParseMode.HTML)
Beispiel #2
0
def check_and_ban(update, user_id, should_message=True):

    chat = update.effective_chat  # type: Optional[Chat]
    sw_ban = sw.get_ban(int(user_id))
    if sw_ban:
        update.effective_chat.kick_member(user_id)
        if should_message:
            update.effective_message.reply_text(
                f"<b>Alert</b>: this user is globally banned.\n"
                f"<code>*bans them from here*</code>.\n"
                f"<b>Appeal chat</b>: {SPAMWATCH_SUPPORT_CHAT}\n"
                f"<b>User ID</b>: <code>{sw_ban['id']}</code>\n"
                f"<b>Ban Reason</b>: <code>{html.escape(sw_ban['reason'])}</code>",
                parse_mode=ParseMode.HTML)
            return
        else:
            return

    if sql.is_user_gbanned(user_id):
        update.effective_chat.kick_member(user_id)
        if should_message:
            text = f"<b>Alert</b>: this user is globally banned.\n" \
                   f"<code>*bans them from here*</code>.\n" \
                   f"<b>Appeal chat</b>: {SUPPORT_CHAT}\n" \
                   f"<b>User ID</b>: <code>{user_id}</code>"
            user = sql.get_gbanned_user(user_id)
            if user.reason:
                text += f"\n<b>Ban Reason:</b> <code>{html.escape(user.reason)}</code>"
            update.effective_message.reply_text(text,
                                                parse_mode=ParseMode.HTML)
Beispiel #3
0
def check_and_ban(update, user_id, should_message=True):
        if sql.is_user_gbanned(user_id):
            update.effective_chat.kick_member(user_id)
        if should_message:
            text = f"<b>Alert</b>: this user is globally banned.\n" \
                   f"<code>*bans them from here*</code>.\n" \
                   f"<b>Appeal chat</b>: {SUPPORT_CHAT}\n" \
                   f"<b>User ID</b>: <code>{user_id}</code>"
            user = sql.get_gbanned_user(user_id)
            if user.reason:
                text += "\nReason: <code>{}</code>".format(html.escape(user.reason))
                update.effective_message.reply_text(text, parse_mode=ParseMode.HTML)
Beispiel #4
0
def __user_info__(user_id):
    is_gbanned = sql.is_user_gbanned(user_id)

    text = "Globally banned: <b>{}</b>"
    if is_gbanned:
        text = text.format("Yes")
        user = sql.get_gbanned_user(user_id)
        if user.reason:
            text += "\nReason: <code>{}</code>".format(html.escape(user.reason))
    else:
        text = text.format("No")
    return text
Beispiel #5
0
def __user_info__(user_id):
    is_gbanned = sql.is_user_gbanned(user_id)

    text = "Globally banned: <b>{}</b>"
    if is_gbanned:
        text = text.format("Yes")
        user = sql.get_gbanned_user(user_id)
        if user.reason:
            text += f"\n<b>Reason:</b> <code>{html.escape(user.reason)}</code>"
        text += f"\n<b>Appeal Chat:</b> {SUPPORT_CHAT}"
    else:
        text = text.format("No")
    return text
Beispiel #6
0
def __user_info__(user_id):
    is_gbanned = sql.is_user_gbanned(user_id)

    text = "Globally banned: <b>{}</b>"
    if user_id == dispatcher.bot.id:
        return ""
    if int(user_id) in SUDO_USERS + TIGER_USERS + WHITELIST_USERS:
        return ""
    if is_gbanned:
        text = text.format("Yes")
        user = sql.get_gbanned_user(user_id)
        if user.reason:
            text += f"\n<b>Reason:</b> <code>{html.escape(user.reason)}</code>"
        text += f"\n<b>Appeal Chat:</b> {SUPPORT_CHAT}"
    else:
        text = text.format("No")
    return text