Fixed IRC message and error listeners reinitializing on reconnect, causing 'split personality' bug.

This commit is contained in:
ThePendulum
2026-10-07 02:48:08 +02:00
parent 529e8338d6
commit 81c728bd9d
2 changed files with 14 additions and 12 deletions
+1
View File
@@ -5,4 +5,5 @@ config/*
!ecosystem.config.js
*.sqlite
points/*
points-*
assets/mash-words.json
+13 -12
View File
@@ -32,6 +32,19 @@ async function init() {
const games = await getGames(bot, config.user.id);
// registered fires again on every reconnect, so these must only be bound once
client.addListener('message', (from, to, body) => onMessage({
from,
to,
recipient: /^#/.test(to) ? null : to,
body,
type: 'message',
}, bot, games));
client.addListener('error', (error) => {
logger.error(error);
});
client.addListener('registered', () => {
logger.info('Connected!');
logger.info('Identifying with NickServ');
@@ -47,18 +60,6 @@ async function init() {
client.say(channel, config.greeting);
}
});
client.addListener('message', (from, to, body) => onMessage({
from,
to,
recipient: /^#/.test(to) ? null : to,
body,
type: 'message',
}, bot, games));
client.addListener('error', (error) => {
logger.error(error);
});
});
}