add factorio destruction sound alert, add command and cheer parser tests

This commit is contained in:
2025-11-27 20:39:17 +01:00
parent c9273afa88
commit d59bbd3690
4 changed files with 68 additions and 1 deletions

View File

@@ -0,0 +1,46 @@
import { describe, expect, test } from "bun:test";
import parseCommandArgs, { parseCheerArgs } from "lib/parseCommandArgs";
describe("command argument parser", () => {
test("split command into chunks", () => {
expect(parseCommandArgs("!execute eponirewq")).toEqual(["eponirewq"]);
expect(parseCommandArgs("!getloot")).toEqual([]);
expect(parseCommandArgs("!inv qwerinope")).toEqual(["qwerinope"]);
expect(parseCommandArgs("!admingive qwerinope silverbullet 67")).toEqual([
"qwerinope",
"silverbullet",
"67",
]);
});
test("handle the !use command", () => {
expect(parseCommandArgs("!use silverbullet albeees")).toEqual(["albeees"]);
expect(parseCommandArgs("!use grenade")).toEqual([]);
});
test("handle special aliases", () => {
expect(parseCommandArgs("i blast mrockstar20", "i")).toEqual([
"mrockstar20",
]);
expect(parseCommandArgs("blastin sefi", "blastin")).toEqual(["sefi"]);
expect(parseCommandArgs("i grenade", "i")).toEqual([]);
});
});
describe("cheer argument parser", () => {
test("basic parsing", () => {
expect(parseCheerArgs("cheer99")).toEqual([]);
expect(parseCheerArgs("grenade out! cheer99")).toEqual(["grenade", "out!"]);
expect(parseCheerArgs("cheer666 albeees")).toEqual(["albeees"]);
expect(parseCheerArgs("albeees cheer666")).toEqual(["albeees"]);
});
test("Remove all cheers", () => {
expect(parseCheerArgs("cheer1 cheer1 cheer1")).toEqual([]);
expect(parseCheerArgs("TAKE CHEER1 THIS chEEr1 SPAM CheeR6969")).toEqual([
"take",
"this",
"spam",
]);
});
});

View File

@@ -0,0 +1,17 @@
import PointRedeem from "pointRedeems";
import { playAlert } from "web/alerts/serverFunctions";
export default new PointRedeem({
name: "sfxFactorioAlert",
title: "Factorio Building Destroyed",
cost: 100,
color: "#A020F0",
prompt: 'Play the Factorio "Building Destroyed" sound effect',
sfxredeem: true,
execution: async (msg) =>
await playAlert({
name: "sound",
user: msg.userDisplayName,
sound: "factorioalert",
}),
});

View File

@@ -21,7 +21,11 @@ export type tntExplosionAlert = alertBase<"tntExplosion"> & {
targets: string[];
};
export type soundAlerts = "mrockmadhouse" | "eddiescream" | "ripbozo";
export type soundAlerts =
| "mrockmadhouse"
| "eddiescream"
| "ripbozo"
| "factorioalert";
export type soundAlert = alertBase<"sound"> & {
sound: soundAlerts;

Binary file not shown.