예제 #1
0
        public void DoActionComment(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
        {
            OCBotMemory ocb = OCBotMemory.Memory;

            MHE(source, client, "Okay I can post a comment on Ticket " + additionalArgs[0] + ". Please type out your comments below.\n \n[If you're done type '@', if you want to make a new line type '#', to cancel say 'cancel']");

            OCBotMemory.ReportData rd = new OCBotMemory.ReportData();
            rd.TicketNumber = int.Parse(additionalArgs[0]);
            rd.ReportStage  = 0;
            ocb.ActiveCommentSessions.Add(agentKey, rd);

            ocb.Save();
        }
예제 #2
0
        public void FileFeatureRequest(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
        {
            OCBotMemory ocb = OCBotMemory.Memory;

            MHE(source, client, "Hi secondlife:///app/agent/" + agentKey.ToString() + "/about ! Can you give me a short summary in a sentence or less about your feature request?\n \n[You can always say 'cancel' at any time to delete this request.]\n[To create a new line type '#']");

            OCBotMemory.ReportData rd = new OCBotMemory.ReportData();
            rd.ReportStage = 0;
            if (ocb.ActiveFeatureSessions.ContainsKey(agentKey))
            {
                MHE(source, client, "* You already had a report session started. I've reset that session for you");
                ocb.ActiveFeatureSessions.Remove(agentKey);
            }

            ocb.ActiveFeatureSessions.Add(agentKey, rd);

            ocb.Save();
        }
예제 #3
0
        public void BeginBugReport(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName)
        {
            MHE(source, client, "Hi secondlife:///app/agent/" + agentKey.ToString() + "/about\nCan you please tell me in a single sentence or less a summary of what this bug is?\n \n[Say 'cancel' at any time before I open a github ticket if you change your mind]");
            OCBotMemory bm = OCBotMemory.Memory;

            OCBotMemory.ReportData RD = new OCBotMemory.ReportData();
            RD.ReportStage = 0;
            if (!bm.ActiveReportSessions.ContainsKey(agentKey))
            {
                bm.ActiveReportSessions.Add(agentKey, RD);
                bm.Save();
            }
            else
            {
                MHE(source, client, "Seems you already had a bug report started. I'll start it from the beginning");
                bm.ActiveReportSessions.Remove(agentKey);
                bm.ActiveReportSessions.Add(agentKey, RD);
                bm.Save();
            }
        }
예제 #4
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();
        }
예제 #5
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();
        }
예제 #6
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();
        }