Support sending Invoice as result of any inline query.
This commit is contained in:
parent
b9bc86fb5a
commit
2379735d9b
@ -2247,30 +2247,30 @@ httpUrl url:string = HttpUrl;
|
||||
//@video_url The URL of the video file (file size must not exceed 1MB) @video_mime_type MIME type of the video file. Must be one of "image/gif" and "video/mp4"
|
||||
//@video_duration Duration of the video, in seconds @video_width Width of the video @video_height Height of the video
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageAnimation, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageAnimation, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultAnimation id:string title:string thumbnail_url:string thumbnail_mime_type:string video_url:string video_mime_type:string video_duration:int32 video_width:int32 video_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a link to an article or web page @id Unique identifier of the query result @url URL of the result, if it exists @hide_url True, if the URL must be not shown @title Title of the result
|
||||
//@param_description A short description of the result @thumbnail_url URL of the result thumbnail, if it exists @thumbnail_width Thumbnail width, if known @thumbnail_height Thumbnail height, if known
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultArticle id:string url:string hide_url:Bool title:string description:string thumbnail_url:string thumbnail_width:int32 thumbnail_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a link to an MP3 audio file @id Unique identifier of the query result @title Title of the audio file @performer Performer of the audio file
|
||||
//@audio_url The URL of the audio file @audio_duration Audio file duration, in seconds
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageAudio, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageAudio, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultAudio id:string title:string performer:string audio_url:string audio_duration:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a user contact @id Unique identifier of the query result @contact User contact @thumbnail_url URL of the result thumbnail, if it exists @thumbnail_width Thumbnail width, if known @thumbnail_height Thumbnail height, if known
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultContact id:string contact:contact thumbnail_url:string thumbnail_width:int32 thumbnail_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a link to a file @id Unique identifier of the query result @title Title of the resulting file @param_description Short description of the result, if known @document_url URL of the file @mime_type MIME type of the file content; only "application/pdf" and "application/zip" are currently allowed
|
||||
//@thumbnail_url The URL of the file thumbnail, if it exists @thumbnail_width Width of the thumbnail @thumbnail_height Height of the thumbnail
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageDocument, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageDocument, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultDocument id:string title:string description:string document_url:string mime_type:string thumbnail_url:string thumbnail_width:int32 thumbnail_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a game @id Unique identifier of the query result @game_short_name Short name of the game @reply_markup Message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
@ -2280,37 +2280,37 @@ inputInlineQueryResultGame id:string game_short_name:string reply_markup:ReplyMa
|
||||
//@live_period Amount of time relative to the message sent time until the location can be updated, in seconds
|
||||
//@title Title of the result @thumbnail_url URL of the result thumbnail, if it exists @thumbnail_width Thumbnail width, if known @thumbnail_height Thumbnail height, if known
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultLocation id:string location:location live_period:int32 title:string thumbnail_url:string thumbnail_width:int32 thumbnail_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents link to a JPEG image @id Unique identifier of the query result @title Title of the result, if known @param_description A short description of the result, if known @thumbnail_url URL of the photo thumbnail, if it exists
|
||||
//@photo_url The URL of the JPEG photo (photo size must not exceed 5MB) @photo_width Width of the photo @photo_height Height of the photo
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessagePhoto, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessagePhoto, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultPhoto id:string title:string description:string thumbnail_url:string photo_url:string photo_width:int32 photo_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a link to a WEBP or TGS sticker @id Unique identifier of the query result @thumbnail_url URL of the sticker thumbnail, if it exists
|
||||
//@sticker_url The URL of the WEBP or TGS sticker (sticker file size must not exceed 5MB) @sticker_width Width of the sticker @sticker_height Height of the sticker
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, inputMessageSticker, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, inputMessageSticker, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultSticker id:string thumbnail_url:string sticker_url:string sticker_width:int32 sticker_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents information about a venue @id Unique identifier of the query result @venue Venue result @thumbnail_url URL of the result thumbnail, if it exists @thumbnail_width Thumbnail width, if known @thumbnail_height Thumbnail height, if known
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultVenue id:string venue:venue thumbnail_url:string thumbnail_width:int32 thumbnail_height:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a link to a page containing an embedded video player or a video file @id Unique identifier of the query result @title Title of the result @param_description A short description of the result, if known
|
||||
//@thumbnail_url The URL of the video thumbnail (JPEG), if it exists @video_url URL of the embedded video player or video file @mime_type MIME type of the content of the video URL, only "text/html" or "video/mp4" are currently supported
|
||||
//@video_width Width of the video @video_height Height of the video @video_duration Video duration, in seconds
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageVideo, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageVideo, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultVideo id:string title:string description:string thumbnail_url:string video_url:string mime_type:string video_width:int32 video_height:int32 video_duration:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
//@description Represents a link to an opus-encoded audio file within an OGG container, single channel audio @id Unique identifier of the query result @title Title of the voice note
|
||||
//@voice_note_url The URL of the voice note file @voice_note_duration Duration of the voice note, in seconds
|
||||
//@reply_markup The message reply markup. Must be of type replyMarkupInlineKeyboard or null
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageVoiceNote, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
//@input_message_content The content of the message to be sent. Must be one of the following types: InputMessageText, InputMessageVoiceNote, InputMessageInvoice, InputMessageLocation, InputMessageVenue or InputMessageContact
|
||||
inputInlineQueryResultVoiceNote id:string title:string voice_note_url:string voice_note_duration:int32 reply_markup:ReplyMarkup input_message_content:InputMessageContent = InputInlineQueryResult;
|
||||
|
||||
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/MessagesManager.h"
|
||||
#include "td/telegram/misc.h"
|
||||
#include "td/telegram/Payments.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
#include "td/telegram/StickersManager.h"
|
||||
@ -254,6 +255,10 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
|
||||
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));
|
||||
}
|
||||
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_);
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageLocation::ID) {
|
||||
TRY_RESULT(location, process_input_message_location(std::move(input_message_content)));
|
||||
if (location.heading != 0) {
|
||||
|
@ -1766,8 +1766,7 @@ static Result<InputMessageContent> create_input_message_content(
|
||||
return Status::Error(400, "Invoices can be sent only by bots");
|
||||
}
|
||||
|
||||
TRY_RESULT(input_invoice, process_input_message_invoice(
|
||||
move_tl_object_as<td_api::inputMessageInvoice>(input_message_content), td));
|
||||
TRY_RESULT(input_invoice, process_input_message_invoice(std::move(input_message_content), td));
|
||||
content = make_unique<MessageInvoice>(std::move(input_invoice));
|
||||
break;
|
||||
}
|
||||
|
@ -640,8 +640,12 @@ InputInvoice get_input_invoice(tl_object_ptr<telegram_api::messageMediaInvoice>
|
||||
return result;
|
||||
}
|
||||
|
||||
Result<InputInvoice> process_input_message_invoice(td_api::object_ptr<td_api::inputMessageInvoice> &&input_invoice,
|
||||
Td *td) {
|
||||
Result<InputInvoice> process_input_message_invoice(
|
||||
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content, Td *td) {
|
||||
CHECK(input_message_content != nullptr);
|
||||
CHECK(input_message_content->get_id() == td_api::inputMessageInvoice::ID);
|
||||
auto input_invoice = move_tl_object_as<td_api::inputMessageInvoice>(input_message_content);
|
||||
|
||||
if (!clean_input_string(input_invoice->title_)) {
|
||||
return Status::Error(400, "Invoice title must be encoded in UTF-8");
|
||||
}
|
||||
@ -838,6 +842,21 @@ tl_object_ptr<telegram_api::inputMediaInvoice> get_input_media_invoice(const Inp
|
||||
input_invoice.start_parameter);
|
||||
}
|
||||
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaInvoice>(
|
||||
flags, false /*ignored*/, false /*ignored*/, input_invoice.title, input_invoice.description,
|
||||
std::move(input_web_document), get_input_invoice(input_invoice.invoice), BufferSlice(input_invoice.payload),
|
||||
input_invoice.provider_token,
|
||||
telegram_api::make_object<telegram_api::dataJSON>(
|
||||
input_invoice.provider_data.empty() ? "null" : input_invoice.provider_data),
|
||||
input_invoice.start_parameter, std::move(reply_markup));
|
||||
}
|
||||
|
||||
vector<FileId> get_input_invoice_file_ids(const InputInvoice &input_invoice) {
|
||||
return photo_get_file_ids(input_invoice.photo);
|
||||
}
|
||||
|
@ -124,13 +124,16 @@ bool operator!=(const InputInvoice &lhs, const InputInvoice &rhs);
|
||||
InputInvoice get_input_invoice(tl_object_ptr<telegram_api::messageMediaInvoice> &&message_invoice, Td *td,
|
||||
DialogId owner_dialog_id);
|
||||
|
||||
Result<InputInvoice> process_input_message_invoice(td_api::object_ptr<td_api::inputMessageInvoice> &&input_invoice,
|
||||
Td *td);
|
||||
Result<InputInvoice> process_input_message_invoice(
|
||||
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content, Td *td);
|
||||
|
||||
tl_object_ptr<td_api::messageInvoice> get_message_invoice_object(const InputInvoice &input_invoice, Td *td);
|
||||
|
||||
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);
|
||||
|
||||
vector<FileId> get_input_invoice_file_ids(const InputInvoice &input_invoice);
|
||||
|
||||
bool operator==(const Address &lhs, const Address &rhs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user