3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-12 13:59:26 +01:00
dbot/modules/udp/udp.js
2014-02-18 18:47:43 +00:00

23 lines
606 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 == this.config.address) {
dbot.say(this.config.server, this.config.channel, message);
}
}.bind(this));
server.bind(this.config.port);
};
exports.fetch = function(dbot) {
return new udp(dbot);
};