Пример #1
0
        /// <summary>
        /// Disconnects the bot from the Twitch account, clean OnlineUsers list and closes TCP connection
        /// </summary>
        public void Disconnect()
        {
            if (!IsBotRunning)
            {
                return;
            }

            try
            {
                if (_botDataManager.BotSettings.FarewellOnBotLeaving)
                {
                    SendChatMessage(_botDataManager.BotDictionary.GoodbyeMessage);
                }

                _usersManager.SaveData();
                reader.Close();
                writer.Close();
                tcpClient.Close();
                _usersManager.ClearOnlineUsers();
            }
            catch (Exception ex)
            {
                _logger.LogError("Error occurred during bot disconnection.\n{ex}", ex);
            }
        }