Skip to content

Commit 0a78bf8

Browse files
committed
🐛 fixed Action Mods bug
Simply didn't work for most cases...
1 parent c5444e8 commit 0a78bf8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

AssistantComputerControl/ActionMods.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
196196
Console.WriteLine("Requires parameter? " + requiresParameter);
197197
Console.WriteLine("Has parameter? " + !String.IsNullOrEmpty(parameter));
198198

199-
string[] secondaryParameters = ActionChecker.GetSecondaryParam(parameter);
199+
string[] secondaryParameters = ActionChecker.GetSecondaryParam(parameter ?? "");
200200
if (requiresSecondaryParameter ? secondaryParameters.Length > 1 : true) { //Also returns the first parameter
201201
if (File.Exists(scriptFileLocation)) {
202-
string accArg = requiresParameter && requiresSecondaryParameter ? JsonConvert.SerializeObject(ActionChecker.GetSecondaryParam(parameter)) : (requiresParameter ? parameter : "");
202+
string secondParameter = secondaryParameters.Length == 1 ? "" : secondaryParameters[1];
203203

204204
try {
205205
ProcessStartInfo p = new ProcessStartInfo {
@@ -214,7 +214,7 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
214214
if (theExtension == ".ps1") {
215215
//Is powershell - open it correctly
216216
p.FileName = "powershell.exe";
217-
p.Arguments = String.Format("-WindowStyle Hidden -file \"{0}\" \"{1}\"", scriptFileLocation, accArg);
217+
p.Arguments = String.Format("-WindowStyle Hidden -file \"{0}\" \"{1}\" \"{2}\"", scriptFileLocation, parameter, secondParameter);
218218
} else if (theExtension == ".py") {
219219
//Python - open it correctly
220220
string minPythonVersion = (jsonTest["options"]["min_python_version"] ?? ""),
@@ -223,7 +223,7 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
223223

224224
if (pythonPath != "") {
225225
p.FileName = GetPythonPath();
226-
p.Arguments = String.Format("{0} \"{1}\"", scriptFileLocation, accArg);
226+
p.Arguments = String.Format("{0} \"{1}\" \"{2}\"", scriptFileLocation, parameter, secondParameter);
227227
} else {
228228
//No python version (or one with the min-max requirements) not found.
229229
string pythonErr;
@@ -251,11 +251,11 @@ public static Tuple<bool, string, bool> ExecuteModAction(string name, string par
251251
} else if (theExtension == ".bat" || theExtension == ".cmd" || theExtension == ".btm") {
252252
//Is batch - open it correctly (https://en.wikipedia.org/wiki/Batch_file#Filename_extensions)
253253
p.FileName = "cmd.exe";
254-
p.Arguments = String.Format("/c {0} \"{1}\"", scriptFileLocation, accArg);
254+
p.Arguments = String.Format("/c {0} \"{1}\" \"{2}\"", scriptFileLocation, parameter, secondParameter);
255255
} else {
256256
//"Other" filetype. Simply open file.
257257
p.FileName = scriptFileLocation;
258-
p.Arguments = accArg;
258+
p.Arguments = String.Format("\"{0}\" \"{1}\"", parameter, secondParameter);
259259
}
260260

261261
Process theP = Process.Start(p);

0 commit comments

Comments
 (0)