feat: add initial experimental Twitch Eventsub support (#5837)

Co-authored-by: nerix <nerixdev@outlook.de>
This commit is contained in:
pajlada
2025-02-02 17:03:24 +01:00
committed by GitHub
parent f9f7d47b43
commit 0f8a29fdb9
130 changed files with 19656 additions and 8 deletions
@@ -461,6 +461,8 @@ CommandController::CommandController(const Paths &paths)
this->registerCommand("/debug-test", &commands::debugTest);
this->registerCommand("/debug-eventsub", &commands::debugEventSub);
this->registerCommand("/shield", &commands::shieldModeOn);
this->registerCommand("/shieldoff", &commands::shieldModeOff);
@@ -9,6 +9,7 @@
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/eventsub/Controller.hpp"
#include "providers/twitch/PubSubActions.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
@@ -189,4 +190,57 @@ QString debugTest(const CommandContext &ctx)
return "";
}
QString debugEventSub(const CommandContext &ctx)
{
(void)ctx;
if (ctx.twitchChannel == nullptr)
{
return "";
}
// purposefully subscribe multiple times to ensure we can't sub too many times
// or create too many connections
static eventsub::SubscriptionHandle handle1;
handle1 = getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
.subscriptionType = "channel.ban",
.subscriptionVersion = "1",
.conditions =
{
{
"broadcaster_user_id",
ctx.twitchChannel->roomId(),
},
},
});
auto handle2 =
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
.subscriptionType = "channel.ban",
.subscriptionVersion = "1",
.conditions =
{
{
"broadcaster_user_id",
ctx.twitchChannel->roomId(),
},
},
});
auto handle3 =
getApp()->getEventSub()->subscribe(eventsub::SubscriptionRequest{
.subscriptionType = "channel.ban",
.subscriptionVersion = "1",
.conditions =
{
{
"broadcaster_user_id",
ctx.twitchChannel->roomId(),
},
},
});
return "";
}
} // namespace chatterino::commands
@@ -24,4 +24,6 @@ QString forceImageUnload(const CommandContext &ctx);
QString debugTest(const CommandContext &ctx);
QString debugEventSub(const CommandContext &ctx);
} // namespace chatterino::commands