This commit is contained in:
NatureFreshMilk 2020-01-20 14:02:07 +01:00
parent a1bf7ff66b
commit 8098f6dc39
5 changed files with 17 additions and 20 deletions

View File

@ -1,6 +1,5 @@
const app = require("../app");
const cfg = require("../config");
const events = require("../events");
var buffer = [];

View File

@ -1,6 +1,6 @@
const Discord = require('discord.js');
module.exports = function(remote, events){
module.exports = function(remote){
Object.keys(remote.channels).forEach(ingame_channel => {
const token = remote.channels[ingame_channel];
const client = new Discord.Client();
@ -15,6 +15,6 @@ module.exports = function(remote, events){
}
});
client.login(token);
client.login(token);
});
}
};

View File

@ -27,13 +27,11 @@ module.exports = function(remote, events){
channel.say(`beerchat_proxy connected! ingame-channel: ${ingame_name}`);
channels[ingame_name] = channel;
});
resolve(channels);
});
client.on('message', function(event) {
if (remote.debug){
console.log("irc-event-in", event)
console.log("irc-event-in", event);
}
if (event.type != "privmsg")
@ -51,9 +49,9 @@ module.exports = function(remote, events){
type: "irc",
name: remote.name,
username: event.nick,
channel: ingame_channel,
channel: channel,
message: event.message
})
});
});
events.on("message-out", function(event){
@ -62,12 +60,12 @@ module.exports = function(remote, events){
return;
if (remote.debug){
console.log("irc-message-out", event)
console.log("irc-message-out", event);
}
const channel = channels[event.channel]
const channel = channels[event.channel];
if (channel) {
channel.say(`<${event.username}${event.type == "minetest" ? "" : event.type}> ${event.message}`)
channel.say(`<${event.username}${event.type == "minetest" ? "" : event.type}> ${event.message}`);
}
});
}
};

View File

@ -11,14 +11,14 @@ const router = require("./router");
const handlers = {
irc: require("./handler/irc"),
discord: require("./handler/discord")
}
};
cfg.remotes.forEach(remote => {
const handler = handlers[remote.type]
const handler = handlers[remote.type];
console.log(`Setting up remote: ${remote.name} with type: ${remote.type}`)
console.log(`Setting up remote: ${remote.name} with type: ${remote.type}`);
handler(remote, events);
})
});
console.log("Starting message router");
router(cfg.remotes, events);

View File

@ -16,7 +16,7 @@ module.exports = function(remotes, events){
username: event.username,
channel: event.channel,
message: event.message
})
});
});
if (event.type != "minetest") {
@ -27,8 +27,8 @@ module.exports = function(remotes, events){
username: event.username,
channel: event.channel,
message: event.message
})
});
}
});
}
};