示例#1
0
 public void controlLED(string ledIP, string ledPort, string ledR, string ledG, string ledB, string ledH, string led_context)
 {
     LED.ip   = ledIP;
     LED.port = ledPort;
     LED.R    = ledR;
     LED.G    = ledG;
     LED.B    = ledB;
     LED.H    = ledH;
     LED.led  = led_context;
     try
     {
         led = new LED(LED.ip, LED.port);
         Thread ControlLEDThread = new Thread(led.sendSettings);
         ControlLEDThread.Start();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
示例#2
0
        public void PatternCheck(string pattern)
        {
            //writetologfile(ircPatterns.chatmessage);
            if (pattern != null)
            {
                if (pattern == ircPatterns.ping)            //ping reply to twitch (every 5 minutes)
                {
                    sendIrcMessage(ircPatterns.pong);
                    return;
                }

                if (pattern.Contains(ircPatterns.chatmessage + channel))        //chatmessages
                {
                    twitchuser userfocus    = AddUser(pattern);
                    string     messagefocus = capIRCString(pattern);

                    if (messagefocus[0].ToString() == ircPatterns.trigger)
                    {
                        twitchcommand commandfocus;
                        messagefocus = messagefocus.Substring(1);
                        string[] messagearguments = messagefocus.Split(' ');

                        if (commanddic.ContainsKey(messagearguments[0]))
                        {
                            commanddic.TryGetValue(messagearguments[0], out commandfocus);

                            if (messagearguments[0] == ircPatterns.led || messagearguments[0] == ircPatterns.onair)
                            {
                                bool newsettings = false;
                                if (messagearguments.Length > 1)
                                {
                                    if (messagearguments.Length > 3)
                                    {
                                        LED.R       = messagearguments[1];
                                        LED.G       = messagearguments[2];
                                        LED.B       = messagearguments[3];
                                        newsettings = true;
                                        LED.led     = "null";
                                    }

                                    if (messagearguments[0] == ircPatterns.led)
                                    {
                                        LED.H  = "255";
                                        LED.ip = "10.0.0.136";
                                    }

                                    if (messagearguments[0] == ircPatterns.onair)
                                    {
                                        LED.H  = "100";
                                        LED.ip = "10.0.0.137";
                                    }

                                    LED led = new LED(LED.ip, LED.port);

                                    switch (messagearguments[1])
                                    {
                                    case ircPatterns.led_red:
                                        LED.R       = "255";
                                        LED.G       = "0";
                                        LED.B       = "0";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_green:
                                        LED.R       = "0";
                                        LED.G       = "255";
                                        LED.B       = "0";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_blue:
                                        LED.R       = "0";
                                        LED.G       = "0";
                                        LED.B       = "255";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_white:
                                        LED.R       = "255";
                                        LED.G       = "255";
                                        LED.B       = "255";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_pink:
                                        LED.R       = "255";
                                        LED.G       = "20";
                                        LED.B       = "147";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_orange:
                                        LED.R       = "255";
                                        LED.G       = "140";
                                        LED.B       = "0";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_yellow:
                                        LED.R       = "255";
                                        LED.G       = "255";
                                        LED.B       = "0";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_cyan:
                                        LED.R       = "0";
                                        LED.G       = "255";
                                        LED.B       = "255";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;

                                    case ircPatterns.led_purple:
                                        LED.R       = "102";
                                        LED.G       = "51";
                                        LED.B       = "153";
                                        LED.led     = "null";
                                        newsettings = true;
                                        break;
                                    }

                                    if (newsettings)
                                    {
                                        led.sendSettings();
                                    }
                                }

                                return;
                            }

                            if (messagearguments[0] == ircPatterns.hello)
                            {
                                sendChatMessage("*waves*");
                                //sendIrcMessage("GET / channel");
                                return;
                            }

                            if (messagearguments[0] == ircPatterns.xsay)
                            {
                                string message = "";

                                //for(int i = 1; i < messagearguments.Length; i++)
                                //{
                                //    message += messagearguments[i] + " ";
                                //}
                                foreach (string splinter in messagearguments)
                                {
                                    message += splinter + " ";
                                }

                                message = message.TrimEnd(' ');

                                string[] tags = (pattern.Substring(0, pattern.IndexOf(ircPatterns.chatmessage))).Split(';');
                                string   name = "";
                                foreach (string tag in tags
                                         ) //get name of command writer
                                {
                                    string prop = tag.Split('=')[0];
                                    switch (prop)
                                    {
                                    case "display-name":
                                    {
                                        if (tag.Split('=').Length > 1)
                                        {
                                            name = tag.Split('=')[1];
                                        }

                                        continue;
                                    }
                                    }
                                }

                                message = message.Remove(40);
                                message = name + " " + message;

                                xcomMessage(message, name);
                                Debug.WriteLine(message);
                            }
                        }
                    }
                }
            }

            /*
             * if (pattern.Contains("!hello"))
             * {
             *  sendChatMessage("*waves*");
             * }
             *
             *
             *
             * ADD CHAT PATTERN CHECKS
             *
             *
             */
        }