基本インストール
node.jsとRedisをepelレポジトリからyumインストール
cmd
$ sudo yum install nodejs --enablerepo=epel -y
$ sudo yum install npm --enablerepo=epel -y
$ sudo yum install redis --enablerepo=epel -y
※ 慣れていれば、一緒にインストールして構わないです
Redisの起動 & 自動起動
cmd
$ sudo service redis restart
$ sudo chkconfig redis on
coffeeScriptとhubotのフレームワークをインストール
cmd
$ sudo npm install -g inherits
$ sudo npm install -g coffee-script
$ sudo npm install -g hubot
※ 慣れていれば、一緒にインストールして構わないです
Hubotを実際に入れていく
hubotのひな形作成
cmd
$ mkdir /deploy/mybot
$ cd /deploy/mybot
$ sudo npm install -g yo generator-hubot
設定
- 実際にyoコマンドにてインストールする
cmd&log
[vagrant@vagrant mybot]$ yo hubot
_____________________________
/ \
//\ | Extracting input for |
////\ _____ | self-replication process |
//////\ /_____\ \ /
======= |[^_/\_]| /----------------------------
| | _|___@@__|__
+===+/ /// \_\
| |_\ /// HUBOT/\\
|___/\// / \\
\ / +---+
\____/ | |
| //| +===+
\// |xx|
[?] Owner: iganari
[?] Bot name: iganaribot
[?] Description: iganari.com
[?] Bot adapter: campfire <--- 何も入れずにEnter
create bin/hubot
create bin/hubot.cmd
create Procfile
create README.md
create external-scripts.json
create hubot-scripts.json
create .gitignore
create package.json
create scripts/example.coffee
create .editorconfig
_____________________________
_____ / \
\ \ | Self-replication process |
| | _____ | complete... |
|__\\| /_____\ \ Good luck with that. /
|//+ |[^_/\_]| /----------------------------
| | _|___@@__|__
+===+/ /// \_\
| |_\ /// HUBOT/\\
|___/\// / \\
\ / +---+
\____/ | |
| //| +===+
\// |xx|
hubotと対話する
cmd&log
$ bin/hubot
iganaribot> iganaribot ping
PONG
※ hubotをインストールする際のbot nameで話しかけないとrespondは返してくれない
example
iganaribot> ping
iganaribot>iganaribot ping
PONG
iganaribot>
hubotとhipchatを連携させる
hipchatのhubot専用アカウント作成
- 作成方法は割愛
- Jabber IDなるものを取得しておく
- パスワードも必要なので忘れずにメモしておく
必要なプラグインのインストール
hubotとhipchatの連携のためのプラグイン
- 依存するライブラリをインストール
$ sudo yum install libicu-devel -y
- hubot <--> Hipchatで連携させるためのプラグイン
$ npm install hubot-hipchat --save
Jabber IDの登録
- hipchat > account settings > XAPP/Jabber info
Jabber ID | password |
---|---|
217122_1511022@chat.hipchat.com | hogehoge |
のときは以下のように入れる
$ cd /deploy/mybot/bin
$ export HUBOT_HIPCHAT_JID="217122_1511022@chat.hipchat.com"
$ export HUBOT_HIPCHAT_PASSWORD="hogehoge"
Hipchatと連携したhubotの起動方法
$ bin/hubot -a hipchat
--> これでhipchatと連携しているはず
hubotとslackを連携させる
hipchat以上に人気の高いslackとの連携
---> 長くなったので別の記事に移動
参考URL
- 基本的なとこ
http://www.atmarkit.co.jp/ait/articles/1408/20/news035.html - アダプター 1
http://gihyo.jp/dev/serial/01/hubot/0001 - アダプター 2
http://www.mrlittlebig.com/blog/057/ - 全体的に参考にしてます
http://qiita.com/kon_yu/items/cdc452bcd2bb89f85de1
- エラーが出た時に
http://qiita.com/bouzuya/items/3f1eff41c361a880505f
- respondとhearの違い
http://blog.fumiz.me/2012/08/05/hubot-irc-bot-script/ - exportコマンドの種類
http://kkurahar.github.io/blog/2013/10/03/hubot-hipchat/ - slackの連携
http://qiita.com/bouzuya/items/2a200c9e8a45e2478bc2 http://memo.sanographix.net/post/88371442780