チャットボットライブラリhubotをインストールとセットアップまで
Hubot installとセットアップ、動作確認まで試したのでメモする。実際にSlackなどの連携までは今回していない。
What’s Hubot?
Github社製のオープンソースのチャットボットライブラリ。CoffeeScript + Node.js環境で動かすことができる。
What is Hubot? Hubot is your friendly robot sidekick. Install him in your company to dramatically improve employee efficiency.
No seriously, what is Hubot? GitHub, Inc., wrote the first version of Hubot to automate our company chat room. Hubot knew how to deploy the site, automate a lot of tasks, and be a source of fun around the office. Eventually he grew to become a formidable force in GitHub, but he led a private, messy life. So we rewrote him. Today’s version of Hubot is open source, written in CoffeeScript on Node.js, and easily deployed on platforms like Heroku. More importantly, Hubot is a standardized way to share scripts between everyone’s robots.
generator-hubotのインストール
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$ npm install -g yo generator-hubot
npm WARN deprecated CSSselect@0.4.1: the module is now available as 'css-select'
npm WARN deprecated CSSwhat@0.4.7: the module is now available as 'css-what'
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/usr/local/bin/yo-complete -> /usr/local/lib/node_modules/yo/lib/completion/index.js
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/lib/cli.js
> spawn-sync@1.0.15 postinstall /usr/local/lib/node_modules/yo/node_modules/spawn-sync
> node postinstall
> yo@2.0.1 postinstall /usr/local/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
Everything looks all right!
+ yo@2.0.1
+ generator-hubot@0.4.0
added 715 packages in 25.991s
yo hubot
コマンドでインストール&セットアップ
以下はコマンドラインインターフェイスで入力する。 Ownerはgitの設定から取得しているっぽい。
- ? Owner Akiko Yokoyama test@example.com
- ? Bot name sample-hubot
- ? Description A simple helpful robot for your Company
- ? Bot adapter campfire
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
$ yo hubot
? ==========================================================================
We're constantly looking for ways to make yo better!
May we anonymously report usage statistics to improve the tool over time?
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== Yes
_____________________________
/ \
//\ | Extracting input for |
////\ _____ | self-replication process |
//////\ /_____\ \ /
======= |[^_/\_]| /----------------------------
| | _|___@@__|__
+===+/ /// \_\
| |_\ /// HUBOT/\\
|___/\// / \\
\ / +---+
\____/ | |
| //| +===+
\// |xx|
? Owner Akiko Yokoyama <xxxx@gmail.com>
? Bot name sample-hubot
? Description A simple helpful robot for your Company
? Bot adapter campfire
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|
npm WARN deprecated coffee-script@1.6.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
npm WARN deprecated connect@2.30.2: connect 2.x series is deprecated
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN hubot-help@0.2.2 requires a peer of coffee-script@^1.12.6 but none is installed. You must install peer dependencies yourself.
+ hubot-heroku-keepalive@1.0.3
+ hubot-diagnostics@0.0.2
+ hubot-google-translate@0.2.1
+ hubot-help@0.2.2
+ hubot-google-images@0.2.7
+ hubot-pugme@0.1.1
+ hubot-scripts@2.17.2
+ hubot@2.19.0
+ hubot-maps@0.0.3
+ hubot-redis-brain@0.0.4
+ hubot-rules@0.1.2
+ hubot-shipit@0.2.1
added 151 packages in 6.652s
ローカルでbin/hubot
コマンドでhubotを動かしてみる
1
2
3
4
5
6
7
8
9
10
$ bin/hubot
npm WARN hubot-help@0.2.2 requires a peer of coffee-script@^1.12.6 but none is installed. You must install peer dependencies yourself.
up to date in 1.105s
sample-hubot> [Tue Mar 06 2018 20:23:40 GMT+0900 (JST)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.
Your hubot-scripts.json is empty, so you just need to remove it.
[Tue Mar 06 2018 20:23:40 GMT+0900 (JST)] ERROR hubot-heroku-keepalive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s | grep web.url | cut -d= -f2)`
[Tue Mar 06 2018 20:23:41 GMT+0900 (JST)] INFO hubot-redis-brain: Using default redis on localhost:6379
実行サンプル
1
2
sample-hubot> sample-hubot echo "hello"
sample-hubot> "hello"
1
2
sample-hubot> sample-hubot ping
sample-hubot> PONG