public static async Task <Stream> TryGetStreamAsync(this ArisaTwitchClient arisaTwitchClient) { GetStreamsResponse streamsResponse = await arisaTwitchClient.StreamsApi.GetStreamsAsync(first : 1, userIds : arisaTwitchClient.ChannelUser.Id.AsList()); if (streamsResponse.Streams.Length == 1) { return(streamsResponse.Streams[0]); } #if DEBUG return(JsonConvert.DeserializeObject <Stream>(@" { ""id"": ""321321321"", ""user_id"": ""123123123"", ""user_name"": ""MOCKUSER"", ""game_id"": ""12345"", ""type"": ""live"", ""title"": ""MOCK TITLE"", ""viewer_count"": 9001, ""started_at"": ""2019-03-22T16:00:00Z"", ""language"": ""en"" } ")); #else return(null); #endif }
public static async Task <TimeSpan?> TryGetStreamUptimeAsync(this ArisaTwitchClient arisaTwitchClient) { Stream stream = await TryGetStreamAsync(arisaTwitchClient); if (stream == null) { return(null); } return(DateTime.UtcNow.Subtract(stream.StartedAt)); }
static async Task Main() { if (!File.Exists("bot.db")) { File.Copy("../../../bot.db", "bot.db"); } ArisaBot = new ArisaTwitchClient(); await ArisaBot.InitializeAsync(); await Task.Delay(Timeout.Infinite); }