private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
        {
            //SET TOTAL VALUES HERE AS WELL
            //END INTERVAL TIMER, ADD IT TO END

            SetIntervalData();
            SetTotalValues();

            if (streamTrackingStopwatch.IsRunning)
            {
                streamTrackingStopwatch.Stop();
                string temp = streamTrackingStopwatch.Elapsed.ToString();
                ws.Cells[lastIntervalRow + 15, 13] = temp;
            }

            streamTrackingStopwatch.Stop();
            string streamTrackingDuration = streamTrackingStopwatch.Elapsed.ToString();

            ws.Cells[17, 13] = streamTrackingDuration;

            ViewCountTimer(false);
            StreamDataIntervalTimer(false);

            Console.WriteLine("Stream is offline");
        }
Ejemplo n.º 2
0
        private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var botService = scope.ServiceProvider.GetRequiredService <IBotService>();
                botService.SendTwitchNotification(e.Channel, TwitchNotificationType.StreamUp);

                Console.WriteLine($"[{DateTime.Now}] Channel {e.Channel} went offline.");
            }
        }
        private Task LiveStreamMonitorServiceOnOnStreamOffline(object?sender, OnStreamOfflineArgs e)
        {
            Console.WriteLine($"Stream offline: {e.Channel}");
            if (!_botProcessDictionary.ContainsKey(e.Channel))
            {
                return(Task.CompletedTask);
            }

            var pid     = _botProcessDictionary[e.Channel];
            var process = Process.GetProcessById(pid);

            process.Kill();
            process.WaitForExit();

            return(Task.CompletedTask);
        }
Ejemplo n.º 4
0
        private static void OnStreamOffline(object sender, OnStreamOfflineArgs streamOffline)
        {
            //HostingMonitor.StartMonitor();

            IsLive = false;

            DateTime?startedAt = DatabaseManager.ActiveStreams.Delete(SettingsManager.Configuration.TwitchStream.Username);

            _ = Discord.DiscordClient.SetStatus();

            string duration = startedAt.HasValue ? $"They were live for {(DateTime.UtcNow - startedAt.Value).TotalMilliseconds.Milliseconds().Humanize(3)}{Environment.NewLine}" : "";

            _ = Discord.DiscordClient.TwitchChannelChange(SettingsManager.Configuration.TwitchStream.DiscordChannel, SettingsManager.Configuration.TwitchStream.Url, null, $"{SettingsManager.Configuration.TwitchStream.DisplayName} is offline", $"{duration}Thanks for watching!");

            LoggingManager.Log.Info($"{SettingsManager.Configuration.TwitchStream.DisplayName} is offline");
        }
Ejemplo n.º 5
0
        public async void OnStreamOffline(object sender, OnStreamOfflineArgs e)
        {
            var subs = WebCalls.GetRootObject();

            List <string> gameIds = new List <string> {
                e.Stream.GameId
            };
            var games = await TwitchApi.Helix.Games.GetGamesAsync(gameIds);

            var channel = await TwitchApi.V5.Channels.GetChannelByIDAsync("109598326");

            Console.WriteLine(e.Stream.ThumbnailUrl);

            var embed = new DiscordEmbedBuilder
            {
                Author = new DiscordEmbedBuilder.EmbedAuthor
                {
                    Name    = channel.DisplayName,
                    IconUrl = channel.Logo
                },
                Color        = DiscordColor.Purple,
                Title        = e.Channel + " is now offline! :(",
                Url          = "https://www.twitch.tv/phenomalytv",
                ImageUrl     = "https://static-cdn.jtvnw.net/previews-ttv/live_user_phenomalytv-320x180.jpg",
                ThumbnailUrl = channel.Logo,
            };

            embed.AddField("Stream Title: ", e.Stream.Title);
            embed.AddField("Viewers: ", e.Stream.ViewerCount.ToString(), true);
            embed.AddField("Subscriptions: ", (subs.data.Count - 1).ToString(), true);
            embed.AddField("Game: ", games.Games[0].Name, true);
            embed.AddField("Time started [GMT]: ", e.Stream.StartedAt.ToShortTimeString(), true);
            embed.AddField("Followers: ", channel.Followers.ToString(), true);
            embed.AddField("Rated Mature?: ", channel.Mature.ToString(), true);
            embed.AddField("Language: ", e.Stream.Language, true);
            var chan = await TwitchBotMain.discord.GetChannelAsync(552255972060692504);

            await chan.SendMessageAsync(" " + e.Channel + " is now offline :(!");

            await chan.SendMessageAsync("\n", embed : embed);
        }
Ejemplo n.º 6
0
        private void OnStreamOffline(object sender, OnStreamOfflineArgs e)
        {
            try
            {
                _logger.LogInformation("Streamer is offline");

                if (_client.IsConnected && _client.JoinedChannels.Any())
                {
                    _client.SendMessage(e.Channel, $"Looks like @{e.Channel} has gone offline, *yawn* powering down");
                }

                _streamStatusApiClient.SaveStreamStatus(new PutStreamStatusRequest
                {
                    BroadcasterUsername = e.Channel.ToLower(),
                    IsOnline            = false
                }).Wait();

                UnScheduleStreamTasks();
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Error OnStreamOffline");
            }
        }
