Skip to content

Instantly share code, notes, and snippets.

@mislav
Created October 27, 2011 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mislav/16eeafcd9f59f398c2cf to your computer and use it in GitHub Desktop.
Save mislav/16eeafcd9f59f398c2cf to your computer and use it in GitHub Desktop.
Hubot command-line
#!/usr/bin/env coffee
Hubot = require '../hubot-github'
Path = require 'path'
Robot = Hubot.robot()
class Cmdline extends Robot
send: (user, strings...) ->
for str in strings
console.log str
@done()
reply: (user, strings...) ->
for str in strings
@send user, "#{user.name}: #{str}"
done: ->
clearTimeout @imminentDeath
@imminentDeath = setTimeout ->
process.exit 0
, 10
noMatch: (message) ->
console.error "nothing matched: #{message.text}"
process.exit 1
run: (line) ->
# console.log(line)
user = @userForId('1', {name: process.env.USER})
@receive new Robot.TextMessage user, line
robot = new Cmdline
args = process.argv.slice(2, process.argv.length)
scriptsPath = Path.resolve __dirname, '../hubot-github/src/hubot/scripts'
robot.load scriptsPath, ->
robot.run("hubot " + args.join(' '))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment