Skip to content

Commit

Permalink
updated spamlist
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenga8533 committed Jan 1, 2024
1 parent 23539bb commit b3b8309
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion changelog.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
15 changes: 11 additions & 4 deletions features/general/SpamHider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
16 changes: 8 additions & 8 deletions utils/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export let data = new PogObject("VolcAddons", {
"emotelist": {},
"cooldownlist": {},
"valuelist": {},
"spamlist": new Set(),
"spamlist": [],
"ignorelist": [],
// kuudra splits stuff
"files": [],
"splits": {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down

0 comments on commit b3b8309

Please sign in to comment.