Skip to content

Commit

Permalink
new parsing and associated test (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
horrible-little-slime authored Nov 2, 2023
1 parent 142fcc4 commit d2ae1dc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/clients/kol.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,38 @@ describe("LoathingChat", () => {
});
});

test("Can parse a system message for rollover in one minute", async () => {
vi.mocked(axios).mockResolvedValueOnce(
await respondWith({
msgs: [
{
msg: "The system will go down for nightly maintenance in 1 minute.",
type: "system",
mid: "1538084998",
who: { name: "System Message", id: "-1", color: "" },
format: "2",
channelcolor: "green",
time: "1698809101",
},
],
}),
);

const messageSpy = vi.fn();

kolClient.on("system", messageSpy);

await kolClient.checkMessages();

expect(messageSpy).toHaveBeenCalledOnce();
expect(messageSpy).toHaveBeenCalledWith({
type: "system",
who: { id: -1, name: "System Message" },
msg: "The system will go down for nightly maintenance in 1 minute.",
time: new Date(1698809101000),
});
});

test("Can parse a system message for rollover complete", async () => {
vi.mocked(axios).mockResolvedValueOnce(
await respondWith({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/kol/announcement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { KoLMessage, kolClient } from "../../clients/kol.js";
import { config } from "../../config.js";

function isAnnouncement(message: KoLMessage) {
return !/^(The system will go down for nightly maintenance in \d+ minutes|Rollover is over).$/.test(
return !/^(The system will go down for nightly maintenance in \d+ minutes?|Rollover is over).$/.test(
message.msg,
);
}
Expand Down

0 comments on commit d2ae1dc

Please sign in to comment.