diff --git a/Bridge/class/Bridge.js b/Bridge/class/Bridge.js index 0c84950..439227c 100644 --- a/Bridge/class/Bridge.js +++ b/Bridge/class/Bridge.js @@ -37,16 +37,10 @@ class Bridge { this.log("Broadcasting", msg); for (const client of this.clients) { - client.broadcast(this.fromatMessageForForward(msg)); + client.broadcast(msg); } } - fromatMessageForForward(msg) { - const res_msg = { ...msg }; - res_msg.text = "<" + msg.author + ">: " + msg.text; - return res_msg; - } - log(...args) { return console.log("[BRIDGE]", ...args); } diff --git a/DiscordBot/class/Client.js b/DiscordBot/class/Client.js index f76bbe9..8509c41 100644 --- a/DiscordBot/class/Client.js +++ b/DiscordBot/class/Client.js @@ -36,7 +36,8 @@ class DiscordClient extends Client { if (this.verbose) console.log("[Discord]", ...args); } - broadcast(msg) { + broadcast(message) { + const msg = this.fromatMessageForForward(message); for (const chan of this.trackedChannels) { if (chan != msg.channel) { // do not send in the channel the message is comming from this.sendTextInChannel(msg.text, chan); @@ -44,6 +45,12 @@ class DiscordClient extends Client { } } + fromatMessageForForward(msg) { + const res_msg = { ...msg }; + res_msg.text = "[**" + msg.author + "**]: " + msg.text; + return res_msg; + } + sendTextInChannel(text, chan) { this.channels.cache .get(chan) diff --git a/IRCBot/class/Client.js b/IRCBot/class/Client.js index 4ee3ed9..7023fc1 100644 --- a/IRCBot/class/Client.js +++ b/IRCBot/class/Client.js @@ -21,7 +21,7 @@ class IRCClient extends Client { const internal_msg = new Message(); internal_msg.fromIRCFormat(msg); - + this.bridge.broadcast(internal_msg); }); } @@ -30,21 +30,28 @@ class IRCClient extends Client { if (this.verbose) console.log("[IRC]", ...args); } - broadcast(msg) { + broadcast(message) { + const msg = this.fromatMessageForForward(message); for (const chan of this.channels) { + // do not send in the channel the message is comming from if (chan != msg.channel) { - // do not send in the channel the message - try { - this.sendTextInChannel(msg.text, chan); - } catch (error) { - this.log("when tryin to send message in ", chan, " got ", error); - } + this.sendTextInChannel(msg.text, chan); } } } + fromatMessageForForward(msg) { + const res_msg = { ...msg }; + res_msg.text = "[" + msg.author + "]: " + msg.text; + return res_msg; + } + sendTextInChannel(text, chan) { - this.channel(chan).say(text); + try { + this.channel(chan).say(text); + } catch (error) { + this.log("when tryin to send message in ", chan, " got ", error); + } } start() {