removed functions from SettingsManager that shouldn't be there
This commit is contained in:
@@ -152,7 +152,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
if (commandName == "/debug-args") {
|
||||
QString msg = QApplication::instance()->arguments().join(' ');
|
||||
|
||||
channel->addMessage(chatterino::Message::createSystemMessage(msg));
|
||||
channel->addMessage(Message::createSystemMessage(msg));
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/uptime") {
|
||||
@@ -161,7 +161,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
QString messageText =
|
||||
streamStatus.live ? streamStatus.uptime : "Channel is not live.";
|
||||
|
||||
channel->addMessage(chatterino::Message::createSystemMessage(messageText));
|
||||
channel->addMessage(Message::createSystemMessage(messageText));
|
||||
|
||||
return "";
|
||||
} else if (commandName == "/ignore" && words.size() >= 2) {
|
||||
@@ -171,13 +171,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(chatterino::Message::createSystemMessage(
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You must be logged in to ignore someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
user->ignore(target, [channel](auto resultCode, const QString &message) {
|
||||
channel->addMessage(chatterino::Message::createSystemMessage(message));
|
||||
channel->addMessage(Message::createSystemMessage(message));
|
||||
});
|
||||
|
||||
return "";
|
||||
@@ -188,13 +188,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel,
|
||||
auto target = words.at(1);
|
||||
|
||||
if (user->isAnon()) {
|
||||
channel->addMessage(chatterino::Message::createSystemMessage(
|
||||
channel->addMessage(Message::createSystemMessage(
|
||||
"You must be logged in to ignore someone"));
|
||||
return "";
|
||||
}
|
||||
|
||||
user->unignore(target, [channel](auto resultCode, const QString &message) {
|
||||
channel->addMessage(chatterino::Message::createSystemMessage(message));
|
||||
channel->addMessage(Message::createSystemMessage(message));
|
||||
});
|
||||
|
||||
return "";
|
||||
|
||||
@@ -32,7 +32,7 @@ HighlightModel *HighlightController::createModel(QObject *parent)
|
||||
return model;
|
||||
}
|
||||
|
||||
void HighlightController::addHighlight(const chatterino::MessagePtr &msg)
|
||||
void HighlightController::addHighlight(const MessagePtr &msg)
|
||||
{
|
||||
// static NotificationPopup popup;
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ public:
|
||||
|
||||
HighlightModel *createModel(QObject *parent);
|
||||
|
||||
void addHighlight(const chatterino::MessagePtr &msg);
|
||||
void addHighlight(const MessagePtr &msg);
|
||||
|
||||
private:
|
||||
bool initialized = false;
|
||||
|
||||
chatterino::ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting = {
|
||||
ChatterinoSetting<std::vector<HighlightPhrase>> highlightsSetting = {
|
||||
"/highlighting/highlights"};
|
||||
};
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
private:
|
||||
bool initialized = false;
|
||||
|
||||
chatterino::ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting = {"/ignore/phrases"};
|
||||
ChatterinoSetting<std::vector<IgnorePhrase>> ignoresSetting = {"/ignore/phrases"};
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
#include "ModerationAction.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "singletons/ResourceManager.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// ModerationAction::ModerationAction(Image *_image, const QString &_action)
|
||||
// : _isImage(true)
|
||||
// , image(_image)
|
||||
// , action(_action)
|
||||
//{
|
||||
//}
|
||||
|
||||
// ModerationAction::ModerationAction(const QString &_line1, const QString &_line2,
|
||||
// const QString &_action)
|
||||
// : _isImage(false)
|
||||
// , image(nullptr)
|
||||
// , line1(_line1)
|
||||
// , line2(_line2)
|
||||
// , action(_action)
|
||||
//{
|
||||
//}
|
||||
|
||||
ModerationAction::ModerationAction(const QString &action)
|
||||
: action_(action)
|
||||
{
|
||||
static QRegularExpression replaceRegex("[!/.]");
|
||||
static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)");
|
||||
|
||||
auto timeoutMatch = timeoutRegex.match(action);
|
||||
|
||||
if (timeoutMatch.hasMatch()) {
|
||||
// if (multipleTimeouts > 1) {
|
||||
QString line1;
|
||||
QString line2;
|
||||
|
||||
int amount = timeoutMatch.captured(1).toInt();
|
||||
|
||||
if (amount < 60) {
|
||||
this->line1_ = QString::number(amount);
|
||||
this->line2_ = "s";
|
||||
} else if (amount < 60 * 60) {
|
||||
this->line1_ = QString::number(amount / 60);
|
||||
this->line2_ = "m";
|
||||
} else if (amount < 60 * 60 * 24) {
|
||||
this->line1_ = QString::number(amount / 60 / 60);
|
||||
this->line2_ = "h";
|
||||
} else {
|
||||
this->line1_ = QString::number(amount / 60 / 60 / 24);
|
||||
this->line2_ = "d";
|
||||
}
|
||||
|
||||
this->line1_ = line1;
|
||||
this->line2_ = line2;
|
||||
// } else {
|
||||
// this->_moderationActions.emplace_back(app->resources->buttonTimeout, str);
|
||||
// }
|
||||
} else if (action.startsWith("/ban ")) {
|
||||
this->image_ = getApp()->resources->buttonBan;
|
||||
} else {
|
||||
QString xD = action;
|
||||
|
||||
xD.replace(replaceRegex, "");
|
||||
|
||||
this->line1_ = xD.mid(0, 2);
|
||||
this->line2_ = xD.mid(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
bool ModerationAction::operator==(const ModerationAction &other) const
|
||||
{
|
||||
return this == std::addressof(other);
|
||||
}
|
||||
|
||||
bool ModerationAction::isImage() const
|
||||
{
|
||||
return this->image_ != nullptr;
|
||||
}
|
||||
|
||||
Image *ModerationAction::getImage() const
|
||||
{
|
||||
return this->image_;
|
||||
}
|
||||
|
||||
const QString &ModerationAction::getLine1() const
|
||||
{
|
||||
return this->line1_;
|
||||
}
|
||||
|
||||
const QString &ModerationAction::getLine2() const
|
||||
{
|
||||
return this->line2_;
|
||||
}
|
||||
|
||||
const QString &ModerationAction::getAction() const
|
||||
{
|
||||
return this->action_;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <pajlada/settings/serialize.hpp>
|
||||
|
||||
#include "util/RapidjsonHelpers.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class Image;
|
||||
|
||||
class ModerationAction
|
||||
{
|
||||
public:
|
||||
ModerationAction(const QString &action_);
|
||||
|
||||
bool operator==(const ModerationAction &other) const;
|
||||
|
||||
bool isImage() const;
|
||||
Image *getImage() const;
|
||||
const QString &getLine1() const;
|
||||
const QString &getLine2() const;
|
||||
const QString &getAction() const;
|
||||
|
||||
private:
|
||||
bool isImage_;
|
||||
Image *image_;
|
||||
QString line1_;
|
||||
QString line2_;
|
||||
QString action_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
namespace pajlada {
|
||||
namespace Settings {
|
||||
|
||||
template <>
|
||||
struct Serialize<chatterino::ModerationAction> {
|
||||
static rapidjson::Value get(const chatterino::ModerationAction &value,
|
||||
rapidjson::Document::AllocatorType &a)
|
||||
{
|
||||
rapidjson::Value ret(rapidjson::kObjectType);
|
||||
|
||||
AddMember(ret, "pattern", value.getAction(), a);
|
||||
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Deserialize<chatterino::ModerationAction> {
|
||||
static chatterino::ModerationAction get(const rapidjson::Value &value)
|
||||
{
|
||||
if (!value.IsObject()) {
|
||||
return chatterino::ModerationAction(QString());
|
||||
}
|
||||
|
||||
QString pattern;
|
||||
|
||||
chatterino::rj::getSafe(value, "pattern", pattern);
|
||||
|
||||
return chatterino::ModerationAction(pattern);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Settings
|
||||
} // namespace pajlada
|
||||
@@ -0,0 +1,28 @@
|
||||
#include "ModerationActions.hpp"
|
||||
|
||||
#include "Application.hpp"
|
||||
#include "singletons/SettingsManager.hpp"
|
||||
|
||||
#include <QRegularExpression>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
ModerationActions::ModerationActions()
|
||||
{
|
||||
}
|
||||
|
||||
void ModerationActions::initialize()
|
||||
{
|
||||
assert(!this->initialized);
|
||||
this->initialized = true;
|
||||
|
||||
for (auto &val : this->setting.getValue()) {
|
||||
this->items.insertItem(val);
|
||||
}
|
||||
|
||||
this->items.delayedItemsChanged.connect([this] { //
|
||||
this->setting.setValue(this->items.getVector());
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include "common/SignalVector2.hpp"
|
||||
#include "controllers/moderationactions/ModerationAction.hpp"
|
||||
#include "singletons/helper/ChatterinoSetting.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
class ModerationActions
|
||||
{
|
||||
public:
|
||||
ModerationActions();
|
||||
|
||||
void initialize();
|
||||
|
||||
UnsortedSignalVector<ModerationAction> items;
|
||||
|
||||
private:
|
||||
ChatterinoSetting<std::vector<ModerationAction>> setting = {"/moderation/actions"};
|
||||
bool initialized = false;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
Reference in New Issue
Block a user