diff --git a/.gitignore b/.gitignore index 1c323dc..38f6671 100755 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ config/* !ecosystem.config.js *.sqlite points/* +points-* assets/mash-words.json diff --git a/src/irc.js b/src/irc.js index 85b73d2..792a95a 100755 --- a/src/irc.js +++ b/src/irc.js @@ -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); - }); }); }