diff --git a/lib/bot.js b/lib/bot.js index 7688ee70..ff56ebde 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -36,6 +36,7 @@ class Bot { this.channels = _.values(options.channelMapping); this.ircStatusNotices = options.ircStatusNotices; this.announceSelfJoin = options.announceSelfJoin; + this.alterPresence = options.alterPresence // Nicks to ignore this.ignoreUsers = options.ignoreUsers || {}; @@ -82,32 +83,49 @@ class Bot { connect() { logger.debug('Connecting to IRC and Discord'); - this.discord.login(this.discordToken); - - const ircOptions = { - userName: this.nickname, - realName: this.nickname, - channels: this.channels, - floodProtection: true, - floodProtectionDelay: 500, - retryCount: 10, - autoRenick: true, - // options specified in the configuration file override the above defaults - ...this.ircOptions - }; + this.discord.login(this.discordToken).then(_ => { + if (this.alterPresence) { + let { secure, port } = this.ircOptions + port = port || 6667 + let name = `irc://${this.server}/${secure ? '+' : ''}${port}` + + this.discord.user.setPresence({ + game: { + type: 'WATCHING', + name + } + }) + } + + const ircOptions = { + userName: this.nickname, + realName: this.nickname, + channels: this.channels, + floodProtection: true, + floodProtectionDelay: 500, + retryCount: 10, + autoRenick: true, + // options specified in the configuration file override the above defaults + ...this.ircOptions + }; - // default encoding to UTF-8 so messages to Discord aren't corrupted - if (!Object.prototype.hasOwnProperty.call(ircOptions, 'encoding')) { - if (irc.canConvertEncoding()) { - ircOptions.encoding = 'utf-8'; - } else { - logger.warn('Cannot convert message encoding; you may encounter corrupted characters with non-English text.\n' + - 'For information on how to fix this, please see: https://github.com/Throne3d/node-irc#character-set-detection'); + // default encoding to UTF-8 so messages to Discord aren't corrupted + if (!Object.prototype.hasOwnProperty.call(ircOptions, 'encoding')) { + if (irc.canConvertEncoding()) { + ircOptions.encoding = 'utf-8'; + } else { + logger.warn('Cannot convert message encoding; you may encounter corrupted characters with non-English text.\n' + + 'For information on how to fix this, please see: https://github.com/Throne3d/node-irc#character-set-detection'); + } } - } - this.ircClient = new irc.Client(this.server, this.nickname, ircOptions); - this.attachListeners(); + this.ircClient = new irc.Client(this.server, this.nickname, ircOptions); + this.attachListeners(); + + + }); + + } attachListeners() {