mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-19 20:11:59 +03:00
add option to dump ready payload because thats useful
This commit is contained in:
@@ -1204,6 +1204,10 @@ void DiscordClient::SetUserAgent(const std::string &agent) {
|
||||
m_websocket.SetUserAgent(agent);
|
||||
}
|
||||
|
||||
void DiscordClient::SetDumpReady(bool dump) {
|
||||
m_dump_ready = dump;
|
||||
}
|
||||
|
||||
bool DiscordClient::IsChannelMuted(Snowflake id) const noexcept {
|
||||
return m_muted_channels.find(id) != m_muted_channels.end();
|
||||
}
|
||||
@@ -1566,6 +1570,17 @@ void DiscordClient::ProcessNewGuild(GuildData &guild) {
|
||||
|
||||
void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) {
|
||||
m_ready_received = true;
|
||||
|
||||
if (m_dump_ready) {
|
||||
const auto name = "./payload_ready-" + Glib::DateTime::create_now_utc().format("%Y-%m-%d_%H-%M-%S") + ".json";
|
||||
auto *fp = std::fopen(name.c_str(), "wb");
|
||||
if (fp != nullptr) {
|
||||
const auto contents = msg.Data.dump(4);
|
||||
std::fwrite(contents.data(), contents.size(), 1, fp);
|
||||
std::fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
ReadyEventData data = msg.Data;
|
||||
for (auto &g : data.Guilds)
|
||||
ProcessNewGuild(g);
|
||||
|
||||
Reference in New Issue
Block a user