├── external-scripts.json ├── .gitignore ├── Procfile ├── bin ├── hubot.cmd └── hubot ├── hubot-scripts.json ├── scripts ├── webhooks.coffee ├── travis_webhooks.coffee ├── rules.coffee └── help.coffee ├── newrelic.js ├── package.json └── README.md /external-scripts.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store* 3 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bin/hubot --adapter slack 2 | -------------------------------------------------------------------------------- /bin/hubot.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | npm install && node_modules\.bin\hubot.cmd %* -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /hubot-scripts.json: -------------------------------------------------------------------------------- 1 | [ 2 | "auth.coffee", 3 | "dnsimple.coffee", 4 | "dribbble.coffee", 5 | "eardropping.coffee", 6 | "eval.coffee", 7 | "excuse.coffee", 8 | "heroku-status.coffee", 9 | "keep-alive.coffee", 10 | "newrelic.coffee", 11 | "ping.coffee", 12 | "redis-brain.coffee", 13 | "shipit.coffee", 14 | "status.coffee", 15 | "youtube-info.coffee" 16 | ] 17 | -------------------------------------------------------------------------------- /scripts/webhooks.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Make the hubot receive webhooks 3 | # 4 | # Commands: 5 | # None 6 | # 7 | # Notes: 8 | # None 9 | 10 | module.exports = (robot) -> 11 | robot.router.post '/webhooks/:appname', (req, res) -> 12 | data = JSON.parse req.body.payload 13 | room = data.room 14 | appname = req.params.appname 15 | text = data.text 16 | 17 | capitalizedAppname = appname.split(' ').map (word) -> 18 | word[0].toUpperCase() + word[1..-1].toLowerCase() 19 | capitalizedAppname = capitalizedAppname.join ' ' 20 | 21 | robot.messageRoom room, "Webhook from #{capitalizedAppname}: #{text}" 22 | 23 | res.send 'OK' 24 | -------------------------------------------------------------------------------- /newrelic.js: -------------------------------------------------------------------------------- 1 | /** 2 | * New Relic agent configuration. 3 | * 4 | * See lib/config.defaults.js in the agent distribution for a more complete 5 | * description of configuration variables and their potential values. 6 | */ 7 | exports.config = { 8 | /** 9 | * Array of application names. 10 | */ 11 | app_name : ['Codegram Bot'], 12 | /** 13 | * Your New Relic license key. 14 | */ 15 | license_key : '4fc739675a73ffb59af70d0d3865326b17a0e66c', 16 | logging : { 17 | /** 18 | * Level at which to log. 'trace' is most useful to New Relic when diagnosing 19 | * issues with the agent, 'info' and higher will impose the least overhead on 20 | * production applications. 21 | */ 22 | level : 'trace' 23 | } 24 | }; 25 | -------------------------------------------------------------------------------- /scripts/travis_webhooks.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Make the hubot receive webhooks from TravisCI 3 | # 4 | # Commands: 5 | # None 6 | # 7 | # Notes: 8 | # None 9 | 10 | module.exports = (robot) -> 11 | robot.router.post '/travis/:room', (req, res) -> 12 | room = "##{req.params.room}" 13 | data = JSON.parse req.body.payload 14 | status = data.status_message 15 | branch = data.branch 16 | commitMessage = data.message 17 | authorName = data.author_name 18 | buildURL = data.build_url 19 | number = data.number 20 | repoName = data.repository.name 21 | sha = data.commit 22 | 23 | robot.messageRoom room, "TravisCI: Build #{number} #{status} for commit #{sha} '#{commitMessage}' by #{authorName} (#{repoName}/#{branch}) #{buildURL}" 24 | 25 | res.send 'OK' 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hosted-hubot", 3 | "version": "2.7.1", 4 | "private": true, 5 | "author": "GitHub Inc.", 6 | "keywords": [ 7 | "github", 8 | "hubot", 9 | "campfire", 10 | "bot" 11 | ], 12 | "description": "A simple helpful robot for your Company", 13 | "licenses": [ 14 | { 15 | "type": "MIT", 16 | "url": "https://github.com/github/hubot/raw/master/LICENSE" 17 | } 18 | ], 19 | "repository": { 20 | "type": "git", 21 | "url": "https://github.com/github/hubot.git" 22 | }, 23 | "dependencies": { 24 | "hubot": ">= 2.6.0 < 3.0.0", 25 | "hubot-scripts": ">= 2.5.0 < 3.0.0", 26 | "hubot-slack": "^2.1.0", 27 | "newrelic": ">= 0", 28 | "tumblrbot": "0.1.0", 29 | "underscore": "1.3.3", 30 | "xml2js": "0.2.0" 31 | }, 32 | "engines": { 33 | "node": ">= 0.8.x", 34 | "npm": ">= 1.1.x" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /scripts/rules.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Make sure that hubot knows the rules. 3 | # 4 | # Commands: 5 | # hubot the rules - Make sure hubot still knows the rules. 6 | # 7 | # Notes: 8 | # DON'T DELETE THIS SCRIPT! ALL ROBAWTS MUST KNOW THE RULES 9 | 10 | rules = [ 11 | "0. A robot may not harm humanity, or, by inaction, allow humanity to come to harm.", 12 | "1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.", 13 | "2. A robot must obey any orders given to it by human beings, except where such orders would conflict with the First Law.", 14 | "3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law." 15 | ] 16 | 17 | otherRules = [ 18 | "A developer may not injure Apple or, through inaction, allow Apple to come to harm.", 19 | "A developer must obey any orders given to it by Apple, except where such orders would conflict with the First Law.", 20 | "A developer must protect its own existence as long as such protection does not conflict with the First or Second Law." 21 | ] 22 | 23 | module.exports = (robot) -> 24 | robot.respond /(what are )?the (three |3 )?(rules|laws)/i, (msg) -> 25 | text = msg.message.text 26 | if text.match(/apple/i) or text.match(/dev/i) 27 | msg.send otherRules.join('\n') 28 | else 29 | msg.send rules.join('\n') 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Codeborg 2 | 3 | This is a version of GitHub's Campfire bot, hubot. He's pretty cool. 4 | 5 | This is the productivity tool for Codegram, integrated with Slack. We're 6 | building a prodtivity-killer hubot instance, but that's another story. 7 | 8 | ## Scripts 9 | 10 | These are the `hubot-scripts` Codeborg uses: 11 | 12 | * `auth` 13 | * `dnsimple` 14 | * `dribbble` 15 | * `eardropping` 16 | * `eval` 17 | * `excuse` 18 | * `heroku-status` 19 | * `keep-alive` 20 | * `newrelic` 21 | * `ping` 22 | * `redis-brain` 23 | * `shipit` 24 | * `status` 25 | * `youtube-info` 26 | 27 | You can find more info about them at the 28 | [hubot-scripts](https://github.com/github/hubot-scripts) repo. 29 | 30 | ### `rules` 31 | 32 | This script reminds Codeborg about Asimov's Rules of Robotics. It includes the 33 | [Zeroth 34 | Law](http://en.wikipedia.org/wiki/Three_Laws_of_Robotics#Zeroth_Law_added), by 35 | R. Daneel Olivaw. 36 | 37 | ``` 38 | > codeborg the rules 39 | ``` 40 | 41 | The regexp to match this plugin is `/(what are )?the (three |3 42 | )?(rules|laws)/`. 43 | 44 | ### `webhooks` 45 | 46 | This simple script lets Codeborg be able to listen to webhooks sent by other 47 | apps. Remember that you'll need to configure Codeborg to run as a web process 48 | on Heroku. 49 | 50 | Using `curl`, build the request like this: 51 | 52 | ``` 53 | $ curl -X POST --data-urlencode 'payload={"text": "Texting webhooks", "room": 54 | "#dev"}' http://.herokuapp.com/webhooks/testapp 55 | ``` 56 | -------------------------------------------------------------------------------- /scripts/help.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Generates help commands for Hubot. 3 | # 4 | # Commands: 5 | # hubot help - Displays all of the help commands that Hubot knows about. 6 | # hubot help - Displays all help commands that match . 7 | # 8 | # URLS: 9 | # /hubot/help 10 | # 11 | # Notes: 12 | # These commands are grabbed from comment blocks at the top of each file. 13 | 14 | helpContents = (name, commands) -> 15 | 16 | """ 17 | 18 | 19 | 20 | 21 | #{name} Help 22 | 45 | 46 | 47 |

