forked from GitHub/dbot
commit
8f2cc5bd4d
12
modules/udp/README.md
Normal file
12
modules/udp/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# UDP
|
||||
Prints UDP packets; designed for a [MediaWiki installation](https://www.mediawiki.org/wiki/Manual:$wgRC2UDPAddress).
|
||||
|
||||
# Configuration
|
||||
## server
|
||||
The server name, as configured in the main ``config.json``, that depressionbot will announce packets on.
|
||||
## channel
|
||||
The channel name, that depressionbot will announce packets on.
|
||||
## port
|
||||
The port depressionbot will listen for UDP packets on.
|
||||
## address
|
||||
The address depressionbot will allow UDP packets from. UDP packets sent from a different address will be ignored.
|
6
modules/udp/config.json
Normal file
6
modules/udp/config.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"port":14628,
|
||||
"address": "127.0.0.1",
|
||||
"server": "freenode",
|
||||
"channel": "#oaosidl"
|
||||
}
|
22
modules/udp/udp.js
Normal file
22
modules/udp/udp.js
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 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 == dbot.config.udp.address) {
|
||||
dbot.say(dbot.config.udp.server, dbot.config.udp.channel, message);
|
||||
}
|
||||
});
|
||||
server.bind(dbot.config.udp.port);
|
||||
};
|
||||
|
||||
exports.fetch = function(dbot) {
|
||||
return new udp(dbot);
|
||||
};
|
Loading…
Reference in New Issue
Block a user