Last active
August 29, 2015 14:11
-
-
Save bouzuya/43bc11e6c837d91f7cf3 to your computer and use it in GitHub Desktop.
設定を読み込む Hubot スクリプトをつくろう ref: http://qiita.com/bouzuya/items/d65a394cac9e76b56d3d
This file contains 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
$ HUBOT_SHELL_USER_NAME='bouzuya' PATH="./node_modules/hubot/node_modules/.bin:$PATH" $(npm bin)/hubot -a shell -n hubot -r src | |
[Sat Dec 13 2014 23:52:40 GMT+0900 (JST)] ERROR process.env.HUBOT_HELLO_XXX_MESSAGE is not defined | |
hubot> |
This file contains 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
$ HUBOT_HELLO_XXX_MESSAGES='["あびゃー","チョリーッス"]' HUBOT_HELLO_XXX_MESSAGE='うるせえ' HUBOT_SHELL_USER_NAME='bouzuya' PATH="./node_modules/hubot/node_modules/.bin:$PATH" $(npm bin)/hubot -a shell -n hubot -r src | |
hubot> hubot hello | |
うるせえ, bouzuya! | |
hubot> hubot hello! | |
あびゃー | |
hubot> |
This file contains 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 | |
# A Hubot script that responds XXX | |
# | |
# Configuration: | |
# HUBOT_HELLO_XXX_MESSAGE | |
# HUBOT_HELLO_XXX_MESSAGES | |
# | |
# Commands: | |
# hubot hello - respond XXX | |
# hubot hello! - respond XXX | |
# | |
# Author: | |
# bouzuya <m@bouzuya.net> | |
config = | |
message: process.env.HUBOT_HELLO_XXX_MESSAGE | |
messages: JSON.parse(process.env.HUBOT_HELLO_XXX_MESSAGES ? '[]') | |
module.exports = (robot) -> | |
unless config.message? | |
robot.logger.error 'process.env.HUBOT_HELLO_XXX_MESSAGE is not defined' | |
return | |
robot.respond /hello$/, (msg) -> | |
msg.send "#{config.message}, #{msg.envelope.user.name}!" | |
robot.respond /hello!$/, (msg) -> | |
message = msg.random config.messages | |
msg.send message if message? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment