Skip to content

Instantly share code, notes, and snippets.

@yoggy
Created June 10, 2014 07:52
Show Gist options
  • Save yoggy/eae94715876e0b435653 to your computer and use it in GitHub Desktop.
Save yoggy/eae94715876e0b435653 to your computer and use it in GitHub Desktop.
Hubotのスクリプトを作ってみたテスト
spawn = require('child_process').spawn
module.exports = (robot) ->
robot.respond /nike$/i, (msg) ->
msg.send 'https://farm8.staticflickr.com/7118/7446163748_fd8ace754f_m.jpg'
robot.respond /sensor$/i, (msg) ->
output = ''
ls = spawn('./sensor.rb')
ls.stdout.on 'data', (data) ->
output += data
console.log data.toString().trim()
ls.on "exit", (code) ->
msg.send output
robot.respond /sensor_gruff$/i, (msg) ->
output = ''
ls = spawn("./sensor_gruff.rb")
ls.stdout.on 'data', (data) ->
output += data
console.log data.toString().trim()
ls.on "exit", (code) ->
msg.send output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment