예제 #1
0
        public Cheer GetCheer(string word)
        {
            var match = Regex.Match(word, @"([A-Za-z]+)(\d+)");

            if (!match.Success)
            {
                return(default(Cheer));
            }

            var name = match.Groups[1].Value.ToLower();

            if (!cheer_dictionary.ContainsKey(name))
            {
                return(default(Cheer));
            }

            var cheer_tiers = cheer_dictionary[name];
            var amount      = int.Parse(match.Groups[2].Value);

            var max_cheer = 0;

            foreach (var key in cheer_tiers.Keys)
            {
                if (amount >= key)
                {
                    max_cheer = Math.Max(max_cheer, key);
                }
            }

            var cache_name = name + '-' + max_cheer;
            var cheer      = cheer_tiers[max_cheer];

            if (image_cache.ContainsKey(cache_name))
            {
                return(new Cheer()
                {
                    Emote = image_cache[cache_name],
                    Color = cheer.Color,
                    Amount = amount,
                });
            }

            var local_path = BaseDir + cache_name + ".gif";

            var img = TwitchDownloader.GetImage(local_path, cheer.Images.DarkMode.Animated[1]);

            image_cache.Add(cache_name, img);

            return(new Cheer()
            {
                Emote = img,
                Color = cheer.Color,
                Amount = amount,
            });
        }
예제 #2
0
        public static Image GetEmote(string name)
        {
            if (name == null)
            {
                return(null);
            }

            if (image_cache.ContainsKey(name))
            {
                return(image_cache[name]);
            }

            var emote_path = BaseDir + name + ".png";
            var url        = string.Format(EmoteDownload, name, EmoteSize);
            var img        = TwitchDownloader.GetImage(emote_path, url);

            image_cache.Add(name, img);

            return(img);
        }
예제 #3
0
        public Image GetEmote(string name)
        {
            if (!emote_dictionary.ContainsKey(name))
            {
                return(null);
            }

            if (image_cache.ContainsKey(name))
            {
                return(image_cache[name]);
            }

            var emote      = emote_dictionary[name];
            var local_path = BaseDir + emote.ID + "." + emote.ImageType;
            var url        = string.Format(EmoteDownload, emote.ID, EmoteSize);
            var img        = TwitchDownloader.GetImage(local_path, url);

            image_cache.Add(name, img);

            return(img);
        }
예제 #4
0
        public Image Lookup(String type, String version)
        {
            var concat = id + "/" + type + "-" + version;

            if (image_cache.ContainsKey(concat))
            {
                return(image_cache[concat]);
            }

            var badge = lookup.ContainsKey(type) && lookup[type].ContainsKey(version) ? lookup[type][version] : default(TwitchBadge);

            if (badge.Name == string.Empty)
            {
                return(null);
            }

            var local_path = BaseDir + concat;
            var img        = TwitchDownloader.GetImage(local_path, badge.URL);

            image_cache[concat] = img;

            return(img);
        }