Clean up emote parsing

This commit is contained in:
Rasmus Karlsson 2019-06-22 14:16:21 +02:00
parent 9cb5e3abb3
commit a34e3084df

View file

@ -958,49 +958,33 @@ void TwitchMessageBuilder::appendTwitchEmote(
Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name) Outcome TwitchMessageBuilder::tryAppendEmote(const EmoteName &name)
{ {
// Special channels, like /whispers and /channels return here auto *app = getApp();
// This means they will not render any BTTV or FFZ emotes
if (this->twitchChannel == nullptr) const auto &globalBttvEmotes = app->twitch.server->getBttvEmotes();
{ const auto &globalFfzEmotes = app->twitch.server->getFfzEmotes();
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;
}
auto flags = MessageElementFlags(); auto flags = MessageElementFlags();
auto emote = boost::optional<EmotePtr>{}; 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; flags = MessageElementFlag::FfzEmote;
} }
else if ((emote = this->twitchChannel->bttvEmote(name))) else if (this->twitchChannel &&
(emote = this->twitchChannel->bttvEmote(name)))
{ {
flags = MessageElementFlag::BttvEmote; flags = MessageElementFlag::BttvEmote;
} }
else if ((emote = this->twitchChannel->globalFfz().emote(name))) else if ((emote = globalFfzEmotes.emote(name)))
{ {
flags = MessageElementFlag::FfzEmote; flags = MessageElementFlag::FfzEmote;
} }
else if ((emote = this->twitchChannel->globalBttv().emote(name))) else if ((emote = globalBttvEmotes.emote(name)))
{ {
flags = MessageElementFlag::BttvEmote; flags = MessageElementFlag::BttvEmote;
} }