Skip to content

Instantly share code, notes, and snippets.

@vexus2
Created April 20, 2015 08:41
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 vexus2/1b708e358205cc277730 to your computer and use it in GitHub Desktop.
Save vexus2/1b708e358205cc277730 to your computer and use it in GitHub Desktop.
Slack内で外部Bot/API経由の特定の発言を受け取って別のアクションを実行するスクリプト
# Description:
# 外部Bot/API経由の特定の発言を受け取って別のアクションを実行する
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
# None
module.exports = (robot) ->
robot.adapter.client?.on? 'raw_message', (msg) ->
return if msg.type isnt 'message' || msg.subtype isnt 'bot_message'
return unless msg.attachments
match = msg.attachments[0].fallback.match(/Failed: (.+?)'s build/)
return if match is null
commit_user = match[1]
channel = robot.adapter.client.getChannelByID msg.channel
# プライベートチャンネルは取得出来ないためundefinedが返される
return if channel is undefined
text = "@#{commit_user} テストが落ちたよー!"
robot.send {room: "##{channel.name}"}, text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment