private static Dictionary<long, Emote> LoadBasicEmotes(string set0, string set33, string set42) { JObject set0Response = JObject.Parse(set0); JObject set33Response = JObject.Parse(set33); JObject set42Response = JObject.Parse(set42); foreach (JObject o in set0Response["emoticon_sets"]["0"]) { long id = long.Parse((string)o["id"]); if (id < 15) { Emote emote = new Emote(); emote.Id = id; emote.Code = UnHtml((string)o["code"]); emote.Description = null; emote.Set = 0; emote.Channel = "--global--"; basicEmotes.Add(id, emote); } } foreach (JObject o in set33Response["emoticon_sets"]["33"]) { long id = long.Parse((string)o["id"]); Emote emote = new Emote(); emote.Id = id; emote.Code = UnHtml((string)o["code"]); emote.Description = null; emote.Set = 33; emote.Channel = "--twitch-turbo--"; basicEmotes.Add(id, emote); } foreach (JObject o in set42Response["emoticon_sets"]["42"]) { long id = long.Parse((string)o["id"]); Emote emote = new Emote(); emote.Id = id; emote.Code = UnHtml((string)o["code"]); emote.Description = null; emote.Set = 42; emote.Channel = "--twitch-turbo--"; basicEmotes.Add(id, emote); } return basicEmotes; }
private static EmoteResponse<Dictionary<long, Emote>> LoadImages(string responseString) { JObject responseObject = JObject.Parse(responseString); Dictionary<string, JObject> images = JsonConvert.DeserializeObject<Dictionary<string, JObject>>(((JObject)responseObject["images"]).ToString()); foreach (KeyValuePair<string, JObject> image in images) { Emote emote = new Emote(); emote.Id = long.Parse(image.Key); emote.Code = (string)image.Value["code"]; emote.Description = (string)image.Value["description"]; string set = (string)image.Value["set"]; if (!string.IsNullOrEmpty(set)) { emote.Set = long.Parse(set); } else { emote.Set = 0; } string channel = (string)image.Value["channel"]; if (!string.IsNullOrEmpty(channel)) { emote.Channel = channel; } else { emote.Channel = "--global--"; } emotes.Add(emote.Id, emote); if (!EmotesByCode.ContainsKey(emote.Code)) { EmotesByCode.Add(emote.Code, emote); } } JsonCache.imagesServerDate = DateTime.Parse((string)responseObject["meta"]["generated_at"]); return new EmoteResponse<Dictionary<long, Emote>>(JsonCache.imagesServerDate.Value, emotes); }