diff --git a/api/server.go b/api/server.go index 89025ad..2bada66 100644 --- a/api/server.go +++ b/api/server.go @@ -89,6 +89,7 @@ type channelLogList struct { type chatMessage struct { Text string `json:"text"` + SystemText string `json:"systemText"` Username string `json:"username"` DisplayName string `json:"displayName"` Channel string `json:"channel"` @@ -457,7 +458,7 @@ func createChatMessage(parsedMessage twitch.Message) chatMessage { Timestamp: timestamp{message.Time}, Username: message.TargetUsername, DisplayName: message.TargetUsername, - Text: buildClearChatMessageText(*message), + SystemText: buildClearChatMessageText(*message), Type: message.Type, Channel: message.Channel, Raw: message.Raw, @@ -468,7 +469,8 @@ func createChatMessage(parsedMessage twitch.Message) chatMessage { Timestamp: timestamp{message.Time}, Username: message.User.Name, DisplayName: message.User.DisplayName, - Text: message.SystemMsg + " " + message.Message, + Text: message.Message, + SystemText: message.SystemMsg, Type: message.Type, Channel: message.Channel, Raw: message.Raw, diff --git a/go.mod b/go.mod index f4f5349..3369678 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.16 require ( github.com/gempir/go-twitch-irc/v3 v3.0.0 github.com/nicklaw5/helix v1.25.0 - github.com/nursik/go-expire-map v1.1.0 // indirect + github.com/nursik/go-expire-map v1.2.0 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 // indirect ) diff --git a/go.sum b/go.sum index cd6e800..3b94661 100644 --- a/go.sum +++ b/go.sum @@ -7,10 +7,8 @@ github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfE github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/nicklaw5/helix v1.25.0 h1:Mrz537izZVsGdM3I46uGAAlslj61frgkhS/9xQqyT/M= github.com/nicklaw5/helix v1.25.0/go.mod h1:yvXZFapT6afIoxnAvlWiJiUMsYnoHl7tNs+t0bloAMw= -github.com/nursik/go-expire-map v1.1.0 h1:C+OJ81JtHDSPJXfuu0g3e8RRjHLd5of8dVzyfDOB9KY= -github.com/nursik/go-expire-map v1.1.0/go.mod h1:wdQsai5n32Uw1IuVXXZoopePGCFh5vb0Dka/TRcboHs= -github.com/nursik/go-ordered-set v0.0.0-20190626022851-0e8872c36517 h1:jau4pavdQo5lHeVTjZEGrm4+zvVGZj8SFQt4awsLLXE= -github.com/nursik/go-ordered-set v0.0.0-20190626022851-0e8872c36517/go.mod h1:qFI7Mmmx8i+Qz8a52FarvpgPQzylvD3w77JAwvnFtKg= +github.com/nursik/go-expire-map v1.2.0 h1:3yl3sVLSnfw4vbo6OVZWP1tFND4CBm4hrYCrrAT5jkU= +github.com/nursik/go-expire-map v1.2.0/go.mod h1:Mrqzxpk2G81At+TAlfImiNrKECj0gfVw7URv3p/eLzU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= diff --git a/web/src/components/ContentLog.tsx b/web/src/components/ContentLog.tsx index 3a8f1a9..d1b6e35 100644 --- a/web/src/components/ContentLog.tsx +++ b/web/src/components/ContentLog.tsx @@ -33,7 +33,7 @@ export function ContentLog({ year, month }: { year: string, month: string }) { const [searchText, setSearchText] = useState(""); const logs = useLog(state.currentChannel ?? "", state.currentUsername ?? "", year, month) - .filter(log => log.text.toLowerCase().includes(searchText.toLowerCase())); + .filter(log => (log.text + log.systemText).toLowerCase().includes(searchText.toLowerCase())); const Row = ({ index, style }: { index: number, style: CSSProperties }) => (
diff --git a/web/src/components/Message.tsx b/web/src/components/Message.tsx index d5cf700..1ab8a35 100644 --- a/web/src/components/Message.tsx +++ b/web/src/components/Message.tsx @@ -7,7 +7,6 @@ import { ThirdPartyEmote } from "../types/ThirdPartyEmote"; import runes from "runes"; const MessageContainer = styled.div` - a { margin: 0 2px; color: var(--theme2); @@ -19,6 +18,10 @@ const MessageContainer = styled.div` } `; +const SystemMessageWrapper = styled.span` +font-style: italic; +`; + const Emote = styled.img` max-height: 18px; margin: 0 2px; @@ -35,10 +38,8 @@ export function Message({ message, thirdPartyEmotes }: { message: LogMessage, th let messageText = message.text; let renderMessagePrefix = ""; - if (message.tags['system-msg']) { - messageText = messageText.replace(message.tags['system-msg'] + " ", ""); - - renderMessagePrefix = `${message.tags['system-msg']} `; + if (message.systemText) { + renderMessagePrefix = `${message.systemText}`; } const messageTextEmoji = runes(messageText); @@ -105,7 +106,10 @@ export function Message({ message, thirdPartyEmotes }: { message: LogMessage, th } } + const prefixElement = renderMessagePrefix ? + {renderMessagePrefix} : null; + return - {renderMessagePrefix}{renderMessage} + {prefixElement}{renderMessagePrefix && renderMessage ? ' ' : ''}{renderMessage} ; }; diff --git a/web/src/types/log.ts b/web/src/types/log.ts index ec23018..ed3c53d 100644 --- a/web/src/types/log.ts +++ b/web/src/types/log.ts @@ -9,6 +9,7 @@ export interface LogMessage extends Omit { export interface RawLogMessage { text: string, + systemText: string, username: string, displayName: string, channel: string,