mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Clean up emote parsing
This commit is contained in:
parent
9cb5e3abb3
commit
a34e3084df
1 changed files with 14 additions and 30 deletions
|
@ -957,50 +957,34 @@ void TwitchMessageBuilder::appendTwitchEmote(
|
|||
}
|
||||
|
||||
Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
|
||||
{
|
||||
// Special channels, like /whispers and /channels return here
|
||||
// This means they will not render any BTTV or FFZ emotes
|
||||
if (this->twitchChannel == nullptr)
|
||||
{
|
||||
auto *app = getApp();
|
||||
const auto &bttvemotes = app->twitch.server->getBttvEmotes();
|
||||
const auto &ffzemotes = app->twitch.server->getFfzEmotes();
|
||||
auto flags = MessageElementFlags();
|
||||
auto emote = boost::optional<EmotePtr>{};
|
||||
{ // bttv/ffz emote
|
||||
if ((emote = bttvemotes.emote(name)))
|
||||
{
|
||||
flags = MessageElementFlag::BttvEmote;
|
||||
}
|
||||
else if ((emote = ffzemotes.emote(name)))
|
||||
{
|
||||
flags = MessageElementFlag::FfzEmote;
|
||||
}
|
||||
if (emote)
|
||||
{
|
||||
this->emplace<EmoteElement>(emote.get(), flags);
|
||||
return Success;
|
||||
}
|
||||
} // bttv/ffz emote
|
||||
return Failure;
|
||||
}
|
||||
|
||||
const auto &globalBttvEmotes = app->twitch.server->getBttvEmotes();
|
||||
const auto &globalFfzEmotes = app->twitch.server->getFfzEmotes();
|
||||
|
||||
auto flags = MessageElementFlags();
|
||||
auto emote = boost::optional<EmotePtr>{};
|
||||
|
||||
if ((emote = this->twitchChannel->ffzEmote(name)))
|
||||
// Emote order:
|
||||
// - FrankerFaceZ Channel
|
||||
// - BetterTTV Channel
|
||||
// - FrankerFaceZ Global
|
||||
// - BetterTTV Global
|
||||
if (this->twitchChannel && (emote = this->twitchChannel->ffzEmote(name)))
|
||||
{
|
||||
flags = MessageElementFlag::FfzEmote;
|
||||
}
|
||||
else if ((emote = this->twitchChannel->bttvEmote(name)))
|
||||
else if (this->twitchChannel &&
|
||||
(emote = this->twitchChannel->bttvEmote(name)))
|
||||
{
|
||||
flags = MessageElementFlag::BttvEmote;
|
||||
}
|
||||
else if ((emote = this->twitchChannel->globalFfz().emote(name)))
|
||||
else if ((emote = globalFfzEmotes.emote(name)))
|
||||
{
|
||||
flags = MessageElementFlag::FfzEmote;
|
||||
}
|
||||
else if ((emote = this->twitchChannel->globalBttv().emote(name)))
|
||||
else if ((emote = globalBttvEmotes.emote(name)))
|
||||
{
|
||||
flags = MessageElementFlag::BttvEmote;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue