LoginSignup
43
42

More than 5 years have passed since last update.

Macでhubotを試す最速手順 [deprecated]

Last updated at Posted at 2014-02-23

Deprecated

この記事は古い記事です。 また気が向いたら更新します。

hubotで反応を返してくれるping pongコマンドを試すまでの、最速手順。

前提

Mac OSX 10.9 && Homebrew


hubot起動まで

  $ brew install node redis # node.jsと redisをインストール
  $ redis-server & # redisを起動しておく。続きは他のタブやウィンドウで実行すること。
  $ npm install -g hubot coffee-script # hubotをインストール
  $ hubot --create YOUR_BOT_NAME # hubotを作成。YOUR_BOT_NAMEは任意の名前(ディレクトリが出来る)
  $ cd YOUR_BOT_NAME; bin/hubot # 作成したディレクトリに移動後、botを起動

コマンド実行

  # 以下のようなメッセージが出てきたらReturnするとHubotのプロンプトが表示される
  [Sun Feb 23 2014 16:23:51 GMT+0900 (JST)] INFO Initializing new data for brain
  Hubot>
  Hubot> hubot ping # hubotに対してpingコマンドを実行すると...
  Hubot> PONG # ピンポンしてくれる
  Hubot> hubot help # ヘルプ。実行できるコマンド一覧など。

以下はオマケ

自分でhubotのコマンド(script)を作る。今回作るのは名前を引数にして、hello worldを返すだけのコマンド。

  $ cd /PATH/TO/YOUR/HUBOT/scripts # 作成したhubotのディレクトリ内のscriptsディレクトリに移動
  $ vim hello.coffee # 下記のhello.coffeeを作成
  $ bin/hubot #作成後、hubotを起動
  Hubot> hubot I am akira
  Hubot> Hello, world! akira
hello.coffee
  module.exports = (robot) ->
    robot.respond /I am (.*)/i, (msg) -> # 正規表現で名前を取得
      msg.send "Hello, world! #{msg.match[1]}"  # match[1]に取得した値

以上。

コマンド作成の参考
hubotスクリプト一覧
スクリプト一覧その2

43
42
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
43
42