public List<string> GetLiveList(Channels channel, bool UseLiveAll) { bool foundstream = false; bool foundunapprovedstream = false; List<string> listmessages = new List<string>(); //channel.LastLiveAnnouncement = DateTime.Now; string liveList = ""; foreach (TwitchStuff streamInfo in channel.StreamInfo) { bool meetswhitelist = true; if (streamInfo.streamerlive == "true") { string addToList = config.LiveMessage; if (channel.LiveMessage != "") addToList = channel.LiveMessage; addToList = Utilities.TemplateString(addToList, streamInfo.streamername, streamInfo.game, streamInfo.streamerviewcount, streamInfo.streamname, config.ServerName.ToLower().Contains("twitch.tv")); liveList = addToList.Trim(); meetswhitelist = channel.MeetsWhiteBlackList(streamInfo); if (UseLiveAll) { meetswhitelist = true; } if (meetswhitelist) { foundstream = true; listmessages.Add(liveList); } else { foundunapprovedstream = true; } liveList = ""; } } if (!foundstream) { if (foundunapprovedstream) { listmessages.Add("No one is currently streaming a whitelisted game. Use liveall to see streams."); } else { listmessages.Add("No one is currently streaming."); } } return listmessages; }
public void SendLiveList(Channels channel, string nick, string[] args) { bool foundstream = false; bool foundunapprovedstream = false; int livestreams = 0; bool hasArgs = (args.Length > 0); List<TwitchStuff> filteredStreamInfos = channel.StreamInfo; foreach (TwitchStuff streamInfo in channel.StreamInfo) { if (streamInfo.streamerlive == "true") { if (channel.MeetsWhiteBlackList(streamInfo)) { if (hasArgs) { if(args.Any(s => streamInfo.game.ToLower().Contains(s.ToLower()) || streamInfo.streamname.ToLower().Contains(s.ToLower()))) livestreams++; } else livestreams++; } } } bool announcetochannel = true; if (livestreams >= 4) { announcetochannel = false; } int timecheck = 60; if (!announcetochannel) { timecheck = 5; } if (channel.LastLiveAnnouncement.AddSeconds(timecheck) <= DateTime.Now) { if (announcetochannel) { channel.LastLiveAnnouncement = DateTime.Now; } string liveList = ""; foreach (TwitchStuff streamInfo in channel.StreamInfo) { bool meetswhitelist = false; if (streamInfo.streamerlive == "true") { string addToList = config.LiveMessage; if (channel.LiveMessage != "") addToList = channel.LiveMessage;//if (channel.LiveMessage != "") addToList = Utilities.TemplateString(addToList, streamInfo.streamername, streamInfo.game, streamInfo.streamerviewcount, streamInfo.streamname, config.ServerName.ToLower().Contains("twitch.tv")); liveList = addToList.Trim(); meetswhitelist = channel.MeetsWhiteBlackList(streamInfo); if (args.Length > 0) { // !LIVE SEARCH FUNCTIONALITY if (!args.Any(s => streamInfo.game.ToLower().Contains(s.ToLower()) || streamInfo.streamname.ToLower().Contains(s.ToLower()))) meetswhitelist = false; } if (meetswhitelist) { if (announcetochannel) { if (!streamInfo.setnotice) { foundstream = true; ircConnection.LocalUser.SendMessage(channel.ChannelName, liveList); }//if (!streamInfo.setnotice) else { foundunapprovedstream = true; }//else }//if(announcetochannel) else { foundstream = true; ircConnection.LocalUser.SendNotice(nick, liveList); }//else }//if (meetswhitelist) else { foundunapprovedstream = true; }//else liveList = ""; }//if (streamInfo.streamerlive == "true") }//foreach (TwitchStuff streamInfo in channel.StreamInfo) if (!foundstream) { if (foundunapprovedstream) { ircConnection.LocalUser.SendMessage(channel.ChannelName, "No one is currently cleared to report on !live. Use !liveall to see streams."); } else { ircConnection.LocalUser.SendMessage(channel.ChannelName, "No one is currently streaming."); } } } }