LoginSignup
2
2

More than 5 years have passed since last update.

Hubotを環境作ってIRCとSlackで動かす

Last updated at Posted at 2015-10-16

Ubuntu14.04でとりあえず確認

Node.js環境

NVMを入れる

$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.2/install.sh | bash
$ source ~/.bashrc
$ nvm --version

Node.jsを入れる

$ nvm ls-remote
$ nvm install v4.1.2
$ node -v

ついでにデフォルトにもしておく

$ nvm alias default 4.1.2

yeomanを入れる

$ npm install -g yo

Hubot

hubotを入れる

$ npm install -g yo generator-hubot

botを作る(bot名はsharl)

hubot --create sharlとすると怒られて以下のcommandが出るので打つ

$ npm install -g yo generator-hubot
$ mkdir -p sharl
$ cd sharl
$ yo hubot

作者とか適当に入れる

$ ./bin/hubot -a shell -n sharl

コンソールが開く

sharl> sharl ping
sharl> PONG

動いた!

IRC連携

hubot-ircを入れる

セットアップ

「Installation and Setup」に沿って実行

npm install hubot-irc --save && npm install

起動

HUBOT_IRC_SERVER="example.com" \
  HUBOT_IRC_ROOMS="#test" \
  HUBOT_IRC_NICK="sharl" \
  HUBOT_IRC_UNFLOOD="true" \
  bin/hubot -a irc --name sharl

IRC

00:29 miyay: @sharl ping
00:29 sharl: PONG
00:30 miyay: @sharl echo hoge
00:30 sharl: hoge
00:30 miyay: @sharl echo ほげ
00:30 sharl: ほげ

Slack連携

Slack側

  1. 左上のチーム名のところを押して「Team Settings」を開く
  2. 左上の「menu」を押し、「Integrations」を開く
  3. Hubotを選び「view」
  4. 名前を決め、「Add Hubot Integration」
  5. アイコンとかチャンネルとか決めて「Add Hubot Integration」
  6. 生成されるTokenをメモる
    • というか起動に必要な環境変数がそのまま表示される

Hubot側

hubot-slackを入れる

npm install hubot-slack --save

起動

HUBOT_SLACK_TOKEN=トークン     bin/hubot -a slack

シェルスクリプトとかにしとくと便利

2
2
0

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
2
2