3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-24 04:49:25 +01:00

Merge branch 'master' of github.com:reality/depressionbot

This commit is contained in:
reality 2013-05-19 10:49:02 +00:00
commit 329a0df7fb
3 changed files with 40 additions and 0 deletions

12
modules/udp/README.md Normal file
View 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
View File

@ -0,0 +1,6 @@
{
"port":14628,
"address": "127.0.0.1",
"server": "freenode",
"channel": "#oaosidl"
}

22
modules/udp/udp.js Normal file
View 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);
};