From a074779441b38b15bfd85a0978603d6fe0add0f0 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 6 Mar 2013 13:55:35 +0000 Subject: [PATCH 1/6] add basic --- modules/rc/config.json | 3 +++ modules/rc/rc.js | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 modules/rc/config.json create mode 100644 modules/rc/rc.js diff --git a/modules/rc/config.json b/modules/rc/config.json new file mode 100644 index 0000000..4e47107 --- /dev/null +++ b/modules/rc/config.json @@ -0,0 +1,3 @@ +{ + "port":1337 +} diff --git a/modules/rc/rc.js b/modules/rc/rc.js new file mode 100644 index 0000000..d25a99d --- /dev/null +++ b/modules/rc/rc.js @@ -0,0 +1,27 @@ +/** + * Module Name: Link + * Description: Stores recent channel rcs, with commands to retrieve + * information about rcs. + */ +var dgram = require('dgram'); + +var rc = function(dbot) { + var server = dgram.createSocket("udp4"); + + server.on("message", function(msg, rinfo) { + console.log(msg.toString()); + }); + + server.bind(dbot.config.rc.port); + + + var commands = { + }; + this.commands = commands; + + this.on = 'PRIVMSG'; +}; + +exports.fetch = function(dbot) { + return new rc(dbot); +}; From 8eb60552fbd63859de1b94c77343367d7b518ada Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 6 Mar 2013 14:17:24 +0000 Subject: [PATCH 2/6] tidy --- modules/rc/rc.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/rc/rc.js b/modules/rc/rc.js index d25a99d..1b57ed0 100644 --- a/modules/rc/rc.js +++ b/modules/rc/rc.js @@ -1,7 +1,7 @@ /** - * Module Name: Link - * Description: Stores recent channel rcs, with commands to retrieve - * information about rcs. + * Module Name: RC + * Description: Relays UDP packets, intended for + * a feed of RecentChanges on a MediaWiki install. */ var dgram = require('dgram'); @@ -9,17 +9,12 @@ var rc = function(dbot) { var server = dgram.createSocket("udp4"); server.on("message", function(msg, rinfo) { + var message = msg.toString(); console.log(msg.toString()); + // dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message); }); server.bind(dbot.config.rc.port); - - - var commands = { - }; - this.commands = commands; - - this.on = 'PRIVMSG'; }; exports.fetch = function(dbot) { From 1082ea65d4518b150b7c818f16db60cd4ab2be0d Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 6 Mar 2013 14:18:43 +0000 Subject: [PATCH 3/6] actually tidy --- modules/rc/rc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/rc/rc.js b/modules/rc/rc.js index 1b57ed0..7a767f6 100644 --- a/modules/rc/rc.js +++ b/modules/rc/rc.js @@ -10,7 +10,7 @@ var rc = function(dbot) { server.on("message", function(msg, rinfo) { var message = msg.toString(); - console.log(msg.toString()); + console.log(message); // dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message); }); From 184d70d3a7cd1e09dc7fd6720210e770b1ebaf62 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 6 Mar 2013 16:34:59 +0000 Subject: [PATCH 4/6] add shizzle --- modules/rc/README.md | 12 ++++++++++++ modules/rc/config.json | 5 ++++- modules/rc/rc.js | 8 ++++---- 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 modules/rc/README.md diff --git a/modules/rc/README.md b/modules/rc/README.md new file mode 100644 index 0000000..b3d5e3b --- /dev/null +++ b/modules/rc/README.md @@ -0,0 +1,12 @@ +# RC +Prints UDP packets; designed for a MediaWiki installation. + +# Configuration +## server +The server name, as configured in the main ``config.json``, that depressionbot will announce packets from. +## channel +The channel name, that depressionbot will announce packets from. +## 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. diff --git a/modules/rc/config.json b/modules/rc/config.json index 4e47107..b1ba13a 100644 --- a/modules/rc/config.json +++ b/modules/rc/config.json @@ -1,3 +1,6 @@ { - "port":1337 + "port":14628, + "address": "127.0.0.1", + "server": "freenode", + "channel": "#zuzak2" } diff --git a/modules/rc/rc.js b/modules/rc/rc.js index 7a767f6..c494636 100644 --- a/modules/rc/rc.js +++ b/modules/rc/rc.js @@ -7,13 +7,13 @@ var dgram = require('dgram'); var rc = function(dbot) { var server = dgram.createSocket("udp4"); - - server.on("message", function(msg, rinfo) { + server.on("message", function(msg, msginfo) { var message = msg.toString(); console.log(message); - // dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message); + if (msginfo.address == dbot.config.rc.address) { + dbot.say(dbot.config.rc.server, dbot.config.rc.channel, message); + } }); - server.bind(dbot.config.rc.port); }; From c26c52a33f9731dd65b8e27738d5745f5eb05d41 Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 6 Mar 2013 16:52:24 +0000 Subject: [PATCH 5/6] tweak grammar of README --- modules/rc/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/rc/README.md b/modules/rc/README.md index b3d5e3b..57ba5ae 100644 --- a/modules/rc/README.md +++ b/modules/rc/README.md @@ -3,9 +3,9 @@ Prints UDP packets; designed for a MediaWiki installation. # Configuration ## server -The server name, as configured in the main ``config.json``, that depressionbot will announce packets from. +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 from. +The channel name, that depressionbot will announce packets on. ## port The port depressionbot will listen for UDP packets on. ## address From 8404cb42458a9662dd4244c90d8c567624e3a69a Mon Sep 17 00:00:00 2001 From: Douglas Gardner Date: Wed, 6 Mar 2013 17:48:48 +0000 Subject: [PATCH 6/6] genericise --- modules/{rc => udp}/README.md | 4 ++-- modules/{rc => udp}/config.json | 2 +- modules/{rc/rc.js => udp/udp.js} | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) rename modules/{rc => udp}/README.md (76%) rename modules/{rc => udp}/config.json (74%) rename modules/{rc/rc.js => udp/udp.js} (58%) diff --git a/modules/rc/README.md b/modules/udp/README.md similarity index 76% rename from modules/rc/README.md rename to modules/udp/README.md index 57ba5ae..1c2b284 100644 --- a/modules/rc/README.md +++ b/modules/udp/README.md @@ -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 diff --git a/modules/rc/config.json b/modules/udp/config.json similarity index 74% rename from modules/rc/config.json rename to modules/udp/config.json index b1ba13a..4619fcd 100644 --- a/modules/rc/config.json +++ b/modules/udp/config.json @@ -2,5 +2,5 @@ "port":14628, "address": "127.0.0.1", "server": "freenode", - "channel": "#zuzak2" + "channel": "#oaosidl" } diff --git a/modules/rc/rc.js b/modules/udp/udp.js similarity index 58% rename from modules/rc/rc.js rename to modules/udp/udp.js index c494636..b7d9b76 100644 --- a/modules/rc/rc.js +++ b/modules/udp/udp.js @@ -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); };