Fixed IRC message and error listeners reinitializing on reconnect, causing 'split personality' bug.
This commit is contained in:
@@ -5,4 +5,5 @@ config/*
|
||||
!ecosystem.config.js
|
||||
*.sqlite
|
||||
points/*
|
||||
points-*
|
||||
assets/mash-words.json
|
||||
|
||||
+13
-12
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user