Permalink
Browse files

Added new web-proxy service for passing raw JSON messages via HTTP or…

… sending messages easily into a channel via HTTP posts.
  • Loading branch information...
1 parent 6b73aa7 commit 9503ccc676785035b9f36bcac2208a473cc9b272 @aaronpk committed Jan 24, 2013
Showing with 33 additions and 0 deletions.
  1. +30 −0 services/web-proxy.js
  2. +3 −0 services/web-proxy.json.dist
View
@@ -0,0 +1,30 @@
+var api = require('zenircbot-api');
+var bot_config = api.load_config('../bot.json');
+var zen = new api.ZenIRCBot(bot_config.redis.host,
+ bot_config.redis.port,
+ bot_config.redis.db);
+var redis = zen.get_redis_client();
+var web_config = api.load_config('./web-proxy.json');
+var express = require('express');
+var app = express();
+
+
+zen.register_commands('web-proxy.js', []);
+
+app.use(express.bodyParser());
+
+app.post('/', function(req, res) {
+ console.log(req.body.payload);
+ redis.publish('out', req.body.payload);
+ res.send('ok', 200);
+});
+
+app.post('/:channel', function(req, res) {
+ console.log(req.params.channel + ": " + req.body.message);
+ zen.send_privmsg(req.params.channel, req.body.message);
+ res.send('ok', 200);
+});
+
+app.listen(web_config.port);
+
+console.log("Listening on "+web_config.port);
@@ -0,0 +1,3 @@
+{
+ "port": 10000
+}

0 comments on commit 9503ccc

Please sign in to comment.