$ mkdir my-hubot
$ cd my-hubot
$ yo hubot
- 色々聞かれる
- 基本的には初期値のままenter
- bot nameは適当にかぶらないように
- adaptorを
slack
に
$ git init
$ git add .
$ git commit -m init
scripts/example.coffee
を開いて、 module.exports = (robot) ->
以降の行をコメント解除
$ bin/hubot
- 起動する
- WARNINGが出るけど気にしなくて大丈夫(気になるならちゃんと読んで)
badger
や@my-hubot open the first doors
等を入力、botの反応を楽しむ。- 一通り楽しんだら
control + C
で停止。 - 先ほどの
scripts/example.coffee
を元に戻す。(コメントアウトし直す。)
scripts/hello.coffee
を新規作成scripts/example.coffee
を参考に、以下の内容で保存
module.exports = (robot) ->
robot.hear /sushi/i, (res) ->
res.send 'やったね☆'
robot.respond /おはよう/i, (res) ->
res.reply 'おはよ☆'
- インデントが意味を持つので注意
$ bin/hubot
sushi
や@my-hubot おはよう
等を入力、botの反応を楽しむ。git add .
git commit -m "my first bot"
- https://github.com/
- 新規リポジトリ作成
git remote add origin git@nantoka-kantoka
とか何とかgit push -u origin master
- ウェブページを開いて確認
- https://www.heroku.com/
- 右上?のNew→Create new app
- Deploy → Deployment method = GitHub
- Deploy → Manual deploy → Deploy Branch
- 現状でデプロイ実行
- Deploy → Automatic deploys → Enable
- 今後はGitHubにpushしたら自動的にデプロイされる
- Settingであれこれする(後で)
- 要管理者権限
- チーム名クリックのメニュー → Apps & Configulations
- → "hubot" で検索して "Add Configulation"
- → Integration Settings → API Tokenの内容をコピー
- → HerokuのSetting → Config Variables → Reveal Config Vars
HUBOT_SLACK_TOKEN
を、Herokuからコピーしてきたトークンの値で作成HUBOT_HEROKU_KEEPALIVE_URL
を、右上 "Open app" のリンク先URLで作成
- hubotインストールした時点でメンバーに追加されてる
- 会話したいチャンネルへ追加
- お楽しみください