mirror of
https://github.com/reality/dbot.git
synced 2024-11-24 21:09:31 +01:00
25 lines
659 B
JavaScript
25 lines
659 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));
|
|
this.onLoad = function() {
|
|
server.bind(this.config.port);
|
|
}.bind(this);
|
|
};
|
|
|
|
exports.fetch = function(dbot) {
|
|
return new udp(dbot);
|
|
};
|