-
-
Save mislav/16eeafcd9f59f398c2cf to your computer and use it in GitHub Desktop.
Hubot command-line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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