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");
 }
 static void SBReload(Command command, Comment c)
 {
     string[] s = c.comment.Split();
     if (s.Length > 1)
     {
         if (s[1].Contains("?"))
         {
             client.SendChatMessage(command.helpComment);
             return;
         }
     }
     FileManager.LoadSoundfiles();
     SoundboardManager.LoadSettings();
     client.SendChatMessage("Soundboard reloaded");
 }
Example #3
0
        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);
            }
        }
        //Trigger with Channel Points
        public static bool CheckCommand(dynamic redemption)
        {
            string rType = redemption.type;

            switch (rType)
            {
            case "MESSAGE":
                break;

            default:
                Console.WriteLine("<" + redemption.type + ">");
                return(false);
            }

            string  redemption2 = redemption.data.message;
            dynamic redeption3  = Newtonsoft.Json.Linq.JObject.Parse(redemption2);
            string  rTitle      = redeption3.data.redemption.reward.title;

            //Play Random
            if (rTitle.ToLower() == FileManager.GetCPPlayRandom().ToLower())
            {
                SoundboardManager.PlayRandom();
                return(true);
            }
            //Play Name or Random
            else if (rTitle.ToLower() == FileManager.GetCPPlayName().ToLower())
            {
                string rMessage = redeption3.data.redemption.user_input;
                SoundboardManager.PlayName(rMessage);
                return(true);
            }
            //Play ID or Random
            else if (rTitle.ToLower() == FileManager.GetCPPlayID().ToLower())
            {
                string rMessage = redeption3.data.redemption.user_input;
                SoundboardManager.PlayID(rMessage);
                return(true);
            }
            //Play Folder or Random
            else if (rTitle.ToLower() == FileManager.GetCPPlayFolder().ToLower())
            {
                string rMessage = redeption3.data.redemption.user_input;
                SoundboardManager.PlayFolder(rMessage);
                return(true);
            }
            else if (rTitle.ToLower() == FileManager.GetCPToggleTTS().ToLower())
            {
                if (TTS.useTTS)
                {
                    TTS.useTTS = false;
                    client.SendChatMessage("Disabled TTS");
                }
                else
                {
                    TTS.useTTS = true;
                    client.SendChatMessage("Enabled TTS");
                }
                return(true);
            }
            else if (rTitle.ToLower() == FileManager.GetCPTTSRead().ToLower())
            {
                string rMessage = redeption3.data.redemption.user_input;
                if (TTS.useTTS)
                {
                    TTS.Speak(rMessage);
                }
                else
                {
                    TTS.useTTS = true;
                    TTS.Speak(rMessage);
                    TTS.useTTS = false;
                }
                return(true);
            }
            return(false);
        }
 static void Play(Command command, Comment c)
 {
     SoundboardManager.PlaySoundeffect(c, command);
 }