diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-08-29 01:14:20 -0400 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2020-08-29 01:14:20 -0400 |
commit | 713ed0f9271bfd9249809940cf214d600adaecab (patch) | |
tree | f6493059fea382df2301823805e0a7fc1a393589 /discord/discord.cpp | |
parent | 299ecc71d980904ad7ffaf6d44254da71f948666 (diff) | |
download | abaddon-portaudio-713ed0f9271bfd9249809940cf214d600adaecab.tar.gz abaddon-portaudio-713ed0f9271bfd9249809940cf214d600adaecab.zip |
add dm's
Diffstat (limited to 'discord/discord.cpp')
-rw-r--r-- | discord/discord.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/discord/discord.cpp b/discord/discord.cpp index 69d95e8..57327dc 100644 --- a/discord/discord.cpp +++ b/discord/discord.cpp @@ -145,6 +145,10 @@ const MessageData *DiscordClient::GetMessage(Snowflake id) const { return &m_messages.at(id); } +const ChannelData *DiscordClient::GetChannel(Snowflake id) const { + return &m_channels.at(id); +} + void DiscordClient::SendChatMessage(std::string content, Snowflake channel) { // @([^@#]{1,32})#(\\d{4}) CreateMessageObject obj; @@ -260,9 +264,17 @@ void DiscordClient::HandleGatewayReady(const GatewayMessage &msg) { for (const auto &g : data.Guilds) { if (g.IsUnavailable) printf("guild (%lld) unavailable\n", g.ID); - else + else { StoreGuild(g.ID, g); + for (const auto &c : g.Channels) + StoreChannel(c.ID, c); + } } + + for (const auto &dm : data.PrivateChannels) { + StoreChannel(dm.ID, dm); + } + m_abaddon->DiscordNotifyReady(); m_user_settings = data.UserSettings; } @@ -291,6 +303,21 @@ void DiscordClient::StoreMessage(Snowflake id, const MessageData &m) { m_chan_to_message_map[m.ChannelID].insert(&m_messages[id]); } +void DiscordClient::StoreChannel(Snowflake id, const ChannelData &c) { + m_channels[id] = c; +} + +std::set<Snowflake> DiscordClient::GetPrivateChannels() const { + auto ret = std::set<Snowflake>(); + + for (const auto &[id, chan] : m_channels) { + if (chan.Type == ChannelType::DM || chan.Type == ChannelType::GROUP_DM) + ret.insert(id); + } + + return ret; +} + void DiscordClient::HeartbeatThread() { while (m_client_connected) { if (!m_heartbeat_acked) { |