From a4125e8de839c87874436787d1ea23ebb529b8bf Mon Sep 17 00:00:00 2001 From: tyler Date: Mon, 27 May 2024 16:07:44 -0400 Subject: [PATCH] Added raid and sub fields to chat view --- chat.go | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/chat.go b/chat.go index c839a48..b05e050 100644 --- a/chat.go +++ b/chat.go @@ -258,6 +258,15 @@ type ChatEventBlock struct { Type string `json:"type"` } +type ChatEventNotification struct { + Badge string `json:"badge"` + Text string `json:"text"` +} + +type ChatEventRaidNotification struct { + StartTs int64 `json:"start_ts"` +} + type ChatEventRant struct { Duration int `json:"duration"` ExpiresOn string `json:"expires_on"` @@ -265,13 +274,15 @@ type ChatEventRant struct { } type ChatEventMessage struct { - Blocks []ChatEventBlock `json:"blocks"` - ChannelID *int64 `json:"channel_id"` - ID string `json:"id"` - Rant *ChatEventRant `json:"rant"` - Text string `json:"text"` - Time string `json:"time"` - UserID string `json:"user_id"` + Blocks []ChatEventBlock `json:"blocks"` + ChannelID *int64 `json:"channel_id"` + ID string `json:"id"` + Notification *ChatEventNotification `json:"notification"` + RaidNotification *ChatEventRaidNotification `json:"raid_notification"` + Rant *ChatEventRant `json:"rant"` + Text string `json:"text"` + Time string `json:"time"` + UserID string `json:"user_id"` } type ChatEventUser struct { @@ -392,7 +403,9 @@ type ChatView struct { ImageUrl string Init bool IsFollower bool + Raid bool Rant int + Sub bool Text string Time time.Time Type string @@ -456,9 +469,17 @@ func parseMessages(eventType string, messages []ChatEventMessage, users map[stri view.Color = user.Color view.ImageUrl = user.Image1 view.IsFollower = user.IsFollower + if message.RaidNotification != nil { + view.Raid = true + } if message.Rant != nil { view.Rant = message.Rant.PriceCents } + if message.Notification != nil { + if message.Notification.Badge == ChatBadgeRecurringSubscription { + view.Sub = true + } + } view.Text = message.Text t, err := time.Parse(time.RFC3339, message.Time) if err != nil {