diff --git a/resources/resources_autogenerated.qrc b/resources/resources_autogenerated.qrc
index 9ec2b2a0a..fcf0b5dac 100644
--- a/resources/resources_autogenerated.qrc
+++ b/resources/resources_autogenerated.qrc
@@ -1,77 +1,77 @@
-
- chatterino2.icns
- contributors.txt
- emoji.json
- emojidata.txt
- error.png
- icon.ico
- icon.png
- pajaDank.png
- tlds.txt
- avatars/fourtf.png
- avatars/pajlada.png
- buttons/addSplit.png
- buttons/addSplitDark.png
- buttons/ban.png
- buttons/banRed.png
- buttons/emote.svg
- buttons/emoteDark.svg
- buttons/menuDark.png
- buttons/menuLight.png
- buttons/mod.png
- buttons/modModeDisabled.png
- buttons/modModeDisabled2.png
- buttons/modModeEnabled.png
- buttons/modModeEnabled2.png
- buttons/timeout.png
- buttons/unban.png
- buttons/unmod.png
- buttons/update.png
- buttons/updateError.png
- examples/moving.gif
- examples/splitting.gif
- licenses/boost_boost.txt
- licenses/emoji-data-source.txt
- licenses/fmt_bsd2.txt
- licenses/libcommuni_BSD3.txt
- licenses/openssl.txt
- licenses/pajlada_settings.txt
- licenses/pajlada_signals.txt
- licenses/qt_lgpl-3.0.txt
- licenses/rapidjson.txt
- licenses/websocketpp.txt
- qss/settings.qss
- settings/about.svg
- settings/aboutlogo.png
- settings/accounts.svg
- settings/behave.svg
- settings/commands.svg
- settings/emote.svg
- settings/notifications.svg
- settings/theme.svg
- sounds/ping2.wav
- split/down.png
- split/left.png
- split/move.png
- split/right.png
- split/up.png
- twitch/admin.png
- twitch/broadcaster.png
- twitch/cheer1.png
- twitch/globalmod.png
- twitch/moderator.png
- twitch/prime.png
- twitch/staff.png
- twitch/subscriber.png
- twitch/turbo.png
- twitch/verified.png
- settings/ignore.svg
- settings/keybinds.svg
- settings/moderation.svg
- settings/notification2.svg
- settings/browser.svg
- settings/externaltools.svg
- settings/advanced.svg
-
-
+ chatterino2.icns
+ contributors.txt
+ emoji.json
+ emojidata.txt
+ error.png
+ icon.ico
+ icon.png
+ pajaDank.png
+ tlds.txt
+ avatars/fourtf.png
+ avatars/pajlada.png
+ buttons/addSplit.png
+ buttons/addSplitDark.png
+ buttons/ban.png
+ buttons/banRed.png
+ buttons/emote.svg
+ buttons/emoteDark.svg
+ buttons/menuDark.png
+ buttons/menuLight.png
+ buttons/mod.png
+ buttons/modModeDisabled.png
+ buttons/modModeDisabled2.png
+ buttons/modModeEnabled.png
+ buttons/modModeEnabled2.png
+ buttons/timeout.png
+ buttons/unban.png
+ buttons/unmod.png
+ buttons/update.png
+ buttons/updateError.png
+ examples/moving.gif
+ examples/splitting.gif
+ licenses/boost_boost.txt
+ licenses/emoji-data-source.txt
+ licenses/fmt_bsd2.txt
+ licenses/libcommuni_BSD3.txt
+ licenses/openssl.txt
+ licenses/pajlada_settings.txt
+ licenses/pajlada_signals.txt
+ licenses/qt_lgpl-3.0.txt
+ licenses/rapidjson.txt
+ licenses/websocketpp.txt
+ qss/settings.qss
+ settings/about.svg
+ settings/aboutlogo.png
+ settings/accounts.svg
+ settings/advanced.svg
+ settings/behave.svg
+ settings/browser.svg
+ settings/commands.svg
+ settings/emote.svg
+ settings/externaltools.svg
+ settings/ignore.svg
+ settings/keybinds.svg
+ settings/moderation.svg
+ settings/notification2.svg
+ settings/notifications.svg
+ settings/theme.svg
+ sounds/ping2.wav
+ split/down.png
+ split/left.png
+ split/move.png
+ split/right.png
+ split/up.png
+ twitch/admin.png
+ twitch/automod.png
+ twitch/broadcaster.png
+ twitch/cheer1.png
+ twitch/globalmod.png
+ twitch/moderator.png
+ twitch/prime.png
+ twitch/staff.png
+ twitch/subscriber.png
+ twitch/turbo.png
+ twitch/verified.png
+
+
\ No newline at end of file
diff --git a/resources/twitch/automod.png b/resources/twitch/automod.png
new file mode 100644
index 000000000..01174644f
Binary files /dev/null and b/resources/twitch/automod.png differ
diff --git a/src/Application.cpp b/src/Application.cpp
index 107f0b05f..23d983fd5 100644
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -234,6 +234,24 @@ void Application::initPubsub()
postToThread([chan, msg] { chan->addMessage(msg); });
});
+ this->twitch.pubsub->signals_.moderation.automodMessage.connect(
+ [&](const auto &action) {
+ auto chan =
+ this->twitch.server->getChannelOrEmptyByID(action.roomID);
+
+ if (chan->isEmpty())
+ {
+ return;
+ }
+
+ auto p = makeAutomodMessage(action);
+
+ postToThread([chan, p] {
+ chan->addMessage(p.first);
+ chan->addMessage(p.second);
+ });
+ });
+
this->twitch.pubsub->start();
auto RequestModerationActions = [=]() {
diff --git a/src/autogenerated/ResourcesAutogen.cpp b/src/autogenerated/ResourcesAutogen.cpp
index ee25daf1f..34cf039ef 100644
--- a/src/autogenerated/ResourcesAutogen.cpp
+++ b/src/autogenerated/ResourcesAutogen.cpp
@@ -32,6 +32,7 @@ Resources2::Resources2()
this->split.right = QPixmap(":/split/right.png");
this->split.up = QPixmap(":/split/up.png");
this->twitch.admin = QPixmap(":/twitch/admin.png");
+ this->twitch.automod = QPixmap(":/twitch/automod.png");
this->twitch.broadcaster = QPixmap(":/twitch/broadcaster.png");
this->twitch.cheer1 = QPixmap(":/twitch/cheer1.png");
this->twitch.globalmod = QPixmap(":/twitch/globalmod.png");
diff --git a/src/autogenerated/ResourcesAutogen.hpp b/src/autogenerated/ResourcesAutogen.hpp
index 075c801eb..fbbb2fbf3 100644
--- a/src/autogenerated/ResourcesAutogen.hpp
+++ b/src/autogenerated/ResourcesAutogen.hpp
@@ -3,8 +3,7 @@
namespace chatterino {
-class Resources2 : public Singleton
-{
+class Resources2 : public Singleton {
public:
Resources2();
@@ -45,6 +44,7 @@ public:
} split;
struct {
QPixmap admin;
+ QPixmap automod;
QPixmap broadcaster;
QPixmap cheer1;
QPixmap globalmod;
diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp
index cc716dd2f..572615a04 100644
--- a/src/messages/Message.hpp
+++ b/src/messages/Message.hpp
@@ -28,6 +28,7 @@ enum class MessageFlag : uint16_t {
PubSub = (1 << 11),
Subscription = (1 << 12),
Notification = (1 << 13),
+ AutoMod = (1 << 14),
};
using MessageFlags = FlagsEnum;
diff --git a/src/messages/MessageBuilder.cpp b/src/messages/MessageBuilder.cpp
index 7ea91fcfa..f2e8bae86 100644
--- a/src/messages/MessageBuilder.cpp
+++ b/src/messages/MessageBuilder.cpp
@@ -1,6 +1,8 @@
#include "MessageBuilder.hpp"
+//#include "Application.hpp"
#include "common/LinkParser.hpp"
+//#include "messages/Image.hpp"
#include "messages/Message.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/PubsubActions.hpp"
@@ -11,6 +13,7 @@
#include "util/IrcHelpers.hpp"
#include
+//#include
namespace chatterino {
@@ -19,6 +22,48 @@ MessagePtr makeSystemMessage(const QString &text)
return MessageBuilder(systemMessage, text).release();
}
+std::pair makeAutomodMessage(
+ const AutomodAction &action)
+{
+ auto builder = MessageBuilder();
+
+ builder.emplace();
+ builder.message().flags.set(MessageFlag::PubSub);
+
+ // Crashes the program atm
+ // builder.emplace(
+ // Image::fromPixmap(getApp()->resources->twitch.automod),
+ // MessageElementFlag::BadgeChannelAuthority)
+ // ->setTooltip("AutoMod");
+ builder.emplace(
+ "AutoMod:", MessageElementFlag::NonBoldUsername,
+ MessageColor(QColor("green")));
+ builder.emplace(
+ ("Held a message for reason: " + action.reason +
+ ". Allow will post it in chat."),
+ MessageElementFlag::Text, MessageColor::Text);
+ builder.message().flags.set(MessageFlag::AutoMod);
+
+ auto message1 = builder.release();
+
+ builder = MessageBuilder();
+ builder.emplace();
+ builder.message().flags.set(MessageFlag::PubSub);
+
+ builder
+ .emplace(action.target.name + ":",
+ MessageElementFlag::NonBoldUsername,
+ MessageColor(QColor("red")))
+ ->setLink({Link::UserInfo, action.target.name});
+ builder.emplace(action.message, MessageElementFlag::Text,
+ MessageColor::Text);
+ builder.message().flags.set(MessageFlag::AutoMod);
+
+ auto message2 = builder.release();
+
+ return std::make_pair(message1, message2);
+}
+
MessageBuilder::MessageBuilder()
: message_(std::make_shared())
{
diff --git a/src/messages/MessageBuilder.hpp b/src/messages/MessageBuilder.hpp
index b09b82ed2..a0171cb2b 100644
--- a/src/messages/MessageBuilder.hpp
+++ b/src/messages/MessageBuilder.hpp
@@ -4,10 +4,12 @@
#include
#include
+#include
namespace chatterino {
struct BanAction;
struct UnbanAction;
+struct AutomodAction;
struct Message;
using MessagePtr = std::shared_ptr;
@@ -19,6 +21,8 @@ const SystemMessageTag systemMessage{};
const TimeoutMessageTag timeoutMessage{};
MessagePtr makeSystemMessage(const QString &text);
+std::pair makeAutomodMessage(
+ const AutomodAction &action);
struct MessageParseArgs {
bool disablePingSounds = false;
@@ -29,6 +33,7 @@ struct MessageParseArgs {
};
class MessageBuilder
+
{
public:
MessageBuilder();
@@ -63,5 +68,4 @@ public:
private:
std::shared_ptr message_;
};
-
} // namespace chatterino
diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp
index cf1be4a72..7137c9666 100644
--- a/src/messages/layouts/MessageLayout.cpp
+++ b/src/messages/layouts/MessageLayout.cpp
@@ -268,6 +268,10 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
{
backgroundColor = app->themes->messages.backgrounds.alternate;
}
+ else if (this->message_->flags.has(MessageFlag::AutoMod))
+ {
+ backgroundColor = app->themes->messages.backgrounds.automod;
+ }
painter.fillRect(buffer->rect(), backgroundColor);
diff --git a/src/providers/twitch/PubsubActions.hpp b/src/providers/twitch/PubsubActions.hpp
index 8b2bfecfb..bb116d937 100644
--- a/src/providers/twitch/PubsubActions.hpp
+++ b/src/providers/twitch/PubsubActions.hpp
@@ -105,4 +105,14 @@ struct ModerationStateAction : PubSubAction {
bool modded;
};
+struct AutomodAction : PubSubAction {
+ using PubSubAction::PubSubAction;
+
+ ActionUser target;
+
+ QString message;
+
+ QString reason;
+};
+
} // namespace chatterino
diff --git a/src/providers/twitch/PubsubClient.cpp b/src/providers/twitch/PubsubClient.cpp
index 6bc866700..50e7b0396 100644
--- a/src/providers/twitch/PubsubClient.cpp
+++ b/src/providers/twitch/PubsubClient.cpp
@@ -520,6 +520,91 @@ PubSub::PubSub()
}
};
+ this->moderationActionHandlers["automod_rejected"] =
+ [this](const auto &data, const auto &roomID) {
+ // Display the automod message and prompt the allow/deny
+ AutomodAction action(data, roomID);
+
+ getCreatedByUser(data, action.source);
+ getTargetUser(data, action.target);
+
+ qDebug() << "test1111";
+ try
+ {
+ const auto &args = getArgs(data);
+
+ if (args.Size() < 1)
+ {
+ return;
+ }
+
+ if (!rj::getSafe(args[0], action.target.name))
+ {
+ return;
+ }
+
+ if (args.Size() >= 2)
+ {
+ if (!rj::getSafe(args[1], action.message))
+ {
+ return;
+ }
+ }
+
+ if (args.Size() >= 3)
+ {
+ if (!rj::getSafe(args[2], action.reason))
+ {
+ return;
+ }
+ }
+
+ this->signals_.moderation.automodMessage.invoke(action);
+ }
+ catch (const std::runtime_error &ex)
+ {
+ log("Error parsing moderation action: {}", ex.what());
+ }
+ };
+
+ this->moderationActionHandlers["denied_automod_message"] =
+ [this](const auto &data, const auto &roomID) {
+ // This message got denied by a moderator
+ qDebug() << "test2222";
+ };
+
+ this->moderationActionHandlers["add_blocked_term"] =
+ [this](const auto &data, const auto &roomID) {
+ // A term has been added
+ qDebug() << "test3333";
+ };
+
+ this->moderationActionHandlers["approved_automod_message"] =
+ [this](const auto &data, const auto &roomID) {
+ // This message got approved by a moderator
+ qDebug() << "test5555";
+ };
+
+ this->moderationActionHandlers["add_permitted_term"] =
+ [this](const auto &data, const auto &roomID) {
+ // This term got a pass through automod
+ qDebug() << "test6666";
+ };
+ this->moderationActionHandlers["modified_automod_properties"] =
+ [this](const auto &data, const auto &roomID) {
+ // The automod settings got modified
+ qDebug() << "test4444";
+ };
+ this->moderationActionHandlers["delete_blocked_term"] =
+ [this](const auto &data, const auto &roomID) {
+ // This term got deleted
+ qDebug() << "test7777";
+ };
+ this->moderationActionHandlers["delete_permitted_term"] =
+ [this](const auto &data, const auto &roomID) {
+ // This term got deleted
+ qDebug() << "test8888";
+ };
this->websocketClient.set_access_channels(websocketpp::log::alevel::all);
this->websocketClient.clear_access_channels(
websocketpp::log::alevel::frame_payload);
diff --git a/src/providers/twitch/PubsubClient.hpp b/src/providers/twitch/PubsubClient.hpp
index f3cc10f15..403abcaaa 100644
--- a/src/providers/twitch/PubsubClient.hpp
+++ b/src/providers/twitch/PubsubClient.hpp
@@ -112,6 +112,8 @@ public:
Signal userBanned;
Signal userUnbanned;
+
+ Signal automodMessage;
} moderation;
struct {