forked from OpenGamers/abaddon
more optional + referencedata
This commit is contained in:
@@ -741,7 +741,7 @@ ChatMessageHeader::ChatMessageHeader(const Message *data) {
|
|||||||
m_author->set_can_focus(false);
|
m_author->set_can_focus(false);
|
||||||
m_author_ev->signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press));
|
m_author_ev->signal_button_press_event().connect(sigc::mem_fun(*this, &ChatMessageHeader::on_author_button_press));
|
||||||
|
|
||||||
if (data->WebhookID.IsValid()) {
|
if (data->WebhookID.has_value()) {
|
||||||
m_extra = Gtk::manage(new Gtk::Label);
|
m_extra = Gtk::manage(new Gtk::Label);
|
||||||
m_extra->get_style_context()->add_class("message-container-extra");
|
m_extra->get_style_context()->add_class("message-container-extra");
|
||||||
m_extra->set_single_line_mode(true);
|
m_extra->set_single_line_mode(true);
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ void DiscordClient::FetchMessagesInChannel(Snowflake id, std::function<void(cons
|
|||||||
m_store.SetMessage(msg.ID, msg);
|
m_store.SetMessage(msg.ID, msg);
|
||||||
AddMessageToChannel(msg.ID, id);
|
AddMessageToChannel(msg.ID, id);
|
||||||
m_store.SetUser(msg.Author.ID, msg.Author);
|
m_store.SetUser(msg.Author.ID, msg.Author);
|
||||||
AddUserToGuild(msg.Author.ID, msg.GuildID);
|
AddUserToGuild(msg.Author.ID, *msg.GuildID);
|
||||||
ids.push_back(msg.ID);
|
ids.push_back(msg.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ void DiscordClient::FetchMessagesInChannelBefore(Snowflake channel_id, Snowflake
|
|||||||
m_store.SetMessage(msg.ID, msg);
|
m_store.SetMessage(msg.ID, msg);
|
||||||
AddMessageToChannel(msg.ID, channel_id);
|
AddMessageToChannel(msg.ID, channel_id);
|
||||||
m_store.SetUser(msg.Author.ID, msg.Author);
|
m_store.SetUser(msg.Author.ID, msg.Author);
|
||||||
AddUserToGuild(msg.Author.ID, msg.GuildID);
|
AddUserToGuild(msg.Author.ID, *msg.GuildID);
|
||||||
ids.push_back(msg.ID);
|
ids.push_back(msg.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -588,7 +588,7 @@ void DiscordClient::HandleGatewayMessageCreate(const GatewayMessage &msg) {
|
|||||||
m_store.SetMessage(data.ID, data);
|
m_store.SetMessage(data.ID, data);
|
||||||
AddMessageToChannel(data.ID, data.ChannelID);
|
AddMessageToChannel(data.ID, data.ChannelID);
|
||||||
m_store.SetUser(data.Author.ID, data.Author);
|
m_store.SetUser(data.Author.ID, data.Author);
|
||||||
AddUserToGuild(data.Author.ID, data.GuildID);
|
AddUserToGuild(data.Author.ID, *data.GuildID);
|
||||||
m_signal_message_create.emit(data.ID);
|
m_signal_message_create.emit(data.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,18 @@ void from_json(const nlohmann::json &j, AttachmentData &m) {
|
|||||||
JS_ON("width", m.Width);
|
JS_ON("width", m.Width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void from_json(const nlohmann::json &j, MessageReferenceData &m) {
|
||||||
|
JS_O("message_id", m.MessageID);
|
||||||
|
JS_O("channel_id", m.ChannelID);
|
||||||
|
JS_O("guild_id", m.GuildID);
|
||||||
|
}
|
||||||
|
|
||||||
|
void to_json(nlohmann::json &j, const MessageReferenceData &m) {
|
||||||
|
JS_IF("message_id", m.MessageID);
|
||||||
|
JS_IF("channel_id", m.ChannelID);
|
||||||
|
JS_IF("guild_id", m.GuildID);
|
||||||
|
}
|
||||||
|
|
||||||
void from_json(const nlohmann::json &j, Message &m) {
|
void from_json(const nlohmann::json &j, Message &m) {
|
||||||
JS_D("id", m.ID);
|
JS_D("id", m.ID);
|
||||||
JS_D("channel_id", m.ChannelID);
|
JS_D("channel_id", m.ChannelID);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ enum class MessageType {
|
|||||||
CHANNEL_FOLLOW_ADD = 12,
|
CHANNEL_FOLLOW_ADD = 12,
|
||||||
GUILD_DISCOVERY_DISQUALIFIED = 14,
|
GUILD_DISCOVERY_DISQUALIFIED = 14,
|
||||||
GUILD_DISCOVERY_REQUALIFIED = 15,
|
GUILD_DISCOVERY_REQUALIFIED = 15,
|
||||||
|
INLINE_REPLY = 19,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class MessageFlags {
|
enum class MessageFlags {
|
||||||
@@ -119,31 +120,40 @@ struct AttachmentData {
|
|||||||
friend void from_json(const nlohmann::json &j, AttachmentData &m);
|
friend void from_json(const nlohmann::json &j, AttachmentData &m);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MessageReferenceData {
|
||||||
|
std::optional<Snowflake> MessageID;
|
||||||
|
std::optional<Snowflake> ChannelID;
|
||||||
|
std::optional<Snowflake> GuildID;
|
||||||
|
|
||||||
|
friend void from_json(const nlohmann::json &j, MessageReferenceData &m);
|
||||||
|
friend void to_json(nlohmann::json &j, const MessageReferenceData &m);
|
||||||
|
};
|
||||||
|
|
||||||
struct Message {
|
struct Message {
|
||||||
Snowflake ID; //
|
Snowflake ID;
|
||||||
Snowflake ChannelID; //
|
Snowflake ChannelID;
|
||||||
Snowflake GuildID; // opt
|
std::optional<Snowflake> GuildID;
|
||||||
User Author; //
|
User Author;
|
||||||
// GuildMember Member; // opt
|
// std::optional<GuildMember> Member;
|
||||||
std::string Content; //
|
std::string Content;
|
||||||
std::string Timestamp; //
|
std::string Timestamp;
|
||||||
std::string EditedTimestamp; // null
|
std::string EditedTimestamp; // null
|
||||||
bool IsTTS; //
|
bool IsTTS;
|
||||||
bool DoesMentionEveryone; //
|
bool DoesMentionEveryone;
|
||||||
std::vector<User> Mentions; //
|
std::vector<User> Mentions;
|
||||||
// std::vector<Role> MentionRoles; //
|
// std::vector<Role> MentionRoles;
|
||||||
// std::vector<ChannelMentionData> MentionChannels; // opt
|
// std::optional<std::vector<ChannelMentionData>> MentionChannels;
|
||||||
std::vector<AttachmentData> Attachments; //
|
std::vector<AttachmentData> Attachments;
|
||||||
std::vector<EmbedData> Embeds; //
|
std::vector<EmbedData> Embeds;
|
||||||
// std::vector<ReactionData> Reactions; // opt
|
// std::optional<std::vector<ReactionData>> Reactions;
|
||||||
std::string Nonce; // opt
|
std::optional<std::string> Nonce;
|
||||||
bool IsPinned; //
|
bool IsPinned;
|
||||||
Snowflake WebhookID; // opt
|
std::optional<Snowflake> WebhookID;
|
||||||
MessageType Type; //
|
MessageType Type;
|
||||||
// MessageActivityData Activity; // opt
|
// std::optional<MessageActivityData> Activity;
|
||||||
// MessageApplicationData Application; // opt
|
// std::optional<MessageApplicationData> Application;
|
||||||
// MessageReferenceData MessageReference; // opt
|
std::optional<MessageReferenceData> MessageReference;
|
||||||
MessageFlags Flags = MessageFlags::NONE; // opt
|
std::optional<MessageFlags> Flags = MessageFlags::NONE;
|
||||||
|
|
||||||
friend void from_json(const nlohmann::json &j, Message &m);
|
friend void from_json(const nlohmann::json &j, Message &m);
|
||||||
void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE
|
void from_json_edited(const nlohmann::json &j); // for MESSAGE_UPDATE
|
||||||
|
|||||||
Reference in New Issue
Block a user