private void SelectIntellisenseEmoticon() { if (this.EmoticonIntellisenseListBox.SelectedItem is EmoteModel) { EmoteModel emoticon = this.EmoticonIntellisenseListBox.SelectedItem as EmoteModel; if (emoticon != null) { this.SelectIntellisenseItem(emoticon.code); } } else if (this.EmoticonIntellisenseListBox.SelectedItem is BetterTTVEmoteModel) { BetterTTVEmoteModel emoticon = this.EmoticonIntellisenseListBox.SelectedItem as BetterTTVEmoteModel; if (emoticon != null) { this.SelectIntellisenseItem(emoticon.code); } } else if (this.EmoticonIntellisenseListBox.SelectedItem is FrankerFaceZEmoteModel) { FrankerFaceZEmoteModel emoticon = this.EmoticonIntellisenseListBox.SelectedItem as FrankerFaceZEmoteModel; if (emoticon != null) { this.SelectIntellisenseItem(emoticon.name); } } this.HideIntellisense(); }
/// <summary> /// Gets all chat emoticons (not including their images). /// /// Caution: This endpoint returns a large amount of data. /// </summary> /// <returns>The chat badges</returns> public async Task <IEnumerable <EmoteModel> > GetChatEmoticons() { JObject jobj = await this.GetJObjectAsync("chat/emoticon_images"); List <EmoteModel> results = new List <EmoteModel>(); if (jobj != null && jobj.ContainsKey("emoticons")) { JArray emoticons = (JArray)jobj["emoticons"]; foreach (JObject emoticon in emoticons) { EmoteModel emote = emoticon.ToObject <EmoteModel>(); emote.setID = emoticon["emoticon_set"].ToString(); results.Add(emote); } } return(results); }
public TwitchChatMessageViewModel(ChatMessagePacketModel message, UserViewModel user = null) : base(message.ID, StreamingPlatformTypeEnum.Twitch, (user != null) ? user : new UserViewModel(message)) { this.User.SetTwitchChatDetails(message); foreach (var kvp in message.EmotesDictionary) { if (!messageEmotesHashSet.Contains(kvp.Key) && kvp.Value.Count > 0) { long emoteID = kvp.Key; Tuple <int, int> instance = kvp.Value.FirstOrDefault(); if (0 <= instance.Item1 && instance.Item1 < message.Message.Length && 0 <= instance.Item2 && instance.Item2 < message.Message.Length) { string emoteCode = message.Message.Substring(instance.Item1, instance.Item2 - instance.Item1 + 1); messageEmotesCache[emoteCode] = new EmoteModel() { id = emoteID, code = emoteCode }; messageEmotesHashSet.Add(kvp.Key); } } } this.HasBits = (int.TryParse(message.Bits, out int bits) && bits > 0); this.IsHighlightedMessage = message.RawPacket.Tags.ContainsKey(TagMessageID) && message.RawPacket.Tags[TagMessageID].Equals(MessageIDHighlightedMessage); if (message.Message.StartsWith(SlashMeAction) && message.Message.Last() == SOHCharacter) { this.IsSlashMe = true; string text = message.Message.Replace(SlashMeAction, string.Empty); this.ProcessMessageContents(text.Substring(0, text.Length - 1)); } else { this.ProcessMessageContents(message.Message); } }
/// <summary> /// Gets all chat emoticons (not including their images) in one or more specified sets. /// </summary> /// <returns>The chat badges</returns> public async Task <IEnumerable <EmoteModel> > GetChatEmoticonsForSet(List <string> sets) { Validator.ValidateList(sets, "sets"); JObject jobj = await this.GetJObjectAsync("chat/emoticon_images?emotesets=" + string.Join(",", sets)); List <EmoteModel> results = new List <EmoteModel>(); if (jobj != null && jobj.ContainsKey("emoticon_sets")) { JObject emoticonSets = (JObject)jobj["emoticon_sets"]; foreach (var kvp in emoticonSets) { string setID = kvp.Key; foreach (JToken token in (JArray)kvp.Value) { EmoteModel emote = token.ToObject <EmoteModel>(); emote.setID = setID; results.Add(emote); } } } return(results); }
/// <summary> /// Gets the emotes available to the user. /// </summary> /// <param name="user">The user to get emotes for</param> /// <returns>The available emotes</returns> public async Task <IEnumerable <EmoteModel> > GetUserEmotes(UserModel user) { Validator.ValidateVariable(user, "user"); JObject jobj = await this.GetJObjectAsync("users/" + user.id + "/emotes"); List <EmoteModel> results = new List <EmoteModel>(); if (jobj != null && jobj.ContainsKey("emoticon_sets")) { JObject emoticonSets = (JObject)jobj["emoticon_sets"]; foreach (var kvp in emoticonSets) { string channelID = kvp.Key; foreach (JToken token in (JArray)kvp.Value) { EmoteModel emote = token.ToObject <EmoteModel>(); emote.channelID = channelID; results.Add(emote); } } } return(results); }