Improve get_input_bot_inline_message_media_* functions.

This commit is contained in:
levlam 2021-03-31 02:54:29 +03:00
parent aa65e2b586
commit 6cf3755707
7 changed files with 35 additions and 18 deletions

View File

@ -58,7 +58,11 @@ tl_object_ptr<telegram_api::inputPhoneContact> Contact::get_input_phone_contact(
}
tl_object_ptr<telegram_api::inputBotInlineMessageMediaContact> Contact::get_input_bot_inline_message_media_contact(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const {
tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const {
int32 flags = 0;
if (reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageMediaContact::REPLY_MARKUP_MASK;
}
return make_tl_object<telegram_api::inputBotInlineMessageMediaContact>(flags, phone_number_, first_name_, last_name_,
vcard_, std::move(reply_markup));
}

View File

@ -57,7 +57,7 @@ class Contact {
tl_object_ptr<telegram_api::inputPhoneContact> get_input_phone_contact(int64 client_id) const;
tl_object_ptr<telegram_api::inputBotInlineMessageMediaContact> get_input_bot_inline_message_media_contact(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const;
tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const;
template <class StorerT>
void store(StorerT &storer) const {

View File

@ -229,16 +229,15 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
}
TRY_RESULT(reply_markup, get_reply_markup(std::move(reply_markup_ptr), true, true, false, true));
auto input_reply_markup = get_input_reply_markup(reply_markup);
int32 flags = 0;
if (input_reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageText::REPLY_MARKUP_MASK;
}
auto constructor_id = input_message_content->get_id();
if (constructor_id == td_api::inputMessageText::ID) {
TRY_RESULT(input_message_text, process_input_message_text(td_->contacts_manager_.get(), DialogId(),
std::move(input_message_content), true));
int32 flags = 0;
if (input_reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageText::REPLY_MARKUP_MASK;
}
if (input_message_text.disable_web_page_preview) {
flags |= telegram_api::inputBotInlineMessageText::NO_WEBPAGE_MASK;
}
@ -253,14 +252,18 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
}
if (constructor_id == td_api::inputMessageContact::ID) {
TRY_RESULT(contact, process_input_message_contact(std::move(input_message_content)));
return contact.get_input_bot_inline_message_media_contact(flags, std::move(input_reply_markup));
return contact.get_input_bot_inline_message_media_contact(std::move(input_reply_markup));
}
if (constructor_id == td_api::inputMessageInvoice::ID) {
TRY_RESULT(input_invoice, process_input_message_invoice(std::move(input_message_content), td_));
return get_input_bot_inline_message_media_invoice(input_invoice, flags, std::move(input_reply_markup), td_);
return get_input_bot_inline_message_media_invoice(input_invoice, std::move(input_reply_markup), td_);
}
if (constructor_id == td_api::inputMessageLocation::ID) {
TRY_RESULT(location, process_input_message_location(std::move(input_message_content)));
int32 flags = 0;
if (input_reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageMediaGeo::REPLY_MARKUP_MASK;
}
if (location.heading != 0) {
flags |= telegram_api::inputBotInlineMessageMediaGeo::HEADING_MASK;
}
@ -274,16 +277,19 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
}
if (constructor_id == td_api::inputMessageVenue::ID) {
TRY_RESULT(venue, process_input_message_venue(std::move(input_message_content)));
return venue.get_input_bot_inline_message_media_venue(flags, std::move(input_reply_markup));
return venue.get_input_bot_inline_message_media_venue(std::move(input_reply_markup));
}
if (constructor_id == allowed_media_content_id) {
TRY_RESULT(caption, process_input_caption(td_->contacts_manager_.get(), DialogId(),
extract_input_caption(input_message_content), true));
int32 flags = 0;
if (input_reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageMediaAuto::REPLY_MARKUP_MASK;
}
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "get_inline_message");
if (!entities.empty()) {
flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK;
flags |= telegram_api::inputBotInlineMessageMediaAuto::ENTITIES_MASK;
}
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(flags, caption.text, std::move(entities),
std::move(input_reply_markup));
}

View File

@ -862,10 +862,14 @@ tl_object_ptr<telegram_api::inputMediaInvoice> get_input_media_invoice(const Inp
}
tl_object_ptr<telegram_api::inputBotInlineMessageMediaInvoice> get_input_bot_inline_message_media_invoice(
const InputInvoice &input_invoice, int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup, Td *td) {
const InputInvoice &input_invoice, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup, Td *td) {
int32 flags = 0;
if (reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageMediaInvoice::REPLY_MARKUP_MASK;
}
auto input_web_document = get_input_web_document(td->file_manager_.get(), input_invoice.photo);
if (input_web_document != nullptr) {
flags |= telegram_api::inputMediaInvoice::PHOTO_MASK;
flags |= telegram_api::inputBotInlineMessageMediaInvoice::PHOTO_MASK;
}
return make_tl_object<telegram_api::inputBotInlineMessageMediaInvoice>(
flags, input_invoice.title, input_invoice.description, std::move(input_web_document),

View File

@ -135,7 +135,7 @@ tl_object_ptr<td_api::messageInvoice> get_message_invoice_object(const InputInvo
tl_object_ptr<telegram_api::inputMediaInvoice> get_input_media_invoice(const InputInvoice &input_invoice, Td *td);
tl_object_ptr<telegram_api::inputBotInlineMessageMediaInvoice> get_input_bot_inline_message_media_invoice(
const InputInvoice &input_invoice, int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup, Td *td);
const InputInvoice &input_invoice, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup, Td *td);
vector<FileId> get_input_invoice_file_ids(const InputInvoice &input_invoice);

View File

@ -67,7 +67,11 @@ SecretInputMedia Venue::get_secret_input_media_venue() const {
}
tl_object_ptr<telegram_api::inputBotInlineMessageMediaVenue> Venue::get_input_bot_inline_message_media_venue(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const {
tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const {
int32 flags = 0;
if (reply_markup != nullptr) {
flags |= telegram_api::inputBotInlineMessageMediaVenue::REPLY_MARKUP_MASK;
}
return make_tl_object<telegram_api::inputBotInlineMessageMediaVenue>(
flags, location_.get_input_geo_point(), title_, address_, provider_, id_, type_, std::move(reply_markup));
}

View File

@ -54,9 +54,8 @@ class Venue {
SecretInputMedia get_secret_input_media_venue() const;
// TODO very strange function
tl_object_ptr<telegram_api::inputBotInlineMessageMediaVenue> get_input_bot_inline_message_media_venue(
int32 flags, tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const;
tl_object_ptr<telegram_api::ReplyMarkup> &&reply_markup) const;
template <class StorerT>
void store(StorerT &storer) const {