diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp index e95a53c..06ca775 100644 --- a/telegram-bot-api/Client.cpp +++ b/telegram-bot-api/Client.cpp @@ -12915,7 +12915,14 @@ Client::FullMessageId Client::add_message(object_ptr &&message, message_info = td::make_unique(); } - message_info->id = message_id; + init_message(message_info.get(), std::move(message), force_update_content); + + return {chat_id, message_id}; +} + +void Client::init_message(MessageInfo *message_info, object_ptr &&message, bool force_update_content) { + int64 chat_id = message->chat_id_; + message_info->id = message->id_; message_info->chat_id = chat_id; message_info->message_thread_id = message->message_thread_id_; message_info->date = message->date_; @@ -12997,11 +13004,9 @@ Client::FullMessageId Client::add_message(object_ptr &&message, } else if (message->content_->get_id() == td_api::messagePoll::ID) { message_info->content = std::move(message->content_); } - set_message_reply_markup(message_info.get(), std::move(message->reply_markup_)); + set_message_reply_markup(message_info, std::move(message->reply_markup_)); message = nullptr; - - return {chat_id, message_id}; } void Client::update_message_content(int64 chat_id, int64 message_id, object_ptr &&content) { diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h index cd34b49..4fe12cc 100644 --- a/telegram-bot-api/Client.h +++ b/telegram-bot-api/Client.h @@ -924,7 +924,7 @@ class Client final : public WebhookActor::Callback { static bool are_equal_inline_keyboards(const td_api::replyMarkupInlineKeyboard *lhs, const td_api::replyMarkupInlineKeyboard *rhs); - void set_message_reply_markup(MessageInfo *message_info, object_ptr &&reply_markup); + static void set_message_reply_markup(MessageInfo *message_info, object_ptr &&reply_markup); static int64 get_sticker_set_id(const object_ptr &content); @@ -975,6 +975,7 @@ class Client final : public WebhookActor::Callback { }; FullMessageId add_message(object_ptr &&message, bool force_update_content = false); + void init_message(MessageInfo *message_info, object_ptr &&message, bool force_update_content); const MessageInfo *get_message(int64 chat_id, int64 message_id, bool force_cache) const; MessageInfo *get_message_editable(int64 chat_id, int64 message_id);