proper routing

This commit is contained in:
NatureFreshMilk 2020-01-20 13:52:47 +01:00
parent cb69e8fd48
commit 4995d57219
2 changed files with 21 additions and 3 deletions

View File

@ -39,13 +39,19 @@ module.exports = function(remote, events){
if (event.type != "privmsg")
return;
//TODO: map ingame channel
var channel = "";
Object.keys(remote.channels).forEach(ingame_channel => {
const irc_channel = remote.channels[ingame_channel];
if (irc_channel == event.target){
channel = ingame_channel;
}
});
events.emit("message-in", {
type: "irc",
name: remote.name,
username: event.nick,
channel: event.target,
channel: ingame_channel,
message: event.message
})
});
@ -61,7 +67,7 @@ module.exports = function(remote, events){
const channel = channels[event.channel]
if (channel) {
channel.say(`<${event.username}> ${event.message}`)
channel.say(`<${event.username}${event.type == "minetest" ? "" : event.type}> ${event.message}`)
}
});
}

View File

@ -9,6 +9,7 @@ module.exports = function(remotes, events){
return;
}
// dispatch to remotes
events.emit("message-out", {
type: event.type,
name: remote.name,
@ -17,6 +18,17 @@ module.exports = function(remotes, events){
message: event.message
})
});
if (event.type != "minetest") {
// dispatch to ingame too
events.emit("message-out", {
type: event.type,
name: "minetest",
username: event.username,
channel: event.channel,
message: event.message
})
}
});
}