mirror of
https://github.com/xaionaro-go/streamctl.git
synced 2025-09-27 11:52:11 +08:00
Display the event type if it's not a chat message
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
package streamcontrol
|
package streamcontrol
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type ChatUserID string
|
type ChatUserID string
|
||||||
type ChatMessageID string
|
type ChatMessageID string
|
||||||
@@ -32,3 +35,35 @@ const (
|
|||||||
EventTypeStreamOffline
|
EventTypeStreamOffline
|
||||||
EventTypeOther
|
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))
|
||||||
|
}
|
||||||
|
@@ -351,7 +351,11 @@ func (ui *chatUIAsList) listUpdateItem(
|
|||||||
removeMsgButton.Enable()
|
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.TimestampSegment.Style.ColorName = colorForPlatform(msg.Platform)
|
||||||
item.UsernameSegment.Text = msg.Username
|
item.UsernameSegment.Text = msg.Username
|
||||||
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)
|
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)
|
||||||
|
@@ -307,7 +307,11 @@ func (ui *chatUIAsText) newItem(
|
|||||||
removeMsgButton.Enable()
|
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.TimestampSegment.Style.ColorName = colorForPlatform(msg.Platform)
|
||||||
item.UsernameSegment.Text = msg.Username
|
item.UsernameSegment.Text = msg.Username
|
||||||
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)
|
item.UsernameSegment.Style.ColorName = colorForUsername(msg.Username)
|
||||||
|
Reference in New Issue
Block a user