Add td_api::editBusinessMessageCaption.

This commit is contained in:
levlam 2024-06-11 14:10:43 +03:00
parent 9e466e2b9b
commit fe29121452
5 changed files with 44 additions and 0 deletions

View File

@ -8468,6 +8468,16 @@ editBusinessMessageLiveLocation business_connection_id:string chat_id:int53 mess
//@input_message_content New content of the message. Must be one of the following types: inputMessageAnimation, inputMessageAudio, inputMessageDocument, inputMessagePhoto or inputMessageVideo
editBusinessMessageMedia business_connection_id:string chat_id:int53 message_id:int53 reply_markup:ReplyMarkup input_message_content:InputMessageContent = BusinessMessage;
//@description Edits the caption of a message sent on behalf of a business account; for bots only
//@business_connection_id Unique identifier of business connection on behalf of which the message was sent
//@chat_id The chat the message belongs to
//@message_id Identifier of the message
//@reply_markup The new message reply markup; pass null if none
//@caption New message content caption; pass null to remove caption; 0-getOption("message_caption_length_max") characters
//@show_caption_above_media Pass true to show the caption above the media; otherwise, caption will be shown below the media. Can be true only for animation, photo, and video messages
editBusinessMessageCaption business_connection_id:string chat_id:int53 message_id:int53 reply_markup:ReplyMarkup caption:formattedText show_caption_above_media:Bool = BusinessMessage;
//@description Checks validness of a name for a quick reply shortcut. Can be called synchronously @name The name of the shortcut; 1-32 characters
checkQuickReplyShortcutName name:string = Ok;

View File

@ -1297,6 +1297,24 @@ void BusinessConnectionManager::do_edit_business_message_media(
get_input_reply_markup(td_->user_manager_.get(), message->reply_markup_));
}
void BusinessConnectionManager::edit_business_message_caption(
BusinessConnectionId business_connection_id, DialogId dialog_id, MessageId message_id,
td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup, td_api::object_ptr<td_api::formattedText> &&input_caption,
bool invert_media, Promise<td_api::object_ptr<td_api::businessMessage>> &&promise) {
TRY_STATUS_PROMISE(promise, check_business_connection(business_connection_id, dialog_id));
TRY_STATUS_PROMISE(promise, check_business_message_id(message_id));
TRY_RESULT_PROMISE(promise, caption,
get_formatted_text(td_, td_->dialog_manager_->get_my_dialog_id(), std::move(input_caption),
td_->auth_manager_->is_bot(), true, false, false));
TRY_RESULT_PROMISE(promise, new_reply_markup,
get_reply_markup(std::move(reply_markup), td_->auth_manager_->is_bot(), true, false, true));
td_->create_handler<EditBusinessMessageQuery>(std::move(promise))
->send(1 << 11, business_connection_id, dialog_id, message_id, caption.text,
get_input_message_entities(td_->user_manager_.get(), caption.entities, "edit_business_message_caption"),
nullptr, invert_media, get_input_reply_markup(td_->user_manager_.get(), new_reply_markup));
}
td_api::object_ptr<td_api::updateBusinessConnection> BusinessConnectionManager::get_update_business_connection(
const BusinessConnection *connection) const {
return td_api::make_object<td_api::updateBusinessConnection>(connection->get_business_connection_object(td_));

View File

@ -90,6 +90,11 @@ class BusinessConnectionManager final : public Actor {
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content,
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise);
void edit_business_message_caption(BusinessConnectionId business_connection_id, DialogId dialog_id,
MessageId message_id, td_api::object_ptr<td_api::ReplyMarkup> &&reply_markup,
td_api::object_ptr<td_api::formattedText> &&input_caption, bool invert_media,
Promise<td_api::object_ptr<td_api::businessMessage>> &&promise);
void get_current_state(vector<td_api::object_ptr<td_api::Update>> &updates) const;
private:

View File

@ -5832,6 +5832,15 @@ void Td::on_request(uint64 id, td_api::editBusinessMessageMedia &request) {
std::move(promise));
}
void Td::on_request(uint64 id, td_api::editBusinessMessageCaption &request) {
CHECK_IS_BOT();
CREATE_REQUEST_PROMISE();
business_connection_manager_->edit_business_message_caption(
BusinessConnectionId(std::move(request.business_connection_id_)), DialogId(request.chat_id_),
MessageId(request.message_id_), std::move(request.reply_markup_), std::move(request.caption_),
request.show_caption_above_media_, std::move(promise));
}
void Td::on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request) {
CHECK_IS_USER();
CREATE_OK_REQUEST_PROMISE();

View File

@ -922,6 +922,8 @@ class Td final : public Actor {
void on_request(uint64 id, td_api::editBusinessMessageMedia &request);
void on_request(uint64 id, td_api::editBusinessMessageCaption &request);
void on_request(uint64 id, const td_api::loadQuickReplyShortcuts &request);
void on_request(uint64 id, const td_api::setQuickReplyShortcutName &request);