bennythejudge / hubot-docker

A dockerized hubot setup

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker-hubot

docker-hubot is a chat bot built on the Hubot framework. It was initially generated by generator-hubot. mybot now runs in a Docker container.

Development

Step 0: Local development setup (non-dockerized)

  • Install Node & Redis (for hubot)
brew install node
brew install redis
  • Install Node Modules (for hubot)
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig
npm install

Step 1a: Running mybot Locally (non-dockerized)

If you are testing scripts that require persistence (redis brain), make sure you start Redis:

redis-server &

Hubot absorbs all of its configuration from environment variables, so you will want to create a .config file, and store the variables you need there. It's suggested to name the file secret-dev-hubot.config, since that is already listed in the .gitignore file.

Once you have your config file, you can start hubot locally in shell using:

. secret-dev-hubot.config; bin/hubot --alias devbot --adapter shell

You'll see some start up output about where your scripts come from and a prompt:

[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell
[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts
[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts
Hubot>

Then you can interact with srbot by typing hubot help.

hubot> hubot help
hubot> 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.
...

You can also test in Slack using the following command:

. secret-dev-hubot.config; bin/hubot --alias hu --adapter slack

Step 1b: Running hubot Locally (Dockerized)

Start a local docker vm using docker-machine:

docker-machine init
docker-machine create --driver virtualbox default
docker-machine env default
eval $(docker-machine env default)

There is a script in ./deploy you can use to run hubot locally. Here is how to get that running.

. secret-dev-hubot.config; ./deploy/build_local_dev.sh

Scripting

An example script is included at scripts/example.coffee, so check it out to get started, along with the Scripting Guide.

For many common tasks, there's a good chance someone has already one to do just the thing.

hubot-scripts

There will inevitably be functionality that everyone will want. Instead of writing it yourself, you can check hubot-scripts for existing scripts.

To enable scripts from the hubot-scripts package, add the script name with extension as a double quoted string to the hubot-scripts.json file in this repo.

external-scripts

Hubot is able to load scripts from third-party npm package. Check the package's documentation, but in general it is:

  1. Add the packages as dependencies into your package.json
  2. npm install to make sure those packages are installed
  3. Add the package name to external-scripts.json as a double quoted string

You can review external-scripts.json to see what is included by default.

Persistence

The bot relies on Redis for persistance; the data stored in Redis is consumed by Upboard to automatically fill out initial emergency info. While Redis is not required for local development, upon deployment, Redis should be available.

In addition, persistance will ensure that if the bot is restarted, emergency state is retained for all rooms.

If you are going to use the hubot-redis-brain package (strongly suggested), you will need to setup Redis and manually set the REDIS_URL variable.

Adapters

Adapters are the interface to the service you want your hubot to run on. This can be something like Campfire or IRC. There are a number of third party adapters that the community have contributed. Check Hubot Adapters for the available ones.

If you would like to run a non-Campfire or shell adapter you will need to add the adapter package as a dependency to the package.json file in the dependencies section.

Once you've added the dependency and run npm install to install it you can then run hubot with the adapter.

$ bin/hubot -a <adapter>

Where <adapter> is the name of your adapter without the hubot- prefix.

About

A dockerized hubot setup


Languages

Language:CoffeeScript 56.1%Language:Shell 19.4%Language:Ruby 11.0%Language:Batchfile 6.8%Language:PowerShell 6.6%