Skip to content

Commit

Permalink
fix(twitch): support lowercase cheers (#981)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
pimothyxd and TroyKomodo authored Feb 17, 2024
1 parent 005c9a6 commit 8d97a71
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion src/site/twitch.tv/modules/chat-vod/ChatVod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -238,7 +238,14 @@ function createMessageComponentRef(data: CommentData) {
token: e.alt,
} as Partial<Twitch.TwitchEmote>),
};
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;
}
Expand Down
10 changes: 9 additions & 1 deletion src/site/twitch.tv/modules/chat/ChatList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -266,6 +266,14 @@ function onChatMessage(msg: ChatMessage, msgData: Twitch.AnyMessage, shouldRende
token: e.alt,
} as Partial<Twitch.TwitchEmote>),
};
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
Expand Down

0 comments on commit 8d97a71

Please sign in to comment.