├── external-scripts.json ├── Procfile ├── bin ├── hubot.cmd └── hubot ├── .gitignore ├── hubot-scripts.json ├── scripts ├── hello.coffee ├── event-slave.coffee ├── auth-example.coffee ├── notifier.coffee ├── nagios-alert.coffee ├── calendar.coffee ├── event-master.coffee ├── cron.coffee ├── events.coffee ├── github-hook-test.coffee ├── ping.coffee ├── storage.coffee ├── github-pubsub-team.coffee ├── github-pubsub-member.coffee ├── template.coffee ├── youtube.coffee ├── pugme.coffee ├── maps.coffee ├── logger.coffee ├── weather.coffee ├── httpd.coffee ├── github-pubsub-issues.coffee ├── jenkins-pubsub-notifier.coffee ├── gitlab-pubsub-issues.coffee ├── rules.coffee ├── gitlab-pubsub-merges.coffee ├── github-pubsub-pulls.coffee ├── gitlab-pubsub-pushes.coffee ├── google-images.coffee ├── jenkins-builder.coffee ├── chef.coffee ├── help.coffee ├── github-pubsub-pushes.coffee ├── github-old-issues.coffee ├── roles.coffee ├── translate.coffee └── auth.coffee ├── hubot.conf.example ├── package.json ├── misc ├── hubot.init.d.centos.sh └── hubot.init.d.debian.sh └── README.md /external-scripts.json: -------------------------------------------------------------------------------- 1 | ["hubot-pubsub"] 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bin/hubot -a campfire -n Hubot 2 | -------------------------------------------------------------------------------- /bin/hubot.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | npm install && node_modules\.bin\hubot.cmd %* -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store* 3 | hubot.conf 4 | hubot.log 5 | hubot.pid 6 | logs/ 7 | -------------------------------------------------------------------------------- /hubot-scripts.json: -------------------------------------------------------------------------------- 1 | ["redis-brain.coffee", "shipit.coffee", "gemwhois.coffee", "http-info.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/hello.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Greet the world 3 | # 4 | # Commands: 5 | # hubot greet - Say hello to the world 6 | # 7 | # Author: 8 | # spajus 9 | module.exports = (robot) -> 10 | robot.respond /greet/i, (msg) -> 11 | msg.send "Hello, World!" 12 | -------------------------------------------------------------------------------- /scripts/event-slave.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Executes commands from `event-master.coffee` 3 | 4 | module.exports = (robot) -> 5 | robot.on 'slave:command', (action, room) -> 6 | robot.messageRoom room, "Slave: doing as told: #{action}" 7 | console.log 'Screw you, master...' 8 | -------------------------------------------------------------------------------- /scripts/auth-example.coffee: -------------------------------------------------------------------------------- 1 | module.exports = (robot) -> 2 | robot.respond /do dangerous stuff/i, (msg) -> 3 | if robot.auth.hasRole(msg.envelope.user, 'developer') 4 | doDangerousStuff(msg) 5 | else 6 | msg.reply "Sorry, you don't have 'developer' role" 7 | 8 | doDangerousStuff = (msg) -> 9 | msg.send "Doing dangerous stuff" 10 | 11 | -------------------------------------------------------------------------------- /scripts/notifier.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Send message to chatroom using HTTP POST 3 | # 4 | # URLS: 5 | # POST /hubot/notify/ (message=) 6 | 7 | module.exports = (robot) -> 8 | robot.router.post '/hubot/notify/:room', (req, res) -> 9 | room = req.params.room 10 | message = req.body.message 11 | robot.messageRoom room, message 12 | res.end() 13 | -------------------------------------------------------------------------------- /scripts/nagios-alert.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Receives Nagios alerts and posts them to chatroom 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # URLS: 8 | # POST /nagios/alert (message=) 9 | 10 | module.exports = (robot) -> 11 | robot.router.post "/nagios/alert", (req, res) -> 12 | res.end() 13 | robot.emit 'pubsub:publish', 'nagios.alert', req.body.message 14 | -------------------------------------------------------------------------------- /scripts/calendar.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Prints out this month's ASCII calendar. 3 | # 4 | # Commands: 5 | # hubot calendar [me] - Print out this month's calendar 6 | # 7 | # Author: 8 | # spajus 9 | child_process = require('child_process') 10 | module.exports = (robot) -> 11 | robot.respond /calendar( me)?/i, (msg) -> 12 | child_process.exec 'cal -h', (error, stdout, stderr) -> 13 | msg.send(stdout) 14 | -------------------------------------------------------------------------------- /scripts/event-master.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Controls slave at event-slave.coffee 3 | # 4 | # Commands: 5 | # hubot tell slave to - Emits event to slave to do the action 6 | 7 | module.exports = (robot) -> 8 | robot.respond /tell slave to (.*)/i, (msg) -> 9 | action = msg.match[1] 10 | room = msg.message.room 11 | msg.send "Master: telling slave to #{action}", -> 12 | robot.emit 'slave:command', action, room 13 | -------------------------------------------------------------------------------- /scripts/cron.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Defines periodic executions 3 | 4 | module.exports = (robot) -> 5 | cronJob = require('cron').CronJob 6 | tz = 'America/Los_Angeles' 7 | new cronJob('0 0 9 * * 1-5', workdaysNineAm, null, true, tz) 8 | new cronJob('0 */5 * * * *', everyFiveMinutes, null, true, tz) 9 | 10 | room = 12345678 11 | 12 | workdaysNineAm = -> 13 | robot.emit 'slave:command', 'wake everyone up', room 14 | 15 | everyFiveMinutes = -> 16 | robot.messageRoom room, 'I will nag you every 5 minutes' 17 | 18 | -------------------------------------------------------------------------------- /scripts/events.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Event system related utilities 3 | # 4 | # Commands: 5 | # hubot fake event - Triggers the event for debugging reasons 6 | # 7 | # Events: 8 | # debug - {user: } 9 | 10 | util = require 'util' 11 | 12 | module.exports = (robot) -> 13 | 14 | robot.respond /FAKE EVENT (.*)/i, (msg) -> 15 | msg.send "fake event '#{msg.match[1]}' triggered" 16 | robot.emit msg.match[1], {user: msg.message.user} 17 | 18 | robot.on 'debug', (event) -> 19 | robot.send event.user, util.inspect event -------------------------------------------------------------------------------- /scripts/github-hook-test.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Dumps HTTP requests received to /github/test 3 | # 4 | # URLS: 5 | # GET /github/test 6 | # POST /github/test 7 | # PUT /github/test 8 | 9 | module.exports = (robot) -> 10 | 11 | robot.router.get "/github/test", (req, res) -> 12 | dump 'Received GET:', req, res 13 | 14 | robot.router.post "/github/test", (req, res) -> 15 | dump 'Received POST:', req, res 16 | 17 | robot.router.put "/github/test", (req, res) -> 18 | dump 'Received PUT:', req, res 19 | 20 | dump = (message, req, res) -> 21 | console.log message, JSON.stringify(req.body, null, 2) 22 | res.end() 23 | -------------------------------------------------------------------------------- /scripts/ping.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Utility commands surrounding Hubot uptime. 3 | # 4 | # Commands: 5 | # hubot ping - Reply with pong 6 | # hubot echo - Reply back with 7 | # hubot time - Reply with current time 8 | # hubot die - End hubot process 9 | 10 | module.exports = (robot) -> 11 | robot.respond /PING$/i, (msg) -> 12 | msg.send "PONG" 13 | 14 | robot.respond /ECHO (.*)$/i, (msg) -> 15 | msg.send msg.match[1] 16 | 17 | robot.respond /TIME$/i, (msg) -> 18 | msg.send "Server time is: #{new Date()}" 19 | 20 | robot.respond /DIE$/i, (msg) -> 21 | msg.send "Goodbye, cruel world." 22 | process.exit 0 23 | 24 | -------------------------------------------------------------------------------- /scripts/storage.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Inspect the data in redis easily 3 | # 4 | # Commands: 5 | # hubot show users - Display all users that hubot knows about 6 | # hubot show storage - Display the contents that are persisted in the brain 7 | 8 | 9 | Util = require "util" 10 | 11 | module.exports = (robot) -> 12 | robot.respond /show storage$/i, (msg) -> 13 | output = Util.inspect(robot.brain.data, false, 4) 14 | msg.send output 15 | 16 | robot.respond /show users$/i, (msg) -> 17 | response = "" 18 | 19 | for own key, user of robot.brain.data.users 20 | response += "#{user.id} #{user.name}" 21 | response += " <#{user.email_address}>" if user.email_address 22 | response += "\n" 23 | 24 | msg.send response 25 | 26 | -------------------------------------------------------------------------------- /hubot.conf.example: -------------------------------------------------------------------------------- 1 | # Rename this file to `hubot.conf` and put your own values 2 | 3 | # Comma separated list of users who administer Hubot Auth 4 | export HUBOT_AUTH_ADMIN=123456,234567 5 | 6 | # Campfire adapter settings 7 | export HUBOT_CAMPFIRE_TOKEN=abcdef123456abcdef12345abcdf12346 8 | export HUBOT_CAMPFIRE_ACCOUNT=hubotorium 9 | export HUBOT_CAMPFIRE_ROOMS=500000,5000001 10 | 11 | # Ignore URLs that contain `github.com/spajus` 12 | export HUBOT_HTTP_INFO_IGNORE_URLS="github\.com/spajus" 13 | 14 | # Jenkins URI for jenkins-builder.coffee 15 | export HUBOT_JENKINS_URI="http://set-to-your-jenkins.com" 16 | export HUBOT_JENKINS_BUILD_TOKEN="somesecret" 17 | 18 | # GitLab root URL and private token 19 | export GITLAB_ROOT_URL="http://set-to-your-gitlab.com" 20 | export GITLAB_API_TOKEN=7FD4pBsEFMfjLnxrQ52x 21 | -------------------------------------------------------------------------------- /scripts/github-pubsub-team.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # An HTTP Listener that notifies about repository team changes 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # URLS: 8 | # POST /github/team/pubsub/ 9 | # 10 | # Authors: 11 | # spajus 12 | 13 | module.exports = (robot) -> 14 | 15 | robot.router.post "/github/team/pubsub/:event", (req, res) -> 16 | res.end("") 17 | event = req.params.event 18 | announceTeamChange req.body, (data) -> 19 | robot.emit 'pubsub:publish', event, data 20 | 21 | announceTeamChange = (data, cb) -> 22 | team = data.team.name 23 | team_perm = data.team.permission 24 | org = data.sender.login 25 | repo = data.repository.full_name 26 | cb "@#{org}/#{team} received #{team_perm} rights on #{repo}" 27 | 28 | -------------------------------------------------------------------------------- /scripts/github-pubsub-member.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # An HTTP Listener that notifies about repo membership changes 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # URLS: 8 | # POST /github/member/pubsub/ 9 | # 10 | # Authors: 11 | # spajus 12 | 13 | module.exports = (robot) -> 14 | 15 | robot.router.post "/github/member/pubsub/:event", (req, res) -> 16 | res.end("") 17 | event = req.params.event 18 | announceMemberChange req.body, (data) -> 19 | robot.emit 'pubsub:publish', event, data 20 | 21 | announceMemberChange = (data, cb) -> 22 | if data.action 23 | who = data.member.login 24 | by_who = data.sender.login 25 | repo = data.repository.full_name 26 | action = data.action 27 | cb "#{repo} membership change: @#{by_who} #{action} @#{who}" 28 | -------------------------------------------------------------------------------- /scripts/template.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # 3 | # 4 | # Dependencies: 5 | # "": "" 6 | # 7 | # Configuration: 8 | # LIST_OF_ENV_VARS_TO_SET 9 | # 10 | # Commands: 11 | # hubot - 12 | # - 13 | # 14 | # Notes: 15 | # 16 | # 17 | # Author: 18 | # 19 | 20 | module.exports = (robot) -> 21 | 22 | robot.respond /jump/i, (msg) -> 23 | msg.emote "jumping!" 24 | 25 | robot.hear /your'e/i, (msg) -> 26 | msg.send "you're" 27 | 28 | robot.hear /what year is it\?/i, (msg) -> 29 | msg.reply new Date().getFullYear() 30 | 31 | robot.router.get "/foo", (req, res) -> 32 | res.end "bar" 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hosted-hubot", 3 | "version": "2.7.1", 4 | "author": "GitHub Inc.", 5 | "keywords": [ 6 | "github", 7 | "hubot", 8 | "campfire", 9 | "bot" 10 | ], 11 | "description": "A simple helpful robot for your Company", 12 | "licenses": [ 13 | { 14 | "type": "MIT", 15 | "url": "https://github.com/github/hubot/raw/master/LICENSE" 16 | } 17 | ], 18 | "repository": { 19 | "type": "git", 20 | "url": "https://github.com/github/hubot.git" 21 | }, 22 | "dependencies": { 23 | "hubot": ">= 2.6.0 < 3.0.0", 24 | "hubot-scripts": ">= 2.5.0 < 3.0.0", 25 | "underscore": "~1.3.3", 26 | "jsdom": "~0.2.15", 27 | "hubot-pubsub": "1.0.0", 28 | "githubot": "~0.5.0", 29 | "cron": "~1.0.3", 30 | "moment": "~2.5.1", 31 | "time": "~0.10.0" 32 | }, 33 | "engines": { 34 | "node": ">= 0.8.x", 35 | "npm": ">= 1.1.x" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /scripts/youtube.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Messing around with the YouTube API. 3 | # 4 | # Commands: 5 | # hubot youtube me - Searches YouTube for the query and returns the video embed link. 6 | module.exports = (robot) -> 7 | robot.respond /(youtube|yt)( me)? (.*)/i, (msg) -> 8 | query = msg.match[3] 9 | robot.http("http://gdata.youtube.com/feeds/api/videos") 10 | .query({ 11 | orderBy: "relevance" 12 | 'max-results': 15 13 | alt: 'json' 14 | q: query 15 | }) 16 | .get() (err, res, body) -> 17 | videos = JSON.parse(body) 18 | videos = videos.feed.entry 19 | 20 | unless videos? 21 | msg.send "No video results for \"#{query}\"" 22 | return 23 | 24 | video = msg.random videos 25 | video.link.forEach (link) -> 26 | if link.rel is "alternate" and link.type is "text/html" 27 | msg.send link.href 28 | 29 | -------------------------------------------------------------------------------- /scripts/pugme.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Pugme is the most important thing in your life 3 | # 4 | # Dependencies: 5 | # None 6 | # 7 | # Configuration: 8 | # None 9 | # 10 | # Commands: 11 | # hubot pug me - Receive a pug 12 | # hubot pug bomb N - get N pugs 13 | 14 | module.exports = (robot) -> 15 | 16 | robot.respond /pug me/i, (msg) -> 17 | msg.http("http://pugme.herokuapp.com/random") 18 | .get() (err, res, body) -> 19 | msg.send JSON.parse(body).pug 20 | 21 | robot.respond /pug bomb( (\d+))?/i, (msg) -> 22 | count = msg.match[2] || 5 23 | msg.http("http://pugme.herokuapp.com/bomb?count=" + count) 24 | .get() (err, res, body) -> 25 | msg.send pug for pug in JSON.parse(body).pugs 26 | 27 | robot.respond /how many pugs are there/i, (msg) -> 28 | msg.http("http://pugme.herokuapp.com/count") 29 | .get() (err, res, body) -> 30 | msg.send "There are #{JSON.parse(body).pug_count} pugs." 31 | 32 | -------------------------------------------------------------------------------- /scripts/maps.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Interacts with the Google Maps API. 3 | # 4 | # Commands: 5 | # hubot map me - Returns a map view of the area returned by `query`. 6 | 7 | module.exports = (robot) -> 8 | 9 | robot.respond /(?:(satellite|terrain|hybrid)[- ])?map me (.+)/i, (msg) -> 10 | mapType = msg.match[1] or "roadmap" 11 | location = msg.match[2] 12 | mapUrl = "http://maps.google.com/maps/api/staticmap?markers=" + 13 | escape(location) + 14 | "&size=400x400&maptype=" + 15 | mapType + 16 | "&sensor=false" + 17 | "&format=png" # So campfire knows it's an image 18 | url = "http://maps.google.com/maps?q=" + 19 | escape(location) + 20 | "&hl=en&sll=37.0625,-95.677068&sspn=73.579623,100.371094&vpsrc=0&hnear=" + 21 | escape(location) + 22 | "&t=m&z=11" 23 | 24 | msg.send mapUrl 25 | msg.send url 26 | 27 | -------------------------------------------------------------------------------- /scripts/logger.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Logs all conversations 3 | # 4 | # Notes: 5 | # Logs can be found at bot's logs/ directory 6 | # 7 | # Author: 8 | # spajus 9 | 10 | module.exports = (robot) -> 11 | fs = require 'fs' 12 | fs.exists './logs/', (exists) -> 13 | if exists 14 | startLogging() 15 | else 16 | fs.mkdir './logs/', (error) -> 17 | unless error 18 | startLogging() 19 | else 20 | console.log "Could not create logs directory: #{error}" 21 | startLogging = -> 22 | console.log "Started logging" 23 | robot.hear //, (msg) -> 24 | fs.appendFile logFileName(msg), formatMessage(msg), (error) -> 25 | console.log "Could not log message: #{error}" if error 26 | logFileName = (msg) -> 27 | safe_room_name = "#{msg.message.room}".replace /[^a-z0-9]/ig, '' 28 | "./logs/#{safe_room_name}.log" 29 | formatMessage = (msg) -> 30 | "[#{new Date()}] #{msg.message.user.name}: #{msg.message.text}\n" 31 | -------------------------------------------------------------------------------- /scripts/weather.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Tells the weather 3 | # 4 | # Configuration: 5 | # HUBOT_WEATHER_API_URL - Optional openweathermap.org API endpoint to use 6 | # HUBOT_WEATHER_UNITS - Temperature units to use. 'metric' or 'imperial' 7 | # 8 | # Commands: 9 | # weather in - Tells about the weather in given location 10 | # 11 | # Author: 12 | # spajus 13 | 14 | process.env.HUBOT_WEATHER_API_URL ||= 15 | 'http://api.openweathermap.org/data/2.5/weather' 16 | process.env.HUBOT_WEATHER_UNITS ||= 'imperial' 17 | 18 | module.exports = (robot) -> 19 | robot.hear /weather in (\w+)/i, (msg) -> 20 | city = msg.match[1] 21 | query = { units: process.env.HUBOT_WEATHER_UNITS, q: city } 22 | url = process.env.HUBOT_WEATHER_API_URL 23 | msg.robot.http(url).query(query).get() (err, res, body) -> 24 | data = JSON.parse(body) 25 | weather = [ "#{Math.round(data.main.temp)} degrees" ] 26 | for w in data.weather 27 | weather.push w.description 28 | msg.reply "It's #{weather.join(', ')} in #{data.name}, #{data.sys.country}" 29 | -------------------------------------------------------------------------------- /scripts/httpd.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # A simple interaction with the built in HTTP Daemon 3 | # 4 | # Dependencies: 5 | # None 6 | # 7 | # Configuration: 8 | # None 9 | # 10 | # Commands: 11 | # None 12 | # 13 | # URLS: 14 | # /hubot/version 15 | # /hubot/ping 16 | # /hubot/time 17 | # /hubot/info 18 | # /hubot/ip 19 | 20 | spawn = require('child_process').spawn 21 | 22 | module.exports = (robot) -> 23 | 24 | robot.router.get "/hubot/version", (req, res) -> 25 | res.end robot.version 26 | 27 | robot.router.post "/hubot/ping", (req, res) -> 28 | res.end "PONG" 29 | 30 | robot.router.get "/hubot/time", (req, res) -> 31 | res.end "Server time is: #{new Date()}" 32 | 33 | robot.router.get "/hubot/info", (req, res) -> 34 | child = spawn('/bin/sh', ['-c', "echo I\\'m $LOGNAME@$(hostname):$(pwd) \\($(git rev-parse HEAD)\\)"]) 35 | 36 | child.stdout.on 'data', (data) -> 37 | res.end "#{data.toString().trim()} running node #{process.version} [pid: #{process.pid}]" 38 | child.stdin.end() 39 | 40 | robot.router.get "/hubot/ip", (req, res) -> 41 | robot.http('http://ifconfig.me/ip').get() (err, r, body) -> 42 | res.end body 43 | -------------------------------------------------------------------------------- /scripts/github-pubsub-issues.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # An HTTP Listener that notifies about new Github issues 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # URLS: 8 | # POST /github/issues/pubsub/ 9 | # 10 | # Authors: 11 | # spajus 12 | 13 | module.exports = (robot) -> 14 | 15 | robot.router.post "/github/issues/pubsub/:event", (req, res) -> 16 | res.end("") 17 | 18 | event = req.params.event 19 | 20 | announceIssue req.body, (data) -> 21 | robot.emit 'pubsub:publish', event, data 22 | 23 | 24 | announceIssue = (data, cb) -> 25 | 26 | if data.action 27 | mentioned = data.issue.body.match(/(^|\s)(@[\w\-\/]+)/g) 28 | 29 | if mentioned 30 | unique = (array) -> 31 | output = {} 32 | output[array[key]] = array[key] for key in [0...array.length] 33 | value for key, value of output 34 | 35 | mentioned = mentioned.map (nick) -> nick.trim() 36 | mentioned = unique mentioned 37 | 38 | mentioned_line = "\nMentioned: #{mentioned.join(", ")}" 39 | else 40 | mentioned_line = '' 41 | 42 | cb "Issue #{data.action}: \"#{data.issue.title}\" " + 43 | "by #{data.issue.user.login}: #{data.issue.html_url}#{mentioned_line}" 44 | 45 | -------------------------------------------------------------------------------- /scripts/jenkins-pubsub-notifier.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # An HTTP Listener that notifies about new Jenkins build failures 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # URLS: 8 | # POST /jenkins/status 9 | # 10 | # Authors: 11 | # spajus 12 | 13 | module.exports = (robot) -> 14 | 15 | robot.router.post "/jenkins/status", (req, res) -> 16 | @failing ||= [] 17 | res.end('') 18 | data = req.body 19 | return unless data.build.phase == 'FINISHED' 20 | 21 | if data.build.status == 'FAILURE' || data.build.status == 'UNSTABLE' 22 | if data.name in @failing 23 | broke = 'still broken' 24 | else 25 | broke = 'just broke' 26 | @failing.push data.name 27 | message = "#{broke} #{data.name} " + 28 | "#{data.build.display_name} (#{data.build.full_url})" 29 | 30 | if data.build.status == 'SUCCESS' 31 | if data.name in @failing 32 | index = @failing.indexOf data.name 33 | @failing.splice index, 1 if index isnt -1 34 | message = "restored #{data.name} " + 35 | "#{data.build.display_name} (#{data.build.full_url})" 36 | 37 | if message 38 | event = "build.#{data.build.status}" 39 | robot.emit 'pubsub:publish', event, message 40 | 41 | -------------------------------------------------------------------------------- /scripts/gitlab-pubsub-issues.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # hubot-pubsub based GitLab issue notifier 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # Commands: 8 | # None 9 | # 10 | # Configuration: 11 | # GITLAB_ROOT_URL 12 | # GITLAB_API_TOKEN 13 | # 14 | # URLS: 15 | # POST /gitlab/issues/pubsub/ 16 | # 17 | # Authors: 18 | # spajus 19 | 20 | module.exports = (robot) -> 21 | api_root = "#{process.env.GITLAB_ROOT_URL}/api/v3" 22 | robot.router.post "/gitlab/issues/pubsub/:event", (req, res) -> 23 | res.end('') 24 | event = req.params.event 25 | try 26 | payload = req.body 27 | attribs = payload.object_attributes 28 | project_url = "#{api_root}/projects/#{attribs.project_id}" 29 | robot.http(project_url) 30 | .header('PRIVATE-TOKEN', process.env.GITLAB_API_TOKEN) 31 | .get() (err, res, body) -> 32 | body = JSON.parse(body) 33 | issue_url = "#{body.web_url}/issues/#{attribs.id}" 34 | issue_message = "#{payload.object_kind} #{attribs.state}: #{attribs.title}" 35 | message = "#{issue_message} (#{issue_url})" 36 | robot.emit 'pubsub:publish', event, message 37 | catch error 38 | console.log "gitlab-pubsub-issues error: #{error}. Payload: #{req.body}" 39 | -------------------------------------------------------------------------------- /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 | "1. A robot may not injure a human being or, through inaction, allow a human being to come to harm.", 12 | "2. A robot must obey any orders given to it by human beings, except where such orders would conflict with the First Law.", 13 | "3. A robot must protect its own existence as long as such protection does not conflict with the First or Second Law." 14 | ] 15 | 16 | otherRules = [ 17 | "A developer may not injure Apple or, through inaction, allow Apple to come to harm.", 18 | "A developer must obey any orders given to it by Apple, except where such orders would conflict with the First Law.", 19 | "A developer must protect its own existence as long as such protection does not conflict with the First or Second Law." 20 | ] 21 | 22 | module.exports = (robot) -> 23 | robot.respond /(what are )?the (three |3 )?(rules|laws)/i, (msg) -> 24 | text = msg.message.text 25 | if text.match(/apple/i) or text.match(/dev/i) 26 | msg.send otherRules.join('\n') 27 | else 28 | msg.send rules.join('\n') 29 | 30 | -------------------------------------------------------------------------------- /scripts/gitlab-pubsub-merges.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # hubot-pubsub based GitLab merge notifier 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # Commands: 8 | # None 9 | # 10 | # Configuration: 11 | # GITLAB_ROOT_URL 12 | # GITLAB_API_TOKEN 13 | # 14 | # URLS: 15 | # POST /gitlab/merges/pubsub/ 16 | # 17 | # Authors: 18 | # spajus 19 | 20 | module.exports = (robot) -> 21 | api_root = "#{process.env.GITLAB_ROOT_URL}/api/v3" 22 | robot.router.post "/gitlab/merges/pubsub/:event", (req, res) -> 23 | res.end('') 24 | event = req.params.event 25 | try 26 | payload = req.body 27 | attribs = payload.object_attributes 28 | project_url = "#{api_root}/projects/#{attribs.target_project_id}" 29 | robot.http(project_url) 30 | .header('PRIVATE-TOKEN', process.env.GITLAB_API_TOKEN) 31 | .get() (err, res, body) -> 32 | body = JSON.parse(body) 33 | issue_url = "#{body.web_url}/merge_requests/#{attribs.id}" 34 | issue_message = "#{payload.object_kind} #{attribs.state}: #{attribs.title}" 35 | message = "#{issue_message} (#{issue_url})" 36 | robot.emit 'pubsub:publish', event, message 37 | catch error 38 | console.log "gitlab-pubsub-merges error: #{error}. Payload: #{req.body}" 39 | -------------------------------------------------------------------------------- /scripts/github-pubsub-pulls.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # hubot-pubsub based GitHub pull request notifier 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # URLS: 8 | # POST /github/pulls/pubsub/ 9 | # 10 | # Authors: 11 | # spajus 12 | 13 | module.exports = (robot) -> 14 | 15 | robot.router.post "/github/pulls/pubsub/:event", (req, res) -> 16 | 17 | event = req.params.event 18 | res.end("") 19 | 20 | announcePullRequest req.body, (data) -> 21 | robot.emit 'pubsub:publish', event, data 22 | 23 | announcePullRequest = (data, cb) -> 24 | if data.action == 'opened' 25 | mentioned = data.pull_request.body.match(/(^|\s)(@[\w\-\/]+)/g) 26 | 27 | if mentioned 28 | unique = (array) -> 29 | output = {} 30 | output[array[key]] = array[key] for key in [0...array.length] 31 | value for key, value of output 32 | 33 | mentioned = mentioned.filter (nick) -> 34 | slashes = nick.match(/\//g) 35 | slashes is null or slashes.length < 2 36 | 37 | mentioned = mentioned.map (nick) -> nick.trim() 38 | mentioned = unique mentioned 39 | 40 | mentioned_line = "\nMentioned: #{mentioned.join(", ")}" 41 | else 42 | mentioned_line = '' 43 | 44 | cb "New pull request \"#{data.pull_request.title}\" " + 45 | "by #{data.pull_request.user.login}: " + 46 | "#{data.pull_request.html_url}#{mentioned_line}" 47 | -------------------------------------------------------------------------------- /scripts/gitlab-pubsub-pushes.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # hubot-pubsub based GitLab push notifier 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # Commands: 8 | # None 9 | # 10 | # URLS: 11 | # POST /gitlab/pushes/pubsub/ 12 | # 13 | # Authors: 14 | # spajus 15 | 16 | module.exports = (robot) -> 17 | 18 | robot.router.post "/gitlab/pushes/pubsub/:event", (req, res) -> 19 | res.end('') 20 | event = req.params.event 21 | try 22 | payload = req.body 23 | prefix = ">>> " 24 | if payload.commits.length > 0 25 | merge_commit = false 26 | author = payload.commits[0].author.name 27 | for commit in payload.commits 28 | if commit.author.name != author 29 | merge_commit = true 30 | break 31 | if merge_commit 32 | message = "#{prefix} merged #{payload.commits.length} " + 33 | "commits on #{payload.repository.name}:" + 34 | payload.ref.replace('refs/heads/', '') 35 | robot.emit 'pubsub:publish', event, message 36 | if payload.commits.length < 10 37 | for commit in payload.commits 38 | robot.emit 'pubsub:publish', event, 39 | " * #{commit.author.name}: #{commit.message} (#{commit.url})" 40 | else 41 | message = "#{prefix}#{payload.commits[0].author.name} " + 42 | "pushed #{payload.commits.length} commits to " + 43 | "#{payload.repository.name}:#{payload.ref.replace('refs/heads/', '')}" 44 | robot.emit 'pubsub:publish', event, message 45 | for commit in payload.commits 46 | robot.emit 'pubsub:publish', event, " * #{commit.message} (#{commit.url})" 47 | catch error 48 | console.log "gitlab-pubsub-pushes error: #{error}. Payload: #{req.body}" 49 | -------------------------------------------------------------------------------- /scripts/google-images.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # A way to interact with the Google Images API. 3 | # 4 | # Commands: 5 | # hubot image me - The Original. Queries Google Images for and returns a random top result. 6 | # hubot animate me - The same thing as `image me`, except adds a few parameters to try to return an animated GIF instead. 7 | # hubot mustache me - Adds a mustache to the specified URL. 8 | # hubot mustache me - Searches Google Images for the specified query and mustaches it. 9 | 10 | module.exports = (robot) -> 11 | robot.respond /(image|img)( me)? (.*)/i, (msg) -> 12 | imageMe msg, msg.match[3], (url) -> 13 | msg.send url 14 | 15 | robot.respond /animate( me)? (.*)/i, (msg) -> 16 | imageMe msg, msg.match[2], true, (url) -> 17 | msg.send url 18 | 19 | robot.respond /(?:mo?u)?sta(?:s|c)he?(?: me)? (.*)/i, (msg) -> 20 | type = Math.floor(Math.random() * 6) 21 | mustachify = "http://mustachify.me/#{type}?src=" 22 | imagery = msg.match[1] 23 | 24 | if imagery.match /^https?:\/\//i 25 | msg.send "#{mustachify}#{imagery}" 26 | else 27 | imageMe msg, imagery, false, true, (url) -> 28 | msg.send "#{mustachify}#{url}" 29 | 30 | imageMe = (msg, query, animated, faces, cb) -> 31 | cb = animated if typeof animated == 'function' 32 | cb = faces if typeof faces == 'function' 33 | q = v: '1.0', rsz: '8', q: query, safe: 'active' 34 | q.imgtype = 'animated' if typeof animated is 'boolean' and animated is true 35 | q.imgtype = 'face' if typeof faces is 'boolean' and faces is true 36 | msg.http('http://ajax.googleapis.com/ajax/services/search/images') 37 | .query(q) 38 | .get() (err, res, body) -> 39 | images = JSON.parse(body) 40 | images = images.responseData?.results 41 | if images?.length > 0 42 | image = msg.random images 43 | cb "#{image.unescapedUrl}#.png" 44 | 45 | -------------------------------------------------------------------------------- /scripts/jenkins-builder.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Triggers Jenkins jobs from chatroom 3 | # 4 | # Configuration: 5 | # HUBOT_JENKINS_URI - Base Jenkins URI 6 | # HUBOT_JENKINS_BUILD_TOKEN - Token for triggering Jenkins builds 7 | # 8 | # Commands: 9 | # hubot build [param=value ...] - build Jenkins job by name 10 | # 11 | # Author: 12 | # spajus 13 | 14 | module.exports = (robot) -> 15 | 16 | jenkins_uri = process.env.HUBOT_JENKINS_URI 17 | build_token = process.env.HUBOT_JENKINS_BUILD_TOKEN 18 | 19 | robot.respond /build ([\w_-]+)/i, (msg) -> 20 | job = msg.match[1] 21 | url = "#{jenkins_uri}/job/#{encodeURI(job)}/build" 22 | msg.robot.http(url).query(token: build_token).get() (err, res, body) -> 23 | item_url = res.headers.location 24 | msg.robot.http("#{item_url}api/json").get() (err, res, body) -> 25 | data = JSON.parse body 26 | if data.executable 27 | msg.send "Building #{data.task.name} (#{data.executable.url})" 28 | else if data.task 29 | msg.send "Added #{data.task.name} (#{data.task.url}) to build queue: #{data.why}" 30 | else 31 | msg.send "Building #{data.name} (#{data.url})" 32 | 33 | robot.respond /build ([\w_-]+) (.+)$/i, (msg) -> 34 | job = msg.match[1] 35 | params = msg.match[2].split /\s+/ 36 | query = { token: build_token } 37 | for param in params 38 | [k, v] = param.split '=' 39 | query[k] = v 40 | url = "#{jenkins_uri}/job/#{encodeURI(job)}/buildWithParameters" 41 | msg.robot.http(url).query(query).get() (err, res, body) -> 42 | item_url = res.headers.location 43 | msg.robot.http("#{item_url}api/json").get() (err, res, body) -> 44 | data = JSON.parse body 45 | if data.executable 46 | msg.send "Building #{data.task.name} (#{data.executable.url})" 47 | else if data.task 48 | msg.send "Added #{data.task.name} (#{data.task.url}) to build queue: #{data.why}" 49 | else 50 | msg.send "Building #{data.name} (#{data.url})" 51 | 52 | 53 | -------------------------------------------------------------------------------- /scripts/chef.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Hubot script that runs Chef's knife 3 | # 4 | # Commands: 5 | # hubot knife - execute knife command (only in devops chat) 6 | # hubot server list - list all our servers registered with chef 7 | # hubot server list - list our servers registered with chef matching a pattern 8 | # hubot server search - search for servers matching chef role (* works) 9 | # hubot servers - search for servers matching '*-' chef role 10 | # hubot server roles - list all chef roles 11 | # hubot server roles - list chef roles matching a pattern 12 | # 13 | # Author: 14 | # spajus 15 | 16 | module.exports = (robot) -> 17 | 18 | cp = require 'child_process' 19 | knife_opts = { cwd: '/home/hubot/knife' } 20 | 21 | handle_response = (msg) -> 22 | (error, stdout, stderr) -> 23 | msg.send stdout if stdout 24 | msg.send "Error: #{stderr}" if stderr 25 | 26 | robot.respond /knife (.*)/i, (msg) -> 27 | if msg.message.room != '' 28 | msg.send "Do it in devops room please" 29 | return 30 | cp.exec "knife #{msg.match[1]}", 31 | knife_opts, handle_response(msg) 32 | 33 | robot.respond /server list$/i, (msg) -> 34 | cp.exec "knife node list", 35 | knife_opts, handle_response(msg) 36 | 37 | robot.respond /server list (.*)/i, (msg) -> 38 | cp.exec "knife node list | grep #{msg.match[1]}", 39 | knife_opts, handle_response(msg) 40 | 41 | robot.respond /server roles?$/i, (msg) -> 42 | cp.exec "knife role list", 43 | knife_opts, handle_response(msg) 44 | 45 | robot.respond /server roles? (.*)/i, (msg) -> 46 | cp.exec "knife role list | grep #{msg.match[1]}$", 47 | knife_opts, handle_response(msg) 48 | 49 | robot.respond /server search (.*)/i, (msg) -> 50 | cp.exec "knife search node 'roles:#{msg.match[1]}' -a run_list", 51 | knife_opts, handle_response(msg) 52 | 53 | robot.respond /servers (.*)/i, (msg) -> 54 | cp.exec "knife search node 'roles:*-#{msg.match[1]}' -i", 55 | knife_opts, handle_response(msg) 56 | 57 | -------------------------------------------------------------------------------- /misc/hubot.init.d.centos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: hubot 4 | # Required-Start: $local_fs $remote_fs $network 5 | # Required-Stop: $local_fs $remote_fs $network 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: hubot init script 9 | # Description: hubot is a friendly chatbot 10 | ### END INIT INFO 11 | 12 | # Author: Tomas Varaneckas 13 | 14 | # Source function library. 15 | . /etc/rc.d/init.d/functions 16 | 17 | DESC="Hubot ${NAME} bot" 18 | NAME=hubot 19 | USER=hubot 20 | GROUP=hubot 21 | BOT_PATH=/home/hubot/campfire 22 | PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:$BOT_PATH/node_modules:$BOT_PATH/node_modules/hubot/node_modules 23 | DAEMON=$BOT_PATH/bin/$NAME 24 | DAEMON_ARGS="--adapter campfire --name hubot" 25 | PIDFILE=$BOT_PATH/$NAME.pid 26 | LOGFILE=$BOT_PATH/$NAME.log 27 | SCRIPTNAME=/etc/init.d/$NAME 28 | 29 | # Read configuration variable file if it is present 30 | [ -r $BOT_PATH/hubot.conf ] && . $BOT_PATH/hubot.conf 31 | 32 | case "$1" in 33 | start) 34 | status="0" 35 | status -p ${PIDFILE} ${NAME} > /dev/null || status="$?" 36 | if [ "$status" = 0 ]; then 37 | status -p ${PIDFILE} ${NAME} 38 | exit 2 39 | fi 40 | 41 | touch $PIDFILE && chown $USER:$GROUP $PIDFILE 42 | if [ "$(whoami)" != "$USER" ]; then 43 | runuser -c "[ -r $BOT_PATH/hubot.conf ] && . $BOT_PATH/hubot.conf && \ 44 | cd $BOT_PATH && $DAEMON $DAEMON_ARGS" - $USER >> \ 45 | ${LOGFILE} 2>&1 & 46 | sleep 2 47 | PID=`pgrep -u $USER node` 48 | echo $PID > $PIDFILE 49 | else 50 | (cd $BOT_PATH; $DAEMON $DAEMON_ARGS >> ${LOGFILE} 2>&1 & echo $! > $PIDFILE) 51 | fi 52 | status -p ${PIDFILE} ${NAME} 53 | ;; 54 | stop) 55 | killproc -p ${PIDFILE} ${NAME} -INT 56 | rm -f ${PIDFILE} 57 | status -p ${PIDFILE} ${NAME} 58 | ;; 59 | status) 60 | status -p ${PIDFILE} ${NAME} 61 | ;; 62 | restart) 63 | $0 stop 64 | $0 start 65 | ;; 66 | *) 67 | echo "Usage: $0 {start|stop|status|restart}" 68 | exit 1 69 | ;; 70 | esac 71 | 72 | # vim:ft=sh 73 | 74 | -------------------------------------------------------------------------------- /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 | #{name} Help 20 | 43 | 44 | 45 |

#{name} Help

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

#{cmds.join '

'}

" 79 | 80 | emit = emit.replace /hubot/ig, "#{robot.name}" 81 | 82 | res.setHeader 'content-type', 'text/html' 83 | res.end helpContents robot.name, emit 84 | -------------------------------------------------------------------------------- /scripts/github-pubsub-pushes.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # hubot-pubsub based GitHub push notifier 3 | # 4 | # Dependencies: 5 | # "hubot-pubsub": "1.0.0" 6 | # 7 | # Commands: 8 | # None 9 | # 10 | # URLS: 11 | # POST /github/pushes/pubsub/ 12 | # 13 | # Authors: 14 | # spajus 15 | 16 | module.exports = (robot) -> 17 | 18 | robot.router.post "/github/pushes/pubsub/:event", (req, res) -> 19 | res.end('') 20 | event = req.params.event 21 | try 22 | payload = req.body 23 | prefix = ">>> " 24 | if payload.commits.length > 0 25 | merge_commit = false 26 | author = payload.commits[0].author.name 27 | for commit in payload.commits 28 | if commit.author.name != author 29 | merge_commit = true 30 | break 31 | if merge_commit 32 | message = "#{prefix}#{payload.pusher.name} merged #{payload.commits.length} " + 33 | "commits on #{payload.repository.name}:" + 34 | "#{payload.ref.replace('refs/heads/', '')} " + 35 | "(compare: #{payload.compare})" 36 | robot.emit 'pubsub:publish', event, message 37 | if payload.commits.length < 10 38 | for commit in payload.commits 39 | robot.emit 'pubsub:publish', event, 40 | " * #{commit.author.name}: #{commit.message} (#{commit.url})" 41 | else 42 | message = "#{prefix}#{payload.commits[0].author.name} " + 43 | "(#{payload.commits[0].author.username}) " + 44 | "pushed #{payload.commits.length} commits to " + 45 | "#{payload.repository.name}:#{payload.ref.replace('refs/heads/', '')}" 46 | if payload.commits.length > 1 47 | message += " (compare: #{payload.compare})" 48 | robot.emit 'pubsub:publish', event, message 49 | for commit in payload.commits 50 | robot.emit 'pubsub:publish', event, " * #{commit.message} (#{commit.url})" 51 | else 52 | robot.emit 'pubsub:publish', event, message 53 | for commit in payload.commits 54 | do (commit) -> 55 | robot.emit 'pubsub:publish', event, " * #{commit.message} (#{commit.url})" 56 | else 57 | if payload.created 58 | if payload.base_ref 59 | base_ref = ': ' + payload.base_ref.replace('refs/heads/', '') 60 | else 61 | base_ref = '' 62 | robot.emit 'pubsub:publish', event, "#{prefix}#{payload.pusher.name} " + 63 | "created: #{payload.ref.replace('refs/heads/', '')}#{base_ref}" 64 | if payload.deleted 65 | robot.emit 'pubsub:publish', event, "#{prefix}#{payload.pusher.name} " + 66 | "deleted: #{payload.ref.replace('refs/heads/', '')}" 67 | catch error 68 | console.log "github-pubsub-pushes error: #{error}. Payload: #{req.body}" 69 | -------------------------------------------------------------------------------- /scripts/github-old-issues.coffee: -------------------------------------------------------------------------------- 1 | # Description 2 | # Find and close old issues in GitHub 3 | # 4 | # Dependencies: 5 | # "githubot": "0.4.1" 6 | # "moment": "2.5.0" 7 | # "hubot-pubsub": "1.0.0" 8 | # "cron" 9 | # 10 | # Configuration: 11 | # HUBOT_GITHUB_TOKEN (optional, if you want to search in private repos) 12 | # HUBOT_GITHUB_ORG - your GitHub organization 13 | # 14 | # Commands: 15 | # hubot close old issues in - Close outdated issues in given repo 16 | # 17 | # Author: 18 | # spajus 19 | 20 | # Override these with your target repos. Keep list empty if using org. 21 | target_repos = [ 22 | 'spajus/hubot-example', 23 | 'spajus/hubot-control' 24 | ] 25 | 26 | # Override with your org. Keep blank if non relevant. 27 | target_org = '' 28 | 29 | # Set your time zone 30 | timezone = 'America/Los_Angeles' 31 | 32 | # Set desired time. 00 00 9 * * 1-5 is monday-friday at 9 AM. 33 | cron_expression = '00 00 9 * * 1-5' 34 | 35 | module.exports = (robot) -> 36 | 37 | github = require('githubot')(robot, apiVersion: 'preview') 38 | cronJob = require('cron').CronJob 39 | moment = require('moment') 40 | 41 | new cronJob(cron_expression, closeOldIssues, null, true, timezone) 42 | 43 | closeOldIssues = -> 44 | org = target_org || process.env.HUBOT_GITHUB_ORG 45 | if org 46 | robot.emit 'github:org:issues:close', org 47 | for repo in target_repos 48 | robot.emit 'github:repo:issues:close', repo 49 | 50 | robot.respond /close old issues (in )?(.+\/[^\s]+)/i, (msg) -> 51 | repo = msg.match[2] 52 | closeOldIssuesIn repo, (data) -> 53 | msg.send data 54 | 55 | robot.on 'github:org:issues:close', (org) -> 56 | github.get "/orgs/#{org}/repos", (data) -> 57 | for repo in data 58 | closeOldIssuesIn repo.full_name, (data) -> 59 | robot.emit 'pubsub:publish', 'github.issue.close', data 60 | 61 | robot.on 'github:repo:issues:close', (repo) -> 62 | closeOldIssuesIn repo, (data) -> 63 | robot.emit 'pubsub:publish', 'github.issue.close', data 64 | 65 | closeOldIssuesIn = (repo, cb) -> 66 | github.handleErrors (response) -> 67 | cb "Error: #{response.statusCode} #{response.error}. Repo: #{repo}" 68 | github.get "repos/#{repo}/issues?state=open", (data) -> 69 | reply = '' 70 | found = false 71 | old_time = moment().subtract 'months', 1 72 | for issue in data 73 | issue_time = moment issue.updated_at, 'YYYY-MM-DDTHH:mm:ssZ' 74 | if issue_time < old_time 75 | found = true 76 | post_data = { body: "Closing old issue: updated #{issue_time.fromNow()}" } 77 | github.post "repos/#{repo}/issues/#{issue.number}/comments", post_data, (post_resp) -> 78 | console.log "Posted comment: #{post_resp.html_url}" 79 | close_data = { state: 'closed' } 80 | github.request 'PATCH', "repos/#{repo}/issues/#{issue.number}", close_data, (close_resp) -> 81 | console.log "Closed issue: #{close_resp.html_url}" 82 | reply = "#{reply}#{issue.title} (#{issue.html_url}) updated #{issue_time.fromNow()}\n" 83 | if found 84 | cb "Found #{data.length} open issues in #{repo}. Closed old ones:\n#{reply}" 85 | else 86 | cb "No old issues found in #{repo}" 87 | 88 | -------------------------------------------------------------------------------- /scripts/roles.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Assign roles to people you're chatting with 3 | # 4 | # Commands: 5 | # hubot is a badass guitarist - assign a role to a user 6 | # hubot is not a badass guitarist - remove a role from a user 7 | # hubot who is - see what roles a user has 8 | # 9 | # Examples: 10 | # hubot holman is an ego surfer 11 | # hubot holman is not an ego surfer 12 | 13 | module.exports = (robot) -> 14 | 15 | if process.env.HUBOT_AUTH_ADMIN? 16 | robot.logger.warning 'The HUBOT_AUTH_ADMIN environment variable is set not going to load roles.coffee, you should delete it' 17 | return 18 | 19 | getAmbiguousUserText = (users) -> 20 | "Be more specific, I know #{users.length} people named like that: #{(user.name for user in users).join(", ")}" 21 | 22 | robot.respond /who is @?([\w .\-]+)\?*$/i, (msg) -> 23 | joiner = ', ' 24 | name = msg.match[1].trim() 25 | 26 | if name is "you" 27 | msg.send "Who ain't I?" 28 | else if name is robot.name 29 | msg.send "The best." 30 | else 31 | users = robot.brain.usersForFuzzyName(name) 32 | if users.length is 1 33 | user = users[0] 34 | user.roles = user.roles or [ ] 35 | if user.roles.length > 0 36 | if user.roles.join('').search(',') > -1 37 | joiner = '; ' 38 | msg.send "#{name} is #{user.roles.join(joiner)}." 39 | else 40 | msg.send "#{name} is nothing to me." 41 | else if users.length > 1 42 | msg.send getAmbiguousUserText users 43 | else 44 | msg.send "#{name}? Never heard of 'em" 45 | 46 | robot.respond /@?([\w .\-_]+) is (["'\w: \-_]+)[.!]*$/i, (msg) -> 47 | name = msg.match[1].trim() 48 | newRole = msg.match[2].trim() 49 | 50 | unless name in ['', 'who', 'what', 'where', 'when', 'why'] 51 | unless newRole.match(/^not\s+/i) 52 | users = robot.brain.usersForFuzzyName(name) 53 | if users.length is 1 54 | user = users[0] 55 | user.roles = user.roles or [ ] 56 | 57 | if newRole in user.roles 58 | msg.send "I know" 59 | else 60 | user.roles.push(newRole) 61 | if name.toLowerCase() is robot.name.toLowerCase() 62 | msg.send "Ok, I am #{newRole}." 63 | else 64 | msg.send "Ok, #{name} is #{newRole}." 65 | else if users.length > 1 66 | msg.send getAmbiguousUserText users 67 | else 68 | msg.send "I don't know anything about #{name}." 69 | 70 | robot.respond /@?([\w .\-_]+) is not (["'\w: \-_]+)[.!]*$/i, (msg) -> 71 | name = msg.match[1].trim() 72 | newRole = msg.match[2].trim() 73 | 74 | unless name in ['', 'who', 'what', 'where', 'when', 'why'] 75 | users = robot.brain.usersForFuzzyName(name) 76 | if users.length is 1 77 | user = users[0] 78 | user.roles = user.roles or [ ] 79 | 80 | if newRole not in user.roles 81 | msg.send "I know." 82 | else 83 | user.roles = (role for role in user.roles when role isnt newRole) 84 | msg.send "Ok, #{name} is no longer #{newRole}." 85 | else if users.length > 1 86 | msg.send getAmbiguousUserText users 87 | else 88 | msg.send "I don't know anything about #{name}." 89 | 90 | -------------------------------------------------------------------------------- /misc/hubot.init.d.debian.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ### BEGIN INIT INFO 3 | # Provides: hubot 4 | # Required-Start: $remote_fs $syslog 5 | # Required-Stop: $remote_fs $syslog 6 | # Default-Start: 2 3 4 5 7 | # Default-Stop: 0 1 6 8 | # Short-Description: Hubot stat / stop script 9 | # Description: Manages starting and stopping of Hubot node bot 10 | ### END INIT INFO 11 | 12 | # Author: Tomas Varaneckas 13 | 14 | # Do NOT "set -e" 15 | 16 | # PATH should only include /usr/* if it runs after the mountnfs.sh script 17 | DESC="Hubot node bot" 18 | NAME=hubot 19 | USER=hubot 20 | GROUP=hubot 21 | BOT_PATH=/home/hubot/campfire 22 | PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:$BOT_PATH/node_modules:$BOT_PATH/node_modules/hubot/node_modules 23 | DAEMON=$BOT_PATH/bin/$NAME 24 | DAEMON_ARGS="--adapter campfire --name hubot" 25 | PIDFILE=$BOT_PATH/$NAME.pid 26 | LOGFILE=$BOT_PATH/$NAME.log 27 | SCRIPTNAME=/etc/init.d/$NAME 28 | INIT_VERBOSE=yes 29 | 30 | # Read configuration variable file if it is present 31 | [ -r $BOT_PATH/hubot.conf ] && . $BOT_PATH/hubot.conf 32 | 33 | # Load the VERBOSE setting and other rcS variables 34 | . /lib/init/vars.sh 35 | 36 | # Define LSB log_* functions. 37 | # Depend on lsb-base (>= 3.2-14) to ensure that this file is present 38 | # and status_of_proc is working. 39 | . /lib/lsb/init-functions 40 | 41 | do_start() 42 | { 43 | status="0" 44 | pidofproc -p $PIDFILE node >/dev/null || status="$?" 45 | [ "$status" = 0 ] && return 2; 46 | 47 | touch $PIDFILE && chown $USER:$GROUP $PIDFILE 48 | 49 | start-stop-daemon --no-close --user $USER --quiet --start --pidfile $PIDFILE -c $USER:$GROUP \ 50 | --make-pidfile \ 51 | --background --chdir $BOT_PATH --exec $DAEMON -- \ 52 | $DAEMON_ARGS >> $LOGFILE 2>&1 \ 53 | || return 2 54 | } 55 | 56 | do_stop() 57 | { 58 | status="0" 59 | pidofproc -p $PIDFILE node >/dev/null || status="$?" 60 | [ "$status" = 3 ] && return 1 61 | 62 | start-stop-daemon --stop --quiet --pidfile $PIDFILE 63 | RETVAL="$?" 64 | [ "$RETVAL" = 2 ] && return 2 65 | rm -f $PIDFILE 66 | return "$RETVAL" 67 | } 68 | 69 | case "$1" in 70 | start) 71 | [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" 72 | do_start 73 | case "$?" in 74 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 75 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 76 | esac 77 | ;; 78 | stop) 79 | [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" 80 | do_stop 81 | case "$?" in 82 | 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 83 | 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; 84 | esac 85 | ;; 86 | status) 87 | status_of_proc -p $PIDFILE node $NAME && exit 0 || exit $? 88 | ;; 89 | restart|force-reload) 90 | log_daemon_msg "Restarting $DESC" "$NAME" 91 | do_stop 92 | case "$?" in 93 | 0|1) 94 | do_start 95 | case "$?" in 96 | 0) log_end_msg 0 ;; 97 | 1) log_end_msg 1 ;; # Old process is still running 98 | *) log_end_msg 1 ;; # Failed to start 99 | esac 100 | ;; 101 | *) 102 | # Failed to stop 103 | log_end_msg 1 104 | ;; 105 | esac 106 | ;; 107 | *) 108 | echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 109 | exit 3 110 | ;; 111 | esac 112 | 113 | : 114 | -------------------------------------------------------------------------------- /scripts/translate.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Allows Hubot to know many languages. 3 | # 4 | # Commands: 5 | # hubot translate me - Searches for a translation for the and then prints that bad boy out. 6 | # hubot translate me from into - Translates from into . Both and are optional 7 | 8 | languages = 9 | "af": "Afrikaans", 10 | "sq": "Albanian", 11 | "ar": "Arabic", 12 | "az": "Azerbaijani", 13 | "eu": "Basque", 14 | "bn": "Bengali", 15 | "be": "Belarusian", 16 | "bg": "Bulgarian", 17 | "ca": "Catalan", 18 | "zh-CN": "Simplified Chinese", 19 | "zh-TW": "Traditional Chinese", 20 | "hr": "Croatian", 21 | "cs": "Czech", 22 | "da": "Danish", 23 | "nl": "Dutch", 24 | "en": "English", 25 | "eo": "Esperanto", 26 | "et": "Estonian", 27 | "tl": "Filipino", 28 | "fi": "Finnish", 29 | "fr": "French", 30 | "gl": "Galician", 31 | "ka": "Georgian", 32 | "de": "German", 33 | "el": "Greek", 34 | "gu": "Gujarati", 35 | "ht": "Haitian Creole", 36 | "iw": "Hebrew", 37 | "hi": "Hindi", 38 | "hu": "Hungarian", 39 | "is": "Icelandic", 40 | "id": "Indonesian", 41 | "ga": "Irish", 42 | "it": "Italian", 43 | "ja": "Japanese", 44 | "kn": "Kannada", 45 | "ko": "Korean", 46 | "la": "Latin", 47 | "lv": "Latvian", 48 | "lt": "Lithuanian", 49 | "mk": "Macedonian", 50 | "ms": "Malay", 51 | "mt": "Maltese", 52 | "no": "Norwegian", 53 | "fa": "Persian", 54 | "pl": "Polish", 55 | "pt": "Portuguese", 56 | "ro": "Romanian", 57 | "ru": "Russian", 58 | "sr": "Serbian", 59 | "sk": "Slovak", 60 | "sl": "Slovenian", 61 | "es": "Spanish", 62 | "sw": "Swahili", 63 | "sv": "Swedish", 64 | "ta": "Tamil", 65 | "te": "Telugu", 66 | "th": "Thai", 67 | "tr": "Turkish", 68 | "uk": "Ukrainian", 69 | "ur": "Urdu", 70 | "vi": "Vietnamese", 71 | "cy": "Welsh", 72 | "yi": "Yiddish" 73 | 74 | getCode = (language,languages) -> 75 | for code, lang of languages 76 | return code if lang.toLowerCase() is language.toLowerCase() 77 | 78 | module.exports = (robot) -> 79 | language_choices = (language for _, language of languages).sort().join('|') 80 | pattern = new RegExp('translate(?: me)?' + 81 | "(?: from (#{language_choices}))?" + 82 | "(?: (?:in)?to (#{language_choices}))?" + 83 | '(.*)', 'i') 84 | robot.respond pattern, (msg) -> 85 | term = "\"#{msg.match[3]}\"" 86 | origin = if msg.match[1] isnt undefined then getCode(msg.match[1], languages) else 'auto' 87 | target = if msg.match[2] isnt undefined then getCode(msg.match[2], languages) else 'en' 88 | 89 | msg.http("https://translate.google.com/translate_a/t") 90 | .query({ 91 | client: 't' 92 | hl: 'en' 93 | multires: 1 94 | sc: 1 95 | sl: origin 96 | ssel: 0 97 | tl: target 98 | tsel: 0 99 | uptl: "en" 100 | text: term 101 | }) 102 | .header('User-Agent', 'Mozilla/5.0') 103 | .get() (err, res, body) -> 104 | data = body 105 | if data.length > 4 and data[0] == '[' 106 | parsed = eval(data) 107 | language =languages[parsed[2]] 108 | parsed = parsed[0] and parsed[0][0] and parsed[0][0][0] 109 | if parsed 110 | if msg.match[2] is undefined 111 | msg.send "#{term} is #{language} for #{parsed}" 112 | else 113 | msg.send "The #{language} #{term} translates as #{parsed} in #{languages[target]}" 114 | 115 | -------------------------------------------------------------------------------- /scripts/auth.coffee: -------------------------------------------------------------------------------- 1 | # Description: 2 | # Auth allows you to assign roles to users which can be used by other scripts 3 | # to restrict access to Hubot commands 4 | # 5 | # Dependencies: 6 | # None 7 | # 8 | # Configuration: 9 | # HUBOT_AUTH_ADMIN - A comma separate list of user IDs 10 | # 11 | # Commands: 12 | # hubot has role - Assigns a role to a user 13 | # hubot doesn't have role - Removes a role from a user 14 | # hubot what role does have - Find out what roles are assigned to a specific user 15 | # hubot who has admin role - Find out who's an admin and can assign roles 16 | # 17 | # Notes: 18 | # * Call the method: robot.auth.hasRole(msg.envelope.user,'') 19 | # * returns bool true or false 20 | # 21 | # * the 'admin' role can only be assigned through the environment variable 22 | # * roles are all transformed to lower case 23 | # 24 | # * The script assumes that user IDs will be unique on the service end as to 25 | # correctly identify a user. Names were insecure as a user could impersonate 26 | # a user 27 | # 28 | # Author: 29 | # alexwilliamsca, tombell 30 | 31 | module.exports = (robot) -> 32 | 33 | unless process.env.HUBOT_AUTH_ADMIN? 34 | robot.logger.warning 'The HUBOT_AUTH_ADMIN environment variable not set' 35 | 36 | if process.env.HUBOT_AUTH_ADMIN? 37 | admins = process.env.HUBOT_AUTH_ADMIN.split ',' 38 | else 39 | admins = [] 40 | 41 | class Auth 42 | hasRole: (user, roles) -> 43 | user = robot.brain.userForId(user.id) 44 | if user? and user.roles? 45 | roles = [roles] if typeof roles is 'string' 46 | for role in roles 47 | return true if role in user.roles 48 | return false 49 | 50 | usersWithRole: (role) -> 51 | users = [] 52 | for own key, user of robot.brain.data.users 53 | if robot.auth.hasRole(msg.envelope.user, role) 54 | users.push(user) 55 | users 56 | 57 | robot.auth = new Auth 58 | 59 | robot.respond /@?(.+) (has) (["'\w: -_]+) (role)/i, (msg) -> 60 | name = msg.match[1].trim() 61 | newRole = msg.match[3].trim().toLowerCase() 62 | 63 | unless name.toLowerCase() in ['', 'who', 'what', 'where', 'when', 'why'] 64 | user = robot.brain.userForName(name) 65 | return msg.reply "#{name} does not exist" unless user? 66 | user.roles or= [] 67 | 68 | if newRole in user.roles 69 | msg.reply "#{name} already has the '#{newRole}' role." 70 | else 71 | if newRole is 'admin' 72 | msg.reply "Sorry, the 'admin' role can only be defined in the HUBOT_AUTH_ADMIN env variable." 73 | else 74 | myRoles = msg.message.user.roles or [] 75 | if msg.message.user.id.toString() in admins 76 | user.roles.push(newRole) 77 | msg.reply "Ok, #{name} has the '#{newRole}' role." 78 | 79 | robot.respond /@?(.+) (doesn't have|does not have) (["'\w: -_]+) (role)/i, (msg) -> 80 | name = msg.match[1].trim() 81 | newRole = msg.match[3].trim().toLowerCase() 82 | 83 | unless name.toLowerCase() in ['', 'who', 'what', 'where', 'when', 'why'] 84 | user = robot.brain.userForName(name) 85 | return msg.reply "#{name} does not exist" unless user? 86 | user.roles or= [] 87 | 88 | if newRole is 'admin' 89 | msg.reply "Sorry, the 'admin' role can only be removed from the HUBOT_AUTH_ADMIN env variable." 90 | else 91 | myRoles = msg.message.user.roles or [] 92 | if msg.message.user.id.toString() in admins 93 | user.roles = (role for role in user.roles when role isnt newRole) 94 | msg.reply "Ok, #{name} doesn't have the '#{newRole}' role." 95 | 96 | robot.respond /(what role does|what roles does) @?(.+) (have)\?*$/i, (msg) -> 97 | name = msg.match[2].trim() 98 | user = robot.brain.userForName(name) 99 | return msg.reply "#{name} does not exist" unless user? 100 | user.roles or= [] 101 | displayRoles = user.roles 102 | 103 | if user.id.toString() in admins 104 | displayRoles.push('admin') 105 | 106 | if displayRoles.length == 0 107 | msg.reply "#{name} has no roles." 108 | else 109 | msg.reply "#{name} has the following roles: #{displayRoles.join(', ')}." 110 | 111 | robot.respond /who has admin role\?*$/i, (msg) -> 112 | adminNames = [] 113 | for admin in admins 114 | user = robot.brain.userForId(admin) 115 | adminNames.push user.name if user? 116 | 117 | if adminNames.length > 0 118 | msg.reply "The following people have the 'admin' role: #{adminNames.join(', ')}" 119 | else 120 | msg.reply "There are no people that have the 'admin' role." 121 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 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]. This README was generated for you by hubot to help get you started. Definitely update and improve to talk about your own instance, how to use and deploy, what functionality he has, etc! 6 | 7 | [heroku]: http://www.heroku.com 8 | 9 | ### Testing Hubot Locally 10 | 11 | You can test your hubot by running the following. 12 | 13 | % bin/hubot 14 | 15 | You'll see some start up output about where your scripts come from and a 16 | prompt. 17 | 18 | [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading adapter shell 19 | [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/scripts 20 | [Sun, 04 Dec 2011 18:41:11 GMT] INFO Loading scripts from /home/tomb/Development/hubot/src/scripts 21 | Hubot> 22 | 23 | Then you can interact with hubot by typing `hubot help`. 24 | 25 | Hubot> hubot help 26 | 27 | Hubot> animate me - The same thing as `image me`, except adds a few 28 | convert me to - Convert expression to given units. 29 | help - Displays all of the help commands that Hubot knows about. 30 | ... 31 | 32 | 33 | ### Scripting 34 | 35 | Take a look at the scripts in the `./scripts` folder for examples. 36 | Delete any scripts you think are useless or boring. Add whatever functionality you 37 | want hubot to have. Read up on what you can do with hubot in the [Scripting Guide](https://github.com/github/hubot/blob/master/docs/scripting.md). 38 | 39 | ### Redis Persistence 40 | 41 | If you are going to use the `redis-brain.coffee` script from `hubot-scripts` 42 | (strongly suggested), you will need to add the Redis to Go addon on Heroku which requires a verified 43 | account or you can create an account at [Redis to Go][redistogo] and manually 44 | set the `REDISTOGO_URL` variable. 45 | 46 | % heroku config:add REDISTOGO_URL="..." 47 | 48 | If you don't require any persistence feel free to remove the 49 | `redis-brain.coffee` from `hubot-scripts.json` and you don't need to worry 50 | about redis at all. 51 | 52 | [redistogo]: https://redistogo.com/ 53 | 54 | ## Adapters 55 | 56 | Adapters are the interface to the service you want your hubot to run on. This 57 | can be something like Campfire or IRC. There are a number of third party 58 | adapters that the community have contributed. Check 59 | [Hubot Adapters][hubot-adapters] for the available ones. 60 | 61 | If you would like to run a non-Campfire or shell adapter you will need to add 62 | the adapter package as a dependency to the `package.json` file in the 63 | `dependencies` section. 64 | 65 | Once you've added the dependency and run `npm install` to install it you can 66 | then run hubot with the adapter. 67 | 68 | % bin/hubot -a 69 | 70 | Where `` is the name of your adapter without the `hubot-` prefix. 71 | 72 | [hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md 73 | 74 | ## hubot-scripts 75 | 76 | There will inevitably be functionality that everyone will want. Instead 77 | of adding it to hubot itself, you can submit pull requests to 78 | [hubot-scripts][hubot-scripts]. 79 | 80 | To enable scripts from the hubot-scripts package, add the script name with 81 | extension as a double quoted string to the `hubot-scripts.json` file in this 82 | repo. 83 | 84 | [hubot-scripts]: https://github.com/github/hubot-scripts 85 | 86 | ## external-scripts 87 | 88 | Tired of waiting for your script to be merged into `hubot-scripts`? Want to 89 | maintain the repository and package yourself? Then this added functionality 90 | maybe for you! 91 | 92 | Hubot is now able to load scripts from third-party `npm` packages! To enable 93 | this functionality you can follow the following steps. 94 | 95 | 1. Add the packages as dependencies into your `package.json` 96 | 2. `npm install` to make sure those packages are installed 97 | 98 | To enable third-party scripts that you've added you will need to add the package 99 | name as a double quoted string to the `external-scripts.json` file in this repo. 100 | 101 | ## Deployment 102 | 103 | % heroku create --stack cedar 104 | % git push heroku master 105 | % heroku ps:scale app=1 106 | 107 | If your Heroku account has been verified you can run the following to enable 108 | and add the Redis to Go addon to your app. 109 | 110 | % heroku addons:add redistogo:nano 111 | 112 | If you run into any problems, checkout Heroku's [docs][heroku-node-docs]. 113 | 114 | You'll need to edit the `Procfile` to set the name of your hubot. 115 | 116 | More detailed documentation can be found on the 117 | [deploying hubot onto Heroku][deploy-heroku] wiki page. 118 | 119 | ### Deploying to UNIX or Windows 120 | 121 | If you would like to deploy to either a UNIX operating system or Windows. 122 | Please check out the [deploying hubot onto UNIX][deploy-unix] and 123 | [deploying hubot onto Windows][deploy-windows] wiki pages. 124 | 125 | [heroku-node-docs]: http://devcenter.heroku.com/articles/node-js 126 | [deploy-heroku]: https://github.com/github/hubot/blob/master/docs/deploying/heroku.md 127 | [deploy-unix]: https://github.com/github/hubot/blob/master/docs/deploying/unix.md 128 | [deploy-windows]: https://github.com/github/hubot/blob/master/docs/deploying/unix.md 129 | 130 | ## Campfire Variables 131 | 132 | If you are using the Campfire adapter you will need to set some environment 133 | variables. Refer to the documentation for other adapters and the configuraiton 134 | of those, links to the adapters can be found on [Hubot Adapters][hubot-adapters]. 135 | 136 | Create a separate Campfire user for your bot and get their token from the web 137 | UI. 138 | 139 | % heroku config:add HUBOT_CAMPFIRE_TOKEN="..." 140 | 141 | Get the numeric IDs of the rooms you want the bot to join, comma delimited. If 142 | you want the bot to connect to `https://mysubdomain.campfirenow.com/room/42` 143 | and `https://mysubdomain.campfirenow.com/room/1024` then you'd add it like this: 144 | 145 | % heroku config:add HUBOT_CAMPFIRE_ROOMS="42,1024" 146 | 147 | Add the subdomain hubot should connect to. If you web URL looks like 148 | `http://mysubdomain.campfirenow.com` then you'd add it like this: 149 | 150 | % heroku config:add HUBOT_CAMPFIRE_ACCOUNT="mysubdomain" 151 | 152 | [hubot-adapters]: https://github.com/github/hubot/blob/master/docs/adapters.md 153 | 154 | ## Restart the bot 155 | 156 | You may want to get comfortable with `heroku logs` and `heroku restart` 157 | if you're having issues. 158 | --------------------------------------------------------------------------------