├── .gitignore ├── Procfile ├── bin ├── hubot.cmd └── hubot ├── hubot-scripts.json ├── external-scripts.json ├── .editorconfig ├── scripts └── latex.coffee ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store* 3 | .hubot_history 4 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bin/hubot --adapter slack --name hbot 2 | 3 | -------------------------------------------------------------------------------- /bin/hubot.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | npm install && node_modules\.bin\hubot.cmd --name "sjtug-bot" %* -------------------------------------------------------------------------------- /hubot-scripts.json: -------------------------------------------------------------------------------- 1 | [ 2 | "roll.coffee", 3 | "xkcd.coffee", 4 | "wikipedia.coffee" 5 | ] 6 | -------------------------------------------------------------------------------- /external-scripts.json: -------------------------------------------------------------------------------- 1 | [ 2 | "hubot-help", 3 | "hubot-heroku-keepalive", 4 | "hubot-google-images", 5 | "hubot-google-translate", 6 | "hubot-maps" 7 | ] 8 | -------------------------------------------------------------------------------- /bin/hubot: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | npm install 6 | export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" 7 | 8 | exec node_modules/.bin/hubot --name "sjtug-bot" "$@" 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | -------------------------------------------------------------------------------- /scripts/latex.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Convert LaTeX text into an image 3 | # 4 | # Dependencies: 5 | # None 6 | # 7 | # Configuration: 8 | # None 9 | # 10 | # Commands: 11 | # hubot latex text - The image for this text 12 | # 13 | # Author: 14 | # Endle 15 | 16 | module.exports = (robot) -> 17 | robot.respond /latex\s+(.*)/i, (msg) -> 18 | tex = encodeURIComponent "#{msg.match[1]}" 19 | link = "http://latex.codecogs.com/gif.latex?#{tex}" 20 | 21 | msg.send "#{link}" 22 | 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sjtug-hubot", 3 | "version": "0.0.0", 4 | "private": true, 5 | "author": "SJTUG ", 6 | "description": "Hubot for SJTUG", 7 | "dependencies": { 8 | "htmlparser": "^1.7.7", 9 | "hubot": "^2.18.0", 10 | "hubot-google-images": "^0.2.6", 11 | "hubot-google-translate": "^0.2.0", 12 | "hubot-help": "^0.1.3", 13 | "hubot-heroku-keepalive": "^1.0.2", 14 | "hubot-maps": "0.0.2", 15 | "hubot-scripts": "^2.16.2", 16 | "hubot-slack": "^3.4.2", 17 | "soupselect": "^0.2.0", 18 | "underscore": "^1.8.3", 19 | "underscore.string": "^3.3.4" 20 | }, 21 | "engines": { 22 | "node": "0.10.x" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sjtug-hubot 2 | 3 | sjtug-hubot is a chat bot built on the [Hubot][hubot] framework. It was 4 | initially generated by [generator-hubot][generator-hubot], and configured to be 5 | deployed on [Heroku][heroku] to get you up and running as quick as possible. 6 | 7 | This README is intended to help get you started. Definitely update and improve 8 | to talk about your own instance, how to use and deploy, what functionality he 9 | has, etc! 10 | 11 | [heroku]: http://www.heroku.com 12 | [hubot]: http://hubot.github.com 13 | [generator-hubot]: https://github.com/github/generator-hubot 14 | 15 | ### Running sjtug-hubot Locally 16 | 17 | You can test your hubot by running the following, however some plugins will not 18 | behave as expected unless the [environment variables](#configuration) they rely 19 | upon have been set. 20 | 21 | You can start sjtug-hubot locally by running: 22 | 23 | % bin/hubot 24 | 25 | You'll see some start up output and a prompt: 26 | 27 | [Sat Feb 28 2015 12:38:27 GMT+0000 (GMT)] INFO Using default redis on localhost:6379 28 | sjtug-hubot> 29 | 30 | Then you can interact with sjtug-hubot by typing `sjtug-hubot help`. 31 | 32 | sjtug-hubot> sjtug-hubot help 33 | sjtug-hubot animate me - The same thing as `image me`, except adds [snip] 34 | sjtug-hubot help - Displays all of the help commands that sjtug-hubot knows about. 35 | ... 36 | 37 | ### Configuration 38 | 39 | A few scripts (including some installed by default) require environment 40 | variables to be set as a simple form of configuration. 41 | 42 | Each script should have a commented header which contains a "Configuration" 43 | section that explains which values it requires to be placed in which variable. 44 | When you have lots of scripts installed this process can be quite labour 45 | intensive. The following shell command can be used as a stop gap until an 46 | easier way to do this has been implemented. 47 | 48 | grep -o 'hubot-[a-z0-9_-]\+' external-scripts.json | \ 49 | xargs -n1 -I {} sh -c 'sed -n "/^# Configuration/,/^#$/ s/^/{} /p" \ 50 | $(find node_modules/{}/ -name "*.coffee")' | \ 51 | awk -F '#' '{ printf "%-25s %s\n", $1, $2 }' 52 | 53 | How to set environment variables will be specific to your operating system. 54 | Rather than recreate the various methods and best practices in achieving this, 55 | it's suggested that you search for a dedicated guide focused on your OS. 56 | 57 | ### Scripting 58 | 59 | An example script is included at `scripts/example.coffee`, so check it out to 60 | get started, along with the [Scripting Guide](scripting-docs). 61 | 62 | For many common tasks, there's a good chance someone has already one to do just 63 | the thing. 64 | 65 | [scripting-docs]: https://github.com/github/hubot/blob/master/docs/scripting.md 66 | 67 | ### external-scripts 68 | 69 | There will inevitably be functionality that everyone will want. Instead of 70 | writing it yourself, you can use existing plugins. 71 | 72 | Hubot is able to load plugins from third-party `npm` packages. This is the 73 | recommended way to add functionality to your hubot. You can get a list of 74 | available hubot plugins on [npmjs.com](npmjs) or by using `npm search`: 75 | 76 | % npm search hubot-scripts panda 77 | NAME DESCRIPTION AUTHOR DATE VERSION KEYWORDS 78 | hubot-pandapanda a hubot script for panda responses =missu 2014-11-30 0.9.2 hubot hubot-scripts panda 79 | ... 80 | 81 | 82 | To use a package, check the package's documentation, but in general it is: 83 | 84 | 1. Use `npm install --save` to add the package to `package.json` and install it 85 | 2. Add the package name to `external-scripts.json` as a double quoted string 86 | 87 | You can review `external-scripts.json` to see what is included by default. 88 | 89 | ##### Advanced Usage 90 | 91 | It is also possible to define `external-scripts.json` as an object to 92 | explicitly specify which scripts from a package should be included. The example 93 | below, for example, will only activate two of the six available scripts inside 94 | the `hubot-fun` plugin, but all four of those in `hubot-auto-deploy`. 95 | 96 | ```json 97 | { 98 | "hubot-fun": [ 99 | "crazy", 100 | "thanks" 101 | ], 102 | "hubot-auto-deploy": "*" 103 | } 104 | ``` 105 | 106 | **Be aware that not all plugins support this usage and will typically fallback 107 | to including all scripts.** 108 | 109 | [npmjs]: https://www.npmjs.com 110 | 111 | ### hubot-scripts 112 | 113 | Before hubot plugin packages were adopted, most plugins were held in the 114 | [hubot-scripts][hubot-scripts] package. Some of these plugins have yet to be 115 | migrated to their own packages. They can still be used but the setup is a bit 116 | different. 117 | 118 | To enable scripts from the hubot-scripts package, add the script name with 119 | extension as a double quoted string to the `hubot-scripts.json` file in this 120 | repo. 121 | 122 | [hubot-scripts]: https://github.com/github/hubot-scripts 123 | 124 | ## Persistence 125 | 126 | If you are going to use the `hubot-redis-brain` package (strongly suggested), 127 | you will need to add the Redis to Go addon on Heroku which requires a verified 128 | account or you can create an account at [Redis to Go][redistogo] and manually 129 | set the `REDISTOGO_URL` variable. 130 | 131 | % heroku config:add REDISTOGO_URL="..." 132 | 133 | If you don't need any persistence feel free to remove the `hubot-redis-brain` 134 | from `external-scripts.json` and you don't need to worry about redis at all. 135 | 136 | [redistogo]: https://redistogo.com/ 137 | 138 | ## Adapters 139 | 140 | Adapters are the interface to the service you want your hubot to run on, such 141 | as Campfire or IRC. There are a number of third party adapters that the 142 | community have contributed. Check [Hubot Adapters][hubot-adapters] for the 143 | available ones. 144 | 145 | If you would like to run a non-Campfire or shell adapter you will need to add 146 | the adapter package as a dependency to the `package.json` file in the 147 | `dependencies` section. 148 | 149 | Once you've added the dependency with `npm install --save` to install it you 150 | can then run hubot with the adapter. 151 | 152 | % bin/hubot -a 153 | 154 | Where `` is the name of your adapter without the `hubot-` prefix. 155 | 156 | [hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md 157 | 158 | ## Deployment 159 | 160 | % heroku create --stack cedar 161 | % git push heroku master 162 | 163 | If your Heroku account has been verified you can run the following to enable 164 | and add the Redis to Go addon to your app. 165 | 166 | % heroku addons:add redistogo:nano 167 | 168 | If you run into any problems, checkout Heroku's [docs][heroku-node-docs]. 169 | 170 | You'll need to edit the `Procfile` to set the name of your hubot. 171 | 172 | More detailed documentation can be found on the [deploying hubot onto 173 | Heroku][deploy-heroku] wiki page. 174 | 175 | ### Deploying to UNIX or Windows 176 | 177 | If you would like to deploy to either a UNIX operating system or Windows. 178 | Please check out the [deploying hubot onto UNIX][deploy-unix] and [deploying 179 | hubot onto Windows][deploy-windows] wiki pages. 180 | 181 | [heroku-node-docs]: http://devcenter.heroku.com/articles/node-js 182 | [deploy-heroku]: https://github.com/github/hubot/blob/master/docs/deploying/heroku.md 183 | [deploy-unix]: https://github.com/github/hubot/blob/master/docs/deploying/unix.md 184 | [deploy-windows]: https://github.com/github/hubot/blob/master/docs/deploying/unix.md 185 | 186 | ## Campfire Variables 187 | 188 | If you are using the Campfire adapter you will need to set some environment 189 | variables. If not, refer to your adapter documentation for how to configure it, 190 | links to the adapters can be found on [Hubot Adapters][hubot-adapters]. 191 | 192 | Create a separate Campfire user for your bot and get their token from the web 193 | UI. 194 | 195 | % heroku config:add HUBOT_CAMPFIRE_TOKEN="..." 196 | 197 | Get the numeric IDs of the rooms you want the bot to join, comma delimited. If 198 | you want the bot to connect to `https://mysubdomain.campfirenow.com/room/42` 199 | and `https://mysubdomain.campfirenow.com/room/1024` then you'd add it like 200 | this: 201 | 202 | % heroku config:add HUBOT_CAMPFIRE_ROOMS="42,1024" 203 | 204 | Add the subdomain hubot should connect to. If you web URL looks like 205 | `http://mysubdomain.campfirenow.com` then you'd add it like this: 206 | 207 | % heroku config:add HUBOT_CAMPFIRE_ACCOUNT="mysubdomain" 208 | 209 | [hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md 210 | 211 | ## Restart the bot 212 | 213 | You may want to get comfortable with `heroku logs` and `heroku restart` if 214 | you're having issues. 215 | --------------------------------------------------------------------------------