From 5c602fea94e2a8584892f9a1870e16ba12e7a482 Mon Sep 17 00:00:00 2001 From: apa420 Date: Sun, 8 Sep 2019 16:01:38 +0000 Subject: [PATCH] Resolved review --- src/providers/twitch/TwitchChannel.cpp | 25 ++++--------------- src/providers/twitch/TwitchChannel.hpp | 5 +--- src/providers/twitch/TwitchMessageBuilder.cpp | 14 +++++------ 3 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 65d272d6e..86e486f3a 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -751,7 +751,8 @@ void TwitchChannel::refreshCheerEmotes() { auto cheerEmoteSet = CheerEmoteSet(); cheerEmoteSet.regex = QRegularExpression( - "^" + set.prefix.toLower() + "([1-9][0-9]*)$"); + "^" + set.prefix + "([1-9][0-9]*)$", + QRegularExpression::CaseInsensitiveOption); for (auto &tier : set.tiers) { @@ -823,14 +824,12 @@ boost::optional TwitchChannel::ffzCustomModBadge() const return boost::none; } -boost::optional, boost::optional, - boost::optional>> - TwitchChannel::cheerEmote(const QString &string) +boost::optional TwitchChannel::cheerEmote(const QString &string) { auto sets = this->cheerEmoteSets_.access(); for (const auto &set : *sets) { - auto match = set.regex.match(string.toLower()); + auto match = set.regex.match(string); if (!match.hasMatch()) { continue; @@ -846,21 +845,7 @@ boost::optional, boost::optional, { if (bitAmount >= emote.minBits) { - using OPEP = boost::optional; - std::tuple> retval; - if (emote.staticEmote) - { - std::get<0>(retval) = emote.staticEmote; - } - if (emote.animatedEmote) - { - std::get<1>(retval) = emote.animatedEmote; - } - if (emote.color != QColor()) - { - std::get<2>(retval) = emote.color; - } - return retval; + return emote; } } } diff --git a/src/providers/twitch/TwitchChannel.hpp b/src/providers/twitch/TwitchChannel.hpp index 4cc6ad1ee..c4840a00b 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -93,10 +93,7 @@ public: const QString &version) const; // Cheers - boost::optional< - std::tuple, boost::optional, - boost::optional>> - cheerEmote(const QString &string); + boost::optional cheerEmote(const QString &string); // Signals pajlada::Signals::NoArgSignal roomIdChanged; diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 8e02f3816..0633e305e 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -1292,21 +1292,21 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string) { return Failure; } - auto &cheerPairAndColor = *cheerOpt; - if (std::get<0>(cheerPairAndColor)) + auto &cheerEmote = *cheerOpt; + if (cheerEmote.staticEmote) { - this->emplace(*std::get<0>(cheerPairAndColor), + this->emplace(cheerEmote.staticEmote, MessageElementFlag::BitsStatic); } - if (std::get<1>(cheerPairAndColor)) + if (cheerEmote.animatedEmote) { - this->emplace(*std::get<1>(cheerPairAndColor), + this->emplace(cheerEmote.animatedEmote, MessageElementFlag::BitsAnimated); } - if (std::get<2>(cheerPairAndColor)) + if (cheerEmote.color != QColor()) { this->emplace(this->bits, MessageElementFlag::BitsAmount, - *std::get<2>(cheerPairAndColor)); + cheerEmote.color); } return Success; }