public bool add(ref string listname, ref string key, ListFlags flags = ListFlags.Unchanged) { try { StringListManager list = OpenList(listname); list.Add(key); if (!(flags.HasFlag(ListFlags.InMemory) | flags.HasFlag(ListFlags.ReadOnly))) { list.Writefile(listname); } return(true); } catch (Exception ex) { Plugin.Log(ex.ToString()); } return(false); }
public bool remove(ref string listname, ref string key, ListFlags flags = ListFlags.Unchanged) { try { StringListManager list = OpenList(listname); list.Removeentry(key); if (!(flags.HasFlag(ListFlags.InMemory) | flags.HasFlag(ListFlags.ReadOnly))) { list.Writefile(listname); } return(false); } catch (Exception ex) { Plugin.Log(ex.ToString()); } // Going to try this form, to reduce code verbosity. return(false); }
public StringListManager ClearOldList(string request, TimeSpan delta, ListFlags flags = ListFlags.Unchanged) { string listfilename = Path.Combine(Plugin.DataPath, request); TimeSpan UpdatedAge = GetFileAgeDifference(listfilename); StringListManager list = OpenList(request, flags); if (File.Exists(listfilename) && UpdatedAge > delta) // BUG: There's probably a better way to handle this { //RequestBot.Instance.QueueChatMessage($"Clearing old session {request}"); list.Clear(); if (!(flags.HasFlag(ListFlags.InMemory) | flags.HasFlag(ListFlags.ReadOnly))) { list.Writefile(request); } } return(list); }