public void ReportIssue(Mod mod, string issue_title, string issue_body, Action on_completion) { Action <string> on_success = delegate(string output) { Main.NewText("Issue submit result: " + output, Color.Yellow); ErrorLogger.Log("Issue submit result: " + output); }; Action <Exception, string> on_fail = (e, output) => { Main.NewText("Issue submit error: " + e.Message, Color.Red); LogHelpers.Log(e.ToString()); }; GithubModIssueReports.ReportIssue(mod, issue_title, issue_body, on_success, on_fail, on_completion); }
//////////////// public override void Action(CommandCaller caller, string input, string[] args) { IList <Mod> mods = ModHelpers.GetAllMods().ToList(); int arg_idx = 1; string title = CommandsHelpers.GetQuotedStringFromArgsAt(args, arg_idx, out arg_idx); if (arg_idx == -1) { caller.Reply("Invalid issue report title string", Color.Red); return; } string body = CommandsHelpers.GetQuotedStringFromArgsAt(args, arg_idx, out arg_idx); if (arg_idx == -1) { caller.Reply("Invalid issue report description string", Color.Red); return; } int mod_idx; if (!int.TryParse(args[0], out mod_idx)) { caller.Reply(args[arg_idx] + " is not an integer", Color.Red); return; } if (mod_idx <= 0 || mod_idx > mods.Count) { caller.Reply(args[arg_idx] + " is not a mod entry; out of range", Color.Red); return; } Action <string> on_success = delegate(string output) { if (output != "Done?") { caller.Reply(output, Color.GreenYellow); } else { caller.Reply("Issue report was not sent", Color.Red); } }; Action <Exception, string> on_fail = (e, output) => { caller.Reply(e.Message, Color.Red); }; GithubModIssueReports.ReportIssue(mods[mod_idx - 1], title, body, on_success, on_fail); }