|
| 1 | +# Hubot |
| 2 | + |
| 3 | +This is a version of GitHub's Campfire bot, hubot. He's pretty cool. |
| 4 | + |
| 5 | +This version is designed to be deployed on [Heroku][heroku]. |
| 6 | + |
| 7 | +[heroku]: http://www.heroku.com |
| 8 | + |
| 9 | +## Playing with Hubot |
| 10 | + |
| 11 | +You'll need to install the necessary dependencies for hubot. All of |
| 12 | +those dependencies are provided by [npm][npmjs]. |
| 13 | + |
| 14 | +[npmjs]: http://npmjs.org |
| 15 | + |
| 16 | +## HTTP Listener |
| 17 | + |
| 18 | +Hubot has a HTTP listener which listens on the port specified by the `PORT` |
| 19 | +environment variable. |
| 20 | + |
| 21 | +You can specify routes to listen on in your scripts by using the `router` |
| 22 | +property on `robot`. |
| 23 | + |
| 24 | +```coffeescript |
| 25 | +module.exports = (robot) -> |
| 26 | + robot.router.get "/hubot/version", (req, res) -> |
| 27 | + res.end robot.version |
| 28 | +``` |
| 29 | + |
| 30 | +There are functions for GET, POST, PUT and DELETE, which all take a route and |
| 31 | +callback function that accepts a request and a response. |
| 32 | + |
| 33 | +### Redis |
| 34 | + |
| 35 | +If you are going to use the `redis-brain.coffee` script from `hubot-scripts` |
| 36 | +you will need to add the Redis to Go addon on Heroku which requires a verified |
| 37 | +account or you can create an account at [Redis to Go][redistogo] and manually |
| 38 | +set the `REDISTOGO_URL` variable. |
| 39 | + |
| 40 | + % heroku config:add REDISTOGO_URL="..." |
| 41 | + |
| 42 | +If you don't require any persistence feel free to remove the |
| 43 | +`redis-brain.coffee` from `hubot-scripts.json` and you don't need to worry |
| 44 | +about redis at all. |
| 45 | + |
| 46 | +[redistogo]: https://redistogo.com/ |
| 47 | + |
| 48 | +### Testing Hubot Locally |
| 49 | + |
| 50 | +You can test your hubot by running the following. |
| 51 | + |
| 52 | + % bin/hubot |
| 53 | + |
| 54 | +You'll see some start up output about where your scripts come from and a |
| 55 | +prompt. |
| 56 | + |
| 57 | + [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell |
| 58 | + [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts |
| 59 | + [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts |
| 60 | + Hubot> |
| 61 | + |
| 62 | +Then you can interact with hubot by typing `hubot help`. |
| 63 | + |
| 64 | + Hubot> hubot help |
| 65 | + |
| 66 | + Hubot> animate me <query> - The same thing as `image me`, except adds a few |
| 67 | + convert me <expression> to <units> - Convert expression to given units. |
| 68 | + help - Displays all of the help commands that Hubot knows about. |
| 69 | + ... |
| 70 | + |
| 71 | +Take a look at the scripts in the `./scripts` folder for examples. |
| 72 | +Delete any scripts you think are silly. Add whatever functionality you |
| 73 | +want hubot to have. |
| 74 | + |
| 75 | +## Adapters |
| 76 | + |
| 77 | +Adapters are the interface to the service you want your hubot to run on. This |
| 78 | +can be something like Campfire or IRC. There are a number of third party |
| 79 | +adapters that the community have contributed. Check the |
| 80 | +[hubot wiki][hubot-wiki] for the available ones. |
| 81 | + |
| 82 | +If you would like to run a non-Campfire or shell adapter you will need to add |
| 83 | +the adapter package as a dependency to the `package.json` file in the |
| 84 | +`dependencies` section. |
| 85 | + |
| 86 | +Once you've added the dependency and run `npm install` to install it you can |
| 87 | +then run hubot with the adapter. |
| 88 | + |
| 89 | + % bin/hubot -a <adapter> |
| 90 | + |
| 91 | +Where `<adapter>` is the name of your adapter without the `hubot-` prefix. |
| 92 | + |
| 93 | +[hubot-wiki]: https://github.com/github/hubot/wiki |
| 94 | + |
| 95 | +## hubot-scripts |
| 96 | + |
| 97 | +There will inevitably be functionality that everyone will want. Instead |
| 98 | +of adding it to hubot itself, you can submit pull requests to |
| 99 | +[hubot-scripts][hubot-scripts]. |
| 100 | + |
| 101 | +To enable scripts from the hubot-scripts package, add the script name with |
| 102 | +extension as a double quoted string to the hubot-scripts.json file in this |
| 103 | +repo. |
| 104 | + |
| 105 | +[hubot-scripts]: https://github.com/github/hubot-scripts |
| 106 | + |
| 107 | +## Deployment |
| 108 | + |
| 109 | + % heroku create --stack cedar |
| 110 | + % git push heroku master |
| 111 | + % heroku ps:scale app=1 |
| 112 | + |
| 113 | +If your Heroku account has been verified you can run the following to enable |
| 114 | +and add the Redis to Go addon to your app. |
| 115 | + |
| 116 | + % heroku addons:add redistogo:nano |
| 117 | + |
| 118 | +If you run into any problems, checkout Heroku's [docs][heroku-node-docs]. |
| 119 | + |
| 120 | +You'll need to edit the `Procfile` to set the name of your hubot. |
| 121 | + |
| 122 | +More detailed documentation can be found on the |
| 123 | +[deploying hubot onto Heroku][deploy-heroku] wiki page. |
| 124 | + |
| 125 | +### Deploying to UNIX or Windows |
| 126 | + |
| 127 | +If you would like to deploy to either a UNIX operating system or Windows. |
| 128 | +Please check out the [deploying hubot onto UNIX][deploy-unix] and |
| 129 | +[deploying hubot onto Windows][deploy-windows] wiki pages. |
| 130 | + |
| 131 | +[heroku-node-docs]: http://devcenter.heroku.com/articles/node-js |
| 132 | +[deploy-heroku]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-Heroku |
| 133 | +[deploy-unix]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-UNIX |
| 134 | +[deploy-windows]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-Windows |
| 135 | + |
| 136 | +## Campfire Variables |
| 137 | + |
| 138 | +If you are using the Campfire adapter you will need to set some environment |
| 139 | +variables. Refer to the documentation for other adapters and the configuraiton |
| 140 | +of those, links to the adapters can be found on the [hubot wiki][hubot-wiki]. |
| 141 | + |
| 142 | +Create a separate Campfire user for your bot and get their token from the web |
| 143 | +UI. |
| 144 | + |
| 145 | + % heroku config:add HUBOT_CAMPFIRE_TOKEN="..." |
| 146 | + |
| 147 | +Get the numeric IDs of the rooms you want the bot to join, comma delimited. If |
| 148 | +you want the bot to connect to `https://mysubdomain.campfirenow.com/room/42` |
| 149 | +and `https://mysubdomain.campfirenow.com/room/1024` then you'd add it like this: |
| 150 | + |
| 151 | + % heroku config:add HUBOT_CAMPFIRE_ROOMS="42,1024" |
| 152 | + |
| 153 | +Add the subdomain hubot should connect to. If you web URL looks like |
| 154 | +`http://mysubdomain.campfirenow.com` then you'd add it like this: |
| 155 | + |
| 156 | + % heroku config:add HUBOT_CAMPFIRE_ACCOUNT="mysubdomain" |
| 157 | + |
| 158 | +[hubot-wiki]: https://github.com/github/hubot/wiki |
| 159 | + |
| 160 | +## Restart the bot |
| 161 | + |
| 162 | +You may want to get comfortable with `heroku logs` and `heroku restart` |
| 163 | +if you're having issues. |
| 164 | + |
0 commit comments