示例#1
0
        public void comment(UUID from, UUID agent, int reportStage, string reply, Destinations source, string agentName)
        {
            OCBotMemory ocb = OCBotMemory.Memory;

            OCBotMemory.ReportData RD = ocb.ActiveCommentSessions[agent];
            if (reply == "cancel")
            {
                ocb.ActiveCommentSessions.Remove(agent);
                ocb.Save();
                MHE(source, from, "Canceled\n \n[Data removed]");
                return;
            }

            ocb.ActiveCommentSessions.Remove(agent);
            if (RD.ReportStage == 0)
            {
                if (reply == "#")
                {
                    RD.ReportBody += "\n";
                }
                else if (reply == "@")
                {
                    RD.ReportStage++;
                    MHE(source, from, "OK. Last question! Is this an Issue or a pull request you want to comment on? \n \n[issue/pr]");
                }
                else
                {
                    RD.ReportBody += reply;
                }
            }
            else if (RD.ReportStage == 1)
            {
                if (reply.ToLower() == "issue")
                {
                    RD.ReportTitle = "issue";
                    RD.ReportStage++;
                    MHE(source, from, "OK\n \n[If you're ready to submit this say 'ready']");
                }
                else if (reply.ToLower() == "pr")
                {
                    RD.ReportTitle = "pr";
                    RD.ReportStage++;
                    MHE(source, from, "OK\n \n[If you're ready to submit this say 'ready']");
                }
                else
                {
                    MHE(source, from, "Unable to recognize reply. Try again");
                }
            }
            else if (RD.ReportStage == 2)
            {
                if (reply != "ready")
                {
                    return;
                }
                else
                {
                    GitHubClient ghc = new GitHubClient(new ProductHeaderValue("OpenCollarBot"));
                    ghc.Credentials = new Credentials("opencollarangel", "Gai3+cOLOkUUIn==");

                    if (RD.ReportTitle == "issue")
                    {
                        if (!ocb.SubmitNewRateUsage(agent))
                        {
                            MHE(source, from, "You have reached your request rate limit for the week.");
                            ocb.Save();
                            return;
                        }
                        ghc.Issue.Comment.Create(ocb.gitowner, ocb.gitrepo, RD.TicketNumber, "Comment from " + agentName + "\n \n" + RD.ReportBody);
                        MHE(source, from, "Data has been submitted!!");
                        ocb.Save();
                        return;
                    }
                    else if (RD.ReportTitle == "pr")
                    {
                        MHE(source, from, "*Error*\n \n[Only issues are supported at this time]\n[Your request limit has not been modified]");
                        ocb.Save();
                        return;
                    }
                    else
                    {
                        ocb.Save();
                        MHE(source, from, "Unrecognized request");
                        return;
                    }
                }
            }



            ocb.ActiveCommentSessions.Add(agent, RD);
            ocb.Save();
        }
示例#2
0
        public void BugResponse(UUID from, UUID agent, int reportStage, string reply, Destinations source, string agentName)
        {
            OCBotMemory ocb = OCBotMemory.Memory;

            OCBotMemory.ReportData RD = ocb.ActiveReportSessions[agent];
            ocb.ActiveReportSessions.Remove(agent);

            if (reply == "cancel")
            {
                MHE(source, from, "Canceled \n \n[Any entered data has been discarded]");
                ocb.Save();
                return;
            }

            if (reportStage == 0)
            {
                MHE(source, from, "Okay give me a moment");
                RD.ReportTitle = reply;
                RD.ReportStage = 1;
                ocb.ActiveReportSessions.Add(agent, RD);
                MHE(source, from, "Okay. Now please go into as much detail about the problem as you would like.  \n \n[Say '@' on a new line when you are done typing out the full description]");
            }
            else if (reportStage == 1)
            {
                if (reply == "@")
                {
                    RD.ReportStage++;
                    MHE(source, from, "Okay secondlife:///app/agent/" + agent.ToString() + "/about if you have any logs to add please add them below.\n \n[If you have no logs, or are done entering your logs, say '@']");
                }
                else
                {
                    RD.ReportBody += "\n" + reply;
                    MHE(source, from, "-Data Added-");
                }
                ocb.ActiveReportSessions.Add(agent, RD);
            }
            else if (reportStage == 2)
            {
                if (reply == "@")
                {
                    RD.ReportStage++;
                    MHE(source, from, "Okay!\n \n[If you are ready to upload this report say 'ready']");
                }
                else
                {
                    MHE(source, from, "-Data Added-");
                    RD.ReportExtraData += "<details>\n<summary>Extra Data</summary>\n\n```\n" + reply + "\n```\n</details>";
                }
                ocb.ActiveReportSessions.Add(agent, RD);
            }
            else
            {
                if (reply != "ready")
                {
                    return;
                }
                int userLevel = 0;
                if (MainConfiguration.Instance.BotAdmins.ContainsKey(agent))
                {
                    userLevel = MainConfiguration.Instance.BotAdmins[agent];
                }

                if (!ocb.SubmitNewRateUsage(agent) && userLevel < 3)
                {
                    MHE(source, from, "You have hit your rate limit (5 max) for 7 days. Your rate limit resets at " + ocb.RateLimiter[agent].Reset_At.ToString());
                    ocb.Save();
                    return;
                }
                MHE(source, from, "Please stand by..");

                GitHubClient ghc  = new GitHubClient(new ProductHeaderValue("OpenCollarBot"));
                Credentials  cred = new Credentials("opencollarangel", Bot.Assemble.ASMInfo.GitPassword);
                ghc.Credentials = cred;
                NewIssue issueX = new NewIssue(RD.ReportTitle);

                issueX.Body = "Issue created by: " + agentName + "\n\n" + RD.ReportBody + "\n\n" + RD.ReportExtraData;
                Task <Issue> tskI = ghc.Issue.Create(ocb.gitowner, ocb.gitrepo, issueX);
                tskI.Wait();

                int issueNumber = tskI.Result.Number;

                if (tskI.Result.State == ItemState.Open)
                {
                    MHE(source, from, "[http://github.com/" + ocb.gitowner + "/" + ocb.gitrepo + "/issues/" + issueNumber.ToString() + " Issue Created - Click Here To View]");
                }
                else
                {
                    MHE(source, from, "Issue creation failure. Try again later. If this issue persists please report this as a bug to group staff. Thank you");
                }
            }

            ocb.Save();
        }