Ejemplo n.º 7
0
        private async void Monitor_OnStreamOfflineAsync(object sender, OnStreamOfflineArgs e)
        {
            try
            {
                var ee = await API.V5.Channels.GetChannelByIDAsync(e.Channel);

                Console.WriteLine($"{Globals.CurrentTime} Monitor     {ee.DisplayName} is offline");

                if (_liveEmbeds.ContainsKey(e.Channel) && _client.ConnectionState == ConnectionState.Connected)
                {
                    await Task.Delay(250);

                    RestUserMessage embed = _liveEmbeds[e.Channel].Item1;
                    await embed.DeleteAsync();

                    _ = _liveEmbeds.TryRemove(e.Channel, out _);
                    // Console.WriteLine($"{Global.CurrentTime} Monitor     TryParse OutResult: {outResult}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Ejemplo n.º 8
0
 // When the stream is offline, try to remove the cooldown
 public void OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     _tweetHelper.RemoveCooldown(e.Stream.UserName);
 }
 private void OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     IsLive = false;
     ConsoleHelper.WriteLine($"OFFLINE: {e.Channel} has stopped streaming.");
 }
Ejemplo n.º 10
0
 private void onStreamOffLine(object sender, OnStreamOfflineArgs e)
 {
     sendMessage("me retiro cuidense");
     Salir(null);
 }
Ejemplo n.º 11
0
 private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 12
0
        private static void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs args)
        {
            Task.Run(async() =>
            {
                try
                {
                    var links = Links.Values.Where(e => string.Equals(e.Value.Split("|", StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(), args.Channel, StringComparison.CurrentCultureIgnoreCase));
                    foreach (var link in links)
                    {
                        var linkValues         = link.Value.Split("|", StringSplitOptions.RemoveEmptyEntries);
                        var streamName         = linkValues.FirstOrDefault();
                        ulong discordMessageId = 0;
                        if (linkValues.Length > 4)
                        {
                            ulong.TryParse(linkValues[4], out discordMessageId);
                        }

                        Log.Debug($"Twitch | {args?.Stream?.UserName} went offline (Id: {args?.Stream?.Id}).");

                        try
                        {
                            // Update discord message, if it still exists.
                            var discordMessage = (await link.Channel.GetMessageAsync(discordMessageId,
                                                                                     CacheMode.AllowDownload,
                                                                                     new RequestOptions()
                            {
                                RetryMode = RetryMode.AlwaysRetry
                            }
                                                                                     ).ConfigureAwait(false)) as IUserMessage;

                            if (discordMessage != null)
                            {
                                var embed        = discordMessage.Embeds.FirstOrDefault();
                                var embedBuilder = new EmbedBuilder()
                                                   .WithTitle(embed.Title)
                                                   .WithAuthor(embed.Author?.Name, embed.Author?.IconUrl, embed.Author?.Url)
                                                   .WithDescription(embed.Description)
                                                   .WithFooter(embed.Footer?.Text, embed.Footer?.IconUrl)
                                                   .WithUrl(embed.Url)
                                                   .WithThumbnailUrl(embed.Thumbnail?.Url)
                                                   .WithFields(embed.Fields.Select(x =>
                                                                                   new EmbedFieldBuilder()
                                                                                   .WithIsInline(x.Inline)
                                                                                   .WithName(x.Name)
                                                                                   .WithValue(x.Value))
                                                               )
                                                   .WithColor(Color.Red)
                                ;
                                await discordMessage.ModifyAsync(x => x.Embed = embedBuilder.Build(), new RequestOptions()
                                {
                                    RetryMode = RetryMode.AlwaysRetry
                                }).ConfigureAwait(false);
                            }
                        }
                        catch { }

                        // Update link
                        link.Value = $"{streamName}|{long.MinValue}|{DateTime.MinValue.Ticks}|{DateTime.MinValue.Ticks}|{ulong.MinValue}";
                        await Ditto.Database.DoAsync((uow) =>
                        {
                            uow.Links.Update(link);
                        }).ConfigureAwait(false);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error($"Error while updating to offline: {ex}");
                }
            });
        }
Ejemplo n.º 13
0
 private async void OnStreamOffline(object sender, OnStreamOfflineArgs args)
 {
     await this.activityManager.ClearStreamAsync();
 }
Ejemplo n.º 14
0
 private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     Log.Write($"{e.Channel} stream went offline. The stream was live for {DateHelper.TimeDiffFormatted(e.Stream.StartedAt, DateTime.Now)}");
 }
Ejemplo n.º 15
0
 private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
 }
Ejemplo n.º 16
0
 private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     Console.WriteLine($">> Stream {e.Stream.Id} has gone offline");
 }
Ejemplo n.º 17
0
 // TODO: Maybe use TweetHelper to thank people for joining?
 public static void OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     Console.WriteLine("Got offline notification!");
     Console.WriteLine("Channel: " + e.Channel);
 }
Ejemplo n.º 18
0
 private void onStreamOfffline(object sender, OnStreamOfflineArgs e)
 {
     MessageBox.Show($"Stream down! Stream: {e.Channel}");
 }
        private void OnStreamOfflineEvent(object sender, OnStreamOfflineArgs e)
        {
            bool removalBool = StreamsOnline.Remove(e.Stream.UserId);

            Console.Out.WriteLine($"Was able to remove {e.Stream.UserName} from the StreamsOnline List? - {removalBool}");
        }
Ejemplo n.º 20
0
 private void Monitor_OnStreamOffline(object sender, OnStreamOfflineArgs e)
 {
     Console.WriteLine("Stream offline from Api");
 }