Пример #1
0
 public void Shutdown()
 {
     ErrorLogging.WriteLine("Planned shutdown performed ");
     Close();
     ErrorLogging.Close();
 }
Пример #2
0
        public void GetStatus()
        {
            if (JsonGrabber.GrabJson(sUrlTwitchStatus, RequestHeaders, "application/json", "application/vnd.twitchtv.v3+json", "GET", out string res))
            {
                try
                {
                    var response = JObject.Parse(res);
                    if (response["data"] != null && response["data"].Children().Count() > 0)
                    {
                        var dataNode = response["data"].First;
                        if (dataNode["title"] != null)
                        {
                            isOnline = true;
                            var title = dataNode["title"].ToString();
                            TitleHasChanged = OldTitle != title;
                            OldTitle        = title;

                            if (dataNode["type"] != null)
                            {
                                var streamType = dataNode["type"].ToString();
                                if (streamType == "live")
                                {
                                    isOnline = true;
                                }
                                else
                                {
                                    isOnline = false;
                                }
                            }

                            if (dataNode["started_at"] != null)
                            {
                                var dateTimeStartAsstring = dataNode["started_at"].ToString();
                                //"2020-02-25t13:42:32z"
                                if (DateTime.TryParse(dateTimeStartAsstring, out DateTime ParsedTime))
                                {
                                    StartTime = ParsedTime.ToUniversalTime();
                                }
                                else
                                {
                                    StartTime = DateTime.MinValue;
                                }
                            }

                            if (dataNode["game_id"] != null)
                            {
                                var gameIdAsString = dataNode["game_id"].ToString();
                                game = ResolveNameFromId(gameIdAsString);
                                if (game == "ul")
                                {
                                    game = String.Empty;
                                }
                                Console.WriteLine(string.Format("{0} - Checked stream status. Is online, playing {1}", channelName, game));
                            }
                            else
                            {
                                Console.WriteLine(string.Format("{0} - Checked stream status. Is online (no game?)", channelName));
                            }

                            if (dataNode["viewer_count"] != null)
                            {
                                var viewers = dataNode["viewer_count"].ToString();
                                if (uint.TryParse(viewers, out uint Value))
                                {
                                    this.LastViewers = Value;
                                }
                            }
                        }
                        else
                        {
                            isOnline = false;
                            Console.WriteLine(string.Format("{0} - Checked stream status. Is offline.", channelName));
                        }
                    }
                    else
                    {
                        isOnline = false;
                        Console.WriteLine(string.Format("{0} - Checked stream status. Is offline.", channelName));
                    }
                }
                catch (Exception e)
                {
                    ErrorLogging.WriteLine("Error trying to parse Json when doing stream update request: " + e.Message);
                    isOnline = false;
                }
            }
            else
            {
                Console.WriteLine("Error checking Json");
            }
        }
Пример #3
0
 private void IrcClient_OnErrorMessage(object sender, IrcEventArgs e)
 {
     ErrorLogging.WriteLine("Error: !" + e.Data.Message);
     Console.WriteLine("Error: " + e.Data.Message);
 }
Пример #4
0
 private void IrcClient_OnError(object sender, ErrorEventArgs e)
 {
     Console.WriteLine("Error: !" + e.ErrorMessage);
     ErrorLogging.WriteLine("Error: !" + e.ErrorMessage);
 }
Пример #5
0
 private void IrcClient_OnConnecting(object sender, EventArgs e)
 {
     ErrorLogging.WriteLine("Connecting...");
 }
Пример #6
0
 private void IrcClient_OnAutoConnectError(object sender, AutoConnectErrorEventArgs e)
 {
     Console.WriteLine("Auto connect error: " + e.Exception);
     ErrorLogging.WriteLine("Auto connect error: " + e.Exception);
 }
Пример #7
0
 private void IrcClient_OnDisconnected(object sender, EventArgs e)
 {
     ActiveChannels.Clear();
     Console.WriteLine("! Disconnected");
     ErrorLogging.WriteLine("! Disconnected");
 }
Пример #8
0
 private void IrcClient_OnRegistered(object sender, EventArgs e)
 {
     this.OnIrcFeedback?.Invoke(Events.IrcFeedback.Verified, "");
     Console.WriteLine("! LOGIN VERIFIED");
     ErrorLogging.WriteLine("! LOGIN VERIFIED");
 }
Пример #9
0
 private void MeebyIrcClient_OnConnectionError(object sender, EventArgs e)
 {
     Console.WriteLine("!!! CONNECTION ERROR!!! " + e.ToString());
     ErrorLogging.WriteLine("!!! CONNECTION ERROR!!! " + e.ToString());
 }