3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00
dbot/modules/udp/udp.js
Douglas Gardner 8404cb4245 genericise
2013-03-06 17:48:48 +00:00

23 lines
611 B
JavaScript

/**
* Module Name: UDP
* Description: Relays UDP packets, intended for
* a feed of RecentChanges on a MediaWiki install.
*/
var dgram = require('dgram');
var udp = function(dbot) {
var server = dgram.createSocket("udp4");
server.on("message", function(msg, msginfo) {
var message = msg.toString();
console.log(message);
if (msginfo.address == dbot.config.udp.address) {
dbot.say(dbot.config.udp.server, dbot.config.udp.channel, message);
}
});
server.bind(dbot.config.udp.port);
};
exports.fetch = function(dbot) {
return new udp(dbot);
};