mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +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);
|
||||
|
||||
@@ -211,6 +211,8 @@ public:
|
||||
void UpdateToken(const std::string &token);
|
||||
void SetUserAgent(const std::string &agent);
|
||||
|
||||
void SetDumpReady(bool dump);
|
||||
|
||||
bool IsChannelMuted(Snowflake id) const noexcept;
|
||||
bool IsGuildMuted(Snowflake id) const noexcept;
|
||||
int GetUnreadStateForChannel(Snowflake id) const noexcept;
|
||||
@@ -229,6 +231,8 @@ private:
|
||||
std::vector<uint8_t> m_decompress_buf;
|
||||
z_stream m_zstream;
|
||||
|
||||
bool m_dump_ready = false;
|
||||
|
||||
static std::string GetAPIURL();
|
||||
static std::string GetGatewayURL();
|
||||
|
||||
|
||||
@@ -255,8 +255,10 @@ void MainWindow::SetupMenu() {
|
||||
m_menu_file.set_submenu(m_menu_file_sub);
|
||||
m_menu_file_reload_css.set_label("Reload CSS");
|
||||
m_menu_file_clear_cache.set_label("Clear file cache");
|
||||
m_menu_file_dump_ready.set_label("Dump ready message");
|
||||
m_menu_file_sub.append(m_menu_file_reload_css);
|
||||
m_menu_file_sub.append(m_menu_file_clear_cache);
|
||||
m_menu_file_sub.append(m_menu_file_dump_ready);
|
||||
|
||||
m_menu_view.set_label("View");
|
||||
m_menu_view.set_submenu(m_menu_view_sub);
|
||||
@@ -335,6 +337,10 @@ void MainWindow::SetupMenu() {
|
||||
Abaddon::Get().GetImageManager().ClearCache();
|
||||
});
|
||||
|
||||
m_menu_file_dump_ready.signal_toggled().connect([this]() {
|
||||
Abaddon::Get().GetDiscordClient().SetDumpReady(m_menu_file_dump_ready.get_active());
|
||||
});
|
||||
|
||||
m_menu_discord_add_recipient.signal_activate().connect([this] {
|
||||
m_signal_action_add_recipient.emit(GetChatActiveChannel());
|
||||
});
|
||||
|
||||
@@ -72,6 +72,7 @@ private:
|
||||
Gtk::Menu m_menu_file_sub;
|
||||
Gtk::MenuItem m_menu_file_reload_css;
|
||||
Gtk::MenuItem m_menu_file_clear_cache;
|
||||
Gtk::CheckMenuItem m_menu_file_dump_ready;
|
||||
|
||||
Gtk::MenuItem m_menu_view;
|
||||
Gtk::Menu m_menu_view_sub;
|
||||
|
||||
Reference in New Issue
Block a user