3
0
mirror of https://github.com/reality/dbot.git synced 2025-01-11 12:32:36 +01:00

genericise

This commit is contained in:
Douglas Gardner 2013-03-06 17:48:48 +00:00
parent c26c52a33f
commit 8404cb4245
3 changed files with 9 additions and 9 deletions

View File

@ -1,5 +1,5 @@
# RC
Prints UDP packets; designed for a MediaWiki installation.
# UDP
Prints UDP packets; designed for a [MediaWiki installation](https://www.mediawiki.org/wiki/Manual:$wgRC2UDPAddress).
# Configuration
## server

View File

@ -2,5 +2,5 @@
"port":14628,
"address": "127.0.0.1",
"server": "freenode",
"channel": "#zuzak2"
"channel": "#oaosidl"
}

View File

@ -1,22 +1,22 @@
/**
* Module Name: RC
* Module Name: UDP
* Description: Relays UDP packets, intended for
* a feed of RecentChanges on a MediaWiki install.
*/
var dgram = require('dgram');
var rc = function(dbot) {
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.rc.address) {
dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message);
if (msginfo.address == dbot.config.udp.address) {
dbot.say(dbot.config.udp.server, dbot.config.udp.channel, message);
}
});
server.bind(dbot.config.rc.port);
server.bind(dbot.config.udp.port);
};
exports.fetch = function(dbot) {
return new rc(dbot);
return new udp(dbot);
};