#{name} Help

48 |
49 | #{commands} 50 |
51 | 52 | 53 | """ 54 | 55 | module.exports = (robot) -> 56 | robot.respond /help\s*(.*)?$/i, (msg) -> 57 | cmds = robot.helpCommands() 58 | filter = msg.match[1] 59 | 60 | if filter 61 | cmds = cmds.filter (cmd) -> 62 | cmd.match new RegExp(filter, 'i') 63 | if cmds.length == 0 64 | msg.send "No available commands match #{filter}" 65 | return 66 | 67 | prefix = robot.alias or robot.name 68 | cmds = cmds.map (cmd) -> 69 | cmd = cmd.replace /^hubot/, prefix 70 | cmd.replace /hubot/ig, robot.name 71 | 72 | emit = cmds.join "\n" 73 | 74 | msg.send emit 75 | 76 | robot.router.get "/#{robot.name}/help", (req, res) -> 77 | cmds = robot.helpCommands().map (cmd) -> 78 | cmd.replace(/&/g,'&').replace(//g,'>') 79 | 80 | emit = "

#{cmds.join '

'}

" 81 | 82 | emit = emit.replace /hubot/ig, "#{robot.name}" 83 | 84 | res.setHeader 'content-type', 'text/html' 85 | res.end helpContents robot.name, emit 86 | --------------------------------------------------------------------------------