Ejemplo n.º 1
0
def check_and_ban(update, user_id, should_message=True):

    chat = update.effective_chat  # type: Optional[Chat]
    try:
        sw_ban = sw.get_ban(int(user_id))
    except:
        sw_ban = None

    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

    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)
Ejemplo n.º 2
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)
Ejemplo n.º 3
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: {}".format(html.escape(user.reason))
    else:
        text = text.format("No")
    return text
Ejemplo n.º 4
0
def check_and_ban(update, user_id, should_message=True):

    chat = update.effective_chat  # type: Optional[Chat]
    if SPB_MODE:
        try:
            status = client.raw_output(int(user_id))
            try:
                bl_check = (status["results"]["attributes"]["is_blacklisted"])
            except:
                bl_check = False

            if bl_check is True:
                bl_res = (status["results"]["attributes"]["blacklist_reason"])
                update.effective_chat.kick_member(user_id)
                if should_message:
                    update.effective_message.reply_text(
                        f"This person was blacklisted on @SpamProtectionBot and has been removed!\nReason: <code>{bl_res}</code>",
                        parse_mode=ParseMode.HTML,
                    )
        except HostDownError:
            log.warning("Spam Protection API is unreachable.")

    try:
        sw_ban = sw.get_ban(int(user_id))
    except AttributeError:
        sw_ban = None
    except (SpamWatchError, Error, UnauthorizedError, NotFoundError, Forbidden,
            TooManyRequests) as e:
        log.warning(f" SpamWatch Error: {e}")
        sw_ban = None

    if sw_ban:
        update.effective_chat.kick_member(user_id)
        if should_message:
            update.effective_message.reply_text(
                f"This person has been detected as a spammer by @SpamWatch and has been removed!\nReason: <code>{sw_ban.reason}</code>",
                parse_mode=ParseMode.HTML,
            )
        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>: @YorkTownEagleUnion\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)
Ejemplo n.º 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
Ejemplo n.º 6
0
def __user_info__(user_id):
    is_gbanned = sql.is_user_gbanned(user_id)

    text = "Küresel olarak yasaklandı: <b>{}</b>"
    if is_gbanned:
        text = text.format("Yes")
        user = sql.get_gbanned_user(user_id)
        if user.reason:
            text += f"\n<b>Sebep:</b> <code>{html.escape(user.reason)}</code>"
        text += f"\n<b>Sohbete İtiraz Et:</b> {SUPPORT_CHAT}"
    else:
        text = text.format("No")
    return text
Ejemplo n.º 7
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
Ejemplo n.º 8
0
def __user_info__(user_id):
    is_gbanned = sql.is_user_gbanned(user_id)
    text = "Malicious: <b>{}</b>"
    if user_id in [777000, 1087968824]:
        return ""
    if user_id == dispatcher.bot.id:
        return ""
    if int(user_id) in DRAGONS + TIGERS + WOLVES:
        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("???")
    return text
Ejemplo n.º 9
0
def __user_info__(user_id):
    is_gbanned = sql.is_user_gbanned(user_id)
    text = "Zərərlidirmi: <b>{}</b>"
    if user_id in [777000, 1087968824]:
        return ""
    if user_id == dispatcher.bot.id:
        return ""
    if int(user_id) in DRAGONS + TIGERS + WOLVES:
        return ""
    if is_gbanned:
        text = text.format("Hə")
        user = sql.get_gbanned_user(user_id)
        if user.reason:
            text += f"\n<b>Səbəb:</b> <code>{html.escape(user.reason)}</code>"
        text += f"\n<b>Müraciət:</b> @{SUPPORT_CHAT}"
    else:
        text = text.format("???")
    return text