feat(eventsub): implement clearchat (#5981)

This commit is contained in:
nerix
2025-02-23 21:28:26 +01:00
committed by GitHub
parent c67801eca5
commit 5fca241188
8 changed files with 199 additions and 7 deletions
+21 -4
View File
@@ -6,9 +6,12 @@
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/twitch/eventsub/MessageBuilder.hpp"
#include "providers/twitch/eventsub/MessageHandlers.hpp"
#include "providers/twitch/PubSubActions.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Settings.hpp"
#include "singletons/WindowManager.hpp"
#include "util/PostToThread.hpp"
#include <boost/json.hpp>
@@ -23,15 +26,24 @@ namespace {
using namespace chatterino;
using namespace chatterino::eventsub;
namespace channel_moderate = lib::payload::channel_moderate::v2;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
const auto &LOG = chatterinoTwitchEventSub;
template <typename Action>
concept CanMakeModMessage =
requires(EventSubMessageBuilder &builder,
const lib::payload::channel_moderate::v2::Event &event,
concept CanMakeModMessage = requires(
EventSubMessageBuilder &builder, const channel_moderate::Event &event,
const std::remove_cvref_t<Action> &action) {
makeModerateMessage(builder, event, action);
};
template <typename Action>
concept CanHandleModMessage =
requires(TwitchChannel *channel, const QDateTime &time,
const channel_moderate::Event &event,
const std::remove_cvref_t<Action> &action) {
makeModerateMessage(builder, event, action);
handleModerateMessage(channel, time, event, action);
};
} // namespace
@@ -199,6 +211,11 @@ void Connection::onChannelModerate(
channel->addMessage(msg, MessageContext::Original);
});
}
if constexpr (CanHandleModMessage<Action>)
{
handleModerateMessage(channel, now, payload.event, action);
}
},
payload.event.action);
}