├── Procfile ├── .gitignore ├── hubot-scripts.json ├── bin └── hubot ├── scripts ├── help.coffee ├── pugme.coffee └── store-messages-couchdb.coffee ├── package.json └── README.md /Procfile: -------------------------------------------------------------------------------- 1 | app: bin/hubot -a irc -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store* 3 | -------------------------------------------------------------------------------- /hubot-scripts.json: -------------------------------------------------------------------------------- 1 | ["tweet.coffee", "shipit.coffee"] 2 | -------------------------------------------------------------------------------- /bin/hubot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | npm install 4 | export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" 5 | 6 | exec node_modules/.bin/hubot "$@" 7 | 8 | -------------------------------------------------------------------------------- /scripts/help.coffee: -------------------------------------------------------------------------------- 1 | # Generates help commands for Hubot. 2 | # 3 | # These commands are grabbed from comment blocks at the top of each file. 4 | # 5 | # help - Displays all of the help commands that Hubot knows about. 6 | # help - Displays all help commands that match . 7 | 8 | module.exports = (robot) -> 9 | robot.respond /help\s*(.*)?$/i, (msg) -> 10 | cmds = robot.helpCommands() 11 | if msg.match[1] 12 | cmds = cmds.filter (cmd) -> cmd.match(new RegExp(msg.match[1])) 13 | msg.send cmds.join("\n") 14 | 15 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hosted-hubot", 3 | "version": "0.2.0", 4 | "author": "GitHub Inc.", 5 | "keywords": "github hubot campfire bot", 6 | "description": "A simple helpful Robot for your Company", 7 | "licenses": [{ 8 | "type": "MIT", 9 | "url": "http://github.com/github/hubot/raw/master/LICENSE" 10 | }], 11 | 12 | "repository": { 13 | "type": "git", 14 | "url": "http://github.com/github/hubot.git" 15 | }, 16 | 17 | "dependencies": { 18 | "hubot": "2.1.3", 19 | "hubot-scripts": ">=2.0.4", 20 | "optparse": "1.0.3", 21 | "hubot-irc": "0.0.6", 22 | "cradle": "0.5.8" 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /scripts/pugme.coffee: -------------------------------------------------------------------------------- 1 | # Pugme is the most important thing in your life 2 | # 3 | # pug me - Receive a pug 4 | # pug bomb N - get N pugs 5 | 6 | module.exports = (robot) -> 7 | 8 | robot.respond /pug me/i, (msg) -> 9 | msg.http("http://pugme.herokuapp.com/random") 10 | .get() (err, res, body) -> 11 | msg.send JSON.parse(body).pug 12 | 13 | robot.respond /pug bomb( (\d+))?/i, (msg) -> 14 | count = msg.match[2] || 5 15 | msg.http("http://pugme.herokuapp.com/bomb?count=" + count) 16 | .get() (err, res, body) -> 17 | msg.send pug for pug in JSON.parse(body).pugs 18 | 19 | robot.respond /how many pugs are there/i, (msg) -> 20 | msg.http("http://pugme.herokuapp.com/count") 21 | .get() (err, res, body) -> 22 | msg.send "There are #{JSON.parse(body).pug_count} pugs." 23 | 24 | -------------------------------------------------------------------------------- /scripts/store-messages-couchdb.coffee: -------------------------------------------------------------------------------- 1 | Url = require "url" 2 | cradle = require "cradle" 3 | 4 | # sets up hooks to persist all messages into couchdb. 5 | module.exports = (robot) -> 6 | info = Url.parse process.env.HUBOT_COUCHDB_URL || 'http://localhost:5984' 7 | if info.auth 8 | auth = info.auth.split(":") 9 | client = new(cradle.Connection) info.hostname, info.port, auth: 10 | username: auth[0] 11 | password: auth[1] 12 | else 13 | client = new(cradle.Connection)(info.hostname, info.port) 14 | 15 | db = client.database(if info.pathname != '/' then info.pathname.slice(1) else "hubot-storage") 16 | 17 | robot.hear /.*$/i, (msg) -> 18 | message = msg.message 19 | message.date = new Date 20 | 21 | # ignore topic and other messages 22 | return if typeof message.user.id == 'undefined' 23 | 24 | db.save message, (err, res) -> 25 | if err then console.error(err) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This hubot hangs around at the #emberjs freenode IRC channel and sends the logs to the CouchDB located at http://emberjs.iriscouch.com/irc 2 | 3 | Hubot needs the following configuration to work like a charm: 4 | 5 | - `heroku config:add HUBOT_IRC_NICK="emberjs-hubot"` 6 | - `heroku config:add HUBOT_IRC_ROOMS="#emberjs"` 7 | - `heroku config:add HUBOT_IRC_SERVER="irc.freenode.net"` 8 | - `heroku config:add HUBOT_COUCHDB_URL="http://USERNAME:PASSWORD@emberjs.iriscouch.com:5984/irc"` 9 | 10 | If the hosting on Heroku has any problems, see alternative hosting at [joyent](http://www.arlocarreon.com/blog/git/githubs-hubot-on-joyents-no-de-smart-machines/) 11 | 12 | --- 13 | 14 | # Hubot 15 | 16 | This is a version of GitHub's Campfire bot, hubot. He's pretty cool. 17 | 18 | This version is designed to be deployed on [Heroku][heroku]. 19 | 20 | [heroku]: http://www.heroku.com 21 | 22 | ## Playing with Hubot 23 | 24 | You'll need to install the necessary dependencies for hubot. All of 25 | those dependencies are provided by [npm][npmjs]. 26 | 27 | [npmjs]: http://npmjs.org 28 | 29 | ## HTTP Listener 30 | 31 | Hubot has a HTTP listener which listens on the port specified by the `PORT` 32 | environment variable. 33 | 34 | You can specify routes to listen on in your scripts by using the `router` 35 | property on `robot`. 36 | 37 | ```coffeescript 38 | module.exports = (robot) -> 39 | robot.router.get "/hubot/version", (req, res) -> 40 | res.end robot.version 41 | ``` 42 | 43 | There are functions for GET, POST, PUT and DELETE, which all take a route and 44 | callback function that accepts a request and a response. 45 | 46 | ### Redis 47 | 48 | If you are going to use the `redis-brain.coffee` script from `hubot-scripts` 49 | you will need to add the Redis to Go addon on Heroku which requires a verified 50 | account or you can create an account at [Redis to Go][redistogo] and manually 51 | set the `REDISTOGO_URL` variable. 52 | 53 | % heroku config:add REDISTOGO_URL="..." 54 | 55 | If you don't require any persistence feel free to remove the 56 | `redis-brain.coffee` from `hubot-scripts.json` and you don't need to worry 57 | about redis at all. 58 | 59 | [redistogo]: https://redistogo.com/ 60 | 61 | ### Testing Hubot Locally 62 | 63 | You can test your hubot by running the following. 64 | 65 | % bin/hubot 66 | 67 | You'll see some start up output about where your scripts come from and a 68 | prompt. 69 | 70 | [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell 71 | [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts 72 | [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts 73 | Hubot> 74 | 75 | Then you can interact with hubot by typing `hubot help`. 76 | 77 | Hubot> hubot help 78 | 79 | Hubot> animate me - The same thing as `image me`, except adds a few 80 | convert me to - Convert expression to given units. 81 | help - Displays all of the help commands that Hubot knows about. 82 | ... 83 | 84 | Take a look at the scripts in the `./scripts` folder for examples. 85 | Delete any scripts you think are silly. Add whatever functionality you 86 | want hubot to have. 87 | 88 | ## Adapters 89 | 90 | Adapters are the interface to the service you want your hubot to run on. This 91 | can be something like Campfire or IRC. There are a number of third party 92 | adapters that the community have contributed. Check the 93 | [hubot wiki][hubot-wiki] for the available ones. 94 | 95 | If you would like to run a non-Campfire or shell adapter you will need to add 96 | the adapter package as a dependency to the `package.json` file in the 97 | `dependencies` section. 98 | 99 | Once you've added the dependency and run `npm install` to install it you can 100 | then run hubot with the adapter. 101 | 102 | % bin/hubot -a 103 | 104 | Where `` is the name of your adapter without the `hubot-` prefix. 105 | 106 | [hubot-wiki]: https://github.com/github/hubot/wiki 107 | 108 | ## hubot-scripts 109 | 110 | There will inevitably be functionality that everyone will want. Instead 111 | of adding it to hubot itself, you can submit pull requests to 112 | [hubot-scripts][hubot-scripts]. 113 | 114 | To enable scripts from the hubot-scripts package, add the script name with 115 | extension as a double quoted string to the hubot-scripts.json file in this 116 | repo. 117 | 118 | [hubot-scripts]: https://github.com/github/hubot-scripts 119 | 120 | ## Deployment 121 | 122 | % heroku create --stack cedar 123 | % git push heroku master 124 | % heroku ps:scale app=1 125 | 126 | If your Heroku account has been verified you can run the following to enable 127 | and add the Redis to Go addon to your app. 128 | 129 | % heroku addons:add redistogo:nano 130 | 131 | If you run into any problems, checkout Heroku's [docs][heroku-node-docs]. 132 | 133 | You'll need to edit the `Procfile` to set the name of your hubot. 134 | 135 | More detailed documentation can be found on the 136 | [deploying hubot onto Heroku][deploy-heroku] wiki page. 137 | 138 | ### Deploying to UNIX or Windows 139 | 140 | If you would like to deploy to either a UNIX operating system or Windows. 141 | Please check out the [deploying hubot onto UNIX][deploy-unix] and 142 | [deploying hubot onto Windows][deploy-windows] wiki pages. 143 | 144 | [heroku-node-docs]: http://devcenter.heroku/com/articles/node-js 145 | [deploy-heroku]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-Heroku 146 | [deploy-unix]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-UNIX 147 | [deploy-windows]: https://github.com/github/hubot/wiki/Deploying-Hubot-onto-Windows 148 | 149 | ## Campfire Variables 150 | 151 | If you are using the Campfire adapter you will need to set some environment 152 | variables. Refer to the documentation for other adapters and the configuraiton 153 | of those, links to the adapters can be found on the [hubot wiki][hubot-wiki]. 154 | 155 | Create a separate Campfire user for your bot and get their token from the web 156 | UI. 157 | 158 | % heroku config:add HUBOT_CAMPFIRE_TOKEN="..." 159 | 160 | Get the numeric IDs of the rooms you want the bot to join, comma delimited. If 161 | you want the bot to connect to `https://mysubdomain.campfirenow.com/room/42` 162 | and `https://mysubdomain.campfirenow.com/room/1024` then you'd add it like this: 163 | 164 | % heroku config:add HUBOT_CAMPFIRE_ROOMS="42,1024" 165 | 166 | Add the subdomain hubot should connect to. If you web URL looks like 167 | `http://mysubdomain.campfirenow.com` then you'd add it like this: 168 | 169 | % heroku config:add HUBOT_CAMPFIRE_ACCOUNT="mysubdomain" 170 | 171 | [hubot-wiki]: https://github.com/github/hubot/wiki 172 | 173 | ## Restart the bot 174 | 175 | You may want to get comfortable with `heroku logs` and `heroku restart` 176 | if you're having issues. 177 | 178 | --------------------------------------------------------------------------------