示例#3
0
        public void FeatureResponse(UUID from, UUID agent, int reportStage, string reply, Destinations source, string agentName)
        {
            OCBotMemory ocb = OCBotMemory.Memory;

            OCBotMemory.ReportData RD = ocb.ActiveFeatureSessions[agent];

            if (reply == "cancel")
            {
                ocb.ActiveFeatureSessions.Remove(agent);
                ocb.Save();
                MHE(source, from, "Canceled\n \n[Report Data has been deleted]");
                return;
            }
            ocb.ActiveFeatureSessions.Remove(agent);
            if (RD.ReportStage == 0)
            {
                // Save report title and prompt user for additional details
                RD.ReportTitle = reply;
                RD.ReportStage++;
                ocb.ActiveFeatureSessions.Add(agent, RD);
                MHE(source, from, "Saved. Can I get an extended description about your feature request?\n \n[Say '@' when you are ready to proceed]");
            }
            else if (RD.ReportStage == 1)
            {
                if (reply == "#")
                {
                    RD.ReportBody += "\n";
                }
                else
                {
                    RD.ReportBody += reply;
                }

                if (reply == "@")
                {
                    RD.ReportStage++;
                    MHE(source, from, "Saved!\n \n[If you are ready to submit this request say '@']");
                }

                ocb.ActiveFeatureSessions.Add(agent, RD);
            }
            else if (RD.ReportStage == 2)
            {
                int LVL = 0;
                if (MainConfiguration.Instance.BotAdmins.ContainsKey(agent))
                {
                    LVL = MainConfiguration.Instance.BotAdmins[agent];
                }
                if (!ocb.SubmitNewRateUsage(agent) && LVL < 3)
                {
                    // Notify user
                    ocb.Save();
                    MHE(source, from, "You have hit your rate limit (5 max) for 7 days. Your rate limit resets at " + ocb.RateLimiter[agent].Reset_At.ToString());
                    return;
                }

                GitHubClient ghc  = new GitHubClient(new ProductHeaderValue("OpenCollarBot"));
                Credentials  cred = new Credentials("opencollarangel", Bot.Assemble.ASMInfo.GitPassword);
                ghc.Credentials = cred;
                NewIssue NI = new NewIssue(RD.ReportTitle);
                NI.Body = "Feature Request filed by: " + agentName + "\n\n" + RD.ReportBody;

                Task <Issue> filed_issue = ghc.Issue.Create(ocb.gitowner, ocb.gitrepo, NI);

                filed_issue.Wait();

                int num = filed_issue.Result.Number;

                if (filed_issue.Result.State == ItemState.Open)
                {
                    MHE(source, from, "[http://github.com/" + ocb.gitowner + "/" + ocb.gitrepo + "/issues/" + num.ToString() + " Feature Request Created]");
                }
                else
                {
                    MHE(source, from, "Ticket creation failure. Try again later.");
                }
            }


            ocb.Save();
        }