Command the Robot
This
post pretty much says everything you need to know
BUT I'll cover the details
Coffee
Hubot scripts are written in Coffee, pretty simple.
Every script will start with this line:
module.exports = (robot) ->
This line is how a plugin "starts"
Interaction
The next line describes what the robot should do:
respond - robot will respond when mentioned
robot.respond /(imitate\scojo)/i, (msg) ->
hear - robot will respond when I word is found
robot.hear /van/i, (msg) ->
Make the robot talk
The next line of your script is what the program actually does when the right word or incantation is spoken.
To make the robot respond, use msg.reply
msg.reply 'OMG GLITTER (allthethings)'
Connect to the internet
Hubot has a built in "request" library on the msg
object
msg.http('https://apiv2-ngrid.preprod.simpleenergy.com/v2/version/')
.get() (err, res, body) ->
try
json = JSON.parse(body)
msg.send "Ngrid Preprod has the follow packages"
msg.send "se-platform: #{ json.version }"
catch error
msg.send "I couldn't find the version for you. So I burned the house down with lemons"
Fabric
Using Fabric we can make GLaDOS execute extremely complex tasks across multiple servers.
Using spawn and
exec we can execute sub-processes.
Use spawn for long running tasks (ie a deploy) and use exec for short tasks
Spawn
When using spawn there will be events emitted and we can listen to and react to those events