mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Added a bunch of stuff, we now collect all the pubsub automod messages and also displays a caught message to a mod
This commit is contained in:
parent
ae18f35dfb
commit
0b2480d715
12 changed files with 249 additions and 79 deletions
|
@ -1,6 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>chatterino2.icns</file>
|
||||
<qresource prefix="/"> <file>chatterino2.icns</file>
|
||||
<file>contributors.txt</file>
|
||||
<file>emoji.json</file>
|
||||
<file>emojidata.txt</file>
|
||||
|
@ -45,9 +44,16 @@
|
|||
<file>settings/about.svg</file>
|
||||
<file>settings/aboutlogo.png</file>
|
||||
<file>settings/accounts.svg</file>
|
||||
<file>settings/advanced.svg</file>
|
||||
<file>settings/behave.svg</file>
|
||||
<file>settings/browser.svg</file>
|
||||
<file>settings/commands.svg</file>
|
||||
<file>settings/emote.svg</file>
|
||||
<file>settings/externaltools.svg</file>
|
||||
<file>settings/ignore.svg</file>
|
||||
<file>settings/keybinds.svg</file>
|
||||
<file>settings/moderation.svg</file>
|
||||
<file>settings/notification2.svg</file>
|
||||
<file>settings/notifications.svg</file>
|
||||
<file>settings/theme.svg</file>
|
||||
<file>sounds/ping2.wav</file>
|
||||
|
@ -57,6 +63,7 @@
|
|||
<file>split/right.png</file>
|
||||
<file>split/up.png</file>
|
||||
<file>twitch/admin.png</file>
|
||||
<file>twitch/automod.png</file>
|
||||
<file>twitch/broadcaster.png</file>
|
||||
<file>twitch/cheer1.png</file>
|
||||
<file>twitch/globalmod.png</file>
|
||||
|
@ -66,12 +73,5 @@
|
|||
<file>twitch/subscriber.png</file>
|
||||
<file>twitch/turbo.png</file>
|
||||
<file>twitch/verified.png</file>
|
||||
<file>settings/ignore.svg</file>
|
||||
<file>settings/keybinds.svg</file>
|
||||
<file>settings/moderation.svg</file>
|
||||
<file>settings/notification2.svg</file>
|
||||
<file>settings/browser.svg</file>
|
||||
<file>settings/externaltools.svg</file>
|
||||
<file>settings/advanced.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
resources/twitch/automod.png
Normal file
BIN
resources/twitch/automod.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 305 B |
|
@ -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 = [=]() {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -28,6 +28,7 @@ enum class MessageFlag : uint16_t {
|
|||
PubSub = (1 << 11),
|
||||
Subscription = (1 << 12),
|
||||
Notification = (1 << 13),
|
||||
AutoMod = (1 << 14),
|
||||
};
|
||||
using MessageFlags = FlagsEnum<MessageFlag>;
|
||||
|
||||
|
|
|
@ -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 <QDateTime>
|
||||
//#include <QImageReader>
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
|
@ -19,6 +22,48 @@ MessagePtr makeSystemMessage(const QString &text)
|
|||
return MessageBuilder(systemMessage, text).release();
|
||||
}
|
||||
|
||||
std::pair<MessagePtr, MessagePtr> makeAutomodMessage(
|
||||
const AutomodAction &action)
|
||||
{
|
||||
auto builder = MessageBuilder();
|
||||
|
||||
builder.emplace<TimestampElement>();
|
||||
builder.message().flags.set(MessageFlag::PubSub);
|
||||
|
||||
// Crashes the program atm
|
||||
// builder.emplace<ImageElement>(
|
||||
// Image::fromPixmap(getApp()->resources->twitch.automod),
|
||||
// MessageElementFlag::BadgeChannelAuthority)
|
||||
// ->setTooltip("AutoMod");
|
||||
builder.emplace<TextElement>(
|
||||
"AutoMod:", MessageElementFlag::NonBoldUsername,
|
||||
MessageColor(QColor("green")));
|
||||
builder.emplace<TextElement>(
|
||||
("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<TimestampElement>();
|
||||
builder.message().flags.set(MessageFlag::PubSub);
|
||||
|
||||
builder
|
||||
.emplace<TextElement>(action.target.name + ":",
|
||||
MessageElementFlag::NonBoldUsername,
|
||||
MessageColor(QColor("red")))
|
||||
->setLink({Link::UserInfo, action.target.name});
|
||||
builder.emplace<TextElement>(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<Message>())
|
||||
{
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
#include <QRegularExpression>
|
||||
#include <ctime>
|
||||
#include <utility>
|
||||
|
||||
namespace chatterino {
|
||||
struct BanAction;
|
||||
struct UnbanAction;
|
||||
struct AutomodAction;
|
||||
struct Message;
|
||||
using MessagePtr = std::shared_ptr<const Message>;
|
||||
|
||||
|
@ -19,6 +21,8 @@ const SystemMessageTag systemMessage{};
|
|||
const TimeoutMessageTag timeoutMessage{};
|
||||
|
||||
MessagePtr makeSystemMessage(const QString &text);
|
||||
std::pair<MessagePtr, MessagePtr> 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> message_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -105,4 +105,14 @@ struct ModerationStateAction : PubSubAction {
|
|||
bool modded;
|
||||
};
|
||||
|
||||
struct AutomodAction : PubSubAction {
|
||||
using PubSubAction::PubSubAction;
|
||||
|
||||
ActionUser target;
|
||||
|
||||
QString message;
|
||||
|
||||
QString reason;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -112,6 +112,8 @@ public:
|
|||
|
||||
Signal<BanAction> userBanned;
|
||||
Signal<UnbanAction> userUnbanned;
|
||||
|
||||
Signal<AutomodAction> automodMessage;
|
||||
} moderation;
|
||||
|
||||
struct {
|
||||
|
|
Loading…
Reference in a new issue