LoginSignup
14

More than 5 years have passed since last update.

Windowsでslackのbotを作る。

Posted at

ドモヽ(´Д` ) ( ´Д`)ノドモ
4:3モニターから買い換えた@ChikuwaJBです。
なんかモニターが大きくなるとパソコンのスペックも上がった気がしますね(意味不明)

WindowsでSlackのbotを作る。

基本的にはhttp://lab.aratana.jp/entry/2014/12/04/185053を参照。

bin/hubotが動かない…

D:\Users\Chikuwa\Documents\slackbot>bin\hubot.cmd
'coffee' は、内部コマンドまたは外部コマンド、
操作可能なプログラムまたはバッチ ファイルとして認識されていません。

テンパる。

解決方法。

npm install -g coffee-script

なんで一緒に入らないの…
まあいいけど。。

なぜかプロジェクト初期だとexample.coffeeが真っ白。

とりあえず自分でコードを書きます。

module.exports = (robot) ->
 robot.hear /chikuwa/i, (res) ->
   res.send "ちくわっておいしいよね(棒)"

こうしたらbin/hubotして

D:\Users\Chikuwa\Documents\slackbot>bin\hubot
slackbot> [Sun Jan 03 2016 05:16:21 GMT+0900 (東京 (標準時))] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web-url | cut -d= -f2)`
[Sun Jan 03 2016 05:16:22 GMT+0900 (東京 (標準時))] INFO hubot-redis-brain: Using default redis on localhost:6379
slackbot> hubot ping
slackbot> chikuwa
slackbot> ちくわっておいしいよね(棒)

よしゃあ。

herokuにあげても動かない。。

調べること30分。。

Procfileファイルの中身を変えたらできた。

Before:

web: bin/hubot -a campfire

After:

web: bin/hubot --adapter slack

なんかこのhubotちゃんslackとは別のcampfireっていうチャットサービスにも対応してるみたいなんですね…

自動判別とかしてくれないのかね・・・

まとめ

結構時間かかりました(1時間半弱)
まだまだ勉強しないと。。。

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
14