fix broadcasting messag

es from discord from untracked channels
This commit is contained in:
vincent 2025-02-19 15:52:31 +01:00
parent 98db841d0e
commit 8b60c229a3
3 changed files with 10 additions and 10 deletions

View file

@ -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);
}
}

View file

@ -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) {

View file

@ -4,5 +4,5 @@
"1161739009614151751",
"727212463988146206"
],
"ircChannels": ["#UrLab"]
"ircChannels": ["#urlab"]
}