From 8d97a71facf436f87a063ccce1c7966f55da0f7b Mon Sep 17 00:00:00 2001 From: pimothyxd <29018740+pimothyxd@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:26:31 +0100 Subject: [PATCH] fix(twitch): support lowercase cheers (#981) If a user sends a cheer in chat it is meant to be turned into an emote with it's text colored differently. It can be sent as it's lowercase and uppercase variant (e.g. "cheer1" & "Cheer1"). 7TV currently seems to only support the uppercase variant. fixes #453 Co-authored-by: Troy --- CHANGELOG-nightly.md | 1 + src/site/twitch.tv/modules/chat-vod/ChatVod.vue | 9 ++++++++- src/site/twitch.tv/modules/chat/ChatList.vue | 10 +++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG-nightly.md b/CHANGELOG-nightly.md index 0306270cd..4245d10bb 100644 --- a/CHANGELOG-nightly.md +++ b/CHANGELOG-nightly.md @@ -3,6 +3,7 @@ **The changes listed here are not assigned to an official release**. - Reinstated animated avatars +- Fixed an issue where lowercase cheers were displayed as text - Added an option to hide the community challenge contributions in the chat - Fixed extension not working on twitch for some users (React 18 support) - Fixed an issue where chat messages (like announcements) did not use the channel accent color diff --git a/src/site/twitch.tv/modules/chat-vod/ChatVod.vue b/src/site/twitch.tv/modules/chat-vod/ChatVod.vue index 58378c84f..e34ad40e5 100644 --- a/src/site/twitch.tv/modules/chat-vod/ChatVod.vue +++ b/src/site/twitch.tv/modules/chat-vod/ChatVod.vue @@ -217,7 +217,7 @@ function createMessageComponentRef(data: CommentData) { const e = tok.content as Twitch.ChatMessage.EmotePart["content"]; if (!e.alt) continue; - msg.nativeEmotes[e.alt + (e.cheerAmount ?? "")] = { + const nativeEmote: SevenTV.ActiveEmote = { id: e.emoteID ?? "", name: e.alt, flags: 0, @@ -238,7 +238,14 @@ function createMessageComponentRef(data: CommentData) { token: e.alt, } as Partial), }; + const emoteName = e.alt + (e.cheerAmount ?? ""); + msg.nativeEmotes[emoteName] = nativeEmote; + + // if it's a cheer we also want to support it's lowercase variant (e.g. Cheer1 & cheer1) + if (e.cheerAmount) { + msg.nativeEmotes[emoteName.toLowerCase()] = nativeEmote; + } msg.body += e.alt; break; } diff --git a/src/site/twitch.tv/modules/chat/ChatList.vue b/src/site/twitch.tv/modules/chat/ChatList.vue index 7ca85930e..f5cb042a2 100644 --- a/src/site/twitch.tv/modules/chat/ChatList.vue +++ b/src/site/twitch.tv/modules/chat/ChatList.vue @@ -245,7 +245,7 @@ function onChatMessage(msg: ChatMessage, msgData: Twitch.AnyMessage, shouldRende // skip over emotes patched in by FFZ and BTTV if (e.emoteID?.startsWith("__FFZ__") || e.emoteID?.startsWith("__BTTV__")) continue; - msg.nativeEmotes[e.alt + (e.cheerAmount ?? "")] = { + const nativeEmote: SevenTV.ActiveEmote = { id: e.emoteID ?? "", name: e.alt, flags: 0, @@ -266,6 +266,14 @@ function onChatMessage(msg: ChatMessage, msgData: Twitch.AnyMessage, shouldRende token: e.alt, } as Partial), }; + const emoteName = e.alt + (e.cheerAmount ?? ""); + + msg.nativeEmotes[emoteName] = nativeEmote; + + // if it's a cheer we also want to support it's lowercase variant (e.g. Cheer1 & cheer1) + if (e.cheerAmount) { + msg.nativeEmotes[emoteName.toLowerCase()] = nativeEmote; + } break; } // replace flagged segments