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
|
!ecosystem.config.js
|
||||||
*.sqlite
|
*.sqlite
|
||||||
points/*
|
points/*
|
||||||
|
points-*
|
||||||
assets/mash-words.json
|
assets/mash-words.json
|
||||||
|
|||||||
+13
-12
@@ -32,6 +32,19 @@ async function init() {
|
|||||||
|
|
||||||
const games = await getGames(bot, config.user.id);
|
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', () => {
|
client.addListener('registered', () => {
|
||||||
logger.info('Connected!');
|
logger.info('Connected!');
|
||||||
logger.info('Identifying with NickServ');
|
logger.info('Identifying with NickServ');
|
||||||
@@ -47,18 +60,6 @@ async function init() {
|
|||||||
client.say(channel, config.greeting);
|
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