Example #1
0
def check_and_ban(update, user_id, should_message=True):
    chat = update.effective_chat
    message = update.effective_message
    try:
        if sw != None:
            sw_ban = sw.get_ban(user_id)
            if sw_ban:
                spamwatch_reason = sw_ban.reason
                chat.kick_member(user_id)
                if should_message:
                    message.reply_text(tld(
                        chat.id,
                        "antispam_spamwatch_banned").format(spamwatch_reason),
                                       parse_mode=ParseMode.HTML)
                    return
                else:
                    return
    except Exception:
        pass

    if sql.is_user_gbanned(user_id):
        chat.kick_member(user_id)
        if should_message:
            userr = sql.get_gbanned_user(user_id)
            usrreason = userr.reason
            if not usrreason:
                usrreason = tld(chat.id, "antispam_no_reason")

            message.reply_text(tld(
                chat.id, "antispam_checkban_user_removed").format(usrreason),
                               parse_mode=ParseMode.MARKDOWN)
            return
Example #2
0
def __user_info__(user_id, chat_id):
    is_gbanned = sql.is_user_gbanned(user_id)
    is_gmuted = sql.is_user_gmuted(user_id)

    if not user_id in SUDO_USERS:

        text = tld(chat_id, "Globally banned: <b>{}</b>")
        if is_gbanned:
            text = text.format(tld(chat_id, "Yes"))
            user = sql.get_gbanned_user(user_id)
            if user.reason:
                text += tld(chat_id,
                            "\nReason: {}").format(html.escape(user.reason))
        else:
            text = text.format(tld(chat_id, "No"))

        text += tld(chat_id, "\nGlobally muted: <b>{}</b>")
        if is_gmuted:
            text = text.format(tld(chat_id, "Yes"))
            user = sql.get_gmuted_user(user_id)
            if user.reason:
                text += tld(chat_id,
                            "\nReason: {}").format(html.escape(user.reason))
        else:
            text = text.format(tld(chat_id, "No"))

        return text
    else:
        return ""
Example #3
0
def __user_info__(user_id, chat_id):
    is_gbanned = sql.is_user_gbanned(user_id)
    is_gmuted = sql.is_user_gmuted(user_id)

    if not user_id in SUDO_USERS:

        text = tld(chat_id,"antispam_gban")
        if is_gbanned:
            text = text.format(tld(chat_id, "antispam_yes"))
            user = sql.get_gbanned_user(user_id)
            if user.reason:
                text += tld(chat_id, "antispam_reason").format(html.escape(user.reason))
        else:
            text = text.format(tld(chat_id, "antispam_no"))
        
        text += tld(chat_id,"antispam_gmuted")
        if is_gmuted:
            text = text.format(tld(chat_id, "antispam_yes"))
            user = sql.get_gmuted_user(user_id)
            if user.reason:
                text += tld(chat_id, "antispam_reason").format(html.escape(user.reason))
        else:
            text = text.format(tld(chat_id, "antispam_no"))

        return text
    else:
        return ""
Example #4
0
def __user_info__(user_id, chat_id):
    is_gbanned = sql.is_user_gbanned(user_id)
    is_gmuted = sql.is_user_gmuted(user_id)

    if not user_id in SUDO_USERS or not user_id in WHITELIST_USERS:

        text = tld(chat_id, "antispam_userinfo_gbanned")
        if is_gbanned:
            text = text.format(tld(chat_id, "common_yes"))
            text += tld(chat_id, "anitspam_appeal")
            user = sql.get_gbanned_user(user_id)
            if user.reason:
                text += tld(chat_id, "antispam_userinfo_gban_reason").format(
                    html.escape(user.reason))
        else:
            text = text.format(tld(chat_id, "common_no"))

        text += tld(chat_id, "antispam_userinfo_gmute")
        if is_gmuted:
            text = text.format(tld(chat_id, "common_yes"))
            text += tld(chat_id, "anitspam_appeal")
            user = sql.get_gmuted_user(user_id)
            if user.reason:
                text += tld(chat_id, "antispam_userinfo_gmute_reason").format(html.escape(user.reason))
        else:
            text = text.format(tld(chat_id, "common_no"))

        return text
    else:
        return ""
Example #5
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:
            userr = sql.get_gbanned_user(user_id)
            usrreason = userr.reason
            if not usrreason:
                usrreason = "No reason given"

            update.effective_message.reply_text(f"*This user is gbanned and have been removed.*\nReason: `{usrreason}`", parse_mode=ParseMode.MARKDOWN)
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 += "\n<b>Reason:</b> {}".format(html.escape(user.reason))
        text += "\n<b>Appeal Chat:</b> @OnePunchSupport"
    else:
        text = text.format("No")
    return text
Example #7
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_markdown("**This user is detected as spam bot by SpamWatch and have been removed!**\n\nPlease visit @SpamWatchSupport to appeal!")
    #        return
    #    else:
    #        return

    if sql.is_user_gbanned(user_id):
        update.effective_chat.kick_member(user_id)
        if should_message:
            userr = sql.get_gbanned_user(user_id)
            usrreason = userr.reason
            if not usrreason:
                usrreason = tld(chat.id, "antispam_no_reason")

            update.effective_message.reply_text(tld(
                chat.id, "antispam_checkban_user_removed").format(usrreason),
                                                parse_mode=ParseMode.MARKDOWN)
            return