利用するレポジトリ
https://github.com/github/hubot
https://github.com/sdimkov/hubot-skype-web
手順
nodejsのインストール
brew install nodejs
Hubotのインストール
npm install -g yo generator-hubot
mkdir myhubot
cd myhubot
yo hubot # 初期設定について質問される
skype-web-adapter のインストール
npm install hubot-skype-web --save
brew install phantomjs
hubot --adapter skype-web
ボット用アカウントを作る
- Skype公式HP からアカウントを作る
- テスト用の窓を用意する
起動スクリプトを作成
起動スクリプトを作り、実行権限を付与する
bin/hubot-skype
#!/bin/sh
set -e
npm install
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"
# 必須設定
export HUBOT_SKYPE_USERNAME="ボットアカウント名"
export HUBOT_SKYPE_PASSWORD="ボットパスワード"
# オプション設定
# export HUBOT_SKYPE_RECONNECT=20 # default: 240
# export HUBOT_LOG_LEVEL="debug" # [debug|info|notice|warning|error|critical|alert|emergency], default: info
# export HUBOT_SKYPE_MAX_MESSAGE_LENGTH Integer, # The maximum length of the message, longer messages are splitted, default: 1500
exec node_modules/.bin/hubot --name "myhubot" --adapter skype-web "$@"
Hello Worldテスト
下記のスクリプトを作成して、
./bin/hubot-skype でHubotを起動
scripts/hello.coffee
# Description:
# Test Command
#
# Commands:
# hello - Reply with "Hello World!"
module.exports = (robot) ->
robot.hear /hello/i, (res) ->
res.send "Hello World!"
hello
と自分のアカウントで発言して、Hello World!
とHubotが返事をしたら成功
続きの情報
開発時の推奨プラグイン
hubot-reload-scripts
<ボット名> reload
と発言すると、スクリプトを再読み込みしてくれる