Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add badges, emotes, and filters for suspicious messages #5060

Merged
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

- Major: Allow use of Twitch follower emotes in other channels if subscribed. (#4922)
- Major: Add `/automod` split to track automod caught messages across all open channels the user moderates. (#4986, #5026)
- Major: Show restricted chat messages and suspicious treatment updates. (#5056)
- Major: Show restricted chat messages and suspicious treatment updates. (#5056, #5060)
- Minor: Migrate to the new Get Channel Followers Helix endpoint, fixing follower count not showing up in usercards. (#4809)
- Minor: The account switcher is now styled to match your theme. (#4817)
- Minor: Add an invisible resize handle to the bottom of frameless user info popups and reply thread popups. (#4795)
Expand Down
16 changes: 12 additions & 4 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,20 @@ void Application::initPubSub()
return;
}

postToThread([chan, action] {
auto twitchChannel =
std::dynamic_pointer_cast<TwitchChannel>(chan);
if (!twitchChannel)
{
return;
}

postToThread([twitchChannel, action] {
const auto p =
TwitchMessageBuilder::makeLowTrustUserMessage(
action, chan->getName());
chan->addMessage(p.first);
chan->addMessage(p.second);
action, twitchChannel->getName(),
twitchChannel.get());
twitchChannel->addMessage(p.first);
twitchChannel->addMessage(p.second);
});
});

Expand Down
4 changes: 4 additions & 0 deletions src/controllers/filters/lang/Filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
* flags.whisper
* flags.reply
* flags.automod
* flags.restricted
* flags.monitored
*
* message.content
* message.length
Expand Down Expand Up @@ -101,6 +103,8 @@ ContextMap buildContextMap(const MessagePtr &m, chatterino::Channel *channel)
{"flags.whisper", m->flags.has(MessageFlag::Whisper)},
{"flags.reply", m->flags.has(MessageFlag::ReplyMessage)},
{"flags.automod", m->flags.has(MessageFlag::AutoMod)},
{"flags.restricted", m->flags.has(MessageFlag::RestrictedMessage)},
{"flags.monitored", m->flags.has(MessageFlag::MonitoredMessage)},
iProdigy marked this conversation as resolved.
Show resolved Hide resolved

{"message.content", m->messageText},
{"message.length", m->messageText.length()},
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/filters/lang/Filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ static const QMap<QString, Type> MESSAGE_TYPING_CONTEXT = {
{"flags.whisper", Type::Bool},
{"flags.reply", Type::Bool},
{"flags.automod", Type::Bool},
{"flags.restricted", Type::Bool},
{"flags.monitored", Type::Bool},
{"message.content", Type::String},
{"message.length", Type::Int},
};
Expand Down
2 changes: 2 additions & 0 deletions src/controllers/filters/lang/Tokenizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ static const QMap<QString, QString> validIdentifiersMap = {
{"flags.whisper", "whisper message?"},
{"flags.reply", "reply message?"},
{"flags.automod", "automod message?"},
{"flags.restricted", "restricted message?"},
{"flags.monitored", "monitored message?"},
{"message.content", "message text"},
{"message.length", "message length"}};

Expand Down
4 changes: 4 additions & 0 deletions src/messages/Message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ enum class MessageFlag : int64_t {
/// The message caught by AutoMod containing the user who sent the message & its contents
AutoModOffendingMessage = (1LL << 31),
LowTrustUsers = (1LL << 32),
/// The message is sent by a user marked as restricted with Twitch's "Low Trust"/"Suspicious User" feature
RestrictedMessage = (1LL << 33),
/// The message is sent by a user marked as monitor with Twitch's "Low Trust"/"Suspicious User" feature
MonitoredMessage = (1LL << 34),
};
using MessageFlags = FlagsEnum<MessageFlag>;

Expand Down
8 changes: 8 additions & 0 deletions src/messages/search/MessageFlagsPredicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ MessageFlagsPredicate::MessageFlagsPredicate(const QString &flags, bool negate)
{
this->flags_.set(MessageFlag::ReplyMessage);
}
else if (flag == "restricted")
{
this->flags_.set(MessageFlag::RestrictedMessage);
}
else if (flag == "monitored")
{
this->flags_.set(MessageFlag::MonitoredMessage);
}
}
}

Expand Down
Loading
Loading