From ab6eda1a4ca2f28613aaabe1c09d153a38c2f94c Mon Sep 17 00:00:00 2001 From: hippoz Date: Fri, 23 Apr 2021 03:05:45 +0300 Subject: [PATCH] display message author username instead of id --- brainlet.h | 13 +++++++++++-- main.cpp | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/brainlet.h b/brainlet.h index ed7bcfe..62b34a6 100644 --- a/brainlet.h +++ b/brainlet.h @@ -46,7 +46,12 @@ namespace Brainlet { } Channel; typedef struct { - std::string authorId; + std::string id; + std::string username; + } MessageAuthor; + + typedef struct { + MessageAuthor author; std::string message; } Message; @@ -271,8 +276,12 @@ namespace Brainlet { .id = data["channel"]["_id"].asString(), .name = data["channel"]["title"].asString() }; + MessageAuthor author = { + .id = data["author"]["_id"].asString(), + .username = data["author"]["username"].asString() + }; Message message = { - .authorId = data["author"]["_id"].asString(), + .author = author, .message = data["content"].asString() }; if (client->onNewMessage) diff --git a/main.cpp b/main.cpp index f636e31..255b45f 100644 --- a/main.cpp +++ b/main.cpp @@ -80,7 +80,7 @@ void addMessage(const Brainlet::Message message) { text->set_halign(Gtk::ALIGN_START); text->set_line_wrap(true); - std::string messageFormatted = message.authorId + ": " + message.message; + std::string messageFormatted = message.author.username + ": " + message.message; text->set_markup(messageFormatted.c_str()); row->add(*text);