Skip to content

Instantly share code, notes, and snippets.

@yo-iida
Created April 10, 2015 11:48
Show Gist options
  • Select an option

  • Save yo-iida/89e6a5faef9c934dd7ca to your computer and use it in GitHub Desktop.

Select an option

Save yo-iida/89e6a5faef9c934dd7ca to your computer and use it in GitHub Desktop.
gitbuckest-to-slack
# Description:
# gitbucket to Slack
#
# Commands:
# None
module.exports = (robot) ->
robot.router.post "/gitbucket-to-slack/:room", (req, res) ->
{ room } = req.params
{ body } = req
try
if body.payload
json = JSON.parse body.payload
message = "==== commit info ====\n"
message += "timestamp: #{json.commits[0].timestamp}\n"
message += "id: #{json.commits[0].id}\n"
message += "author: #{json.commits[0].author.name}<#{json.commits[0].author.email}>\n"
message += "message: #{json.commits[0].message}\n"
message += "url: #{json.commits[0].url}\n"
if message?
robot.messageRoom room, message
res.end "OK"
else
robot.messageRoom room, "gitbucket integration error."
res.end "Error"
catch error
robot.send
res.end "Error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment