Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions archipelagoHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,11 @@ client.items.on("itemsReceived", (items) => {
loadCache(); //make sure the cache is loaded before sending any item to chat
if (notifiedItems.includes(696969)){ onCountdown("TRUE"); }
for (let i of items) {
// I'm sure that there was a reason to add 100000 to the id, but uh, clearly past delilah did not do me any favors
if (notifiedItems.includes(Number(i.id))) { continue; }
if (notifiedItems.includes(Number(i.id) + 100000)) { continue; }
if (Number(i.id) > 12400) {
notifiedItems.push(Number(i.id) + 100000);
} else {
notifiedItems.push(Number(i.id)) }
const itemKey = { id: Number(i.id), locationId: Number(i.locationId) };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Data Mismatch Breaks Countdown State

The countdown flag check uses .includes(696969) with a primitive number, but notifiedItems now stores objects with { id, locationId } structure. This check will always fail since .includes() compares objects by reference, breaking countdown state tracking.

Fix in Cursor Fix in Web

if (notifiedItems.some(notifiedItem => notifiedItem.id === itemKey.id && notifiedItem.locationId === itemKey.locationId)) { continue; }
notifiedItems.push(itemKey);
messageUtil.saveItems(notifiedItems, fileName);
console.debug(`ID ${i.id}, Name ${i.name}, Sender ${i.sender}, Flags ${i.flags}`);
console.debug(`ID ${i.id}, Name ${i.name}, Sender ${i.sender}, Flags ${i.flags}, LocationId ${i.locationId}`);
onItemReceived(i.id, i.name, i.sender, i.flags);
}
})
Expand Down
2 changes: 1 addition & 1 deletion bot-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function onItem(id, item, player, flags) {
if (Math.random() < 0.6) { currently_dead = true; }
const timedOutUser = await webhook.postInChat(messageUtil.generateRandomText(messageUtil.ITEM_TRAP, { item: item, player: player }), currently_dead, false);
if (timedOutUser) {
console.log(`${timedOutUser} user died`);
console.log(`${timedOutUser} user died`);
deathLink(timedOutUser);
}
}
Expand Down
2 changes: 1 addition & 1 deletion messageUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function loadFiles() {
}

function myCallback() {
console.debug(`Saved ${jsonItems}`);
console.debug(`Saved ${jsonItems.length} items.`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Misleading Item Count in Debug Output

The debug message uses jsonItems.length which returns the character count of the JSON string, not the number of items. Since jsonItems is assigned JSON.stringify(collectedItems) on line 111, the logged value represents string length rather than item count as the message "items" suggests.

Fix in Cursor Fix in Web

}

function saveItems(collectedItems, filename) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chatipelago",
"version": "1.2.6",
"version": "1.2.7",
"description": "Chatipelago",
"main": "app.js",
"type": "module",
Expand Down
17 changes: 7 additions & 10 deletions webhook-put.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,14 @@ async function postInChat(message, trap, bounced) {
if (trap) {
// Trap message triggers additional trap-related actions with response
await sendMessage(message);
const response = await streamerbotclient.doAction(config.streamerbotActions.trapMessage, {
customEventResponse: true
});
const response = await streamerbotclient.doAction(
config.streamerbotActions.trapMessage,
{ "timedOutUser": "Chat" },
{ customEventResponse: true }
);
console.debug('ResponseCustomEventResponseArgs:', response.customEventResponseArgs);
return response.customEventResponseArgs.randomUser0 || "Chat";
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Regression: Unsafe Data Access Causes Errors

The code accesses response.customEventResponseArgs.randomUser0 without null-checking customEventResponseArgs first. The previous implementation had null-checking (if (response.customEventResponseArgs && ...)). If customEventResponseArgs is undefined, this will throw TypeError instead of returning the "Chat" fallback.

Fix in Cursor Fix in Web


// Extract the timedOutUser argument from the response
if (response.customEventResponseArgs && response.customEventResponseArgs.timedOutUser) {
console.log('Chat user died:', response.customEventResponseArgs.timedOutUser);
return response.customEventResponseArgs.timedOutUser;
}

return response;
} else if (bounced) {
// Bounced message enables emote mode for 30 seconds
await sendMessage(message);
Expand Down