fix: properly stack/merge PubSub & IRC timeouts again (#5855)

This commit is contained in:
pajlada
2025-01-25 12:13:33 +01:00
committed by GitHub
parent 3214e0a80b
commit 8554bd4d65
6 changed files with 64 additions and 8 deletions
@@ -1,12 +1,17 @@
#include "controllers/commands/builtin/chatterino/Debugging.hpp"
#include "Application.hpp"
#include "common/Channel.hpp"
#include "common/Env.hpp"
#include "common/Literals.hpp"
#include "controllers/commands/CommandContext.hpp"
#include "messages/Image.hpp"
#include "messages/Message.hpp"
#include "messages/MessageBuilder.hpp"
#include "messages/MessageElement.hpp"
#include "providers/twitch/PubSubActions.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "singletons/Theme.hpp"
#include "util/PostToThread.hpp"
@@ -140,7 +145,46 @@ QString debugTest(const CommandContext &ctx)
return "";
}
ctx.channel->addSystemMessage("debug-test called");
const auto command = ctx.words.value(1);
if (command == "timeout-pubsub")
{
QJsonObject data;
data["created_by_user_id"] = ctx.twitchChannel->roomId();
data["created_by"] = ctx.twitchChannel->getName();
BanAction action(data, ctx.twitchChannel->roomId());
action.source.id = ctx.twitchChannel->roomId();
action.source.login = ctx.twitchChannel->getName();
action.target.id = "11148817";
action.target.login = "pajlada";
action.duration = 10;
MessageBuilder msg(action, QDateTime::currentDateTime());
msg->flags.set(MessageFlag::PubSub);
ctx.channel->addOrReplaceTimeout(msg.release(),
QDateTime::currentDateTime());
}
else if (command == "timeout-irc")
{
auto nowMillis = QDateTime::currentDateTime().toSecsSinceEpoch();
const auto ircText =
QString(
"@tmi-sent-ts=%1;room-id=117166826;user-id=11148817;badges=;"
"badge-info=;flags=;user-type=;emotes=;target-user-id=11148817;"
"ban-"
"duration=1 :tmi.twitch.tv CLEARCHAT #testaccount_420 pajlada")
.arg(nowMillis);
getApp()->getTwitch()->addFakeMessage(ircText);
}
else
{
ctx.channel->addSystemMessage(
QString("debug-test called with command: '%1'").arg(command));
}
return "";
}