OSS編~Hubotを試してみる01~

Hubot(ヒューボット)はGitHub社が開発したbotフレームワークです。

HipChat, Skype, IRC, その他チャット系のツールにオリジナルのbotを住まわせ、開発フローに組み込むことでチャットツールを通して自動化したりする事が可能になります。

インストール

1.必要環境セットアップ

Hubotのインストールに必要なパッケージ等をインストールしていきます。

Node.jsとnpmをEPELからインストールします。

1$ sudo yum -y install nodejs npm --enablerepo=epel

2.Hubotのインストール

公式のGetting Started を参考にHubotをインストールします。

npmコマンドを利用して実施します。

1$ sudo npm install -g hubot coffee-script

3.botの作成

それではhubotコマンドでbotを作成してみます。

1$ hubot --create myhubot

コマンドを実行したパスに以下が作成されます。

gitを利用している場合gitignoreがあるので簡単に管理が出来ます。

1$ tree -a myhubot/2myhubot/3├── bin4│   ├── hubot5│   └── hubot.cmd6├── external-scripts.json7├── .gitignore8├── hubot-scripts.json9├── package.json10├── Procfile11├── README.md12└── scripts13    ├── events.coffee14    ├── google-images.coffee15    ├── help.coffee16    ├── httpd.coffee17    ├── maps.coffee18    ├── ping.coffee19    ├── pugme.coffee20    ├── roles.coffee21    ├── rules.coffee22    ├── storage.coffee23    ├── translate.coffee24    └── youtube.coffee25262 directories, 20 files

4.botの実行

それではbotを立ち上げてみます。

1$ cd myhubot/2$ bin/hubot

今回はshell adapterで起動します。

Helpでコマンドを確認してみます。

1Hubot> hubot: help2Hubot> Events:3debug - {user: <user object to send message to>}4Hubot <user> is a badass guitarist - assign a role to a user5Hubot <user> is not a badass guitarist - remove a role from a user67Hubot animate me <query> - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead.8Hubot die - End Hubot process9Hubot echo <text> - Reply back with <text>10Hubot fake event <event> - Triggers the <event> event for debugging reasons11Hubot help - Displays all of the help commands that Hubot knows about.12Hubot help <query> - Displays all help commands that match <query>.13Hubot image me <query> - The Original. Queries Google Images for <query> and returns a random top result.14Hubot map me <query> - Returns a map view of the area returned by `query`.15Hubot mustache me <query> - Searches Google Images for the specified query and mustaches it.16Hubot mustache me <url> - Adds a mustache to the specified URL.17Hubot ping - Reply with pong18Hubot pug bomb N - get N pugs19Hubot pug me - Receive a pug20Hubot show storage - Display the contents that are persisted in the brain21Hubot show users - Display all users that Hubot knows about22Hubot the rules - Make sure Hubot still knows the rules.23Hubot time - Reply with current time2425Hubot translate me <phrase> - Searches for a translation for the <phrase> and then prints that bad boy out.26Hubot translate me from <source> into <target> <phrase> - Translates <phrase> from <source> into <target>. Both <source> and <target> are optional27Hubot who is <user> - see what roles a user has28Hubot youtube me <query> - Searches YouTube for the query and returns the video embed link.29ship it - Display a motivation squirrel

いかがでしたでしょうか?

次回は『OSS編~Hubotを試してみる02~』と題して、Hubotのスクリプトを試してみたいと思います。

お楽しみに!!!

この記事を書いた人

aws-recipe-user