From 8b60c229a38caa6a197003a1b0a0b5a93c81731d Mon Sep 17 00:00:00 2001 From: vincent <> Date: Wed, 19 Feb 2025 15:52:31 +0100 Subject: [PATCH] fix broadcasting messag es from discord from untracked channels --- DiscordBot/class/Client.js | 6 ++++-- IRCBot/class/Client.js | 12 +++++------- config.json | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/DiscordBot/class/Client.js b/DiscordBot/class/Client.js index c27b16f..f76bbe9 100644 --- a/DiscordBot/class/Client.js +++ b/DiscordBot/class/Client.js @@ -19,10 +19,12 @@ class DiscordClient extends Client { this.trackedChannels = channels; this.on("messageCreate", (msg) => { - //this.log("message recived", msg); + this.log("message recived", msg); // catch self messages if (msg.author.id == this.user.id) return; + // only propagate messages from tracked channels + if (!this.trackedChannels.includes(msg.channelId)) return; const internal_msg = new Message(); internal_msg.fromDiscordFormat(msg); @@ -36,7 +38,7 @@ class DiscordClient extends Client { broadcast(msg) { for (const chan of this.trackedChannels) { - if (chan != msg.channel) { // do not send in the channel the message + if (chan != msg.channel) { // do not send in the channel the message is comming from this.sendTextInChannel(msg.text, chan); } } diff --git a/IRCBot/class/Client.js b/IRCBot/class/Client.js index ca3a04a..4ee3ed9 100644 --- a/IRCBot/class/Client.js +++ b/IRCBot/class/Client.js @@ -9,7 +9,7 @@ class IRCClient extends Client { this.verbose = verbose; this.on("message", (msg) => { - //this.log("message recived", msg); + this.log("message recived", msg); if (msg.from_server) return; if (!msg.target) return; @@ -17,14 +17,11 @@ class IRCClient extends Client { msg.target = msg.target.toLowerCase(); // catch self messages - if (msg.nick == this.user.nick) { - return; - } - - this.log("Message is okay"); + if (msg.nick == this.user.nick) return; const internal_msg = new Message(); internal_msg.fromIRCFormat(msg); + this.bridge.broadcast(internal_msg); }); } @@ -35,7 +32,8 @@ class IRCClient extends Client { broadcast(msg) { for (const chan of this.channels) { - if (chan != msg.channel) { // do not send in the channel the message + if (chan != msg.channel) { + // do not send in the channel the message try { this.sendTextInChannel(msg.text, chan); } catch (error) { diff --git a/config.json b/config.json index a807048..99fdfc8 100644 --- a/config.json +++ b/config.json @@ -4,5 +4,5 @@ "1161739009614151751", "727212463988146206" ], - "ircChannels": ["#UrLab"] + "ircChannels": ["#urlab"] }