Display the event type if it's not a chat message
Some checks failed
rolling-release / build (push) Has been cancelled
rolling-release / rolling-release (push) Has been cancelled

This commit is contained in:
Dmitrii Okunev
2025-07-13 19:15:16 +01:00
parent c82718d6ae
commit c03b71b4c7
3 changed files with 46 additions and 3 deletions

View File

@@ -1,6 +1,9 @@
package streamcontrol
import "time"
import (
"fmt"
"time"
)
type ChatUserID string
type ChatMessageID string
@@ -32,3 +35,35 @@ const (
EventTypeStreamOffline
EventTypeOther
)
func (t EventType) String() string {
switch t {
case EventTypeUndefined:
return "undefined"
case EventTypeChatMessage:
return "chat_message"
case EventTypeCheer:
return "cheer"
case EventTypeAutoModHold:
return "automod_hold"
case EventTypeAdBreak:
return "ad_break"
case EventTypeBan:
return "ban"
case EventTypeFollow:
return "follow"
case EventTypeRaid:
return "raid"
case EventTypeChannelShoutoutReceive:
return "channel_shoutout_receive"
case EventTypeSubscribe:
return "subscribe"
case EventTypeStreamOnline:
return "stream_online"
case EventTypeStreamOffline:
return "stream_offline"
case EventTypeOther:
return "other"
}
return fmt.Sprintf("unknown_%d", int(t))
}

View File

@@ -351,7 +351,11 @@ func (ui *chatUIAsList) listUpdateItem(
removeMsgButton.Enable()
}
}
item.TimestampSegment.Text = msg.CreatedAt.Format("15:04:05")
newText := msg.CreatedAt.Format("05")
if msg.EventType != streamcontrol.EventTypeChatMessage {
newText += fmt.Sprintf(" %s", msg.EventType.String())
}
item.TimestampSegment.Text = newText
item.TimestampSegment.Style.ColorName = colorForPlatform(msg.Platform)
item.UsernameSegment.Text = msg.Username
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)

View File

@@ -307,7 +307,11 @@ func (ui *chatUIAsText) newItem(
removeMsgButton.Enable()
}
}
item.TimestampSegment.Text = msg.CreatedAt.Format("15:04:05")
newText := msg.CreatedAt.Format("05")
if msg.EventType != streamcontrol.EventTypeChatMessage {
newText += fmt.Sprintf(" %s", msg.EventType.String())
}
item.TimestampSegment.Text = newText
item.TimestampSegment.Style.ColorName = colorForPlatform(msg.Platform)
item.UsernameSegment.Text = msg.Username
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)