Exemple #1
0
        /// <summary>
        /// Stops the bot. Disconnects bot from his Twitch account and discarding TCP connection
        /// </summary>
        public void Stop()
        {
            if (!IsConnectionAlive)
            {
                _logger.LogWarning("Can't stop the bot! Bot is not running.");
                return;
            }

            this.readingTimer.Change(Timeout.Infinite, 200);
            Disconnect();

            // Shutdown points timer
            if (_pointsManager.IsTimerRunning)
            {
                _pointsManager.StopPointsTimer();
            }

            // Shutdown experience timer
            if (_experienceManager.TimerRunning)
            {
                _experienceManager.StopExperienceTimer();
            }

            IsBotRunning = false;
            this.uptime.Stop();
            this.uptimeTimer.Change(Timeout.Infinite, 0);
            _logger.LogInformation("Bot has been stopped.");
        }