Skip to content

Instantly share code, notes, and snippets.

@jamessantiago
Created December 27, 2013 06:46
Show Gist options
  • Save jamessantiago/8143492 to your computer and use it in GitHub Desktop.
Save jamessantiago/8143492 to your computer and use it in GitHub Desktop.
MMBot script for use with the MMBot.Powershell package
//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