fixato github del tutto SPERO

This commit is contained in:
Enrico Fasoli 2015-04-25 15:21:57 +02:00
parent 482ddc7c57
commit 53c247ae01
2 changed files with 6 additions and 6 deletions

View File

@ -2,20 +2,19 @@
# interazioni tra asjon e github
module.exports = (robot) ->
robot.router.post '/hubot/githubhook/:room', (req, res) ->
robot.router.post '/hubot/githubhook/:room/:name', (req, res) ->
res.send 200
if !process.env.GITHUB_API_SECRET
console.log 'non sono configurato per GITHUB API WEBHOOKS!'
return
else if process.env.GITHUB_API_SECRET isnt req.headers["X-Hub-Signature"]
else if "sha1="+process.env.GITHUB_API_SECRET isnt req.headers["x-hub-signature"]
console.log 'MALFORMED GITHUB API SECRET: was',
req.headers["X-Hub-Signature"], 'but expected', process.env.GITHUB_API_SECRET
req.headers["x-hub-signature"], 'but expected', "sha1="+process.env.GITHUB_API_SECRET
return
console.log req.body
robot.send req.params.room, JSON.stringify req.body
dest = name: req.params.name, room: req.params.room
if req.body.ref is 'refs/head/master'
s = 'Sono stato aggiornato!\n'
cm = req.body.commits.map (c) ->
[c.committer.username,c.message].join ' -> '
commits = cm.join '\n'
robot.send req.params.room, s+commits
robot.send dest, s+commits

View File

@ -70,6 +70,7 @@ module.exports = (robot) ->
.get() (err, r, body) ->
res.send 'dovrei essere a ' + body
robot.respond /con chi stai parlando/i, (res) ->
console.log res.message.user, res.message.room
if res.message.user.name is res.message.room
res.send 'sto parlando con te, '+res.message.user.name
else