Add quickReplyMessage.reply_markup.

This commit is contained in:
levlam 2024-03-06 15:56:50 +03:00
parent 06831c2836
commit bc1a8d2bc2
4 changed files with 28 additions and 7 deletions

View File

@ -3784,7 +3784,8 @@ storyInteractions total_count:int32 total_forward_count:int32 total_reaction_cou
//@via_bot_user_id If non-zero, the user identifier of the bot through which this message was sent
//@media_album_id Unique identifier of an album this message belongs to. Only audios, documents, photos and videos can be grouped together in albums
//@content Content of the message
quickReplyMessage id:int53 sending_state:MessageSendingState can_be_edited:Bool reply_to_message_id:int53 via_bot_user_id:int53 media_album_id:int64 content:MessageContent = QuickReplyMessage;
//@reply_markup Inline keyboard reply markup for the message; may be null if none
quickReplyMessage id:int53 sending_state:MessageSendingState can_be_edited:Bool reply_to_message_id:int53 via_bot_user_id:int53 media_album_id:int64 content:MessageContent reply_markup:ReplyMarkup = QuickReplyMessage;
//@description Describes a shortcut that can be used for a quick reply
//@id Unique shortcut identifier

View File

@ -26690,6 +26690,7 @@ Result<td_api::object_ptr<td_api::messages>> MessagesManager::send_quick_reply_s
Message *m = get_message_to_send(d, MessageId(), std::move(input_reply_to), message_send_options,
std::move(content.content_), content.invert_media_, &need_update_dialog_pos, false,
nullptr, DialogId(), true);
m->reply_markup = std::move(content.reply_markup_);
m->disable_web_page_preview = content.disable_web_page_preview_;
m->media_album_id = content.media_album_id_;
original_message_id_to_new_message_id.emplace(content.original_message_id_, m->message_id);

View File

