public void PerformSitCommand(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory bmem = OCBotMemory.Memory; if (additionalArgs[0] == "unsit") { BotSession.Instance.grid.Self.Stand(); bmem.sit_cube = UUID.Zero; bmem.Save(); } else { UUID obj = UUID.Zero; try { obj = UUID.Parse(additionalArgs[0]); BotSession.Instance.grid.Self.RequestSit(obj, Vector3.Zero); bmem.sit_cube = obj; bmem.Save(); } catch (Exception e) { MHE(source, client, "Failed to sit! UUID invalid"); } } }
private void On_NewInventoryOffer(object sender, InventoryObjectOfferedEventArgs e) { MHE(Destinations.DEST_LOCAL, e.Offer.FromAgentID, "Checking notice creation sessions.."); OCBotMemory ocMem = OCBotMemory.Memory; if (ocMem.NoticeSessions.ContainsKey(e.Offer.FromAgentID)) { MHE(Destinations.DEST_LOCAL, e.Offer.FromAgentID, "Checking.."); OCBotMemory.NoticeCreationSessions nCS = ocMem.NoticeSessions[e.Offer.FromAgentID]; if (nCS.State == 5) { MHE(Destinations.DEST_LOCAL, e.Offer.FromAgentID, "Stand by.. Accepting inventory and moving it into place"); AssetType dataType = e.AssetType; UUID AssetID = e.ObjectID; UUID DestinationFolder = grid.Inventory.FindFolderForType(dataType); e.Accept = true; e.FolderID = DestinationFolder; nCS.TemporaryNotice.NoticeAttachment = AssetID; nCS.State++; ocMem.NoticeSessions[e.Offer.FromAgentID] = nCS; ocMem.Save(); MHE(Destinations.DEST_LOCAL, e.Offer.FromAgentID, "Here's the details of the built notice, please very it is correct\n \nNotice Summary: " + nCS.TemporaryNotice.NoticeSummary + "\nNotice Description: " + nCS.TemporaryNotice.NoticeDescription + "\nNotice has attachment: " + nCS.TemporaryNotice.HasAttachment.ToString() + "\nNotice Attachment ID: " + nCS.TemporaryNotice.NoticeAttachment.ToString() + "\nRepeats: " + nCS.TemporaryNotice.Repeats.ToString() + "\n \n[To confirm this, say 'confirm']"); } } else { MHE(Destinations.DEST_LOCAL, e.Offer.FromAgentID, "Notice session does not exist!"); e.Accept = false; } }
public void InviteToGroupByChat(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; if (DateTime.Now < ocb.InviteLastSent) { MHE(source, client, "There is a 2 minute cooldown between sending group invites."); } ocb.InviteLastSent = DateTime.Now.AddMinutes(2); ocb.Save(); UUID groupID = client; UUID sendTo = UUID.Zero; if (additionalArgs.Length == 1) { sendTo = UUID.Parse(additionalArgs[0]); } if (sendTo == UUID.Zero) { return; } else { List <UUID> role = new List <UUID>(); role.Add(UUID.Zero); BotSession.Instance.grid.Groups.Invite(groupID, role, sendTo); MHE(source, client, "Sent the invite"); } }
public void auto_buildnotice(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { // Check staff group is set OCBotMemory ocb = OCBotMemory.Memory; if (ocb.StaffGroup != UUID.Zero) { // Build notice & send OCBotMemory.Notices new_notice = new OCBotMemory.Notices(); new_notice.GroupKey = ocb.StaffGroup; new_notice.HasAttachment = false; new_notice.InternalName = "kicknotice"; new_notice.LastSent = DateTime.MinValue; new_notice.NoticeAttachment = UUID.Zero; string kicked = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(additionalArgs[0])); string raw_msg = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(additionalArgs[1])); string kicked_by = System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(additionalArgs[2])); new_notice.NoticeSummary = "Automatic Kick Notification"; new_notice.Repeats = false; new_notice.NoticeDescription = raw_msg; ocb.NoticeLists.Add("kicknotice", new_notice); ocb.Save(); } }
public void SetAlertGroup(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; ocb.AlertGroup = UUID.Parse(additionalArgs[0]); ocb.Save(); }
public void Set_GitRepo(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; ocb.gitrepo = additionalArgs[0]; ocb.Save(); MHE(source, client, "Repository name set"); }
public void resave(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; if (File.Exists("OpenCollarBot.json")) { File.Delete("OpenCollarBot.json"); } ocb.Save(); }
public void ResetAllRateLimits(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; // Reset limits! ocb.RateLimiter = new Dictionary <UUID, OCBotMemory.RateData>(); MHE(source, client, "Reset completed"); ocb.Save(); }
public void set_staffgroup(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; ocb.StaffGroup = UUID.Parse(additionalArgs[0]); ocb.Save(); MHE(source, client, "Staff Group has been set to: " + ocb.StaffGroup.ToString() + "\n \n[I will send kick notices to this group automatically]"); }
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(); } }
public void clear_bug_reports(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; ocb.ActiveReportSessions = new Dictionary <UUID, OCBotMemory.ReportData>(); ocb.ActiveFeatureSessions = new Dictionary <UUID, OCBotMemory.ReportData>(); ocb.ActiveCommentSessions = new Dictionary <UUID, OCBotMemory.ReportData>(); ocb.Save(); MHE(source, client, "Cleared all active reports"); }
public void SetActiveGroup(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { UUID groupKey = UUID.Parse(additionalArgs[0]); BotSession.Instance.grid.Groups.ActivateGroup(groupKey); OCBotMemory bmem = OCBotMemory.Memory; bmem.GroupKey = groupKey; bmem.Save(); }
public void ResetRateLimits(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; // Reset limit! UUID userKey = UUID.Parse(additionalArgs[0]); ocb.RateLimiter.Remove(userKey); MHE(source, client, "User now has 5 remaining queries"); MHE(Destinations.DEST_AGENT, userKey, "Rate blocks reset for you. You now have 5 remaining bugs/features you can submit from inworld. Remember there is not a limit if you use the github site."); ocb.Save(); }
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(); }
public void SetLoginDefault(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory mem = OCBotMemory.Memory; if (additionalArgs[0].ToLower() == "region") { mem.DefaultRegion = BotSession.Instance.grid.Network.CurrentSim.Name; } else { mem.DefaultLocation = BotSession.Instance.grid.Self.SimPosition; } mem.Save(); }
public void run() { if (Directory.Exists("GroupCache")) { Directory.Delete("GroupCache", true); // Clear cache on restart } registry = CommandRegistry.Instance; grid = BotSession.Instance.grid; grid.Inventory.InventoryObjectOffered += On_NewInventoryOffer; grid.Groups.GroupRoleDataReply += CacheGroupRoles; grid.Groups.GroupMembersReply += Groups_GroupMembersReply; LastScheduleCheck = DateTime.Now - TimeSpan.FromMinutes(5); Log = BotSession.Instance.Logger; BMem = OCBotMemory.Memory; if (BMem.status != "") { MHE(Destinations.DEST_LOCAL, UUID.Zero, BMem.status); } CM = new CommandManager(); ReloadGroupsCache(); if (grid.Network.CurrentSim.Name != BMem.DefaultRegion && BMem.DefaultRegion != "") { if (BMem.DefaultLocation != Vector3.Zero) { grid.Self.Teleport(BMem.DefaultRegion, BMem.DefaultLocation); } } if (BMem.sit_cube != UUID.Zero) { grid.Self.RequestSit(BMem.sit_cube, Vector3.Zero); } if (BMem.GroupKey != UUID.Zero) { grid.Groups.ActivateGroup(BMem.GroupKey); } BMem.iHaveBeenTeleported = false; BMem.Save(); // disable on relog grid.Self.ScriptDialog += onScriptDialog; }
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(); }
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(); }
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(); }
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(); }