From b8a83261b085898930131789d87e1f7dbc18f224 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Mon, 20 Jan 2020 07:25:09 +0100 Subject: [PATCH] partial rewrite --- src/api/rx.js | 8 ++------ src/api/tx.js | 11 +++-------- src/clients/irc.js | 4 ++++ src/events.js | 28 +++++++++++++++++++++++++++- 4 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 src/clients/irc.js diff --git a/src/api/rx.js b/src/api/rx.js index 26b9967..f849582 100644 --- a/src/api/rx.js +++ b/src/api/rx.js @@ -13,21 +13,17 @@ app.post('/', jsonParser, function(req, res){ return; } - const channel = channels[req.body.channel]; + const channel = channels[req.body.source_channel]; const main_channel = channels.main; if (channel){ // player message channel.say( - (req.body.playername ? `<${req.body.playername}> ` : "") + + (req.body.source ? `<${req.body.source}> ` : "") + req.body.message ); - } else if (!req.body.channel) { - // system message - main_channel.say(req.body.message); } - }) .catch(e => console.log(e)); diff --git a/src/api/tx.js b/src/api/tx.js index 49ea960..0b63ee3 100644 --- a/src/api/tx.js +++ b/src/api/tx.js @@ -21,7 +21,6 @@ app.get('/', function(req, res){ } var channel_name; - var direct = false; Object.keys(cfg.channels).forEach(ingame_name => { const irc_name = cfg.channels[ingame_name]; @@ -31,14 +30,10 @@ app.get('/', function(req, res){ } }); - if (event.target == cfg.username){ - direct = true; - } - res.json({ - direct: direct, - channel: channel_name, - username: event.nick, + source_system: event.source_system, + target: channel_name, // mapped channel name: "#main", "#lag" + source: event.nick, // "somedude" message: event.message }); } diff --git a/src/clients/irc.js b/src/clients/irc.js new file mode 100644 index 0000000..ba0c4ce --- /dev/null +++ b/src/clients/irc.js @@ -0,0 +1,4 @@ + +modules.exports = function(){ + +} diff --git a/src/events.js b/src/events.js index 31393b8..a2a164d 100644 --- a/src/events.js +++ b/src/events.js @@ -1,4 +1,30 @@ +/* +Events: + + +## "message" + +{ + // source messaging system + // "irc", "discord", "minetest", etc + source_system: "irc" + + // the target channel/username + target: "#main", + + // the source username + source; "SomeDude", + + // the source channel: "#main", "#lag", etc + source_channel: "", + + //the actual message + message: "xyz", +} + + +*/ + const EventEmitter = require("events"); - module.exports = new EventEmitter();