Esempio n. 1
0
        private static async Task SetRGBColor(string rawSTR, string user)
        {
            try
            {
                if (!device.IsConnected)
                {
                    return;
                }

                //trabalhar a string para remover dados
                string[] rgb = rawSTR.Split("rgb")[1].Replace("(", "").Replace(")", "").Split(",");
                int      r   = int.Parse(rgb[0]);
                int      g   = int.Parse(rgb[1]);
                int      b   = int.Parse(rgb[2]);

                if (r > 255 || r < 0 || g > 255 || g < 0 || b > 255 || b < 0 || (r == 0 && g == 0 && b == 0))
                {
                    throw new Exception("Parametro(s) inválido(s)");
                }

                await device.SetRGBColor(r, g, b);
            }
            catch (Exception ex)
            {
                await IrcEngine.CommandCorrector(rawSTR, "!Light", user, true);
            }
        }
Esempio n. 2
0
        public static async Task Xandao(string txt, string user)
        {
            try
            {
                //sem await para não ter q parar as luzes e depois falar o texto
                Light.StartLightFlow();

                Sounds.Xandao();

                await Light.StopLightFlow();
            }
            catch (Exception ex)
            {
                await IrcEngine.CommandCorrector(txt, "!AudioVisual", user, true);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Execute all the services
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            Logger.Info("starting irc");

            if (Config.GetBoolValue(Globals.YokXmlUseirc))
            {
                if (!IrcEngine.GetInstance().Start())
                {
                    Logger.Error("Irc start failed");
                }
            }
            else
            {
                if (!IrcEngine.GetInstance().Stop())
                {
                    Logger.Error("Irc stop failed");
                }

                Logger.Info("IRC DISABLED");
            }

            Logger.Info("starting email");

            if (Config.GetBoolValue(Globals.YokXmlUseemail))
            {
                if (ScheduleEngine.Check())
                {
                    if (!EmailEngine.Send())
                    {
                        Logger.Error("Email send failed");
                    }
                }
                else
                {
                    Logger.Info("Data not ready to send");
                }
            }
            else
            {
                Logger.Info("EMAIL DISABLED");
            }
        }
Esempio n. 4
0
        public static async Task Command(string cmd, string user)
        {
            bool founded = false;

            cmd = cmd.Trim().Replace("\r\n", "");
            if (cmd.StartsWith("rgb"))
            {
                await SetRGBColor(cmd, user);

                founded = true;
            }


            switch (cmd)
            {
            case "blue":
                await SetRGBColor("rgb(0,0,255)", user);

                founded = true;
                break;

            case "red":
                await SetRGBColor("rgb(255,0,0)", user);

                founded = true;
                break;

            case "green":
                await SetRGBColor("rgb(0,255,0)", user);

                founded = true;
                break;

            case "yellow":
                await SetRGBColor("rgb(255,255,0)", user);

                founded = true;
                break;

            case "white":
                await SetRGBColor("rgb(255,255,255)", user);

                founded = true;
                break;

            case "pink":
                await SetRGBColor("rgb(255,0,155)", user);

                founded = true;
                break;

            case "orange":
                await SetRGBColor("rgb(255,155,0)", user);

                founded = true;
                break;

            case "purple":
                await SetRGBColor("rgb(127,0,255)", user);

                founded = true;
                break;

            case "random":
                await Random(user);

                founded = true;
                break;
            }

            //não encontrou nenhum comando
            if (!founded)
            {
                await IrcEngine.CommandCorrector(cmd, "!Light", user, true);
            }
        }