More than 3 years have passed since last update.
1回目はコチラ
Slackと連携するための準備
- slackでBOT用のトークンを取得する
-
コチラを参考にして環境変数の設定までおこなう。
- なお、起動時に
bin/hubot
を叩くので覗いて見たら中で npm install
を実行してから、node_modules/.bin/hubot
を起動するshellだったので、npm install
の後にexport HUBOT_SLACK_TOKEN=xxxxxxx
を入れて起動する直前でトークンを設定するようにしてみた。
- これで、環境変数設定し忘れたりしなくなるかな。。。
- Slack側での確認
- 後はhubotをinviteしたチャンネルで呼びかけて見たら反応してくれる!
- 単純につなぐまでは出来たので、後は好きな様にカスタマイズ!!!
- いつも名前呼びかけるのもダルいので、特定のチャンネルに投稿されたら反応するようにする
# scripts/norabot.coffee
#Commands:
# msg - Return a message msg
#
module.exports = (robot) ->
robot.hear /(.*)$/i, (msg) ->
room = msg.envelope.room
text = msg.message.text
text_en = encodeURIComponent text
if room == "test"
msg.send room, "#{text} "
- 上記は
test
チャンネルに発言された内容をオウム返しする
- 正規表現を覚えればなんか色々できちゃいそう。正規表現覚えなきゃ。。。
Why not register and get more from Qiita?
- We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
- you can read useful information later efficiently
By "stocking" the articles you like, you can search right away
Sign upLogin