From e8f657de947ea43cb8abce28943a46d185069fc7 Mon Sep 17 00:00:00 2001 From: reality Date: Sat, 7 May 2016 16:29:18 +0000 Subject: [PATCH] that should learn it --- modules/udp/udp.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/modules/udp/udp.js b/modules/udp/udp.js index 78e5a0a..0cff950 100644 --- a/modules/udp/udp.js +++ b/modules/udp/udp.js @@ -6,20 +6,24 @@ var dgram = require('dgram'); var udp = function(dbot) { + var servers = []; + _.each(dbot.config.modules.udp.servers, function(data) { var server = dgram.createSocket("udp4"); + server.on("message", function(msg, msginfo) { var message = msg.toString(); if (msginfo.address == data.address) { dbot.say(data.server, data.channel, message); } }.bind(this)); - this.onLoad = function() { - _.each(dbot.config.modules.udp.servers, function(data) { - server.bind(data.port); - }); - }.bind(this); - }.bind(this)); + }); + + this.onLoad = function() { + _.each(servers, function(server) { + server.bind(data.port); + }); + }.bind(this); }; exports.fetch = function(dbot) {