Glide Note

glidenote's blog

Githubで利用されているボットシステムHUBOTを動かしてみた

Githubで利用されているらしいボットシステムHUBOTを触ってみました。 HUBOTを動かすのに、node.jsとnpmが必要なので先に導入。導入環境はScientific Linux6.1です

node.jsの導入

node.jsから最新版0.6.8(2012年1月23日現在)を導入。

1
2
3
4
5
6
7
8
mkdir ~/src
cd ~/src
wget http://nodejs.org/dist/v0.6.8/node-v0.6.8.tar.gz
tar zxvf node-v0.6.8.tar.gz
cd node-v0.6.8
./configure
make
sudo make install

npmの導入

1
2
3
sudo -s
curl http://npmjs.org/install.sh | sh
exit

依存ライブラリの導入

1
2
3
4
cd ~
git clone git://github.com/github/hubot.git
cd hubot
npm install

HUBOTの起動

このままだとcoffee-scriptのpathが見つけられないので、exportで一時的にpathを通す。

1
export PATH="node_modules/.bin:$PATH"

HUBOTを起動

1
bin/hubot

hubot help を打ってみると下記のような感じ

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ bin/hubot
[Tue, 24 Jan 2012 09:47:47 GMT] INFO Loading scripts from /home/akira/src/node-v0.6.8/hubot/scripts
[Tue, 24 Jan 2012 09:47:47 GMT] INFO Loading scripts from /home/akira/src/node-v0.6.8/hubot/src/scripts
Hubot> hubot help
Hubot> <user> is a badass guitarist - assign a role to a user
<user> is not a badass guitarist - remove a role from a user
animate me <query>  - The same thing as `image me`, except adds a few
convert me <expression> to <units> - Convert expression to given units.
help - Displays all of the help commands that Hubot knows about.
help <query> - Displays all help commands that match <query>.
image me <query>    - The Original. Queries Google Images for <query> and
map me <query> - Returns a map view of the area returned by `query`.
math me <expression> - Calculate the given expression.
mustache me <query> - Searches Google Images for the specified query and
mustache me <url>   - Adds a mustache to the specified URL.
pug bomb N - get N pugs
pug me - Receive a pug
show storage - Display the contents that are persisted in redis
show users - Display all users that hubot knows about
translate me <phrase> - Searches for a translation for the <phrase> and then
translate me from <source> into <target> <phrase> - Translates <phrase> from <source> into <target>. Both <source> and <target> are optional
who is <user> - see what roles a user has
youtube me <query> - Searches YouTube for the query and returns the video

渋谷の地図を聞いてみると

1
2
3
Hubot> hubot map me shibuya
Hubot> http://maps.google.com/maps/api/staticmap?markers=shibuya&size=400x400&maptype=roadmap&sensor=false&format=png
Hubot> http://maps.google.com/maps?q=shibuya&hl=en&sll=37.0625,-95.677068&sspn=73.579623,100.371094&vpsrc=0&hnear=shibuya&t=m&z=11

とりあえず動かすのは簡単にできた。
CoffeeScriptで機能拡張するようなので勉強しよう

Comments