コード例 #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(SubVO subVO)
        {
            logEvent(String.Format("{0} just subscribed at tier {1}", subVO.nick, subVO.tier));

            SubTiers subTier = SubTiers.Unassigned;

            switch (subVO.tier.ToLower())
            {
            case "prime":
                subTier = SubTiers.Prime;
                break;

            case "1000":
                subTier = SubTiers.Tier1;
                break;

            case "2000":
                subTier = SubTiers.Tier2;
                break;

            case "3000":
                subTier = SubTiers.Tier3;
                break;
            }

            if (subVO.gift)
            {
                if (Properties.Settings.Default.giftSubs)
                {
                    HandleGiftSubAction(subTier);
                }
            }
            else
            {
                bool doColors = HandleSubAction(subTier);
                if (doColors)
                {
                    foreach (Match match in Regex.Matches(subVO.message, @"#([0-9a-fA-F]{6})"))
                    {
                        if (!string.IsNullOrEmpty(match.Value))
                        {
                            SetHexColor(match.Value);
                        }
                    }
                }
            }
        }