system channel check

This commit is contained in:
Thomas Rudin 2020-01-22 20:22:42 +01:00
parent 56d3d55b77
commit 616fc61b30
2 changed files with 18 additions and 2 deletions

View File

@ -15,7 +15,15 @@ module.exports = function(remote, events){
console.log("Discord-message-out", event);
}
const discord_channel_name = event.channel ? remote.channels[event.channel] : remote.channels[remote.system_channel];
let discord_channel_name;
if (event.channel != null)
// channel name sent, map to config channels
discord_channel_name = remote.channels[event.channel];
else
// no channel sent, assuming system message
discord_channel_name = remote.channels[remote.system_channel];
if (!discord_channel_name){
console.warn("discord, not mapped channel found", event.channel);
return;

View File

@ -63,7 +63,15 @@ module.exports = function(remote, events){
console.log("irc-message-out", event);
}
const channel = event.channel ? channels[event.channel] : channels[remote.system_channel];
let channel;
if (event.channel != null)
// channel name sent, map to config channels
channel = channels[event.channel];
else
// no channel sent, assuming system message
channel = channels[remote.system_channel];
if (channel) {
if (event.username){
channel.say(`<${event.username}${event.type == "minetest" ? "" : "@" + event.name}> ${event.message}`);