Skip to content

Instantly share code, notes, and snippets.

@saboyutaka
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saboyutaka/11163046 to your computer and use it in GitHub Desktop.
Save saboyutaka/11163046 to your computer and use it in GitHub Desktop.
GitHub webhookが出力するログをidobataで特定のroomで再度mentionする。
module.exports = (robot) ->
robot.hear /.*/, (msg) ->
if process.env.HUBOT_IDOBATA_GITHUB_MENTION_ROOM and
process.env.HUBOT_GITHUB_REPO and
msg.message.user.name is 'GitHub' and
!/@/.test(msg.message.text)
msg.message.data.room_id = process.env.HUBOT_IDOBATA_GITHUB_MENTION_ROOM
repo = process.env.HUBOT_GITHUB_REPO
message_text = msg.message.text
reg = new RegExp(repo + '#(\\d+)')
result = message_text.match reg
link = "https://github.com/#{repo}/issues/#{result[1]}"
msg.send message_text.replace reg, link
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment