Added more functionality and clickable deny and accept buttons that don't do anything, this also fixes the issue with the background not working properly
This commit is contained in:
@@ -113,6 +113,8 @@ struct AutomodAction : PubSubAction {
|
||||
QString message;
|
||||
|
||||
QString reason;
|
||||
|
||||
QString msgID;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -532,6 +532,8 @@ PubSub::PubSub()
|
||||
try
|
||||
{
|
||||
const auto &args = getArgs(data);
|
||||
const auto &msgID = getMsgID(data);
|
||||
// qDebug() << QString::fromStdString(rj::stringify(data));
|
||||
|
||||
if (args.Size() < 1)
|
||||
{
|
||||
@@ -559,6 +561,11 @@ PubSub::PubSub()
|
||||
}
|
||||
}
|
||||
|
||||
if (!rj::getSafe(msgID, action.msgID))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->signals_.moderation.automodMessage.invoke(action);
|
||||
}
|
||||
catch (const std::runtime_error &ex)
|
||||
@@ -624,7 +631,7 @@ PubSub::PubSub()
|
||||
|
||||
// Add an initial client
|
||||
this->addClient();
|
||||
}
|
||||
} // namespace chatterino
|
||||
|
||||
void PubSub::addClient()
|
||||
{
|
||||
|
||||
@@ -23,6 +23,18 @@ const rapidjson::Value &getArgs(const rapidjson::Value &data)
|
||||
return args;
|
||||
}
|
||||
|
||||
const rapidjson::Value &getMsgID(const rapidjson::Value &data)
|
||||
{
|
||||
if (!data.HasMember("msg_id"))
|
||||
{
|
||||
throw std::runtime_error("Missing member msg_id");
|
||||
}
|
||||
|
||||
const auto &msgID = data["msg_id"];
|
||||
|
||||
return msgID;
|
||||
}
|
||||
|
||||
bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user)
|
||||
{
|
||||
return rj::getSafe(data, "created_by", user.name) &&
|
||||
|
||||
@@ -12,6 +12,7 @@ class TwitchAccount;
|
||||
struct ActionUser;
|
||||
|
||||
const rapidjson::Value &getArgs(const rapidjson::Value &data);
|
||||
const rapidjson::Value &getMsgID(const rapidjson::Value &data);
|
||||
|
||||
bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user);
|
||||
|
||||
|
||||
@@ -413,6 +413,8 @@ AccessGuard<const TwitchAccount::TwitchAccountEmoteData>
|
||||
return this->emotes_.accessConst();
|
||||
}
|
||||
|
||||
// AutoModActions
|
||||
|
||||
void TwitchAccount::parseEmotes(const rapidjson::Document &root)
|
||||
{
|
||||
auto emoteData = this->emotes_.access();
|
||||
|
||||
@@ -108,6 +108,12 @@ public:
|
||||
void loadEmotes();
|
||||
AccessGuard<const TwitchAccountEmoteData> accessEmotes() const;
|
||||
|
||||
// Automod actions
|
||||
void autoModAllow(const QString msgID,
|
||||
std::function<void()> successCallback);
|
||||
void autoModDeny(const QString msgID,
|
||||
std::function<void()> successCallback);
|
||||
|
||||
private:
|
||||
void parseEmotes(const rapidjson::Document &document);
|
||||
void loadEmoteSetData(std::shared_ptr<EmoteSet> emoteSet);
|
||||
|
||||
Reference in New Issue
Block a user