Permalink
Browse files

Bitbucket works, includes bitty support and looks good, cloudkick add…

…ed, skeletonhttpd example file added.
  • Loading branch information...
1 parent edcc633 commit 6f34fc21d06a72cf5263bc81709985afda16a26a @johnhamelink committed Feb 2, 2012
Showing with 80 additions and 6 deletions.
  1. +13 −3 bitbucket.js
  2. +33 −0 cloudkick.js
  3. +1 −1 github.js
  4. +3 −2 httpd.js
  5. +30 −0 skeletonhttpd.js
View
@@ -2,10 +2,11 @@ module.exports = flow = {
robot: null,
express: null,
pubsub: null,
+ bitly: null,
init: function(robot,express,pubsub){
this.robot = robot;
this.express = express;
- this.pubsub = express;
+ this.pubsub = pubsub;
this.setUpExpress();
this.setUpHubot();
},
@@ -23,8 +24,17 @@ module.exports = flow = {
this.robot.hear('',function(msg){
flow.pubsub.removeAllListeners('bitbucket/newCommit');
flow.pubsub.on('bitbucket/newCommit',function(payload){
- var response = '['+payload.repository.name+'] New commit by '+payload.commits[0].author+': "'+payload.commits[0].message+'" '+payload.repository.website+payload.repository.absolute_url.'changeset/'+payload.repository.commits[0].node;
- msg.send(response);
+ payload.commits[0].message = payload.commits[0].message.replace(/\n/gm,"");
+ var url = null;
+ var Bitly = require('bitly');
+ var bitly = new Bitly('s0l1dsnak3123', 'R_36bd50ae52c1ad2de6eb92fe4ee3233d');
+ bitly.shorten('https://bitbucket.org' payload.repository.absolute_url 'changeset/' payload.commits[0].node,function(err,resp){
+ if(err) throw err;
+ console.log(resp.data);
+ url = resp.data['url'];
+ var response = '\00307[' payload.repository.name ']\003 \00304 ' payload.commits.length '\003 \00300' payload.commits[0].author '\003: "' payload.commits[0].message '" \00302' url '\003 \00304ChangeSet: \003 ' payload.commits[0].node;
+ msg.send(response);
+ });
});
});
}
View
@@ -0,0 +1,33 @@
+module.exports = flow = {
+ robot: null,
+ express: null,
+ pubsub: null,
+ init: function(robot,express,pubsub){
+ this.robot = robot;
+ this.express = express;
+ this.pubsub = express;
+ this.setUpExpress();
+ this.setUpHubot();
+ },
+ setUpExpress: function(){
+ this.express.get('/cloudkick',function(req,res){
+ res.send('POST this URL with the payload parameter from bitbucket here.');
+ });
+
+ this.express.post('/cloudkick',function(req,res){
+ console.log(res);
+ flow.pubsub.emit('cloudkick/hook',(req.body));
+ res.send('Received');
+ });
+ },
+ setUpHubot: function(){
+ this.robot.hear('',function(msg){
+ flow.pubsub.removeAllListeners('cloudkick/hook');
+ flow.pubsub.on('cloudkick/hook',function(payload){
+ var response = payload;
+ //var response = '\00307[' payload.state_change.current.status ']\003 \00300' payload.state_change.current.status_details '\003 \00304' payload.state_change.current.time;
+ msg.send(response);
+ });
+ });
+ }
+}
View
@@ -23,7 +23,7 @@ module.exports = flow = {
this.robot.hear('',function(msg){
flow.pubsub.removeAllListeners('github/newCommit');
flow.pubsub.on('github/newCommit',function(payload){
- var response = '['+payload.repository.name+'] New commit by '+payload.commits[0].author.name+': "'+payload.commits[0].message+'" '+payload.commits[0].url;
+ var response = '[' payload.repository.name '] New commit by ' payload.commits[0].author.name ': "' payload.commits[0].message '" ' payload.commits[0].url;
msg.send(response);
});
});
View
@@ -6,7 +6,8 @@ module.exports = function(robot){
express = express.createServer(express.logger(),express.bodyParser());
var github = require('./github.js').init(robot,express,pubsub),
- bitbucket = require('./bitbucket.js').init(robot,express,pubsub),
- skeleton = require('./skeletonhttpd.js').init(robot,express,pubsub);
+ bitbucket = require('./bitbucket.js').init(robot,express,pubsub),
+ skeleton = require('./skeletonhttpd.js').init(robot,express,pubsub),
+ cloudkick = require('./cloudkick.js').init(robot,express,pubsub);
express.listen(1337);
};
View
@@ -0,0 +1,30 @@
+module.exports = flow = {
+ robot: null,
+ express: null,
+ pubsub: null,
+ init: function(robot,express,pubsub){
+ this.robot = robot;
+ this.express = express;
+ this.pubsub = express;
+ this.setUpExpress();
+ this.setUpHubot();
+ },
+ setUpExpress: function(){
+ this.express.get('/skel',function(req,res){
+ res.send('POST this URL with the parameters and hubot will print out a JSON array to your adapter.');
+ });
+
+ this.express.post('/skel',function(req,res){
+ flow.pubsub.emit('skeleton',req.body);
+ res.send('Received');
+ });
+ },
+ setUpHubot: function(){
+ this.robot.hear('',function(msg){
+ flow.pubsub.removeAllListeners('skeleton');
+ flow.pubsub.on('skeleton',function(payload){
+ msg.send(JSON.stringify(payload));
+ });
+ });
+ }
+}

0 comments on commit 6f34fc2

Please sign in to comment.