mirror of
https://github.com/celisej567/abaddon.git
synced 2026-09-13 20:18:50 +03:00
show RECIPIENT_ADD, RECIPIENT_REMOVE messages
This commit is contained in:
@@ -232,6 +232,19 @@ void ChatMessageItemContainer::UpdateTextComponent(Gtk::TextView *tv) {
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case MessageType::RECIPIENT_ADD: {
|
||||
const auto &adder = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID);
|
||||
const auto &added = data->Mentions[0];
|
||||
b->insert_markup(s, "<i><span color='#999999'><span color='#eeeeee'>" + adder->Username + "</span> added <span color='#eeeeee'>" + added.Username + "</span></span></i>");
|
||||
} break;
|
||||
case MessageType::RECIPIENT_REMOVE: {
|
||||
const auto &adder = Abaddon::Get().GetDiscordClient().GetUser(data->Author.ID);
|
||||
const auto &added = data->Mentions[0];
|
||||
if (adder->ID == added.ID)
|
||||
b->insert_markup(s, "<i><span color='#999999'><span color='#eeeeee'>" + adder->Username + "</span> left</span></i>");
|
||||
else
|
||||
b->insert_markup(s, "<i><span color='#999999'><span color='#eeeeee'>" + adder->Username + "</span> removed <span color='#eeeeee'>" + added.Username + "</span></span></i>");
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1030,6 +1030,9 @@ void DiscordClient::StoreMessageData(const Message &msg) {
|
||||
if (!cur.has_value())
|
||||
m_store.SetEmoji(r.Emoji.ID, r.Emoji);
|
||||
}
|
||||
|
||||
for (const auto &user : msg.Mentions)
|
||||
m_store.SetUser(user.ID, user);
|
||||
}
|
||||
|
||||
void DiscordClient::LoadEventMap() {
|
||||
|
||||
@@ -173,7 +173,7 @@ struct Message {
|
||||
std::string EditedTimestamp; // null
|
||||
bool IsTTS;
|
||||
bool DoesMentionEveryone;
|
||||
std::vector<User> Mentions; // currently discarded in store
|
||||
std::vector<User> Mentions; // full user accessible
|
||||
// std::vector<Role> MentionRoles;
|
||||
// std::optional<std::vector<ChannelMentionData>> MentionChannels;
|
||||
std::vector<AttachmentData> Attachments;
|
||||
|
||||
@@ -189,16 +189,9 @@ void Store::SetMessage(Snowflake id, const Message &message) {
|
||||
Bind(m_set_msg_stmt, 7, message.EditedTimestamp);
|
||||
Bind(m_set_msg_stmt, 8, message.IsTTS);
|
||||
Bind(m_set_msg_stmt, 9, message.DoesMentionEveryone);
|
||||
Bind(m_set_msg_stmt, 10, "[]"s); // mentions, a const char* literal will call the bool overload instead of std::string
|
||||
{
|
||||
std::string tmp;
|
||||
tmp = nlohmann::json(message.Attachments).dump();
|
||||
Bind(m_set_msg_stmt, 11, tmp);
|
||||
}
|
||||
{
|
||||
std::string tmp = nlohmann::json(message.Embeds).dump();
|
||||
Bind(m_set_msg_stmt, 12, tmp);
|
||||
}
|
||||
Bind(m_set_msg_stmt, 10, nlohmann::json(message.Mentions).dump());
|
||||
Bind(m_set_msg_stmt, 11, nlohmann::json(message.Attachments).dump());
|
||||
Bind(m_set_msg_stmt, 12, nlohmann::json(message.Embeds).dump());
|
||||
Bind(m_set_msg_stmt, 13, message.IsPinned);
|
||||
Bind(m_set_msg_stmt, 14, message.WebhookID);
|
||||
Bind(m_set_msg_stmt, 15, static_cast<uint64_t>(message.Type));
|
||||
|
||||
@@ -44,8 +44,24 @@ void from_json(const nlohmann::json &j, User &m) {
|
||||
void to_json(nlohmann::json &j, const User &m) {
|
||||
j["id"] = m.ID;
|
||||
j["username"] = m.Username;
|
||||
j["avatar"] = m.Avatar;
|
||||
// rest of stuff as needed im too lazy and its probably not necessary
|
||||
j["discriminator"] = m.Discriminator;
|
||||
if (m.Avatar == "")
|
||||
j["avatar"] = nullptr;
|
||||
else
|
||||
j["avatar"] = m.Avatar;
|
||||
JS_IF("bot", m.IsBot);
|
||||
JS_IF("system", m.IsSystem);
|
||||
JS_IF("mfa_enabled", m.IsMFAEnabled);
|
||||
JS_IF("locale", m.Locale);
|
||||
JS_IF("verified", m.IsVerified);
|
||||
JS_IF("email", m.Email);
|
||||
JS_IF("flags", m.Flags);
|
||||
JS_IF("premium_type", m.PremiumType);
|
||||
JS_IF("public_flags", m.PublicFlags);
|
||||
JS_IF("desktop", m.IsDesktop);
|
||||
JS_IF("mobile", m.IsMobile);
|
||||
JS_IF("nsfw_allowed", m.IsNSFWAllowed);
|
||||
JS_IF("phone", m.Phone);
|
||||
}
|
||||
|
||||
void User::update_from_json(const nlohmann::json &j, User &m) {
|
||||
|
||||
@@ -19,10 +19,10 @@ struct User {
|
||||
std::optional<int> PublicFlags;
|
||||
|
||||
// undocumented (opt)
|
||||
bool IsDesktop = false; //
|
||||
bool IsMobile = false; //
|
||||
bool IsNSFWAllowed = false; // null
|
||||
std::string Phone; // null?
|
||||
std::optional<bool> IsDesktop;
|
||||
std::optional<bool> IsMobile;
|
||||
std::optional<bool> IsNSFWAllowed; // null
|
||||
std::optional<std::string> Phone; // null?
|
||||
|
||||
friend void from_json(const nlohmann::json &j, User &m);
|
||||
friend void to_json(nlohmann::json &j, const User &m);
|
||||
|
||||
Reference in New Issue
Block a user