hubotとは
GitHubが開発したオープンソースのチャットボット。Node.js上で起動します。データの保存が必要であればRedisも必要です。
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.
Raspberry PiでHubotを起動
hubotのドキュメントを参照
Node.jsをインストールします。
$ sudo apt update
$ sudo apt install -y nodejs npm
$ sudo npm cache clean
$ sudo npm install npm -g
$ sudo npm install n -g
$ sudo n lts
次にhubot generatorをインストールします。
sudo npm install -g yo generator-hubot
$ mkdir homebot # ボットの名称をとりあえず homebot とする
$ cd homebot
$ yo hubot
? Owner # メールアドレスなどを入力(デフォルトのままでOK)
? Bot name # 「homebot」と入力
? Description # 空白でもOK
? Bot adapter # 「slack」と入力
Hubotはデータを保存する為にRedisが必要です。
Redisをインストールします。
$ sudo apt install redis-server
</brHubotをadapter
オプションなし(shell>Hubotをadapter
オプションなし(shell adapter)で起動します。
$ 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.
WARNING Loading scripts from hubot-scripts.json is deprecated
ERROR hubot-heroku-keepalive included, ...
適宜エラーを解消しましょう
$ rm hubot-scripts.json # 不要なファイルを削除
$ nano external-scripts.json # heroku用の設定を削除
[
:
"hubot-heroku-keepalive", # 削除
:
]
再度hubotを起動します。
$ bin/hubot
INFO hubot-redis-brain: Using default redis on localhost:6379
INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
homebot> homebot ping # ping
homebot> PONG # PONGが返ってきたら、雛形を生成できている