async Task BuildChatEvent(string channel, JObject chatEvent) { await Task.Yield(); TrovoChatEventType eventType = (TrovoChatEventType)chatEvent.Value <int>("type"); TrovoChatUser user = new TrovoChatUser(chatEvent.Value <string>("nick_name"), chatEvent.Value <string>("avatar"), chatEvent.ContainsKey("medals") ? chatEvent["medals"].ToObject <string[]>() : new string[0], chatEvent.ContainsKey("sub_lv") ? int.Parse(chatEvent.Value <string>("sub_lv").Substring(5)) : 0); switch (eventType) { case TrovoChatEventType.GIFT: JObject giftData = JObject.Parse(chatEvent.Value <string>("content")); Event?.Invoke(this, new TrovoDonationEvent(channel, user, giftData.Value <string>("gift"), giftData.Value <int>("num"))); break; case TrovoChatEventType.RAID: Event?.Invoke(this, new TrovoChatMessage(eventType, channel, user, $"Raided the stream!")); break; default: Event?.Invoke(this, new TrovoChatMessage(eventType, channel, user, chatEvent.Value <string>("content"))); break; } }
public TrovoChatMessage(TrovoChatEventType eventType, string channel, TrovoChatUser user, string message) : base(Platform.Trovo, channel, user.DisplayName, message) { EventType = eventType; User = user; }