Last active
May 25, 2016 10:10
-
-
Save Mumakil/1a8b2f12c82c6cc04b89 to your computer and use it in GitHub Desktop.
Hubot helper scripts
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
# 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 | |
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
# 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