Created
April 20, 2015 08:41
-
-
Save vexus2/1b708e358205cc277730 to your computer and use it in GitHub Desktop.
Slack内で外部Bot/API経由の特定の発言を受け取って別のアクションを実行するスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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