@ -21,6 +21,8 @@
#include "td/telegram/MessageSelfDestructType.h"
#include "td/telegram/misc.h"
#include "td/telegram/RepliedMessageInfo.h"
#include "td/telegram/ReplyMarkup.h"
#include "td/telegram/ReplyMarkup.hpp"
#include "td/telegram/Td.h"
#include "td/telegram/Version.h"
@ -223,6 +225,7 @@ void QuickReplyManager::QuickReplyMessage::store(StorerT &storer) const {
bool has_send_error_message = !is_server && !send_error_message.empty();
bool has_try_resend_at = !is_server && try_resend_at != 0;
bool has_media_album_id = media_album_id != 0;
bool has_reply_markup = reply_markup != nullptr;
BEGIN_STORE_FLAGS();
STORE_FLAG(has_edit_date);
STORE_FLAG(has_random_id);
@ -240,6 +243,7 @@ void QuickReplyManager::QuickReplyMessage::store(StorerT &storer) const {
STORE_FLAG(has_send_error_message);
STORE_FLAG(has_try_resend_at);
STORE_FLAG(has_media_album_id);
STORE_FLAG(has_reply_markup);
END_STORE_FLAGS();
td::store(message_id, storer);
td::store(shortcut_id, storer);
@ -274,6 +278,9 @@ void QuickReplyManager::QuickReplyMessage::store(StorerT &storer) const {
td::store(media_album_id, storer);
}
store_message_content(content.get(), storer);
if (has_reply_markup) {
td::store(reply_markup, storer);
}
}
template <class ParserT>
@ -288,6 +295,7 @@ void QuickReplyManager::QuickReplyMessage::parse(ParserT &parser) {
bool has_send_error_message;
bool has_try_resend_at;
bool has_media_album_id;
bool has_reply_markup;
BEGIN_PARSE_FLAGS();
PARSE_FLAG(has_edit_date);
PARSE_FLAG(has_random_id);
@ -305,6 +313,7 @@ void QuickReplyManager::QuickReplyMessage::parse(ParserT &parser) {
PARSE_FLAG(has_send_error_message);
PARSE_FLAG(has_try_resend_at);
PARSE_FLAG(has_media_album_id);
PARSE_FLAG(has_reply_markup);
END_PARSE_FLAGS();
td::parse(message_id, parser);
td::parse(shortcut_id, parser);
@ -339,6 +348,9 @@ void QuickReplyManager::QuickReplyMessage::parse(ParserT &parser) {
td::parse(media_album_id, parser);
}
parse_message_content(content, parser);
if (has_reply_markup) {
td::parse(reply_markup, parser);
}
}
QuickReplyManager::Shortcut::~Shortcut() = default;
@ -491,9 +503,8 @@ unique_ptr<QuickReplyManager::QuickReplyMessage> QuickReplyManager::create_messa
message->fwd_from_ != nullptr || message->views_ != 0 || message->forwards_ != 0 ||
message->replies_ != nullptr || message->reactions_ != nullptr || message->ttl_period_ != 0 ||
!message->out_ || message->post_ || message->from_scheduled_ || message->pinned_ || message->noforwards_ ||
message->mentioned_ || message->media_unread_ || message->reply_markup_ != nullptr ||
!message->restriction_reason_.empty() || !message->post_author_.empty() ||
message->from_boosts_applied_ != 0) {
message->mentioned_ || message->media_unread_ || !message->restriction_reason_.empty() ||
!message->post_author_.empty() || message->from_boosts_applied_ != 0) {
LOG(ERROR) << "Receive an invalid quick reply from " << source << ": " << to_string(message);
}
if (message->saved_peer_id_ != nullptr) {
@ -555,6 +566,8 @@ unique_ptr<QuickReplyManager::QuickReplyMessage> QuickReplyManager::create_messa
result->legacy_layer = (message->legacy_ ? MTPROTO_LAYER : 0);
result->invert_media = message->invert_media_;
result->content = std::move(content);
result->reply_markup =
get_reply_markup(std::move(message->reply_markup_), td_->auth_manager_->is_bot(), true, false);
if (media_album_id != 0) {
if (!is_allowed_media_group_content(content_type)) {
@ -591,6 +604,7 @@ void QuickReplyManager::add_quick_reply_message_dependencies(Dependencies &depen
auto is_bot = td_->auth_manager_->is_bot();
dependencies.add(m->via_bot_user_id);
add_message_content_dependencies(dependencies, m->content.get(), is_bot);
add_reply_markup_dependencies(dependencies, m->reply_markup.get());
}
bool QuickReplyManager::can_edit_quick_reply_message(const QuickReplyMessage *m) const {
@ -639,7 +653,8 @@ td_api::object_ptr<td_api::quickReplyMessage> QuickReplyManager::get_quick_reply
return td_api::make_object<td_api::quickReplyMessage>(
m->message_id.get(), get_message_sending_state_object(m), can_be_edited, m->reply_to_message_id.get(),
td_->contacts_manager_->get_user_id_object(m->via_bot_user_id, "via_bot_user_id"), m->media_album_id,
get_quick_reply_message_message_content_object(m));
get_quick_reply_message_message_content_object(m),
get_reply_markup_object(td_->contacts_manager_.get(), m->reply_markup));
}
int32 QuickReplyManager::get_shortcut_message_count(const Shortcut *s) {
@ -1410,8 +1425,9 @@ Result<vector<QuickReplyManager::QuickReplyMessageContent>> QuickReplyManager::g
auto disable_web_page_preview = message->disable_web_page_preview &&
content->get_type() == MessageContentType::Text &&
!has_message_content_web_page(content.get());
result.push_back({std::move(content), message->message_id, message->reply_to_message_id, message->media_album_id,
message->invert_media, disable_web_page_preview});
result.push_back({std::move(content), message->message_id, message->reply_to_message_id,
dup_reply_markup(message->reply_markup), message->media_album_id, message->invert_media,
disable_web_page_preview});
}
return std::move(result);

View File

@ -30,6 +30,7 @@ namespace td {
class Dependencies;
class MessageContent;
struct ReplyMarkup;
class Td;
class QuickReplyManager final : public Actor {
@ -65,6 +66,7 @@ class QuickReplyManager final : public Actor {
unique_ptr<MessageContent> content_;
MessageId original_message_id_;
MessageId original_reply_to_message_id_;
unique_ptr<ReplyMarkup> reply_markup_;
int64 media_album_id_;
bool invert_media_;
bool disable_web_page_preview_;
@ -115,6 +117,7 @@ class QuickReplyManager final : public Actor {
int64 media_album_id = 0;
unique_ptr<MessageContent> content;
unique_ptr<ReplyMarkup> reply_markup;
mutable uint64 send_message_log_event_id = 0;