mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat: indicate which mods start and cancel raids (#5563)
This commit is contained in:
parent
af309b726f
commit
956186d1a1
|
@ -27,6 +27,7 @@
|
||||||
- Minor: Links can now have prefixes and suffixes such as parentheses. (#5486, #5515)
|
- Minor: Links can now have prefixes and suffixes such as parentheses. (#5486, #5515)
|
||||||
- Minor: Added support for scrolling in splits with touchscreen panning gestures. (#5524)
|
- Minor: Added support for scrolling in splits with touchscreen panning gestures. (#5524)
|
||||||
- Minor: Removed experimental IRC support. (#5547)
|
- Minor: Removed experimental IRC support. (#5547)
|
||||||
|
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
|
||||||
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
|
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
|
||||||
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
|
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
|
||||||
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
||||||
|
|
|
@ -152,9 +152,8 @@ QString startRaid(const CommandContext &ctx)
|
||||||
channel{ctx.channel}](const HelixUser &targetUser) {
|
channel{ctx.channel}](const HelixUser &targetUser) {
|
||||||
getHelix()->startRaid(
|
getHelix()->startRaid(
|
||||||
twitchChannel->roomId(), targetUser.id,
|
twitchChannel->roomId(), targetUser.id,
|
||||||
[channel, targetUser] {
|
[] {
|
||||||
channel->addSystemMessage(QString("You started to raid %1.")
|
// do nothing
|
||||||
.arg(targetUser.displayName));
|
|
||||||
},
|
},
|
||||||
[channel, targetUser](auto error, auto message) {
|
[channel, targetUser](auto error, auto message) {
|
||||||
auto errorMessage = formatStartRaidError(error, message);
|
auto errorMessage = formatStartRaidError(error, message);
|
||||||
|
@ -202,8 +201,8 @@ QString cancelRaid(const CommandContext &ctx)
|
||||||
|
|
||||||
getHelix()->cancelRaid(
|
getHelix()->cancelRaid(
|
||||||
ctx.twitchChannel->roomId(),
|
ctx.twitchChannel->roomId(),
|
||||||
[channel{ctx.channel}] {
|
[] {
|
||||||
channel->addSystemMessage("You cancelled the raid.");
|
// do nothing
|
||||||
},
|
},
|
||||||
[channel{ctx.channel}](auto error, auto message) {
|
[channel{ctx.channel}](auto error, auto message) {
|
||||||
auto errorMessage = formatCancelRaidError(error, message);
|
auto errorMessage = formatCancelRaidError(error, message);
|
||||||
|
|
|
@ -880,6 +880,40 @@ MessageBuilder::MessageBuilder(const WarnAction &action)
|
||||||
this->message().searchText = text;
|
this->message().searchText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MessageBuilder::MessageBuilder(const RaidAction &action)
|
||||||
|
: MessageBuilder()
|
||||||
|
{
|
||||||
|
this->emplace<TimestampElement>();
|
||||||
|
this->message().flags.set(MessageFlag::System);
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
|
||||||
|
this->emplaceSystemTextAndUpdate(action.source.login, text)
|
||||||
|
->setLink({Link::UserInfo, "id:" + action.source.id});
|
||||||
|
this->emplaceSystemTextAndUpdate("initiated a raid to", text);
|
||||||
|
this->emplaceSystemTextAndUpdate(action.target + ".", text)
|
||||||
|
->setLink({Link::UserInfo, action.target});
|
||||||
|
|
||||||
|
this->message().messageText = text;
|
||||||
|
this->message().searchText = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBuilder::MessageBuilder(const UnraidAction &action)
|
||||||
|
: MessageBuilder()
|
||||||
|
{
|
||||||
|
this->emplace<TimestampElement>();
|
||||||
|
this->message().flags.set(MessageFlag::System);
|
||||||
|
|
||||||
|
QString text;
|
||||||
|
|
||||||
|
this->emplaceSystemTextAndUpdate(action.source.login, text)
|
||||||
|
->setLink({Link::UserInfo, "id:" + action.source.id});
|
||||||
|
this->emplaceSystemTextAndUpdate("canceled the raid.", text);
|
||||||
|
|
||||||
|
this->message().messageText = text;
|
||||||
|
this->message().searchText = text;
|
||||||
|
}
|
||||||
|
|
||||||
MessageBuilder::MessageBuilder(const AutomodUserAction &action)
|
MessageBuilder::MessageBuilder(const AutomodUserAction &action)
|
||||||
: MessageBuilder()
|
: MessageBuilder()
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,8 @@ namespace chatterino {
|
||||||
struct BanAction;
|
struct BanAction;
|
||||||
struct UnbanAction;
|
struct UnbanAction;
|
||||||
struct WarnAction;
|
struct WarnAction;
|
||||||
|
struct RaidAction;
|
||||||
|
struct UnraidAction;
|
||||||
struct AutomodAction;
|
struct AutomodAction;
|
||||||
struct AutomodUserAction;
|
struct AutomodUserAction;
|
||||||
struct AutomodInfoAction;
|
struct AutomodInfoAction;
|
||||||
|
@ -127,6 +129,8 @@ public:
|
||||||
MessageBuilder(const BanAction &action, uint32_t count = 1);
|
MessageBuilder(const BanAction &action, uint32_t count = 1);
|
||||||
MessageBuilder(const UnbanAction &action);
|
MessageBuilder(const UnbanAction &action);
|
||||||
MessageBuilder(const WarnAction &action);
|
MessageBuilder(const WarnAction &action);
|
||||||
|
MessageBuilder(const RaidAction &action);
|
||||||
|
MessageBuilder(const UnraidAction &action);
|
||||||
MessageBuilder(const AutomodUserAction &action);
|
MessageBuilder(const AutomodUserAction &action);
|
||||||
|
|
||||||
MessageBuilder(LiveUpdatesAddEmoteMessageTag, const QString &platform,
|
MessageBuilder(LiveUpdatesAddEmoteMessageTag, const QString &platform,
|
||||||
|
|
|
@ -172,6 +172,16 @@ struct AutomodInfoAction : PubSubAction {
|
||||||
} type;
|
} type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RaidAction : PubSubAction {
|
||||||
|
using PubSubAction::PubSubAction;
|
||||||
|
|
||||||
|
QString target;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct UnraidAction : PubSubAction {
|
||||||
|
using PubSubAction::PubSubAction;
|
||||||
|
};
|
||||||
|
|
||||||
struct WarnAction : PubSubAction {
|
struct WarnAction : PubSubAction {
|
||||||
using PubSubAction::PubSubAction;
|
using PubSubAction::PubSubAction;
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,35 @@ PubSub::PubSub(const QString &host, std::chrono::seconds pingInterval)
|
||||||
this->moderation.userWarned.invoke(action);
|
this->moderation.userWarned.invoke(action);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this->moderationActionHandlers["raid"] = [this](const auto &data,
|
||||||
|
const auto &roomID) {
|
||||||
|
RaidAction action(data, roomID);
|
||||||
|
|
||||||
|
action.source.id = data.value("created_by_user_id").toString();
|
||||||
|
action.source.login = data.value("created_by").toString();
|
||||||
|
|
||||||
|
const auto args = data.value("args").toArray();
|
||||||
|
|
||||||
|
if (args.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
action.target = args[0].toString();
|
||||||
|
|
||||||
|
this->moderation.raidStarted.invoke(action);
|
||||||
|
};
|
||||||
|
|
||||||
|
this->moderationActionHandlers["unraid"] = [this](const auto &data,
|
||||||
|
const auto &roomID) {
|
||||||
|
UnraidAction action(data, roomID);
|
||||||
|
|
||||||
|
action.source.id = data.value("created_by_user_id").toString();
|
||||||
|
action.source.login = data.value("created_by").toString();
|
||||||
|
|
||||||
|
this->moderation.raidCanceled.invoke(action);
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// This handler is no longer required as we use the automod-queue topic now
|
// This handler is no longer required as we use the automod-queue topic now
|
||||||
this->moderationActionHandlers["automod_rejected"] =
|
this->moderationActionHandlers["automod_rejected"] =
|
||||||
|
|
|
@ -44,6 +44,8 @@ struct PubSubAutoModQueueMessage;
|
||||||
struct AutomodAction;
|
struct AutomodAction;
|
||||||
struct AutomodUserAction;
|
struct AutomodUserAction;
|
||||||
struct AutomodInfoAction;
|
struct AutomodInfoAction;
|
||||||
|
struct RaidAction;
|
||||||
|
struct UnraidAction;
|
||||||
struct WarnAction;
|
struct WarnAction;
|
||||||
struct PubSubLowTrustUsersMessage;
|
struct PubSubLowTrustUsersMessage;
|
||||||
struct PubSubWhisperMessage;
|
struct PubSubWhisperMessage;
|
||||||
|
@ -104,6 +106,9 @@ public:
|
||||||
Signal<ModeChangedAction> modeChanged;
|
Signal<ModeChangedAction> modeChanged;
|
||||||
Signal<ModerationStateAction> moderationStateChanged;
|
Signal<ModerationStateAction> moderationStateChanged;
|
||||||
|
|
||||||
|
Signal<RaidAction> raidStarted;
|
||||||
|
Signal<UnraidAction> raidCanceled;
|
||||||
|
|
||||||
Signal<BanAction> userBanned;
|
Signal<BanAction> userBanned;
|
||||||
Signal<UnbanAction> userUnbanned;
|
Signal<UnbanAction> userUnbanned;
|
||||||
Signal<WarnAction> userWarned;
|
Signal<WarnAction> userWarned;
|
||||||
|
|
|
@ -648,6 +648,40 @@ void TwitchIrcServer::initialize()
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this->connections_.managedConnect(
|
||||||
|
getApp()->getTwitchPubSub()->moderation.raidStarted,
|
||||||
|
[this](const auto &action) {
|
||||||
|
auto chan = this->getChannelOrEmptyByID(action.roomID);
|
||||||
|
|
||||||
|
if (chan->isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto msg = MessageBuilder(action).release();
|
||||||
|
|
||||||
|
postToThread([chan, msg] {
|
||||||
|
chan->addMessage(msg, MessageContext::Original);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
this->connections_.managedConnect(
|
||||||
|
getApp()->getTwitchPubSub()->moderation.raidCanceled,
|
||||||
|
[this](const auto &action) {
|
||||||
|
auto chan = this->getChannelOrEmptyByID(action.roomID);
|
||||||
|
|
||||||
|
if (chan->isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto msg = MessageBuilder(action).release();
|
||||||
|
|
||||||
|
postToThread([chan, msg] {
|
||||||
|
chan->addMessage(msg, MessageContext::Original);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
this->connections_.managedConnect(
|
this->connections_.managedConnect(
|
||||||
getApp()->getTwitchPubSub()->pointReward.redeemed, [this](auto &data) {
|
getApp()->getTwitchPubSub()->pointReward.redeemed, [this](auto &data) {
|
||||||
QString channelId = data.value("channel_id").toString();
|
QString channelId = data.value("channel_id").toString();
|
||||||
|
|
Loading…
Reference in a new issue