//Rotates to next ONLINE host in multihost list private bool nextHost() { if (TwitchLib.TwitchApi.BroadcasterOnline("burkeblack").Result) { Common.ChatClient.SendMessage("[Multihost] Burke detected as being online. Multihost stopped."); rotator.Stop(); return(false); } Host nextHost; refreshHostsList(); List <Host> onlineHosts = WebCalls.getOnlineMultihostStreamers(hosts).Result; if (onlineHosts.Count != 0) { if (currentHost != null && TwitchLib.TwitchApi.BroadcasterOnline(currentHost.Streamer).Result) { int multiIndex = 0; int currentHostIndex = 0; foreach (Host host in onlineHosts) { if (currentHost.Streamer == host.Streamer) { currentHostIndex = multiIndex; } multiIndex++; } if (currentHostIndex == onlineHosts.Count - 1) { nextHost = onlineHosts[0]; } else { nextHost = onlineHosts[currentHostIndex + 1]; } } else { nextHost = onlineHosts[new Random().Next(0, onlineHosts.Count - 1)]; } if (nextHost.Information != "") { Common.ChatClient.SendMessage(string.Format("Next host: {0}. {1}", nextHost.Streamer, nextHost.Information), Common.DryRun); } else { Common.ChatClient.SendMessage(string.Format("Next host: {0}.", nextHost.Streamer), Common.DryRun); } Common.ChatClient.SendMessage(string.Format("Use !extend to extend the host by {0} minutes. Use !remaining to see how many minutes remain in the host!", extendDuration), Common.DryRun); curMinute = 0; hostStreamer(nextHost); return(true); } else { Common.ChatClient.SendMessage("There are no multihost channels online at the moment. Will try again on next rotation.", Common.DryRun); curMinute = 0; return(false); } }
// Function that is run on first host, returns true if successful, false if failed private bool firstHost() { switch (startType) { case StartType.RANDOM: Common.ChatClient.SendMessage("Multihost started. Discovering a random online multihost streamer...", Common.DryRun); List <Host> onlineHosts = WebCalls.getOnlineMultihostStreamers(hosts).Result; if (onlineHosts.Count != 0) { currentHost = onlineHosts[new Random().Next(0, onlineHosts.Count - 1)]; if (currentHost.Information != "") { Common.ChatClient.SendMessage(string.Format("We'll kick things off with '{0}'. {1}", currentHost.Streamer, currentHost.Information), Common.DryRun); } else { Common.ChatClient.SendMessage(string.Format("We'll kick things off with '{0}'.", currentHost.Streamer), Common.DryRun); } Common.ChatClient.SendMessage(multihostInfo); } else { Common.ChatClient.SendMessage("No online hosts detected. Multihost random function failed.", Common.DryRun); return(false); } break; case StartType.SET_HOST: foreach (Host streamer in hosts) { if (streamer.Streamer.ToLower() == setHostName.ToLower()) { currentHost = streamer; if (streamer.Information != "") { Common.ChatClient.SendMessage(string.Format("Multihost started with '{0}'. {1}", streamer.Streamer, streamer.Information), Common.DryRun); } else { Common.ChatClient.SendMessage(string.Format("Multihost started with '{0}'.", streamer.Streamer), Common.DryRun); } currentHost = streamer; hostStreamer(streamer); return(true); } } Host newHost = new Host(setHostName, ""); hosts.Add(newHost); currentHost = newHost; Common.ChatClient.SendMessage(string.Format("Multihost started with '{0}'.", newHost.Streamer), Common.DryRun); hostStreamer(newHost); Common.ChatClient.SendMessage(multihostInfo); break; case StartType.MANUAL: Common.ChatClient.SendMessage(string.Format("Multihost started, remaining on the current host! Use !extend to extend the host by {0} minutes. Use !remaining to see how many minutes remain in the host!", extendDuration), Common.DryRun); break; } return(true); }
// Public function to guess next hosted streamer, returns true if successful, false if failed public bool guess() { if (currentHost == null) { Common.ChatClient.SendMessage("Cannot guess the host of a manually assigned host, or a host that does not exist in the multihost list."); return(false); } if (TwitchLib.TwitchApi.BroadcasterOnline(currentHost.Streamer).Result) { refreshHostsList(); List <Host> onlineHosts = WebCalls.getOnlineMultihostStreamers(hosts).Result; int curIndex = 0; foreach (Host host in onlineHosts) { if (currentHost.Streamer.ToLower() == host.Streamer.ToLower()) { if (curIndex == onlineHosts.Count - 1) { if (onlineHosts[0].Information != "") { Common.ChatClient.SendMessage(string.Format("The next host will be {0}. {1}", onlineHosts[0].Streamer, onlineHosts[1].Information), Common.DryRun); } else { Common.ChatClient.SendMessage(string.Format("The next host will be {0}.", onlineHosts[0].Streamer), Common.DryRun); } } else { if (onlineHosts[curIndex + 1].Information != "") { Common.ChatClient.SendMessage(string.Format("The next host will be {0}. {1}", onlineHosts[curIndex + 1].Streamer, onlineHosts[curIndex + 1].Information), Common.DryRun); } else { Common.ChatClient.SendMessage(string.Format("The next host will be {0}.", onlineHosts[curIndex + 1].Streamer), Common.DryRun); } } return(true); } curIndex++; } Common.ChatClient.SendMessage("Current online host was not found in multihost list. Next host will be random online multihost streamer.", Common.DryRun); return(false); } else { Common.ChatClient.SendMessage("The current host is not online. The next host will be a random online multihost streamer.", Common.DryRun); return(false); } }