mirror of
https://github.com/reality/dbot.git
synced 2025-01-11 12:32:36 +01:00
genericise
This commit is contained in:
parent
c26c52a33f
commit
8404cb4245
@ -1,5 +1,5 @@
|
|||||||
# RC
|
# UDP
|
||||||
Prints UDP packets; designed for a MediaWiki installation.
|
Prints UDP packets; designed for a [MediaWiki installation](https://www.mediawiki.org/wiki/Manual:$wgRC2UDPAddress).
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
## server
|
## server
|
@ -2,5 +2,5 @@
|
|||||||
"port":14628,
|
"port":14628,
|
||||||
"address": "127.0.0.1",
|
"address": "127.0.0.1",
|
||||||
"server": "freenode",
|
"server": "freenode",
|
||||||
"channel": "#zuzak2"
|
"channel": "#oaosidl"
|
||||||
}
|
}
|
@ -1,22 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* Module Name: RC
|
* Module Name: UDP
|
||||||
* Description: Relays UDP packets, intended for
|
* Description: Relays UDP packets, intended for
|
||||||
* a feed of RecentChanges on a MediaWiki install.
|
* a feed of RecentChanges on a MediaWiki install.
|
||||||
*/
|
*/
|
||||||
var dgram = require('dgram');
|
var dgram = require('dgram');
|
||||||
|
|
||||||
var rc = function(dbot) {
|
var udp = function(dbot) {
|
||||||
var server = dgram.createSocket("udp4");
|
var server = dgram.createSocket("udp4");
|
||||||
server.on("message", function(msg, msginfo) {
|
server.on("message", function(msg, msginfo) {
|
||||||
var message = msg.toString();
|
var message = msg.toString();
|
||||||
console.log(message);
|
console.log(message);
|
||||||
if (msginfo.address == dbot.config.rc.address) {
|
if (msginfo.address == dbot.config.udp.address) {
|
||||||
dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message);
|
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) {
|
exports.fetch = function(dbot) {
|
||||||
return new rc(dbot);
|
return new udp(dbot);
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user