-
-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
27 changed files
with
174 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.