that should learn it

This commit is contained in:
reality 2016-05-07 16:29:18 +00:00
parent aeea5a7e18
commit e8f657de94

View File

@ -6,20 +6,24 @@
var dgram = require('dgram'); var dgram = require('dgram');
var udp = function(dbot) { var udp = function(dbot) {
var servers = [];
_.each(dbot.config.modules.udp.servers, function(data) { _.each(dbot.config.modules.udp.servers, function(data) {
var server = dgram.createSocket("udp4"); var server = dgram.createSocket("udp4");
server.on("message", function(msg, msginfo) { server.on("message", function(msg, msginfo) {
var message = msg.toString(); var message = msg.toString();
if (msginfo.address == data.address) { if (msginfo.address == data.address) {
dbot.say(data.server, data.channel, message); dbot.say(data.server, data.channel, message);
} }
}.bind(this)); }.bind(this));
});
this.onLoad = function() { this.onLoad = function() {
_.each(dbot.config.modules.udp.servers, function(data) { _.each(servers, function(server) {
server.bind(data.port); server.bind(data.port);
}); });
}.bind(this); }.bind(this);
}.bind(this));
}; };
exports.fetch = function(dbot) { exports.fetch = function(dbot) {