-
-
Save rwilkes/aa4b16206e8e9481b183 to your computer and use it in GitHub Desktop.
MMBot script for use with the MMBot.Powershell package
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
//Notes: | |
//Requires the MMBot.Powershell nuget package | |
//Output objects must either support a ToString method or be a string to display properly | |
//It is recommended to use the PowershellModule script instead of this one to control what is executed | |
using MMBot.Powershell; | |
var robot = Require<Robot>(); | |
robot.Respond(@"(ps|powershell) (.*)", msg => | |
{ | |
var command = msg.Match[2]; | |
try | |
{ | |
foreach (string result in robot.ExecutePowershellCommand(command)) | |
{ | |
msg.Send(result); | |
} | |
} | |
catch (Exception) | |
{ | |
msg.Send("erm....issues, move along"); | |
} | |
}); | |
robot.AddHelp("mmbot powershell <command> - Executes a powershell command."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment