There are hundreds of scripts available for Hubot, offering you lots of great functionality without writing any code of your own. While the majority of these scripts are designed for fun, some can be extremely useful, depending on your technology stack.
Most scripts have Commands:
section in their documentation header, and these commands can be seen using hubot help
or hubot help <topic>
in the chatroom. You can also see the help by visiting http://<hubot_host>:<hubot_port>/hubot/help
in your browser.
A majority of scripts come as part of hubot-scripts
dependency of you Hubot instance. You can explore node_modules/hubot-scripts/src/scripts
directory to see what’s in there.
hubot@botserv:~/campfire$
ls node_modules/hubot-scripts/src/scripts/
There is also a catalog of these scripts available at http://hubot-script-catalog.herokuapp.com/, but it’s more fun to dig around the source at GitHub: https://github.com/github/hubot-scripts
There is also a newly introduced GitHub organization for new Hubot scripts that do not come bundled together with every Hubot installation. You can find these scripts at https://github.com/hubot-scripts.
If you want to enable a script that is in hubot-scripts
package, simply add it’s file name to hubot-scripts.json
. It should have some scripts added in there right out of the box, so if you wan to add gemwhois.coffee
, your hubot-scripts.json
could look like this:
hubot-scripts.json
[
"redis-brain.coffee"
,
"shipit.coffee"
,
"gemwhois.coffee"
]
You have to restart Hubot every time you modify hubot-scripts.json
. Then try if it works.
Tomas V. hubot gem whois rails
Hubot gem name: rails
owners: David Heinemeier Hansson
info: Ruby on Rails is a full-stack web framework optimize\
d for programmer
happiness and sustainable productivity. It encourage\
s beautiful code
by favoring convention over configuration.
version: 4.0.2
downloads: 31088002
homepage: http://www.rubyonrails.org
documentation: http://api.rubyonrails.org
source code: http://github.com/rails/rails
Some scripts will have extra dependencies that you will have to install before use. For instance, has two dependencies listed in it’s header:
...
# Dependencies:
# "jsdom": "0.2.15"
# "underscore": "1.3.3"
...
Install them with npm install --save <dependency>
and it will add the dependency to your package.json
automatically:
hubot@botserv:~/campfire$
npm install --save jsdom underscore hubot@botserv:~/campfire$
grep -E jsdom\|
underscore package.json "underscore": "~1.5.2",
"jsdom": "~0.8.10"
Note that installed dependencies are newer, and that sometimes can break the scripts, so if for some reason it does not work, try reinstalling the packages with exact versions that are provided, like this:
npm uninstall --save jsdom underscore
unbuild [email protected]
unbuild [email protected]
npm install --save [email protected] [email protected]
hubot@botserv:~/campfire$
grep -E jsdom\|
underscore package.json "underscore": "~1.3.3",
"jsdom": "~0.2.15"
Now add http-info.coffee
to hubot-scripts.json
, restart the bot and casually mention some URL in the chatroom to see what happens.
Tomas V. hubot help http Hubot http(s)://<site> - prints the title and meta description for sites \ linked. Tomas V. check out https://github.com/spajus/hubot-control Hubot spajus/hubot-control - GitHub hubot-control - Control Hubot via web interface
Script packages from https://github.com/hubot-scripts organization need to be installed with npm
first. Let’s include , which allows you to keep track of karma for arbitrary things.
hubot@focus:~/campfire$
npm install --save hubot-plusplus
Then add hubot-plusplus
to external-scripts.json
, so it looks like this:
external-scripts.json
[
"hubot-plusplus"
]
Finally, restart your Hubot and try it out.
Tomas V. ruby++ Hubot ruby has 1 points Tomas V. java-- Hubot java has -1 points
Many scripts require additional configuration via environmental variables. You can put them to your hubot.conf
, next to adapter configuration. http-info
script that we have previously enabled uses HUBOT_HTTP_INFO_IGNORE_URLS
to exclude URLs by regex pattern. It’s useful if you paste a lot of internal urls in your chat and you don’t want Hubot to be all noisy about them. Let’s make our Hubot ignore anything with github.com/spajus
in it.
hubot.conf
# Campfire adapter configuration
... # Ignore URLs that contain `github.com/spajus`
export
HUBOT_HTTP_INFO_IGNORE_URLS
=
"github\.com/spajus"
Restart Hubot and try it out.
Tomas V. https://github.com/github/hubot
Hubot github/hubot - GitHub
hubot - A customizable, kegerator-powered life embetterment robot.
Tomas V. https://github.com/spajus/hubot-pubsub
http://hubot-script-catalog.herokuapp.com/
Hubot Hubot Script Catalog
After trying out a lot of scripts, you will definitely want to get rid of some. Just remove the script name from hubot-scripts.json
or external-scripts.json
, and optionally uninstall node modules.
hubot@focus:~/campfire$
npm uninstall --save hubot-plusplus unbuild [email protected]