diff --git a/changelog.json b/changelog.json index f0dc1b59..377260d8 100644 --- a/changelog.json +++ b/changelog.json @@ -1,5 +1,5 @@ [ - "- TODO: Added ignorelist (swapped ignorelist and blacklist functionality)", + "- Added ignorelist (swapped ignorelist and blacklist functionality)", "- Added spamlist", "- TODO: Added pest warp", "- TODO: Added /va nw", diff --git a/features/general/SpamHider.js b/features/general/SpamHider.js index 99ddc962..38827abb 100644 --- a/features/general/SpamHider.js +++ b/features/general/SpamHider.js @@ -5,7 +5,14 @@ import { data, registerWhen } from "../../utils/variables"; * Removes any identical chat messages in spamlist from chat. */ registerWhen(register("chat", (text, event) => { - if (!(text in data.spamlist)) return; - - cancel(event); -}).setCriteria("${text}"), () => data.spamlist.size !== 0); + for (let i = 0; i < data.spamlist.length; i++) { + const pattern = data.spamlist[i]; + const regexPattern = pattern.replace(/\${\w+}/g, '(.*?)'); + const regex = new RegExp('^' + regexPattern + '$', 'i'); + + if (regex.test(text)) { + cancel(event); + return; + } + }; +}).setCriteria("${text}"), () => data.spamlist.length !== 0); diff --git a/index.js b/index.js index b71d1a03..a205e28e 100644 --- a/index.js +++ b/index.js @@ -318,6 +318,11 @@ register ("command", (...args) => { case "sl": updateList(args, data.spamlist, "spamlist"); break; + case "ignorelist": + case "ignore": + case "il": + updateList(args, data.ignorelist, "ignorelist"); + break; // Kuudra Splits case "splits": // Kuudra splits case "split": diff --git a/utils/variables.js b/utils/variables.js index c788d961..1ff8e29d 100644 --- a/utils/variables.js +++ b/utils/variables.js @@ -28,7 +28,8 @@ export let data = new PogObject("VolcAddons", { "emotelist": {}, "cooldownlist": {}, "valuelist": {}, - "spamlist": new Set(), + "spamlist": [], + "ignorelist": [], // kuudra splits stuff "files": [], "splits": { @@ -164,14 +165,12 @@ let lines = [5858, 5859]; export function updateList(args, list, listName) { const isArray = Array.isArray(list); const command = args[1] - const item = listName === "moblist" ? args.slice(2).join(' ') : args.slice(2).join(' ').toLowerCase(); + const item = listName === "moblist" || listName === "spamlist" ? args.slice(2).join(' ') : args.slice(2).join(' ').toLowerCase(); // Object pairs - const value = listName === "cdlist" || listName === "valuelist" ? unformatNumber(args[2]) : - listName === "spamlist" ? "消える" : args.slice(3).join(' '); + const value = listName === "cdlist" || listName === "valuelist" ? unformatNumber(args[2]) : args.slice(3).join(' '); const key = listName === "cdlist" || listName === "valuelist" ? - Player?.getHeldItem()?.getItemNBT()?.getCompoundTag("tag")?.getCompoundTag("ExtraAttributes")?.getString("id") : - listName === "spamlist" ? args.splice(2).join(' ') : args[2]; + Player?.getHeldItem()?.getItemNBT()?.getCompoundTag("tag")?.getCompoundTag("ExtraAttributes")?.getString("id") : args[2]; switch (command) { case "add": // ADD TO LIST @@ -180,8 +179,7 @@ export function updateList(args, list, listName) { ChatLib.chat(`${LOGO + GREEN}Successfully added "${WHITE + item + GREEN}" to the ${listName}!`); } else if (!isArray && !(key in list)) { list[key] = value; - if (listName === "spamlist") ChatLib.chat(`${LOGO + GREEN}Successfully added "${WHITE + key + GREEN}" to the ${listName}!`); - else ChatLib.chat(`${LOGO + GREEN}Successfully linked "${WHITE + value + GREEN}" to [${WHITE + key + GREEN}]!`); + ChatLib.chat(`${LOGO + GREEN}Successfully linked "${WHITE + value + GREEN}" to [${WHITE + key + GREEN}]!`); } else ChatLib.chat(`${LOGO + RED}[${WHITE + (isArray ? item : key + RED)}] is already in the ${listName}!`); break; case "remove": // REMOVE FROM LIST @@ -260,6 +258,7 @@ export function updateList(args, list, listName) { list.push("vanquisher"); list.push("jawbus"); list.push("thunder"); + list.push("inquisitor"); ChatLib.chat(`${LOGO + GREEN}Successfully set moblist to default!`); break; } @@ -281,6 +280,7 @@ ${DARK_AQUA}Special args (put in front, e.x 'a60'): base += `${GRAY}<${WHITE}[MC Entity Class], [Stand Name]${GRAY}>>`; else if (listName === "colorlist") base += "[moblist var] [r] [g] [b]"; else if (listName === "valuelist") base += `[value]\n${DARK_GRAY}This will set the value of your currently held item.`; + else if (listName === "spamlist") base += "[phrase]\n§8Remember to add variables with ${var}, for example:\n §8`va sl add Guild > ${player} left."; else base += "[item]"; ChatLib.chat(base);