public static async Task StreamOffline(string beamId) { IMixerManager mixerManager = new MixerManager(); var stream = await mixerManager.GetChannelByName(beamId); var live = BotFiles.GetCurrentlyLiveBeamChannels().FirstOrDefault(x => x.Name == beamId); if (live == null) { return; } foreach (var message in live.ChannelMessages) { var serverFile = BotFiles.GetConfiguredServers().FirstOrDefault(x => x.Id == message.GuildId); if (serverFile == null) { continue; } if (serverFile.DeleteWhenOffline) { await DiscordHelper.DeleteMessage(message.GuildId, message.ChannelId, message.MessageId); } else { await DiscordHelper.SetOfflineStream(message.GuildId, serverFile.StreamOfflineMessage, message.ChannelId, message.MessageId); } BotFiles.DeleteLiveBeamChannel(beamId); } }
public async Task Live() { var beam = BotFiles.GetCurrentlyLiveBeamChannels(); var hitbox = BotFiles.GetCurrentlyLiveHitboxChannels(); var twitch = BotFiles.GetCurrentlyLiveTwitchChannels(); var youtube = BotFiles.GetCurrentlyLiveYouTubeChannels(); var picarto = BotFiles.GetCurrentlyLivePicartoChannels(); var guildId = Context.Guild.Id; var beamLive = ""; var hitboxLive = ""; var twitchLive = ""; var youtubeLive = ""; var picartoLive = ""; foreach (var b in beam) { foreach (var cm in b.ChannelMessages) { if (cm.GuildId == guildId) { var channel = await _mixerManager.GetChannelById(b.Name); if (channel != null && channel.online) { beamLive += channel.token + ", "; } break; } } } foreach (var p in picarto) { foreach (var cm in p.ChannelMessages) { if (cm.GuildId == guildId) { var channel = await _mixerManager.GetChannelById(p.Name); if (channel != null && channel.online) { picartoLive += channel.token + ", "; } break; } } } foreach (var h in hitbox) { foreach (var cm in h.ChannelMessages) { if (cm.GuildId == guildId) { hitboxLive += h.Name + ", "; break; } } } foreach (var t in twitch) { foreach (var cm in t.ChannelMessages) { if (cm.GuildId == guildId) { var channel = await _twitchManager.GetStreamById(t.Name); if (channel != null && channel.stream != null) { twitchLive += channel.stream.channel.name + ", "; } break; } } } foreach (var yt in youtube) { foreach (var cm in yt.ChannelMessages) { if (cm.GuildId == guildId) { var channel = await _youtubeManager.GetLiveVideoByChannelId(yt.Name); if (channel != null && channel.items != null && channel.items.Count > 0) { youtubeLive += channel.items[0].snippet.channelTitle + ", "; } break; } } } beamLive = beamLive.Trim().TrimEnd(','); hitboxLive = hitboxLive.Trim().TrimEnd(','); twitchLive = twitchLive.Trim().TrimEnd(','); youtubeLive = youtubeLive.Trim().TrimEnd(','); picartoLive = picartoLive.Trim().TrimEnd(','); string info = "```Markdown\r\n" + "# Currently Live\r\n" + "- Mixer: " + beamLive + "\r\n" + "- Picarto: " + picartoLive + "\r\n" + "- Smashcast: " + hitboxLive + "\r\n" + "- Twitch: " + twitchLive + "\r\n" + "- YouTube Gaming: " + youtubeLive + "\r\n" + "```\r\n"; await Context.Channel.SendMessageAsync(info); }