Added raid and sub fields to chat view

This commit is contained in:
tyler 2024-05-27 16:07:44 -04:00
parent 3818644bb0
commit a4125e8de8

35
chat.go
View file

@ -258,6 +258,15 @@ type ChatEventBlock struct {
Type string `json:"type"` 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 { type ChatEventRant struct {
Duration int `json:"duration"` Duration int `json:"duration"`
ExpiresOn string `json:"expires_on"` ExpiresOn string `json:"expires_on"`
@ -265,13 +274,15 @@ type ChatEventRant struct {
} }
type ChatEventMessage struct { type ChatEventMessage struct {
Blocks []ChatEventBlock `json:"blocks"` Blocks []ChatEventBlock `json:"blocks"`
ChannelID *int64 `json:"channel_id"` ChannelID *int64 `json:"channel_id"`
ID string `json:"id"` ID string `json:"id"`
Rant *ChatEventRant `json:"rant"` Notification *ChatEventNotification `json:"notification"`
Text string `json:"text"` RaidNotification *ChatEventRaidNotification `json:"raid_notification"`
Time string `json:"time"` Rant *ChatEventRant `json:"rant"`
UserID string `json:"user_id"` Text string `json:"text"`
Time string `json:"time"`
UserID string `json:"user_id"`
} }
type ChatEventUser struct { type ChatEventUser struct {
@ -392,7 +403,9 @@ type ChatView struct {
ImageUrl string ImageUrl string
Init bool Init bool
IsFollower bool IsFollower bool
Raid bool
Rant int Rant int
Sub bool
Text string Text string
Time time.Time Time time.Time
Type string Type string
@ -456,9 +469,17 @@ func parseMessages(eventType string, messages []ChatEventMessage, users map[stri
view.Color = user.Color view.Color = user.Color
view.ImageUrl = user.Image1 view.ImageUrl = user.Image1
view.IsFollower = user.IsFollower view.IsFollower = user.IsFollower
if message.RaidNotification != nil {
view.Raid = true
}
if message.Rant != nil { if message.Rant != nil {
view.Rant = message.Rant.PriceCents view.Rant = message.Rant.PriceCents
} }
if message.Notification != nil {
if message.Notification.Badge == ChatBadgeRecurringSubscription {
view.Sub = true
}
}
view.Text = message.Text view.Text = message.Text
t, err := time.Parse(time.RFC3339, message.Time) t, err := time.Parse(time.RFC3339, message.Time)
if err != nil { if err != nil {