Clean up TwitchAccount emote stuff (#4243)
* Remove unused TwitchAccount FollowResult enum * Remove unused TwitchEmoteSetResolverResponse struct * Remove unused and unimplemented `getEmoteSetBatches` function definition * Remove unused `loadEmoteSetData` and `staticEmoteSets` from TwitchAccount * Remove forward declaration of TwitchAccount in TwitchAccountManager * Clean up IgnorePhrase includes * add missing newline in pubsubmanager.cpp
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "providers/irc/IrcChannel2.hpp"
|
||||
#include "providers/irc/IrcServer.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchCommon.hpp"
|
||||
#include "providers/twitch/TwitchIrcServer.hpp"
|
||||
#include "providers/twitch/TwitchMessageBuilder.hpp"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/MessageBuilder.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "util/FormatTime.hpp"
|
||||
#include "util/Helpers.hpp"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "controllers/highlights/HighlightController.hpp"
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "common/QLogging.hpp"
|
||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
#include "controllers/ignores/IgnorePhrase.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "providers/twitch/TwitchAccount.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
IgnorePhrase::IgnorePhrase(const QString &pattern, bool isRegex, bool isBlock,
|
||||
const QString &replace, bool isCaseSensitive)
|
||||
: pattern_(pattern)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(pattern)
|
||||
, isBlock_(isBlock)
|
||||
, replace_(replace)
|
||||
, isCaseSensitive_(isCaseSensitive)
|
||||
{
|
||||
if (this->isCaseSensitive_)
|
||||
{
|
||||
regex_.setPatternOptions(
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
}
|
||||
else
|
||||
{
|
||||
regex_.setPatternOptions(
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
}
|
||||
}
|
||||
|
||||
bool IgnorePhrase::operator==(const IgnorePhrase &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->isRegex_, this->isBlock_,
|
||||
this->replace_, this->isCaseSensitive_) ==
|
||||
std::tie(other.pattern_, other.isRegex_, other.isBlock_,
|
||||
other.replace_, other.isCaseSensitive_);
|
||||
}
|
||||
|
||||
const QString &IgnorePhrase::getPattern() const
|
||||
{
|
||||
return this->pattern_;
|
||||
}
|
||||
|
||||
bool IgnorePhrase::isRegex() const
|
||||
{
|
||||
return this->isRegex_;
|
||||
}
|
||||
|
||||
bool IgnorePhrase::isRegexValid() const
|
||||
{
|
||||
return this->regex_.isValid();
|
||||
}
|
||||
|
||||
bool IgnorePhrase::isMatch(const QString &subject) const
|
||||
{
|
||||
return !this->pattern_.isEmpty() &&
|
||||
(this->isRegex()
|
||||
? (this->regex_.isValid() &&
|
||||
this->regex_.match(subject).hasMatch())
|
||||
: subject.contains(this->pattern_, this->caseSensitivity()));
|
||||
}
|
||||
|
||||
const QRegularExpression &IgnorePhrase::getRegex() const
|
||||
{
|
||||
return this->regex_;
|
||||
}
|
||||
|
||||
bool IgnorePhrase::isBlock() const
|
||||
{
|
||||
return this->isBlock_;
|
||||
}
|
||||
|
||||
const QString &IgnorePhrase::getReplace() const
|
||||
{
|
||||
return this->replace_;
|
||||
}
|
||||
|
||||
bool IgnorePhrase::isCaseSensitive() const
|
||||
{
|
||||
return this->isCaseSensitive_;
|
||||
}
|
||||
|
||||
Qt::CaseSensitivity IgnorePhrase::caseSensitivity() const
|
||||
{
|
||||
return this->isCaseSensitive_ ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||
}
|
||||
|
||||
const std::unordered_map<EmoteName, EmotePtr> &IgnorePhrase::getEmotes() const
|
||||
{
|
||||
return this->emotes_;
|
||||
}
|
||||
|
||||
bool IgnorePhrase::containsEmote() const
|
||||
{
|
||||
if (!this->emotesChecked_)
|
||||
{
|
||||
const auto &accvec = getApp()->accounts->twitch.accounts;
|
||||
for (const auto &acc : accvec)
|
||||
{
|
||||
const auto &accemotes = *acc->accessEmotes();
|
||||
for (const auto &emote : accemotes.emotes)
|
||||
{
|
||||
if (this->replace_.contains(emote.first.string,
|
||||
Qt::CaseSensitive))
|
||||
{
|
||||
this->emotes_.emplace(emote.first, emote.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->emotesChecked_ = true;
|
||||
}
|
||||
return !this->emotes_.empty();
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "controllers/accounts/AccountController.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "singletons/Settings.hpp"
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
@@ -10,118 +9,39 @@
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class IgnorePhrase
|
||||
{
|
||||
public:
|
||||
bool operator==(const IgnorePhrase &other) const
|
||||
{
|
||||
return std::tie(this->pattern_, this->isRegex_, this->isBlock_,
|
||||
this->replace_, this->isCaseSensitive_) ==
|
||||
std::tie(other.pattern_, other.isRegex_, other.isBlock_,
|
||||
other.replace_, other.isCaseSensitive_);
|
||||
}
|
||||
|
||||
IgnorePhrase(const QString &pattern, bool isRegex, bool isBlock,
|
||||
const QString &replace, bool isCaseSensitive)
|
||||
: pattern_(pattern)
|
||||
, isRegex_(isRegex)
|
||||
, regex_(pattern)
|
||||
, isBlock_(isBlock)
|
||||
, replace_(replace)
|
||||
, isCaseSensitive_(isCaseSensitive)
|
||||
{
|
||||
if (this->isCaseSensitive_)
|
||||
{
|
||||
regex_.setPatternOptions(
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
}
|
||||
else
|
||||
{
|
||||
regex_.setPatternOptions(
|
||||
QRegularExpression::CaseInsensitiveOption |
|
||||
QRegularExpression::UseUnicodePropertiesOption);
|
||||
}
|
||||
}
|
||||
const QString &replace, bool isCaseSensitive);
|
||||
|
||||
const QString &getPattern() const
|
||||
{
|
||||
return this->pattern_;
|
||||
}
|
||||
bool operator==(const IgnorePhrase &other) const;
|
||||
|
||||
bool isRegex() const
|
||||
{
|
||||
return this->isRegex_;
|
||||
}
|
||||
const QString &getPattern() const;
|
||||
|
||||
bool isRegexValid() const
|
||||
{
|
||||
return this->regex_.isValid();
|
||||
}
|
||||
bool isRegex() const;
|
||||
|
||||
bool isMatch(const QString &subject) const
|
||||
{
|
||||
return !this->pattern_.isEmpty() &&
|
||||
(this->isRegex() ? (this->regex_.isValid() &&
|
||||
this->regex_.match(subject).hasMatch())
|
||||
: subject.contains(this->pattern_,
|
||||
this->caseSensitivity()));
|
||||
}
|
||||
bool isRegexValid() const;
|
||||
|
||||
const QRegularExpression &getRegex() const
|
||||
{
|
||||
return this->regex_;
|
||||
}
|
||||
bool isMatch(const QString &subject) const;
|
||||
|
||||
bool isBlock() const
|
||||
{
|
||||
return this->isBlock_;
|
||||
}
|
||||
const QRegularExpression &getRegex() const;
|
||||
|
||||
const QString &getReplace() const
|
||||
{
|
||||
return this->replace_;
|
||||
}
|
||||
bool isBlock() const;
|
||||
|
||||
bool isCaseSensitive() const
|
||||
{
|
||||
return this->isCaseSensitive_;
|
||||
}
|
||||
const QString &getReplace() const;
|
||||
|
||||
Qt::CaseSensitivity caseSensitivity() const
|
||||
{
|
||||
return this->isCaseSensitive_ ? Qt::CaseSensitive : Qt::CaseInsensitive;
|
||||
}
|
||||
bool isCaseSensitive() const;
|
||||
|
||||
const std::unordered_map<EmoteName, EmotePtr> &getEmotes() const
|
||||
{
|
||||
return this->emotes_;
|
||||
}
|
||||
Qt::CaseSensitivity caseSensitivity() const;
|
||||
|
||||
bool containsEmote() const
|
||||
{
|
||||
if (!this->emotesChecked_)
|
||||
{
|
||||
const auto &accvec = getApp()->accounts->twitch.accounts;
|
||||
for (const auto &acc : accvec)
|
||||
{
|
||||
const auto &accemotes = *acc->accessEmotes();
|
||||
for (const auto &emote : accemotes.emotes)
|
||||
{
|
||||
if (this->replace_.contains(emote.first.string,
|
||||
Qt::CaseSensitive))
|
||||
{
|
||||
this->emotes_.emplace(emote.first, emote.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->emotesChecked_ = true;
|
||||
}
|
||||
return !this->emotes_.empty();
|
||||
}
|
||||
const std::unordered_map<EmoteName, EmotePtr> &getEmotes() const;
|
||||
|
||||
bool containsEmote() const;
|
||||
|
||||
private:
|
||||
QString pattern_;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "util/RapidJsonSerializeQString.hpp"
|
||||
|
||||
#include <pajlada/serialize.hpp>
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
|
||||
Reference in New Issue
Block a user