static void ReloadSettings(Command command, Comment c)
 {
     string[] s = c.comment.Split();
     if (s.Length > 1)
     {
         if (s[1].Contains("?"))
         {
             client.SendChatMessage(command.helpComment);
             return;
         }
     }
     FileManager.LoadSettings();
     AudioDeviceManager.LoadSettings();
     CommandIdentifier.LoadSettings();
     CommentProcessor.LoadSettings();
     ExecutionOrderManager.LoadSettings();
     if (pubsub != null)
     {
         pubsub.Disconnect();
         pubsub.LoadSettings();
     }
     SoundboardManager.LoadSettings();
     TTS.LoadSettings();
     client.SendChatMessage("Reloaded all settings");
 }
        public static string GetTTSText(Comment c)
        {
            string ttsText = "";

            if (CheckTTSBlacklist(c))
            {
                return("");                     //Check if user is allowed to be read out
            }
            c = CommentProcessor.CheckAlias(c); // Then replace

            if (!String.IsNullOrWhiteSpace(c.user) && !String.IsNullOrWhiteSpace(c.comment) && _executionOrder != "")
            {
                foreach (char exe in _executionOrder)
                {
                    switch (exe)
                    {
                    case 'u':
                        ttsText += " " + c.user;
                        break;

                    case 'c':
                        ttsText += " " + c.comment;
                        break;

                    case 'b':
                        ttsText += " " + FileManager.GetRandomBridgeWord();
                        break;

                    case 'n':
                        NotificationSoundManager.Play();
                        break;

                    default:
                        Console.WriteLine("Wrong execution order letter detected. Current execution order: " + _executionOrder);
                        break;
                    }
                }
                if (ttsText.IndexOf(" ") == 0)
                {
                    ttsText = ttsText.Substring(1, ttsText.Length - 1);
                }
                return(ttsText);
            }
            else
            {
                return("");
            }
        }
        void Init()
        {
            //fm = new FileManager(); //Init FileManager to get all infos feed into the programm

            Console.OutputEncoding = System.Text.Encoding.UTF8; //Changes the Console Encoding to UTF8 (Might be usefull, might be not)
            FileManager.LoadSettings();                         //Setup File Manager

            client = new IrcClient(FileManager.GetIrcClient(), FileManager.GetPort(), FileManager.GetBotName(), FileManager.GetOAuth(), FileManager.GetChannelName().ToLower());
            pinger = new Pinger(client); //Create a Pinger that pings the server every 5 minutes to prevent this connection getting closed
            tjb    = new TwitchJsonBuilder(new string[] { "channel-points-channel-v1." + FileManager.GetChannelID() }, FileManager.GetAppAuth());
            pubSub = new PubSubService(tjb, client);

            //Load all Settings in (These functions can also be used to reload settings)
            AudioDeviceManager.LoadSettings();
            NotificationSoundManager.LoadSettings();
            TTS.LoadSettings();
            SoundboardManager.LoadSettings(client);
            CommandIdentifier.LoadSettings(client, pubSub);
            CommentProcessor.LoadSettings();
            ExecutionOrderManager.LoadSettings();

            //Check the needed settings to create a connection, exit if something is wrong
            if (FileManager.GetIrcClient() == null || FileManager.GetPort() == 0 || FileManager.GetBotName() == null || FileManager.GetOAuth() == null || FileManager.GetChannelName() == null)
            {
                Console.WriteLine("An error occured while checking your Settings, please check your Settings.txt");
                Console.WriteLine("Press any key to continue");
                Console.ReadKey();
                Application.Exit();
                return;
            }

            pinger.Start();                                                          //Start the Pinger
            Console.WriteLine(FileManager.GetBotName() + " is ready!");
            while (true)                                                             //Loop throu this, react when something in the chat happend
            {
                var     rawMsg = client.ReadMessage();                               //The whole Message from the IRC Server
                Comment c      = new Comment(rawMsg);                                //Create a new Comment out of it. Cut out the Username ans the Message
                c = CommentProcessor.Process(c);                                     //Edit the given User Comment
                string executionOrder = FileManager.GetNotificationExecutionOrder(); //Check if to read it out and how
                string ttsText        = ExecutionOrderManager.GetTTSText(c);         //The text how it should be converted to speech


                if (ttsText == "" && !String.IsNullOrWhiteSpace(c.user) && !String.IsNullOrWhiteSpace(c.comment))
                {
                    Console.WriteLine(c.user + ": " + c.comment);                                                                                               //If comment is empty, write normal comment in console
                }
                else if (ttsText != "" && !String.IsNullOrWhiteSpace(c.user) && !String.IsNullOrWhiteSpace(c.comment))
                {
                    Console.WriteLine(ttsText);
                    TTS.Speak(ttsText);
                }

                //If the Comment is not empty or just spaces execute a notification
                //if (!String.IsNullOrWhiteSpace(c.user) && !String.IsNullOrWhiteSpace(c.comment) && !cp.CheckBlacklist(c) && executionOrder != "")
                //{
                //    //foreach (char exe in executionOrder)
                //    //{
                //    //    if (exe.ToString() == "u") //Username
                //    //    {
                //    //        ttsText += " " + c.user;
                //    //    }
                //    //    if (exe.ToString() == "c") //Commant
                //    //    {
                //    //        ttsText += " " + c.comment;
                //    //    }
                //    //    if (exe.ToString() == "b") //Bridgeword
                //    //    {
                //    //        ttsText += " " + fm.GetRandomBridgeWord();
                //    //    }
                //    //    if (exe.ToString() == "n") //Notification Sound
                //    //    {
                //    //        nsm.Play();
                //    //        //Play Random Notification Sound
                //    //    }
                //    //}
                //    //Cut out the first space if there is one (there should be allways one)
                //    if (ttsText.IndexOf(" ") == 0) ttsText = ttsText.Substring(1, ttsText.Length - 1);
                //    if (ttsText == "") //If string is empty, at least write the normal commant in the console
                //    {
                //        Console.WriteLine(c.user + ": " + c.comment);
                //    }
                //    else
                //    {
                //        Console.WriteLine(ttsText);
                //        tts.Speak(ttsText);
                //    }
                //}
                //else if(c.user != "" && c.comment != "") Console.WriteLine(c.user + ": " + c.comment);
            }
        }