public void modify_existing_notice(UUID client, int level, string[] additionalArgs,
                                           Destinations source,
                                           UUID agentKey, string agentName)
        {
            // This command will modify an existing notice
            if (OCBotMemory.Memory.NoticeLists.ContainsKey(additionalArgs[0]))
            {
                OCBotMemory.Notices existingNotice = OCBotMemory.Memory.NoticeLists[additionalArgs[0]];
                MHE(source, client, $"OK!\n \nHere is the information currently set\nDescription: {existingNotice.NoticeSummary}\nBody: {existingNotice.NoticeDescription}\nGroup Key: {existingNotice.GroupKey.ToString()}\nHas Attachment? [{existingNotice.HasAttachment.ToString()}]\nAttachment UUID: {existingNotice.NoticeAttachment.ToString()}\nRepeats: [{existingNotice.Repeats.ToString()}]");
                OCBotMemory.NoticeCreationSessions newSess = new OCBotMemory.NoticeCreationSessions();
                newSess.State           = 0;
                newSess.TemporaryNotice = existingNotice;
                newSess.SessionAv       = agentKey;

                MHE(source, client, "You will be asked for the various different properties. To skip over something say: skip");



                if (OCBotMemory.Memory.NoticeSessions.ContainsKey(agentKey))
                {
                    MHE(source, client, "You appear to have already had a notice creator session running. Restarting");
                    OCBotMemory.Memory.NoticeSessions.Remove(agentKey);
                }
                OCBotMemory.Memory.NoticeSessions.Add(agentKey, newSess);
                MHE(source, client, "Please submit a summary of the notice");
            }
            else
            {
                MHE(source, client, "There is no such notice with that ID");
            }
        }
        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();
            }
        }