fix: mark global BTTV emotes as zero-width at creation (#6440)
* fix: mark global BTTV emotes as zero-width at creation * changelog * nit: slightly different formatting --------- Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -78,11 +78,6 @@ const QRegularExpression allUsernamesMentionRegex("^" + regexHelpString);
|
||||
|
||||
const QRegularExpression SPACE_REGEX("\\s");
|
||||
|
||||
const QSet<QString> zeroWidthEmotes{
|
||||
"SoSnowy", "IceCold", "SantaHat", "TopHat",
|
||||
"ReinDeer", "CandyCane", "cvMask", "cvHazmat",
|
||||
};
|
||||
|
||||
struct HypeChatPaidLevel {
|
||||
std::chrono::seconds duration;
|
||||
uint8_t numeric;
|
||||
@@ -421,7 +416,7 @@ EmotePtr makeSharedChatBadge(const QString &sourceName,
|
||||
});
|
||||
}
|
||||
|
||||
std::tuple<std::optional<EmotePtr>, MessageElementFlags, bool> parseEmote(
|
||||
std::tuple<std::optional<EmotePtr>, MessageElementFlags> parseEmote(
|
||||
TwitchChannel *twitchChannel, const EmoteName &name)
|
||||
{
|
||||
// Emote order:
|
||||
@@ -445,31 +440,19 @@ std::tuple<std::optional<EmotePtr>, MessageElementFlags, bool> parseEmote(
|
||||
emote = twitchChannel->ffzEmote(name);
|
||||
if (emote)
|
||||
{
|
||||
return {
|
||||
emote,
|
||||
MessageElementFlag::FfzEmote,
|
||||
false,
|
||||
};
|
||||
return {emote, MessageElementFlag::FfzEmote};
|
||||
}
|
||||
|
||||
emote = twitchChannel->bttvEmote(name);
|
||||
if (emote)
|
||||
{
|
||||
return {
|
||||
emote,
|
||||
MessageElementFlag::BttvEmote,
|
||||
false,
|
||||
};
|
||||
return {emote, MessageElementFlag::BttvEmote};
|
||||
}
|
||||
|
||||
emote = twitchChannel->seventvEmote(name);
|
||||
if (emote)
|
||||
{
|
||||
return {
|
||||
emote,
|
||||
MessageElementFlag::SevenTVEmote,
|
||||
emote.value()->zeroWidth,
|
||||
};
|
||||
return {emote, MessageElementFlag::SevenTVEmote};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,38 +461,22 @@ std::tuple<std::optional<EmotePtr>, MessageElementFlags, bool> parseEmote(
|
||||
emote = globalFfzEmotes->emote(name);
|
||||
if (emote)
|
||||
{
|
||||
return {
|
||||
emote,
|
||||
MessageElementFlag::FfzEmote,
|
||||
false,
|
||||
};
|
||||
return {emote, MessageElementFlag::FfzEmote};
|
||||
}
|
||||
|
||||
emote = globalBttvEmotes->emote(name);
|
||||
if (emote)
|
||||
{
|
||||
return {
|
||||
emote,
|
||||
MessageElementFlag::BttvEmote,
|
||||
zeroWidthEmotes.contains(name.string),
|
||||
};
|
||||
return {emote, MessageElementFlag::BttvEmote};
|
||||
}
|
||||
|
||||
emote = globalSeventvEmotes->globalEmote(name);
|
||||
if (emote)
|
||||
{
|
||||
return {
|
||||
emote,
|
||||
MessageElementFlag::SevenTVEmote,
|
||||
emote.value()->zeroWidth,
|
||||
};
|
||||
return {emote, MessageElementFlag::SevenTVEmote};
|
||||
}
|
||||
|
||||
return {
|
||||
{},
|
||||
{},
|
||||
false,
|
||||
};
|
||||
return {{}, {}};
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -2240,14 +2207,15 @@ void MessageBuilder::appendUsername(const QVariantMap &tags,
|
||||
Outcome MessageBuilder::tryAppendEmote(TwitchChannel *twitchChannel,
|
||||
const EmoteName &name)
|
||||
{
|
||||
auto [emote, flags, zeroWidth] = parseEmote(twitchChannel, name);
|
||||
auto [emote, flags] = parseEmote(twitchChannel, name);
|
||||
|
||||
if (!emote)
|
||||
{
|
||||
return Failure;
|
||||
}
|
||||
|
||||
if (zeroWidth && getSettings()->enableZeroWidthEmotes && !this->isEmpty())
|
||||
if ((*emote)->zeroWidth && getSettings()->enableZeroWidthEmotes &&
|
||||
!this->isEmpty())
|
||||
{
|
||||
// Attempt to merge current zero-width emote into any previous emotes
|
||||
auto *asEmote = dynamic_cast<EmoteElement *>(&this->back());
|
||||
|
||||
Reference in New Issue
Block a user