Skip to content

Instantly share code, notes, and snippets.

@Mumakil
Last active May 25, 2016 10:10
Show Gist options
  • Save Mumakil/1a8b2f12c82c6cc04b89 to your computer and use it in GitHub Desktop.
Save Mumakil/1a8b2f12c82c6cc04b89 to your computer and use it in GitHub Desktop.
Hubot helper scripts
# Add to hubot's scripts/ when developing hubot scripts in flowdock
# to enable easy debugging when errors happen. Posts all errors with stack
# traces to first flow it knows about.
module.exports = (robot) ->
if process.env.NODE_ENV == 'development'
robot.on 'error', (error) ->
errorMessage = "ERROR:\n"
if error.stack?
errorMessage += error.stack
else
errorMessage += error.toString()
robot.logger.error errorMessage
errorMessage = errorMessage.split('\n').map((line) -> " " + line).join('\n')
robot.messageRoom robot.adapter.flows[0].id, errorMessage
# Say to room
#
# message room <room> <text> - Say text to another room
module.exports = (robot) ->
robot.respond /message room ([^\s]+) (.+)/i, (msg) ->
robot.logger.debug 'Sending message "' + msg.match[2] + '" to room ' + msg.match[1]
robot.messageRoom msg.match[1], msg.match[2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment