コード例 #1
0
ファイル: global_bans.py プロジェクト: NoobPeoples/Violet
def check_and_ban(update, user_id, should_message=True):
    try:
        spmban = spamwtc.get_ban(int(user_id))
        cas_banned = check_cas(user_id)

        if spmban or cas_banned:
            update.effective_chat.kick_member(user_id)
            if should_message:
                if spmban and cas_banned:
                    banner = "@Spamwatch and Combot Anti Spam"
                    reason = f"\n<code>{spmban.reason}</code>\n\nand <a href='{cas_banned}'>CAS Banned</a>"
                elif cas_banned:
                    banner = "Combot Anti Spam"
                    reason = f"<a href='{cas_banned}''>CAS Banned</a>"
                elif spmban:
                    banner = "@Spamwatch"
                    reason = f"<code>{spmban.reason}</code>"

                send_message(
                    update.effective_message,
                    "#SPAM_SHIELD\n\nOrang ini telah terdeteksi sebagai robot spam"
                    f"oleh {banner} dan telah dihapusd!\nAlasan: {reason}",
                    parse_mode=ParseMode.HTML,
                )
                return

    except Exception:
        pass

    if gban_db.is_user_gbanned(user_id):
        update.effective_chat.kick_member(user_id)
        if should_message:
            usr = gban_db.get_gbanned_user(user_id)
            greason = usr["reason"]
            if not greason:
                greason = "Tidak ada alasan yang diberikan"

            send_message(
                update.effective_message,
                f"*Waspada! pengguna ini telah diblokir dan telah dihapus!*\n*Alasan*: {greason}",
                parse_mode=ParseMode.MARKDOWN,
            )
            return
コード例 #2
0
def __user_info__(user_id):
    is_gbanned = gban_db.is_user_gbanned(user_id)
    spmban = spamwtc.get_ban(int(user_id))
    cas_banned = check_cas(user_id)

    text = "<b>Globally banned</b>: {}"

    if int(user_id) in DEV_USERS + SUDO_USERS + SUPPORT_USERS:
        return ""

    if user_id in (777000, 1087968824):
        return ""

    if cas_banned or spmban or is_gbanned:
        text = text.format("Yes")
        if is_gbanned:
            user = gban_db.get_gbanned_user(user_id)
            text += "\n<b>Alasan:</b> {}".format(html.escape(user["reason"]))
    else:
        text = text.format("No")
    return text