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");
 }
 //Process the given command and return it
 public static Comment Process(Comment c)
 {
     if (CheckBlacklist(c))
     {
         return(new Comment(c.user, ""));    //Return empty comment and do nothing
     }
     if (!CommandIdentifier.CheckCommand(c)) //before everything else is changed, check if it's a command
     {
         c.user = RemoveNumeric(c.user);     //Remove numbers from name for faster reading? Hm... could be bad
         c      = SpamProtection(c);         //Check with the Spam protection before giving it back
         return(c);
     }
     else   //If it is a command, remove the comment to not read it out in the TTS
     {
         c.comment = "";
         return(c);
     }
 }
Esempio n. 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);
            }
        }
 //Channel Point redemption, Check if redemption is connected to code
 private void Pubsub_OnRewardRedeemed(object sender, OnRewardRedeemedArgs e)
 {
     CommandIdentifier.CheckCommand(e);
     //RewardRedeemedDebug(e); //Log everything of a channel point redemption
 }
Esempio n. 5
0
        void PubSubMessageRecived(object sender, MessageReceivedEventArgs e)
        {
            dynamic redemption = Newtonsoft.Json.Linq.JObject.Parse(e.Message);

            CommandIdentifier.CheckCommand(redemption);
        }