コード例 #1
0
        public async Task <string> GetAnimatedCheerURL(string prefix, int quantity, bool dark = true)
        {
            if (!hasData)
            {
                TwitchCheermotes cheermotes = await helixHelper.GetCheermotes(botConfig.BroadcasterId);

                foreach (TwitchCheermotes.Datum cheermote in cheermotes.Data)
                {
                    cheerLookup.Add(cheermote.Prefix.ToLower(), cheermote.Tiers);
                }

                hasData = true;
            }

            prefix = prefix.ToLower();

            if (cheerLookup.ContainsKey(prefix))
            {
                List <TwitchCheermotes.Datum.Tier> tierList = cheerLookup[prefix];

                TwitchCheermotes.Datum.Tier lastMatch = null;

                for (int i = 0; i < tierList.Count; i++)
                {
                    if (quantity >= tierList[i].MinBits)
                    {
                        lastMatch = tierList[i];
                    }
                    else
                    {
                        break;
                    }
                }

                if (lastMatch != null)
                {
                    if (dark)
                    {
                        return(lastMatch.Images.Dark.Animated.HugeURL);
                    }
                    else
                    {
                        return(lastMatch.Images.Light.Animated.HugeURL);
                    }
                }
            }

            return(null);
        }