Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow sending IRC topic changes to Discord #380

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"#irc
should be
"#irc"

],
"ircOptions": { // Optional node-irc options
"floodProtection": false, // On by default
"floodProtectionDelay": 1000 // 500 by default
Expand Down
14 changes: 14 additions & 0 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {};
Expand Down Expand Up @@ -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);
Expand Down