From a34e3084df2e8957ed544e19f2aa572ff1b6e137 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 22 Jun 2019 14:16:21 +0200 Subject: [PATCH] Clean up emote parsing --- src/providers/twitch/TwitchMessageBuilder.cpp | 44 ++++++------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 98cca8476..ed9923215 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -958,49 +958,33 @@ 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{}; - { // bttv/ffz emote - if ((emote = bttvemotes.emote(name))) - { - flags = MessageElementFlag::BttvEmote; - } - else if ((emote = ffzemotes.emote(name))) - { - flags = MessageElementFlag::FfzEmote; - } - if (emote) - { - this->emplace(emote.get(), flags); - return Success; - } - } // bttv/ffz emote - return Failure; - } + auto *app = getApp(); + + const auto &globalBttvEmotes = app->twitch.server->getBttvEmotes(); + const auto &globalFfzEmotes = app->twitch.server->getFfzEmotes(); auto flags = MessageElementFlags(); auto emote = boost::optional{}; - 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; }