Skip to content

Commit c03b71b

Browse files
committed
Display the event type if it's not a chat message
1 parent c82718d commit c03b71b

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

pkg/streamcontrol/event.go

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package streamcontrol
22

3-
import "time"
3+
import (
4+
"fmt"
5+
"time"
6+
)
47

58
type ChatUserID string
69
type ChatMessageID string
@@ -32,3 +35,35 @@ const (
3235
EventTypeStreamOffline
3336
EventTypeOther
3437
)
38+
39+
func (t EventType) String() string {
40+
switch t {
41+
case EventTypeUndefined:
42+
return "undefined"
43+
case EventTypeChatMessage:
44+
return "chat_message"
45+
case EventTypeCheer:
46+
return "cheer"
47+
case EventTypeAutoModHold:
48+
return "automod_hold"
49+
case EventTypeAdBreak:
50+
return "ad_break"
51+
case EventTypeBan:
52+
return "ban"
53+
case EventTypeFollow:
54+
return "follow"
55+
case EventTypeRaid:
56+
return "raid"
57+
case EventTypeChannelShoutoutReceive:
58+
return "channel_shoutout_receive"
59+
case EventTypeSubscribe:
60+
return "subscribe"
61+
case EventTypeStreamOnline:
62+
return "stream_online"
63+
case EventTypeStreamOffline:
64+
return "stream_offline"
65+
case EventTypeOther:
66+
return "other"
67+
}
68+
return fmt.Sprintf("unknown_%d", int(t))
69+
}

pkg/streampanel/chat_as_list.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ func (ui *chatUIAsList) listUpdateItem(
351351
removeMsgButton.Enable()
352352
}
353353
}
354-
item.TimestampSegment.Text = msg.CreatedAt.Format("15:04:05")
354+
newText := msg.CreatedAt.Format("05")
355+
if msg.EventType != streamcontrol.EventTypeChatMessage {
356+
newText += fmt.Sprintf(" %s", msg.EventType.String())
357+
}
358+
item.TimestampSegment.Text = newText
355359
item.TimestampSegment.Style.ColorName = colorForPlatform(msg.Platform)
356360
item.UsernameSegment.Text = msg.Username
357361
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)

pkg/streampanel/chat_as_text.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ func (ui *chatUIAsText) newItem(
307307
removeMsgButton.Enable()
308308
}
309309
}
310-
item.TimestampSegment.Text = msg.CreatedAt.Format("15:04:05")
310+
newText := msg.CreatedAt.Format("05")
311+
if msg.EventType != streamcontrol.EventTypeChatMessage {
312+
newText += fmt.Sprintf(" %s", msg.EventType.String())
313+
}
314+
item.TimestampSegment.Text = newText
311315
item.TimestampSegment.Style.ColorName = colorForPlatform(msg.Platform)
312316
item.UsernameSegment.Text = msg.Username
313317
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)

0 commit comments

Comments
 (0)