fix broadcasting messag
es from discord from untracked channels
This commit is contained in:
parent
98db841d0e
commit
8b60c229a3
3 changed files with 10 additions and 10 deletions
|
|
@ -19,10 +19,12 @@ class DiscordClient extends Client {
|
||||||
this.trackedChannels = channels;
|
this.trackedChannels = channels;
|
||||||
|
|
||||||
this.on("messageCreate", (msg) => {
|
this.on("messageCreate", (msg) => {
|
||||||
//this.log("message recived", msg);
|
this.log("message recived", msg);
|
||||||
|
|
||||||
// catch self messages
|
// catch self messages
|
||||||
if (msg.author.id == this.user.id) return;
|
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();
|
const internal_msg = new Message();
|
||||||
internal_msg.fromDiscordFormat(msg);
|
internal_msg.fromDiscordFormat(msg);
|
||||||
|
|
@ -36,7 +38,7 @@ class DiscordClient extends Client {
|
||||||
|
|
||||||
broadcast(msg) {
|
broadcast(msg) {
|
||||||
for (const chan of this.trackedChannels) {
|
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);
|
this.sendTextInChannel(msg.text, chan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class IRCClient extends Client {
|
||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
|
|
||||||
this.on("message", (msg) => {
|
this.on("message", (msg) => {
|
||||||
//this.log("message recived", msg);
|
this.log("message recived", msg);
|
||||||
|
|
||||||
if (msg.from_server) return;
|
if (msg.from_server) return;
|
||||||
if (!msg.target) return;
|
if (!msg.target) return;
|
||||||
|
|
@ -17,14 +17,11 @@ class IRCClient extends Client {
|
||||||
msg.target = msg.target.toLowerCase();
|
msg.target = msg.target.toLowerCase();
|
||||||
|
|
||||||
// catch self messages
|
// catch self messages
|
||||||
if (msg.nick == this.user.nick) {
|
if (msg.nick == this.user.nick) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log("Message is okay");
|
|
||||||
|
|
||||||
const internal_msg = new Message();
|
const internal_msg = new Message();
|
||||||
internal_msg.fromIRCFormat(msg);
|
internal_msg.fromIRCFormat(msg);
|
||||||
|
|
||||||
this.bridge.broadcast(internal_msg);
|
this.bridge.broadcast(internal_msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -35,7 +32,8 @@ class IRCClient extends Client {
|
||||||
|
|
||||||
broadcast(msg) {
|
broadcast(msg) {
|
||||||
for (const chan of this.channels) {
|
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 {
|
try {
|
||||||
this.sendTextInChannel(msg.text, chan);
|
this.sendTextInChannel(msg.text, chan);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,5 @@
|
||||||
"1161739009614151751",
|
"1161739009614151751",
|
||||||
"727212463988146206"
|
"727212463988146206"
|
||||||
],
|
],
|
||||||
"ircChannels": ["#UrLab"]
|
"ircChannels": ["#urlab"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue