partial rewrite
This commit is contained in:
parent
a4f58cab9c
commit
b8a83261b0
@ -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));
|
||||
|
||||
|
@ -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
|
||||
});
|
||||
}
|
||||
|
4
src/clients/irc.js
Normal file
4
src/clients/irc.js
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
modules.exports = function(){
|
||||
|
||||
}
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user