3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-18 00:22:35 +01:00
dbot/modules/rc/rc.js

23 lines
603 B
JavaScript
Raw Normal View History

2013-03-06 14:55:35 +01:00
/**
2013-03-06 15:17:24 +01:00
* Module Name: RC
* Description: Relays UDP packets, intended for
* a feed of RecentChanges on a MediaWiki install.
2013-03-06 14:55:35 +01:00
*/
var dgram = require('dgram');
var rc = function(dbot) {
var server = dgram.createSocket("udp4");
2013-03-06 17:34:59 +01:00
server.on("message", function(msg, msginfo) {
2013-03-06 15:17:24 +01:00
var message = msg.toString();
2013-03-06 15:18:43 +01:00
console.log(message);
2013-03-06 17:34:59 +01:00
if (msginfo.address == dbot.config.rc.address) {
dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message);
}
2013-03-06 14:55:35 +01:00
});
server.bind(dbot.config.rc.port);
};
exports.fetch = function(dbot) {
return new rc(dbot);
};