Last active
March 4, 2024 21:31
-
-
Save dzimine/9612702 to your computer and use it in GitHub Desktop.
A script to make Hubot run a command. Done both in JS and coffee script. Never put it in production :)
This file contains hidden or 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
# Description: | |
# Runs a command on hubot | |
# TOTAL VIOLATION of any and all security! | |
# | |
# Commands: | |
# hubot cmd <command> - runs a command on hubot host | |
module.exports = (robot) -> | |
robot.respond /CMD (.*)$/i, (msg) -> | |
# console.log(msg) | |
@exec = require('child_process').exec | |
cmd = msg.match[1] | |
msg.send "Running [#{cmd}]..." | |
@exec cmd, (error, stdout, stderr) -> | |
if error | |
msg.send error | |
msg.send stderr | |
else | |
msg.send stdout |
This file contains hidden or 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
// Description: | |
// Runs a command on hubot | |
// TOTAL VIOLATION of any and all security! | |
// | |
// Commands: | |
// hubot run <command> - runs a command on hubot host | |
module.exports = function(robot) { | |
robot.respond("/RUN (.*)$/i", function(msg) { | |
console.log(msg); | |
var cmd = msg.match[1]; | |
msg.send("Running " + cmd); | |
var exec = require('child_process').exec; | |
exec(cmd, function(error, stdout, stderr) { | |
if (error) { | |
msg.send(error); | |
msg.send(stderr); | |
} else { | |
msg.send(stdout); | |
} | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment