private void OnBTTVChannelEmoticonsLoaded(BTTVEmoticonCollection collection) { if (collection == null) { return; } if (collection.ChannelEmoticons != null) { foreach (BTTVEmoticon emote in collection.ChannelEmoticons) { string image = string.Format(TAG_EMOTE, emote.GetImage()); Body = Body.Replace(emote.Code, image); } } if (collection.SharedEmoticons != null) { foreach (BTTVEmoticon emote in collection.SharedEmoticons) { string image = string.Format(TAG_EMOTE, emote.GetImage()); Body = Body.Replace(emote.Code, image); } } }
public static void LoadChannelEmoticons(string channel) { if (channel == null) { return; } try { using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(string.Format(CHANNEL_EMOTE_URL, channel)); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = client.GetAsync("").Result; string json = response.Content.ReadAsStringAsync().Result; ChannelEmoticons = JsonConvert.DeserializeObject <BTTVEmoticonCollection> (json); } } catch { ChannelEmoticons = null; } finally { OnChannelEmoticonsLoaded?.Invoke(ChannelEmoticons); } }