public void ToggleMaillist(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; List <OCBotMemory.MailListMember> Members = ML.Members; foreach (OCBotMemory.MailListMember Member in Members) { if (Member.MemberID == agentKey) { // Flip status OCBotMemory.MailListMember M = Member; M.FlipOpt(); ML.Members.Remove(Member); ML.Members.Add(M); ocb.MailingLists[additionalArgs[0]] = ML; ocb.Save(); MHE(source, client, "Successfully flipped your opt-in status to " + tf(M.OptOut)); return; } } MHE(source, client, "Could not locate entry in that mailing list"); }
public void ListsRateLimits(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; // list! if (ocb.RateLimiter != null) { if (ocb.RateLimiter.Count > 0) { foreach (KeyValuePair <UUID, OCBotMemory.RateData> kvp in ocb.RateLimiter) { MHE(source, agentKey, "secondlife:///app/agent/" + kvp.Key.ToString() + "/about [ResetDate: " + kvp.Value.Reset_At.ToString() + "; RequestsSubmitted: " + kvp.Value.SubmitCount.ToString() + "]"); } } else { MHE(source, agentKey, "Nothing to list."); } } else { MHE(source, agentKey, "CRITICAL FAILURE!\n \n[ Error. Rate limit array is NULL ]"); } ocb.Save(); }
public void ToggleMaillistOpt(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; if (agentKey != ML.MailListOwner) { MHE(source, client, "You must be the maillist owner to change that"); return; } if (additionalArgs[1].ToLower() == "y") { ML.AllowOptOut = true; } else { ML.AllowOptOut = false; } MHE(source, client, "Updated"); ocb.MailingLists[additionalArgs[0]] = ML; ocb.Save(); }
public void MakeMailingList(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { // Create the new mailing list OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = new OCBotMemory.MailList(); ML.Members = new List <OCBotMemory.MailListMember>(); ML.MailListOwner = agentKey; ML.ListName = additionalArgs[0]; ML.PrepFrom = UUID.Zero; ML.PrepMsg = ""; ML.PrepState = 0; if (additionalArgs[1].ToLower() == "y") { ML.AllowOptOut = true; } else { ML.AllowOptOut = false; } MHE(source, client, "Mailing list '" + additionalArgs[0] + "' has been created successfully.\n \n[Note: Regardless of whether you enabled opt out. The first time a message is sent to this person, info will be included on how to opt out of all bot related mailing lists. These changes are reflected in a separate list.]"); ocb.MailingLists.Add(additionalArgs[0], ML); ocb.Save(); }
public void RemListMember(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { // Create the new mailing list OCBotMemory ocb = OCBotMemory.Memory; UUID TheMember = UUID.Parse(additionalArgs[1]); OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; List <OCBotMemory.MailListMember> Members = ML.Members; foreach (OCBotMemory.MailListMember Member in Members) { if (Member.MemberID == TheMember) { Members.Remove(Member); ML.Members = Members; ocb.MailingLists[additionalArgs[0]] = ML; ocb.Save(); MHE(source, client, "The member has been removed from the mailing list '" + additionalArgs[0] + "'"); return; } } MHE(source, client, "No changes made. Could not find that member in the list"); }
public void reset_notice_sess(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; ocb.NoticeSessions = new Dictionary <UUID, OCBotMemory.NoticeCreationSessions>(); ocb.Save(); }
public void HandleMailListData(UUID agent, UUID from, Destinations source, string MailingListName, string reply) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = ocb.MailingLists[MailingListName]; if (reply == "cancel") { ML.PrepFrom = UUID.Zero; ML.PrepMsg = ""; ML.PrepState = 0; MHE(source, from, "OK. Deleted the prepared data. Resuming normal operations"); ocb.MailingLists[MailingListName] = ML; ocb.Save(); return; } if (reply == "#") { ML.PrepMsg += "\n"; ocb.MailingLists[MailingListName] = ML; ocb.Save(); return; } if (reply == "@") { MHE(source, from, "Okay! Dispatching a example message to you. If it looks right then use the -maillist_send- command. View the help data for more info. If it does not look right.. Just start the process over, it'll erase the existing data"); ML.PrepMsg = "_\n \n[Mailing List Notification]\n[List: " + ML.ListName + "]\n*You are receiving this message because you are a member of the mailing list\n \n" + ML.PrepMsg; ML.PrepState = 2; MHE(Destinations.DEST_AGENT, agent, ML.PrepMsg); ocb.MailingLists[MailingListName] = ML; ocb.Save(); return; } if (ML.PrepState == 1) { ML.PrepMsg += reply; ocb.MailingLists[MailingListName] = ML; ocb.Save(); } }
public void rm_notice(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; if (ocb.NoticeLists.ContainsKey(additionalArgs[0])) { ocb.NoticeLists.Remove(additionalArgs[0]); } ocb.Save(); }
public void ToggleMaillistOff(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; if (!ocb.BlacklistMailingList.Contains(agentKey)) { ocb.BlacklistMailingList.Add(agentKey); } ocb.Save(); MHE(source, client, "OK"); }
public void StartNewDispatchedMessage(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; ML.PrepState = 1; ML.PrepFrom = agentKey; ML.PrepMsg = ""; ocb.MailingLists[additionalArgs[0]] = ML; ocb.Save(); MHE(source, client, "Okay you can type out your message now. \n \n[To indicate completion type '@', and for a new line type '#', and to cancel: 'cancel']"); }
public void RMMailLists(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; if (ML.MailListOwner == agentKey) { ocb.MailingLists.Remove(additionalArgs[0]); ocb.Save(); MHE(source, client, "Deleted mail list"); } }
public void AddListMember(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { // Create the new mailing list OCBotMemory ocb = OCBotMemory.Memory; UUID add_member = UUID.Parse(additionalArgs[1]); // Lets check data OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; List <OCBotMemory.MailListMember> Members = ML.Members; if (Members == null) { Members = new List <OCBotMemory.MailListMember>(); } foreach (OCBotMemory.MailListMember Member in Members) { if (Member.MemberID == add_member) { MHE(source, client, "This member is already added to the list"); if (ocb.BlacklistMailingList.Contains(add_member)) { MHE(source, client, "If this person is having trouble getting mailing list notifications, have them opt back into mailing lists. They are currently opted out of all mailing list functionality."); } return; } } OCBotMemory.MailListMember NewMember = new OCBotMemory.MailListMember(); NewMember.OptOut = false; NewMember.Informed = false; NewMember.MemberID = add_member; Members.Add(NewMember); ML.Members = Members; ocb.MailingLists[additionalArgs[0]] = ML; MHE(source, client, "Added."); ocb.Save(); }
public void ReplaceMailListMembers(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { // Create the new mailing list OCBotMemory ocb = OCBotMemory.Memory; MHE(source, client, "Stand by.."); OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; if (ML.MailListOwner != agentKey) { MHE(source, client, "PERMISSION ERROR: You are not the MailList Owner. Please only edit mailing lists you own or have created yourself"); return; } List <OCBotMemory.MailListMember> Members = new List <OCBotMemory.MailListMember>(); string sURL = additionalArgs[1]; WebRequest WR = WebRequest.Create(sURL); WebResponse resp = WR.GetResponse(); Stream S = resp.GetResponseStream(); StreamReader SR = new StreamReader(S); string CSV = SR.ReadToEnd(); string[] CSVList = new string[] { ",", ", " }; string[] listData = CSV.Split(CSVList, StringSplitOptions.RemoveEmptyEntries); foreach (string D in listData) { OCBotMemory.MailListMember NewMember = new OCBotMemory.MailListMember(); NewMember.Informed = false; NewMember.OptOut = false; NewMember.MemberID = UUID.Parse(D); Members.Add(NewMember); } ML.Members = Members; ocb.MailingLists[additionalArgs[0]] = ML; ocb.Save(); MHE(source, client, "Mailing list member list completely replaced by CSV contents"); }
public void create_notice(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; if (ocb.NoticeSessions.ContainsKey(agentKey)) { // Remove session MHE(source, client, "You already had a notice creation session in progress, restarting session"); ocb.NoticeSessions.Remove(agentKey); } OCBotMemory.NoticeCreationSessions nCS = new OCBotMemory.NoticeCreationSessions(); nCS.SessionAv = agentKey; nCS.State = 0; nCS.TemporaryNotice = new OCBotMemory.Notices(); nCS.TemporaryNotice.InternalName = additionalArgs[0]; ocb.NoticeSessions.Add(agentKey, nCS); ocb.Save(); MHE(source, client, "Okay! Notice session started! To stop at any time say 'cancel'\n \n[Please submit a summary of the notice!]"); }
public void update_notice_sess(UUID fromID, UUID agentKey, string request, Destinations sourceLoc, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.NoticeCreationSessions nCS = ocb.NoticeSessions[agentKey]; if (request.ToLower() == "cancel") { ocb.NoticeSessions.Remove(agentKey); ocb.Save(); MHE(sourceLoc, fromID, "Canceled"); return; } else if (request.ToLower() == "skip") { MHE(sourceLoc, fromID, "Stand by..."); switch (nCS.State) { case 0: { MHE(sourceLoc, fromID, $"Notice summary remains set to: {nCS.TemporaryNotice.NoticeSummary}"); nCS.State++; MHE(sourceLoc, fromID, "Notice summary set!\n \n[Type out the body of the notice]"); break; } case 1: { MHE(sourceLoc, fromID, $"Notice description remains set to: {nCS.TemporaryNotice.NoticeDescription}"); nCS.State++; MHE(sourceLoc, fromID, "Notice description set!\n \n[Should the notice repeat every 2 weeks? (y/n)]"); break; } case 2: { MHE(sourceLoc, fromID, $"Repeat remains set to: {nCS.TemporaryNotice.Repeats.ToString()}"); nCS.State++; MHE(sourceLoc, fromID, "Notice will " + (nCS.TemporaryNotice.Repeats ? "" : " -not- ") + " repeat every 2 weeks\n \n[What group should this notice be sent in? (expect:UUID)]"); break; } case 3: { MHE(sourceLoc, fromID, $"Group Key remains set to: {nCS.TemporaryNotice.GroupKey.ToString()}"); nCS.State++; MHE(sourceLoc, fromID, "Group set! (Will verify that I am in this group after all data is set)\n \n[Want an attachment set? (y/n)]"); break; } case 4: { MHE(sourceLoc, fromID, $"Attachment UUID remains set to: {nCS.TemporaryNotice.NoticeAttachment.ToString()}"); nCS.State = 6; MHE(sourceLoc, fromID, "Here's the details of the built notice, please verify 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']"); break; } } ocb.NoticeSessions[agentKey] = nCS; ocb.Save(); return; } if (nCS.State == 0) { nCS.State++; nCS.TemporaryNotice.NoticeSummary = request; ocb.NoticeSessions[agentKey] = nCS; ocb.Save(); MHE(sourceLoc, fromID, "Notice summary set!\n \n[Type out the body of the notice]"); } else if (nCS.State == 1) { nCS.State++; nCS.TemporaryNotice.NoticeDescription = request; ocb.NoticeSessions[agentKey] = nCS; ocb.Save(); MHE(sourceLoc, fromID, "Notice description set!\n \n[Should the notice repeat every 2 weeks? (y/n)]"); } else if (nCS.State == 2) { nCS.State++; if (request.ToLower() == "y") { nCS.TemporaryNotice.Repeats = true; } else { nCS.TemporaryNotice.Repeats = false; } ocb.NoticeSessions[agentKey] = nCS; ocb.Save(); MHE(sourceLoc, fromID, "Notice will " + (nCS.TemporaryNotice.Repeats ? "" : " -not- ") + " repeat every 2 weeks\n \n[What group should this notice be sent in? (expect:UUID)]"); } else if (nCS.State == 3) { nCS.State++; nCS.TemporaryNotice.GroupKey = UUID.Parse(request); ocb.NoticeSessions[agentKey] = nCS; ocb.Save(); MHE(sourceLoc, fromID, "Group set! (Will verify that I am in this group after all data is set)\n \n[Want an attachment set? (y/n)]"); } else if (nCS.State == 4) { nCS.State++; if (request.ToLower() == "y") { nCS.TemporaryNotice.HasAttachment = true; } else { nCS.TemporaryNotice.HasAttachment = false; } if (nCS.TemporaryNotice.HasAttachment) { MHE(sourceLoc, fromID, "Okay!\n \n[Send me the inventory item you want on the notice (must have transfer and copy permissions!!)]"); } else { nCS.State = 6; MHE(sourceLoc, fromID, "Here's the details of the built notice, please verify 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']"); } ocb.NoticeSessions[agentKey] = nCS; ocb.Save(); } else if (nCS.State == 6) { if (request.ToLower() == "confirm") { MHE(sourceLoc, fromID, "Okay! Scheduling.. Stand by"); // Adding notice to task scheduler if (!ocb.NoticeLists.ContainsKey(nCS.TemporaryNotice.InternalName)) { ocb.NoticeLists.Add(nCS.TemporaryNotice.InternalName, ocb.NoticeSessions[agentKey].TemporaryNotice); } else { ocb.NoticeLists[nCS.TemporaryNotice.InternalName] = ocb.NoticeSessions[agentKey].TemporaryNotice; } // Notice is now scheduled, remove session ocb.NoticeSessions.Remove(agentKey); MHE(sourceLoc, fromID, "Scheduled notice to be dispatched, please wait a few moments"); ocb.Save(); } } }
public static void PerformCheck(DateTime LastScheduleCheck) { if (DateTime.Now > LastScheduleCheck) { LastScheduleCheck = DateTime.Now + TimeSpan.FromMinutes(5); OCBotMemory bm = OCBotMemory.Memory; Dictionary <string, OCBotMemory.Notices> NoticeLists = bm.NoticeLists; Dictionary <int, OCBotMemory.Notices> NoticeEditQueue = new Dictionary <int, OCBotMemory.Notices>(); foreach (KeyValuePair <string, OCBotMemory.Notices> entry in NoticeLists) { // check notice information OCBotMemory.Notices Notice = bm.NoticeLists[entry.Key]; if (entry.Value.Repeats) { if (entry.Value.LastSent == null) { Notice.LastSent = DateTime.Now - TimeSpan.FromMinutes(90); } // Check datetime if (Notice.LastSent < DateTime.Now) { MH(Destinations.DEST_LOCAL, UUID.Zero, "Dispatching scheduled notice"); // Send notice and update information GroupNotice NewNotice = new GroupNotice(); if (Notice.HasAttachment) { NewNotice.AttachmentID = Notice.NoticeAttachment; } else { NewNotice.AttachmentID = UUID.Zero; } NewNotice.Message = Notice.NoticeDescription; NewNotice.OwnerID = BotSession.Instance.grid.Self.AgentID; NewNotice.Subject = Notice.NoticeSummary; BotSession.Instance.grid.Groups.SendGroupNotice(Notice.GroupKey, NewNotice); Notice.LastSent = DateTime.Now + TimeSpan.FromDays(14); NoticeEditQueue.Add(1, Notice); // This will edit the entry break; } } else { GroupNotice NewNotice = new GroupNotice(); if (Notice.HasAttachment) { NewNotice.AttachmentID = Notice.NoticeAttachment; } else { NewNotice.AttachmentID = UUID.Zero; } NewNotice.Message = Notice.NoticeDescription; NewNotice.OwnerID = BotSession.Instance.grid.Self.AgentID; NewNotice.Subject = Notice.NoticeSummary; BotSession.Instance.grid.Groups.SendGroupNotice(Notice.GroupKey, NewNotice); NoticeEditQueue.Add(2, Notice); // Will delete the notice MH(Destinations.DEST_LOCAL, UUID.Zero, "Dispatching single-use notice"); break; } } foreach (KeyValuePair <int, OCBotMemory.Notices> entry in NoticeEditQueue) { if (entry.Key == 1) { bm.NoticeLists[entry.Value.InternalName] = entry.Value; } else if (entry.Key == 2) { bm.NoticeLists.Remove(entry.Value.InternalName); } } bm.Save(); } }
public void Dispatch(UUID client, int level, string[] additionalArgs, Destinations source, UUID agentKey, string agentName) { OCBotMemory ocb = OCBotMemory.Memory; OCBotMemory.MailList ML = ocb.MailingLists[additionalArgs[0]]; List <OCBotMemory.MailListMember> Members = ML.Members; Console.WriteLine("Enter foreach with " + Members.Count.ToString() + " members"); for (int i = 0; i < Members.Count; i++) { OCBotMemory.MailListMember Member = Members[i]; Console.WriteLine("ENTER Blacklist check for " + Member.MemberID.ToString()); if (ocb.BlacklistMailingList.Contains(Member.MemberID)) { // Totally ignore sending a message to this user. } else { string PreparedStatement = ML.PrepMsg; if (Member.Informed) { bool CanSend = true; if (ML.AllowOptOut) { if (Member.OptOut) { CanSend = false; } } if (CanSend) { MHE(Destinations.DEST_AGENT, Member.MemberID, ML.PrepMsg); } } else { bool CanSend = true; if (ML.AllowOptOut) { if (Member.OptOut) { CanSend = false; } } if (CanSend) { MHE(Destinations.DEST_AGENT, Member.MemberID, ML.PrepMsg + "\n \n[I see this is the first time you are receiving a message on this mailing list]\n[If you want to opt out from this mailing list, you can send the command: maillist_opt [list_name]]\n[If you want to opt out from all mailing lists you can send: maillist_off/maillist_on]"); Console.WriteLine("Begin replace"); Member.setInformed(); ML.Members[i] = Member; Console.WriteLine("Replaced maillist entry"); } } } Console.WriteLine("EXIT Blacklist Check for " + Member.MemberID.ToString()); } Console.WriteLine("Foreach complete"); MHE(Destinations.DEST_AGENT, ML.MailListOwner, ML.PrepMsg); ML.PrepFrom = UUID.Zero; ML.PrepMsg = ""; ML.PrepState = 0; ocb.MailingLists[additionalArgs[0]] = ML; ocb.Save(); }