コード例 #1
0
ファイル: Form1.cs プロジェクト: moonspeak/lightbot-net-app
        private void HandleOnMessage(string channel, string msg)
        {
            logEvent(string.Format("Received '{0}' from pubsub", msg, channel));

            if (msg.Contains("\"type\":\"cheer\""))
            {
                CheerVO cheer = JsonConvert.DeserializeObject <CheerVO>(msg);
                HandleAction(cheer);
            }
            else if (msg.Contains("\"type\":\"command\""))
            {
                CommandVO commandVO = JsonConvert.DeserializeObject <CommandVO>(msg);
                HandleAction(commandVO);
            }
            else if (msg.Contains("\"type\":\"sub\""))
            {
                SubVO subVO = JsonConvert.DeserializeObject <SubVO>(msg);
                HandleAction(subVO);
            }
            else if (msg.Contains("\"type\":\"raid\""))
            {
                RaidVO raidVO = JsonConvert.DeserializeObject <RaidVO>(msg);
                HandleAction(raidVO);
            }
            else
            {
                // wtf
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: moonspeak/lightbot-net-app
        private void HandleAction(CheerVO cheer)
        {
            logEvent(String.Format("{0} cheered {1} bits!", cheer.nick, cheer.amount));
            if (cheer.amount >= Properties.Settings.Default.largeCheerFloor && Properties.Settings.Default.largeCheer)
            {
                if (Properties.Settings.Default.largeCheerAction.ToLower() == "blink")
                {
                    DoBlink();
                }
                else if (Properties.Settings.Default.largeCheerAction.ToLower() == "loop")
                {
                    DoColorLoop();
                }
            }
            if (cheer.amount >= Properties.Settings.Default.cheerFloor)
            {
                int count = 1;
                foreach (Match match in Regex.Matches(cheer.message, @"#([0-9a-fA-F]{6})"))
                {
                    if (count * Properties.Settings.Default.cheerFloor <= cheer.amount)
                    {
                        if (!string.IsNullOrEmpty(match.Value))
                        {
                            SetHexColor(match.Value);
                        }
                    }
                    Thread.Sleep(3000);
                    count++;
                }
            }



            if (cheer.amount >= Properties.Settings.Default.offFloor && cheer.message.Contains("!off") && Properties.Settings.Default.onOff)
            {
                SetLightsOff();
            }
            else if (cheer.amount >= Properties.Settings.Default.onFloor && cheer.message.Contains("!on") && Properties.Settings.Default.onOff)
            {
                SetLightsOn();
            }
        }