private List <Streamers> streamer_processing(string data) { try { List <Streamers> ls = new List <Streamers>(); XmlDocument doc = new XmlDocument(); doc.LoadXml(data); foreach (XmlElement xitem in doc.DocumentElement.SelectNodes("//item")) { Streamers stream = new Streamers(); XmlDocument mdoc = new XmlDocument(); mdoc.LoadXml("<root>" + xitem.GetXml() + "</root>"); foreach (XmlElement link in mdoc.DocumentElement.SelectNodes("//id")) { stream.id = link.InnerText; } foreach (XmlElement link in mdoc.DocumentElement.SelectNodes("//name")) { stream.name = link.InnerText; } ls.Add(stream); } return(ls); } catch (Exception) { throw new System.InvalidOperationException("Error to load streamers"); } }
static DB() { ActiveEvents = new ActiveEvents(); ActiveGiveaways = new ActiveGiveaways(); BackgroundInventory = new BackgroundInventory(); Cooldowns = new Cooldowns(); Events = new Database.Events(); EventLogs = new EventLogs(); EventSchedule = new EventSchedule(); GiveawayLogs = new GiveawayLogs(); Giveaways = new Giveaways(); Inventory = new Inventory(); LeagueData = new LeagueData(); Mappings = new Mappings(); ModerationLogs = new ModerationLogs(); PendingUsers = new PendingUsers(); ProfileBackgrounds = new ProfileBackgrounds(); Rewards = new Rewards(); RoleInventory = new RoleInventory(); Roles = new Roles(); Settings = new Settings(); Statistics = new Statistics(); Streamers = new Streamers(); SystemTimers = new SystemTimers(); TempRoles = new TempRoles(); Toxicity = new Toxicity(); Users = new Users(); }
public void AddNewStreamer(StreamerData streamer) { if (!CheckNotifyLimit()) { streamer.UseNotify = false; } Streamers.Add(streamer); }
public void SaveStreamer(StreamerData streamer) { if (!Streamers.Contains(streamer)) { throw new Exception("Tried to save streamer data that not managed in detector!"); } var path = Path.Combine(PlatformUtils.Instance.GetConfigBasePath(), "Streamers"); PlatformUtils.Instance.EnsureDirectory(path); path = Path.Combine(path, streamer.Id + ".json"); PlatformUtils.Instance.WriteAllBytes(path, streamer.SaveToBytes()); }
public void RemoveStreamerById(string id) { Streamers.RemoveAll(t => { return(t.Id == id); }); try { PlatformUtils.Instance.DeleteFile(Path.Combine(PlatformUtils.Instance.GetConfigBasePath(), "Streamers", id + ".json")); } catch { } }
public void LoadStreamers() { Streamers.Clear(); try { var basePath = Path.Combine(PlatformUtils.Instance.GetConfigBasePath(), "Streamers"); foreach (var path in PlatformUtils.Instance.GetFiles(basePath)) { Streamers.Add(StreamerData.LoadFromBytes(PlatformUtils.Instance.ReadAllBytes(Path.Combine(basePath, path)))); } } catch { } }
public int GetUseNotifyTotal() { return(Streamers.FindAll(t => t.UseNotify).Count); }
public bool CheckNotifyLimit() { return(Streamers.FindAll(t => t.UseNotify).Count < 100); }