differentiate formatting of messages between channels
This commit is contained in:
parent
8b60c229a3
commit
44c1d6690d
3 changed files with 25 additions and 17 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fromatMessageForForward(msg) {
|
||||
const res_msg = { ...msg };
|
||||
res_msg.text = "[" + msg.author + "]: " + msg.text;
|
||||
return res_msg;
|
||||
}
|
||||
|
||||
sendTextInChannel(text, chan) {
|
||||
try {
|
||||
this.channel(chan).say(text);
|
||||
} catch (error) {
|
||||
this.log("when tryin to send message in ", chan, " got ", error);
|
||||
}
|
||||
}
|
||||
|
||||
start() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue