Skip to content

Instantly share code, notes, and snippets.

@bouzuya
Last active August 29, 2015 14:11
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 bouzuya/43bc11e6c837d91f7cf3 to your computer and use it in GitHub Desktop.
Save bouzuya/43bc11e6c837d91f7cf3 to your computer and use it in GitHub Desktop.
設定を読み込む Hubot スクリプトをつくろう ref: http://qiita.com/bouzuya/items/d65a394cac9e76b56d3d
$ 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>
$ 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>
# 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