diff --git a/README.md b/README.md index f3272f1d..19395b61 100644 --- a/README.md +++ b/README.md @@ -71,6 +71,9 @@ First you need to create a Discord bot user, which you can do by following the i "#discord": "#irc channel-password", // Add channel keys after the channel name "1234567890": "#channel" // Use a discord channel ID instead of its name (so you can rename it or to disambiguate) }, + "channelTopicsToDiscord": [ // Sends topic changes from IRC to Discord + "#irc + ], "ircOptions": { // Optional node-irc options "floodProtection": false, // On by default "floodProtectionDelay": 1000 // 500 by default diff --git a/lib/bot.js b/lib/bot.js index 418c7a41..77d96a5d 100644 --- a/lib/bot.js +++ b/lib/bot.js @@ -37,6 +37,7 @@ class Bot { this.ircStatusNotices = options.ircStatusNotices; this.announceSelfJoin = options.announceSelfJoin; this.webhookOptions = options.webhooks; + this.channelTopicsToDiscord = options.channelTopicsToDiscord; // Nicks to ignore this.ignoreUsers = options.ignoreUsers || {}; @@ -238,6 +239,19 @@ class Bot { } }); + if (typeof this.channelTopicsToDiscord !== 'undefined') { + this.ircClient.on('topic', (channel, topic, nick, message) => { + if (message.command !== 'rpl_topicwhotime') { + logger.debug('Received topic change from IRC:', channel, topic); + const channelIncluded = this.channelTopicsToDiscord === true || + this.channelTopicsToDiscord.includes(channel); + if (channelIncluded) { + this.sendExactToDiscord(channel, `*${nick}* has changed the topic to "${topic}"`); + } + } + }); + } + if (logger.level === 'debug') { this.discord.on('debug', (message) => { logger.debug('Received debug event from Discord', message);