|
| 1 | +## docker-hubot |
| 2 | + |
| 3 | +docker-hubot is a chat bot built on the [Hubot][hubot] framework. It was initially generated by [generator-hubot][generator-hubot]. mybot now runs in a Docker container. |
| 4 | + |
| 5 | +[hubot]: http://hubot.github.com |
| 6 | +[generator-hubot]: https://github.com/github/generator-hubot |
| 7 | + |
| 8 | +### Development |
| 9 | + |
| 10 | +#### Step 0: Local development setup (non-dockerized) |
| 11 | + |
| 12 | +* Install Node & Redis (for hubot) |
| 13 | + |
| 14 | +``` |
| 15 | +brew install node |
| 16 | +brew install redis |
| 17 | +``` |
| 18 | + |
| 19 | +* Install Node Modules (for hubot) |
| 20 | + |
| 21 | +``` |
| 22 | +export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig:/opt/X11/lib/pkgconfig |
| 23 | +npm install |
| 24 | +``` |
| 25 | + |
| 26 | + |
| 27 | +### Step 1a: Running mybot Locally (non-dockerized) |
| 28 | + |
| 29 | +If you are testing scripts that require persistence (redis brain), make sure you start Redis: |
| 30 | + |
| 31 | +``` |
| 32 | +redis-server & |
| 33 | +``` |
| 34 | + |
| 35 | +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. |
| 36 | + |
| 37 | +Once you have your config file, you can start hubot locally in shell using: |
| 38 | + |
| 39 | +``` |
| 40 | +. secret-dev-hubot.config; bin/hubot --alias devbot --adapter shell |
| 41 | +``` |
| 42 | + |
| 43 | +You'll see some start up output about where your scripts come from and a |
| 44 | +prompt: |
| 45 | + |
| 46 | +``` |
| 47 | +[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell |
| 48 | +[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts |
| 49 | +[Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts |
| 50 | +Hubot> |
| 51 | +``` |
| 52 | + |
| 53 | +Then you can interact with srbot by typing `hubot help`. |
| 54 | + |
| 55 | +``` |
| 56 | +hubot> hubot help |
| 57 | +hubot> animate me <query> - The same thing as `image me`, except adds a few |
| 58 | +convert me <expression> to <units> - Convert expression to given units. |
| 59 | +help - Displays all of the help commands that Hubot knows about. |
| 60 | +... |
| 61 | +``` |
| 62 | + |
| 63 | +You can also test in Slack using the following command: |
| 64 | + |
| 65 | +``` |
| 66 | +. secret-dev-hubot.config; bin/hubot --alias hu --adapter slack |
| 67 | +``` |
| 68 | + |
| 69 | +### Step 1b: Running hubot Locally (Dockerized) |
| 70 | + |
| 71 | +Start a local docker vm using docker-machine: |
| 72 | + |
| 73 | +``` |
| 74 | +docker-machine init |
| 75 | +docker-machine create --driver virtualbox default |
| 76 | +docker-machine env default |
| 77 | +eval $(docker-machine env default) |
| 78 | +``` |
| 79 | + |
| 80 | +There is a script in ./deploy you can use to run hubot locally. Here is |
| 81 | +how to get that running. |
| 82 | + |
| 83 | +``` |
| 84 | +. secret-dev-hubot.config; ./deploy/build_local_dev.sh |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +# Scripting |
| 90 | + |
| 91 | +An example script is included at `scripts/example.coffee`, so check it out to |
| 92 | +get started, along with the [Scripting Guide](https://github.com/github/hubot/blob/master/docs/scripting.md). |
| 93 | + |
| 94 | +For many common tasks, there's a good chance someone has already one to do just |
| 95 | +the thing. |
| 96 | + |
| 97 | +## hubot-scripts |
| 98 | + |
| 99 | +There will inevitably be functionality that everyone will want. Instead |
| 100 | +of writing it yourself, you can check |
| 101 | +[hubot-scripts][hubot-scripts] for existing scripts. |
| 102 | + |
| 103 | +To enable scripts from the hubot-scripts package, add the script name with |
| 104 | +extension as a double quoted string to the `hubot-scripts.json` file in this |
| 105 | +repo. |
| 106 | + |
| 107 | +[hubot-scripts]: https://github.com/github/hubot-scripts |
| 108 | + |
| 109 | +## external-scripts |
| 110 | + |
| 111 | +Hubot is able to load scripts from third-party `npm` package. Check the package's documentation, but in general it is: |
| 112 | + |
| 113 | +1. Add the packages as dependencies into your `package.json` |
| 114 | +2. `npm install` to make sure those packages are installed |
| 115 | +3. Add the package name to `external-scripts.json` as a double quoted string |
| 116 | + |
| 117 | +You can review `external-scripts.json` to see what is included by default. |
| 118 | + |
| 119 | +## Persistence |
| 120 | + |
| 121 | +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. |
| 122 | + |
| 123 | +In addition, persistance will ensure that if the bot is restarted, emergency state is retained for all rooms. |
| 124 | + |
| 125 | +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. |
| 126 | + |
| 127 | +[redis]: https://redis.io/ |
| 128 | + |
| 129 | +## Adapters |
| 130 | + |
| 131 | +Adapters are the interface to the service you want your hubot to run on. This |
| 132 | +can be something like Campfire or IRC. There are a number of third party |
| 133 | +adapters that the community have contributed. Check |
| 134 | +[Hubot Adapters][hubot-adapters] for the available ones. |
| 135 | + |
| 136 | +If you would like to run a non-Campfire or shell adapter you will need to add |
| 137 | +the adapter package as a dependency to the `package.json` file in the |
| 138 | +`dependencies` section. |
| 139 | + |
| 140 | +Once you've added the dependency and run `npm install` to install it you can |
| 141 | +then run hubot with the adapter. |
| 142 | + |
| 143 | + $ bin/hubot -a <adapter> |
| 144 | + |
| 145 | +Where `<adapter>` is the name of your adapter without the `hubot-` prefix. |
| 146 | + |
| 147 | +[hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md |
| 148 | + |
0 commit comments