add user joined messages

This commit is contained in:
ouwou 2020-09-21 21:01:32 -04:00
parent 74526d16c9
commit af8058c9cb
4 changed files with 48 additions and 8 deletions

View File

@ -381,3 +381,26 @@ void ChatMessageEmbedItem::UpdateAttributes() {
void ChatMessageEmbedItem::Update() {
UpdateAttributes();
}
ChatMessageUserEventItem::ChatMessageUserEventItem(const Message *data) {
ID = data->ID;
m_label = Gtk::manage(new Gtk::Label);
get_style_context()->add_class("message-text");
get_style_context()->add_class("message-text-user-event");
set_can_focus(false);
set_halign(Gtk::ALIGN_FILL);
set_hexpand(true);
m_label->set_halign(Gtk::ALIGN_START);
m_label->set_use_markup();
if (data->Type == MessageType::GUILD_MEMBER_JOIN)
m_label->set_markup("<span color='#999999'><i>[user joined]</i></span>");
add(*m_label);
show_all();
AttachMenuHandler(this);
}
void ChatMessageUserEventItem::Update() {}

View File

@ -9,6 +9,7 @@ enum class ChatDisplayType {
Text,
Embed,
Image,
GuildMemberJoin,
};
// contains the username and timestamp, chat items get stuck into its box
@ -109,3 +110,15 @@ protected:
Gtk::Box *m_main;
Gtk::Label *m_attrib_label = nullptr;
};
class ChatMessageUserEventItem
: public Gtk::EventBox
, public ChatMessageItem {
public:
ChatMessageUserEventItem(const Message *data);
virtual void Update();
protected:
Gtk::Label *m_label;
};

View File

@ -87,6 +87,8 @@ ChatDisplayType ChatWindow::GetMessageDisplayType(const Message *data) {
return ChatDisplayType::Text;
else if (data->Type == MessageType::DEFAULT && data->Embeds.size() > 0)
return ChatDisplayType::Embed;
else if (data->Type == MessageType::GUILD_MEMBER_JOIN)
return ChatDisplayType::GuildMemberJoin;
return ChatDisplayType::Unknown;
}
@ -106,6 +108,8 @@ ChatMessageItem *ChatWindow::CreateMessageComponent(const Message *data) {
});
} else if (type == ChatDisplayType::Embed) {
widget = Gtk::manage(new ChatMessageEmbedItem(data));
} else if (type == ChatDisplayType::GuildMemberJoin) {
widget = Gtk::manage(new ChatMessageUserEventItem(data));
}
if (widget == nullptr) return nullptr;

View File

@ -10,17 +10,17 @@ enum class MessageType {
RECIPIENT_ADD = 1,
RECIPIENT_REMOVE = 2,
CALL = 3,
CHANNEL_NaME_CHANGE = 4,
CHANNEL_NAME_CHANGE = 4,
CHANNEL_ICON_CHANGE = 5,
CHANNEL_PINNED_MESSAGE = 6,
GUILD_MEMBER_JOIN = 6,
USER_PREMIUM_GUILD_SUBSCRIPTION = 7,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 8,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 9,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 10,
GUILD_MEMBER_JOIN = 7,
USER_PREMIUM_GUILD_SUBSCRIPTION = 8,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11,
CHANNEL_FOLLOW_ADD = 12,
GUILD_DISCOVERY_DISQUALIFIED = 13,
GUILD_DISCOVERY_REQUALIFIED = 14,
GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED = 15,
};
enum class MessageFlags {