Implement simple ignored phrase system
This commit is contained in:
@@ -19,7 +19,6 @@ void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> set
|
||||
}
|
||||
|
||||
SettingManager::SettingManager()
|
||||
: _ignoredKeywords(new std::vector<QString>)
|
||||
{
|
||||
qDebug() << "init SettingManager";
|
||||
|
||||
@@ -37,7 +36,6 @@ SettingManager::SettingManager()
|
||||
void SettingManager::initialize()
|
||||
{
|
||||
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
|
||||
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
|
||||
|
||||
this->timestampFormat.connect([](auto, auto) {
|
||||
auto app = getApp();
|
||||
@@ -151,11 +149,6 @@ std::vector<ModerationAction> SettingManager::getModerationActions() const
|
||||
return this->_moderationActions;
|
||||
}
|
||||
|
||||
const std::shared_ptr<std::vector<QString>> SettingManager::getIgnoredKeywords() const
|
||||
{
|
||||
return this->_ignoredKeywords;
|
||||
}
|
||||
|
||||
void SettingManager::updateModerationActions()
|
||||
{
|
||||
auto app = getApp();
|
||||
@@ -224,21 +217,5 @@ void SettingManager::updateModerationActions()
|
||||
}
|
||||
}
|
||||
|
||||
void SettingManager::updateIgnoredKeywords()
|
||||
{
|
||||
static QRegularExpression newLineRegex("(\r\n?|\n)+");
|
||||
|
||||
auto items = new std::vector<QString>();
|
||||
|
||||
for (const QString &line : this->ignoredKeywords.getValue().split(newLineRegex)) {
|
||||
QString line2 = line.trimmed();
|
||||
|
||||
if (!line2.isEmpty()) {
|
||||
items->push_back(line2);
|
||||
}
|
||||
}
|
||||
|
||||
this->_ignoredKeywords = std::shared_ptr<std::vector<QString>>(items);
|
||||
}
|
||||
} // namespace singletons
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -86,7 +86,6 @@ public:
|
||||
|
||||
/// Ingored Users
|
||||
BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers", true};
|
||||
QStringSetting ignoredKeywords = {"/ignore/ignoredKeywords", ""};
|
||||
|
||||
/// Moderation
|
||||
QStringSetting moderationActions = {"/moderation/actions", "/ban {user}\n/timeout {user} 300"};
|
||||
@@ -123,16 +122,13 @@ public:
|
||||
void recallSnapshot();
|
||||
|
||||
std::vector<ModerationAction> getModerationActions() const;
|
||||
const std::shared_ptr<std::vector<QString>> getIgnoredKeywords() const;
|
||||
pajlada::Signals::NoArgSignal wordFlagsChanged;
|
||||
|
||||
private:
|
||||
std::vector<ModerationAction> _moderationActions;
|
||||
std::unique_ptr<rapidjson::Document> snapshot;
|
||||
std::shared_ptr<std::vector<QString>> _ignoredKeywords;
|
||||
|
||||
void updateModerationActions();
|
||||
void updateIgnoredKeywords();
|
||||
|
||||
messages::MessageElement::Flags wordFlags = messages::MessageElement::Default;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user