diff --git a/src/handler/irc.js b/src/handler/irc.js index 8d7e7ec..686f49f 100644 --- a/src/handler/irc.js +++ b/src/handler/irc.js @@ -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}`) } }); } diff --git a/src/router.js b/src/router.js index a6ab9c9..9c38877 100644 --- a/src/router.js +++ b/src/router.js @@ -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 + }) + } }); }