Update layer to 75. Support entities in captions.
GitOrigin-RevId: a633d5d57c52794da0fc1b6de04f4ff1a4ed00fd
This commit is contained in:
parent
d6102462c2
commit
d7ecc96113
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
||||
|
||||
project(TDLib VERSION 1.0.6 LANGUAGES CXX C)
|
||||
project(TDLib VERSION 1.0.7 LANGUAGES CXX C)
|
||||
|
||||
option(TD_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TDLib API.")
|
||||
|
||||
|
@ -79,7 +79,9 @@ cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ..
|
||||
C:\src\vcpkg> .\vcpkg install openssl zlib
|
||||
```
|
||||
* Build `TDLib` with CMake as explained in [building](#building), but instead of `cmake -DCMAKE_BUILD_TYPE=Release ..` use
|
||||
```cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=C:\src\vcpkg\scripts\buildsystems\vcpkg.cmake ..```.
|
||||
```
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=C:\src\vcpkg\scripts\buildsystems\vcpkg.cmake ..
|
||||
```
|
||||
|
||||
#### Linux
|
||||
* Install all dependencies using your package manager.
|
||||
|
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
|
||||
|
||||
project(TdExample VERSION 1.0 LANGUAGES CXX)
|
||||
|
||||
find_package(Td 1.0.6 REQUIRED)
|
||||
find_package(Td 1.0.7 REQUIRED)
|
||||
|
||||
add_executable(tdjson_example tdjson_example.cpp)
|
||||
target_link_libraries(tdjson_example PRIVATE Td::TdJson)
|
||||
|
@ -100,7 +100,8 @@ class TdExample {
|
||||
auto send_message = td_api::make_object<td_api::sendMessage>();
|
||||
send_message->chat_id_ = chat_id;
|
||||
auto message_content = td_api::make_object<td_api::inputMessageText>();
|
||||
message_content->text_ = std::move(text);
|
||||
message_content->text_ = td_api::make_object<td_api::formattedText>();
|
||||
message_content->text_->text_ = std::move(text);
|
||||
send_message->input_message_content_ = std::move(message_content);
|
||||
|
||||
send_query(std::move(send_message), {});
|
||||
@ -194,7 +195,7 @@ class TdExample {
|
||||
auto sender_user_name = get_user_name(update_new_message.message_->sender_user_id_);
|
||||
std::string text;
|
||||
if (update_new_message.message_->content_->get_id() == td_api::messageText::ID) {
|
||||
text = static_cast<td_api::messageText &>(*update_new_message.message_->content_).text_;
|
||||
text = static_cast<td_api::messageText &>(*update_new_message.message_->content_).text_->text_;
|
||||
}
|
||||
std::cerr << "Got message: [chat_id:" << chat_id << "] [from:" << sender_user_name << "] ["
|
||||
<< text << "]" << std::endl;
|
||||
|
@ -258,7 +258,7 @@ public final class Example {
|
||||
TdApi.InlineKeyboardButton[] row = {new TdApi.InlineKeyboardButton("https://telegram.org?1", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?2", new TdApi.InlineKeyboardButtonTypeUrl()), new TdApi.InlineKeyboardButton("https://telegram.org?3", new TdApi.InlineKeyboardButtonTypeUrl())};
|
||||
TdApi.ReplyMarkup replyMarkup = new TdApi.ReplyMarkupInlineKeyboard(new TdApi.InlineKeyboardButton[][]{row, row, row});
|
||||
|
||||
TdApi.InputMessageContent content = new TdApi.InputMessageText(message, false, true, null, null);
|
||||
TdApi.InputMessageContent content = new TdApi.InputMessageText(new TdApi.FormattedText(message, null), false, true);
|
||||
client.send(new TdApi.SendMessage(chatId, 0, false, false, replyMarkup, content), defaultHandler);
|
||||
}
|
||||
|
||||
|
@ -180,8 +180,10 @@ EOT
|
||||
* Usage example:
|
||||
* \\code
|
||||
* auto get_authorization_state_request = td::td_api::make_object<td::td_api::getAuthorizationState>();
|
||||
* auto message_text = td::td_api::make_object<td::td_api::formattedText>("Hello, world!!!",
|
||||
* std::vector<td::td_api::object_ptr<td::td_api::textEntities>>());
|
||||
* auto send_message_request = td::td_api::make_object<td::td_api::sendMessage>(chat_id, 0, false, false, nullptr,
|
||||
* td::td_api::make_object<td::td_api::inputMessageText>("Hello, world!!!", false, true, {}, nullptr));
|
||||
* td::td_api::make_object<td::td_api::inputMessageText>(std::move(message_text), false, true));
|
||||
* \\endcode
|
||||
*
|
||||
* \\tparam Type Type of an object to construct.
|
||||
|
@ -176,6 +176,12 @@ maskPosition point:MaskPoint x_shift:double y_shift:double scale:double = MaskPo
|
||||
//@description Represents a part of the text that needs to be formatted in some unusual way @offset Offset of the entity in UTF-16 code points @length Length of the entity, in UTF-16 code points @type Type of the entity
|
||||
textEntity offset:int32 length:int32 type:TextEntityType = TextEntity;
|
||||
|
||||
//@description Contains a list of text entities @entities List of text entities
|
||||
textEntities entities:vector<textEntity> = TextEntities;
|
||||
|
||||
//@description A text with some entities @text The text @entities Entities contained in the text
|
||||
formattedText text:string entities:vector<textEntity> = FormattedText;
|
||||
|
||||
|
||||
//@description Describes an animation file. The animation must be encoded in GIF or MPEG4 format @duration Duration of the animation, in seconds; as defined by the sender @width Width of the animation @height Height of the animation
|
||||
//@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file, usually "image/gif" or "video/mp4" @thumbnail Animation thumbnail; may be null @animation File containing the animation
|
||||
@ -218,8 +224,8 @@ location latitude:double longitude:double = Location;
|
||||
venue location:location title:string address:string provider:string id:string = Venue;
|
||||
|
||||
//@description Describes a game @id Game ID @short_name Game short name. To share a game use the URL https://t.me/{bot_username}?game={game_short_name} @title Game title @text Game text, usually containing scoreboards for a game
|
||||
//@text_entities Entities contained in the text @param_description Game description @photo Game photo @animation Game animation; may be null
|
||||
game id:int64 short_name:string title:string text:string text_entities:vector<textEntity> description:string photo:photo animation:animation = Game;
|
||||
//@param_description Game description @photo Game photo @animation Game animation; may be null
|
||||
game id:int64 short_name:string title:string text:formattedText description:string photo:photo animation:animation = Game;
|
||||
|
||||
|
||||
//@description Describes a user profile photo @id Photo identifier; 0 for an empty photo. Can be used to find a photo in a list of userProfilePhotos
|
||||
@ -527,7 +533,7 @@ chatTypeSecret secret_chat_id:int32 user_id:int32 = ChatType;
|
||||
//@unread_mention_count Number of unread messages with a mention/reply in the chat
|
||||
//@notification_settings Notification settings for this chat
|
||||
//@reply_markup_message_id Identifier of the message from which reply markup needs to be used; 0 if there is no default custom reply markup in the chat
|
||||
//@draft_message A draft of a message in the chat; may be null. parse_mode in input_message_text will always be null
|
||||
//@draft_message A draft of a message in the chat; may be null
|
||||
//@client_data Contains client-specific data associated with the chat. (For example, the chat position or local chat notification settings can be stored here.) Persistent if a message database is used
|
||||
chat id:int53 type:ChatType title:string photo:chatPhoto last_message:message order:int64 is_pinned:Bool unread_count:int32 last_read_inbox_message_id:int53 last_read_outbox_message_id:int53 unread_mention_count:int32 notification_settings:notificationSettings reply_markup_message_id:int53 draft_message:draftMessage client_data:string = Chat;
|
||||
|
||||
@ -791,20 +797,20 @@ paymentReceipt date:int32 payments_provider_user_id:int32 invoice:invoice order_
|
||||
|
||||
//@class MessageContent @description Contains the content of a message
|
||||
|
||||
//@description A text message @text Text of the message @entities Entities contained in the text @web_page A preview of the web page that's mentioned in the text; may be null
|
||||
messageText text:string entities:vector<textEntity> web_page:webPage = MessageContent;
|
||||
//@description A text message @text Text of the message @web_page A preview of the web page that's mentioned in the text; may be null
|
||||
messageText text:formattedText web_page:webPage = MessageContent;
|
||||
|
||||
//@description An animation message (GIF-style). @animation Message content @caption Animation caption
|
||||
messageAnimation animation:animation caption:string = MessageContent;
|
||||
messageAnimation animation:animation caption:formattedText = MessageContent;
|
||||
|
||||
//@description An audio message @audio Message content @caption Audio caption
|
||||
messageAudio audio:audio caption:string = MessageContent;
|
||||
messageAudio audio:audio caption:formattedText = MessageContent;
|
||||
|
||||
//@description A document message (general file) @document Message content @caption Document caption
|
||||
messageDocument document:document caption:string = MessageContent;
|
||||
messageDocument document:document caption:formattedText = MessageContent;
|
||||
|
||||
//@description A photo message @photo Message content @caption Photo caption
|
||||
messagePhoto photo:photo caption:string = MessageContent;
|
||||
messagePhoto photo:photo caption:formattedText = MessageContent;
|
||||
|
||||
//@description An expired photo message (self-destructed after TTL has elapsed)
|
||||
messageExpiredPhoto = MessageContent;
|
||||
@ -813,7 +819,7 @@ messageExpiredPhoto = MessageContent;
|
||||
messageSticker sticker:sticker = MessageContent;
|
||||
|
||||
//@description A video message @video Message content @caption Video caption
|
||||
messageVideo video:video caption:string = MessageContent;
|
||||
messageVideo video:video caption:formattedText = MessageContent;
|
||||
|
||||
//@description An expired video message (self-destructed after TTL has elapsed)
|
||||
messageExpiredVideo = MessageContent;
|
||||
@ -822,7 +828,7 @@ messageExpiredVideo = MessageContent;
|
||||
messageVideoNote video_note:videoNote is_viewed:Bool = MessageContent;
|
||||
|
||||
//@description A voice note message @voice_note Message content @caption Voice note caption @is_listened True, if at least one of the recipients has listened to the voice note
|
||||
messageVoiceNote voice_note:voiceNote caption:string is_listened:Bool = MessageContent;
|
||||
messageVoiceNote voice_note:voiceNote caption:formattedText is_listened:Bool = MessageContent;
|
||||
|
||||
//@description A message with a location @location Message content @live_period Time relative to the message sent date until which the location can be updated, in seconds
|
||||
messageLocation location:location live_period:int32 = MessageContent;
|
||||
@ -943,19 +949,6 @@ textEntityTypeTextUrl url:string = TextEntityType;
|
||||
textEntityTypeMentionName user_id:int32 = TextEntityType;
|
||||
|
||||
|
||||
//@class TextParseMode @description Describes the way the text should be parsed for MessageEntities. By default, text is treated as-is
|
||||
|
||||
//@description The text should be parsed in markdown-style
|
||||
textParseModeMarkdown = TextParseMode;
|
||||
|
||||
//@description The text should be parsed in HTML-style
|
||||
textParseModeHTML = TextParseMode;
|
||||
|
||||
|
||||
//@description Contains a list of text entities @entities List of text entities
|
||||
textEntities entities:vector<textEntity> = TextEntities;
|
||||
|
||||
|
||||
//@description A thumbnail to be sent along with a file; should be in JPEG or WEBP format for stickers, and less than 200 kB in size @thumbnail Thumbnail file to send. Sending thumbnails by file_id is currently not supported
|
||||
//@width Thumbnail width, usually shouldn't exceed 90. Use 0 if unknown @height Thumbnail height, usually shouldn't exceed 90. Use 0 if unknown
|
||||
inputThumbnail thumbnail:InputFile width:int32 height:int32 = InputThumbnail;
|
||||
@ -963,36 +956,36 @@ inputThumbnail thumbnail:InputFile width:int32 height:int32 = InputThumbnail;
|
||||
|
||||
//@class InputMessageContent @description The content of a message to send
|
||||
|
||||
//@description A text message @text Text to be sent @disable_web_page_preview True, if rich web page previews for URLs in the message text should be disabled @clear_draft True, if a chat message draft should be deleted
|
||||
//@entities Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. Can't be used with a non-null parse_mode @parse_mode Text parse mode; may be null. Can't be used in combination with enitities
|
||||
inputMessageText text:string disable_web_page_preview:Bool clear_draft:Bool entities:vector<textEntity> parse_mode:TextParseMode = InputMessageContent;
|
||||
//@description A text message @text Formatted text to be sent. Only Bold, Italic, Code, Pre, PreCode and TextUrl entities are allowed to be specified manually
|
||||
//@disable_web_page_preview True, if rich web page previews for URLs in the message text should be disabled @clear_draft True, if a chat message draft should be deleted
|
||||
inputMessageText text:formattedText disable_web_page_preview:Bool clear_draft:Bool = InputMessageContent;
|
||||
|
||||
//@description An animation message (GIF-style). @animation Animation file to be sent @thumbnail Animation thumbnail, if available @duration Duration of the animation, in seconds @width Width of the animation; may be replaced by the server @height Height of the animation; may be replaced by the server @caption Animation caption; 0-200 characters
|
||||
inputMessageAnimation animation:InputFile thumbnail:inputThumbnail duration:int32 width:int32 height:int32 caption:string = InputMessageContent;
|
||||
inputMessageAnimation animation:InputFile thumbnail:inputThumbnail duration:int32 width:int32 height:int32 caption:formattedText = InputMessageContent;
|
||||
|
||||
//@description An audio message @audio Audio file to be sent @album_cover_thumbnail Thumbnail of the cover for the album, if available @duration Duration of the audio, in seconds; may be replaced by the server @title Title of the audio; 0-64 characters; may be replaced by the server
|
||||
//@performer Performer of the audio; 0-64 characters, may be replaced by the server @caption Audio caption; 0-200 characters
|
||||
inputMessageAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string caption:string = InputMessageContent;
|
||||
inputMessageAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string caption:formattedText = InputMessageContent;
|
||||
|
||||
//@description A document message (general file) @document Document to be sent @thumbnail Document thumbnail, if available @caption Document caption; 0-200 characters
|
||||
inputMessageDocument document:InputFile thumbnail:inputThumbnail caption:string = InputMessageContent;
|
||||
inputMessageDocument document:InputFile thumbnail:inputThumbnail caption:formattedText = InputMessageContent;
|
||||
|
||||
//@description A photo message @photo Photo to send @thumbnail Photo thumbnail to be sent, this is sent to the other party in secret chats only @added_sticker_file_ids File identifiers of the stickers added to the photo, if applicable @width Photo width @height Photo height @caption Photo caption; 0-200 characters
|
||||
//@ttl Photo TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats
|
||||
inputMessagePhoto photo:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> width:int32 height:int32 caption:string ttl:int32 = InputMessageContent;
|
||||
inputMessagePhoto photo:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> width:int32 height:int32 caption:formattedText ttl:int32 = InputMessageContent;
|
||||
|
||||
//@description A sticker message @sticker Sticker to be sent @thumbnail Sticker thumbnail, if available @width Sticker width @height Sticker height
|
||||
inputMessageSticker sticker:InputFile thumbnail:inputThumbnail width:int32 height:int32 = InputMessageContent;
|
||||
|
||||
//@description A video message @video Video to be sent @thumbnail Video thumbnail, if available @added_sticker_file_ids File identifiers of the stickers added to the video, if applicable @duration Duration of the video, in seconds @width Video width @height Video height @caption Video caption; 0-200 characters
|
||||
//@ttl Video TTL (Time To Live), in seconds (0-60). A non-zero TTL can be specified only in private chats
|
||||
inputMessageVideo video:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> duration:int32 width:int32 height:int32 caption:string ttl:int32 = InputMessageContent;
|
||||
inputMessageVideo video:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> duration:int32 width:int32 height:int32 caption:formattedText ttl:int32 = InputMessageContent;
|
||||
|
||||
//@description A video note message @video_note Video note to be sent @thumbnail Video thumbnail, if available @duration Duration of the video, in seconds @length Video width and height; must be positive and not greater than 640
|
||||
inputMessageVideoNote video_note:InputFile thumbnail:inputThumbnail duration:int32 length:int32 = InputMessageContent;
|
||||
|
||||
//@description A voice note message @voice_note Voice note to be sent @duration Duration of the voice note, in seconds @waveform Waveform representation of the voice note, in 5-bit format @caption Voice note caption; 0-200 characters
|
||||
inputMessageVoiceNote voice_note:InputFile duration:int32 waveform:bytes caption:string = InputMessageContent;
|
||||
inputMessageVoiceNote voice_note:InputFile duration:int32 waveform:bytes caption:formattedText = InputMessageContent;
|
||||
|
||||
//@description A message with a location @location Location to be sent @live_period Period for which the location can be updated, in seconds; should bebetween 60 and 86400 for a live location and 0 otherwise
|
||||
inputMessageLocation location:location live_period:int32 = InputMessageContent;
|
||||
@ -1711,6 +1704,15 @@ count count:int32 = Count;
|
||||
text text:string = Text;
|
||||
|
||||
|
||||
//@class TextParseMode @description Describes the way the text should be parsed for TextEntities
|
||||
|
||||
//@description The text should be parsed in markdown-style
|
||||
textParseModeMarkdown = TextParseMode;
|
||||
|
||||
//@description The text should be parsed in HTML-style
|
||||
textParseModeHTML = TextParseMode;
|
||||
|
||||
|
||||
//@class Proxy @description Contains information about a proxy server
|
||||
|
||||
//@description An empty proxy server
|
||||
@ -2169,7 +2171,7 @@ editMessageLiveLocation chat_id:int53 message_id:int53 reply_markup:ReplyMarkup
|
||||
|
||||
//@description Edits the message content caption. Non-bots can edit messages for a limited period of time. Returns the edited message after the edit is completed server-side
|
||||
//@chat_id The chat the message belongs to @message_id Identifier of the message @reply_markup The new message reply markup; for bots only @caption New message content caption; 0-200 characters
|
||||
editMessageCaption chat_id:int53 message_id:int53 reply_markup:ReplyMarkup caption:string = Message;
|
||||
editMessageCaption chat_id:int53 message_id:int53 reply_markup:ReplyMarkup caption:formattedText = Message;
|
||||
|
||||
//@description Edits the message reply markup; for bots only. Returns the edited message after the edit is completed server-side
|
||||
//@chat_id The chat the message belongs to @message_id Identifier of the message @reply_markup New message reply markup
|
||||
@ -2182,7 +2184,7 @@ editInlineMessageText inline_message_id:string reply_markup:ReplyMarkup input_me
|
||||
editInlineMessageLiveLocation inline_message_id:string reply_markup:ReplyMarkup location:location = Ok;
|
||||
|
||||
//@description Edits the caption of an inline message sent via a bot; for bots only @inline_message_id Inline message identifier @reply_markup New message reply markup @caption New message content caption; 0-200 characters
|
||||
editInlineMessageCaption inline_message_id:string reply_markup:ReplyMarkup caption:string = Ok;
|
||||
editInlineMessageCaption inline_message_id:string reply_markup:ReplyMarkup caption:formattedText = Ok;
|
||||
|
||||
//@description Edits the reply markup of an inline message sent via a bot; for bots only @inline_message_id Inline message identifier @reply_markup New message reply markup
|
||||
editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup = Ok;
|
||||
@ -2191,6 +2193,9 @@ editInlineMessageReplyMarkup inline_message_id:string reply_markup:ReplyMarkup =
|
||||
//@description Returns all entities (mentions, hashtags, bot commands, URLs, and email addresses) contained in the text. This is an offline method. May be called before authorization. Can be called synchronously @text The text in which to look for entites
|
||||
getTextEntities text:string = TextEntities;
|
||||
|
||||
//@description Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. This is an offline method. May be called before authorization. Can be called synchronously @text The text which should be parsed @parse_mode Text parse mode
|
||||
parseTextEntities text:string parse_mode:TextParseMode = FormattedText;
|
||||
|
||||
//@description Returns the MIME type of a file, guessed by its extension. Returns an empty string on failure. This is an offline method. May be called before authorization. Can be called synchronously @file_name The name of the file or path to the file
|
||||
getFileMimeType file_name:string = Text;
|
||||
|
||||
|
Binary file not shown.
@ -40,16 +40,16 @@ inputFile#f52ff27f id:long parts:int name:string md5_checksum:string = InputFile
|
||||
inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile;
|
||||
|
||||
inputMediaEmpty#9664f57f = InputMedia;
|
||||
inputMediaUploadedPhoto#2f37e231 flags:# file:InputFile caption:string stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaPhoto#81fa373a flags:# id:InputPhoto caption:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaUploadedPhoto#1e287d04 flags:# file:InputFile stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaPhoto#b3ba0635 flags:# id:InputPhoto ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
|
||||
inputMediaContact#a6e45987 phone_number:string first_name:string last_name:string = InputMedia;
|
||||
inputMediaUploadedDocument#e39621fd flags:# nosound_video:flags.3?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> caption:string stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaDocument#5acb668e flags:# id:InputDocument caption:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaUploadedDocument#5b38c6c1 flags:# nosound_video:flags.3?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia;
|
||||
inputMediaDocument#23ab23d2 flags:# id:InputDocument ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaVenue#c13d1c11 geo_point:InputGeoPoint title:string address:string provider:string venue_id:string venue_type:string = InputMedia;
|
||||
inputMediaGifExternal#4843b0fd url:string q:string = InputMedia;
|
||||
inputMediaPhotoExternal#922aec1 flags:# url:string caption:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaDocumentExternal#b6f74335 flags:# url:string caption:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaPhotoExternal#e5bbfe1a flags:# url:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaDocumentExternal#fb52dc99 flags:# url:string ttl_seconds:flags.0?int = InputMedia;
|
||||
inputMediaGame#d33f43f3 id:InputGame = InputMedia;
|
||||
inputMediaInvoice#f4e096c3 flags:# title:string description:string photo:flags.0?InputWebDocument invoice:Invoice payload:bytes provider:string provider_data:DataJSON start_param:string = InputMedia;
|
||||
inputMediaGeoLive#7b1a118f geo_point:InputGeoPoint period:int = InputMedia;
|
||||
@ -125,11 +125,11 @@ message#44f9b43d flags:# out:flags.1?true mentioned:flags.4?true media_unread:fl
|
||||
messageService#9e19a1f6 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true id:int from_id:flags.8?int to_id:Peer reply_to_msg_id:flags.3?int date:int action:MessageAction = Message;
|
||||
|
||||
messageMediaEmpty#3ded6320 = MessageMedia;
|
||||
messageMediaPhoto#b5223b0f flags:# photo:flags.0?Photo caption:flags.1?string ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaPhoto#695150d7 flags:# photo:flags.0?Photo ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
|
||||
messageMediaContact#5e7d2f39 phone_number:string first_name:string last_name:string user_id:int = MessageMedia;
|
||||
messageMediaUnsupported#9f84f49e = MessageMedia;
|
||||
messageMediaDocument#7c4414d3 flags:# document:flags.0?Document caption:flags.1?string ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaDocument#9cb070d7 flags:# document:flags.0?Document ttl_seconds:flags.2?int = MessageMedia;
|
||||
messageMediaWebPage#a32dd600 webpage:WebPage = MessageMedia;
|
||||
messageMediaVenue#2ec0533f geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MessageMedia;
|
||||
messageMediaGame#fdb19008 game:Game = MessageMedia;
|
||||
@ -570,7 +570,7 @@ messages.foundGifs#450a1c0a next_offset:int results:Vector<FoundGif> = messages.
|
||||
messages.savedGifsNotModified#e8025ca2 = messages.SavedGifs;
|
||||
messages.savedGifs#2e0709a5 hash:int gifs:Vector<Document> = messages.SavedGifs;
|
||||
|
||||
inputBotInlineMessageMediaAuto#292fed13 flags:# caption:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaAuto#3380c786 flags:# message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageText#3dcd7a87 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaGeo#c1b15d65 flags:# geo_point:InputGeoPoint period:int reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
inputBotInlineMessageMediaVenue#aaafadc8 flags:# geo_point:InputGeoPoint title:string address:string provider:string venue_id:string reply_markup:flags.2?ReplyMarkup = InputBotInlineMessage;
|
||||
@ -582,7 +582,7 @@ inputBotInlineResultPhoto#a8d864a7 id:string type:string photo:InputPhoto send_m
|
||||
inputBotInlineResultDocument#fff8fdc4 flags:# id:string type:string title:flags.1?string description:flags.2?string document:InputDocument send_message:InputBotInlineMessage = InputBotInlineResult;
|
||||
inputBotInlineResultGame#4fa417f2 id:string short_name:string send_message:InputBotInlineMessage = InputBotInlineResult;
|
||||
|
||||
botInlineMessageMediaAuto#a74b15b flags:# caption:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaAuto#764cf810 flags:# message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageText#8c7f65e2 flags:# no_webpage:flags.0?true message:string entities:flags.1?Vector<MessageEntity> reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaGeo#b722de65 flags:# geo:GeoPoint period:int reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
botInlineMessageMediaVenue#4366232e flags:# geo:GeoPoint title:string address:string provider:string venue_id:string reply_markup:flags.2?ReplyMarkup = BotInlineMessage;
|
||||
@ -820,7 +820,7 @@ recentMeUrlStickerSet#bc0a57dc url:string set:StickerSetCovered = RecentMeUrl;
|
||||
|
||||
help.recentMeUrls#e0310d7 urls:Vector<RecentMeUrl> chats:Vector<Chat> users:Vector<User> = help.RecentMeUrls;
|
||||
|
||||
inputSingleMedia#5eaa7809 media:InputMedia random_id:long = InputSingleMedia;
|
||||
inputSingleMedia#31bc3d25 media:InputMedia flags:# random_id:long message:string entities:flags.0?Vector<MessageEntity> = InputSingleMedia;
|
||||
|
||||
---functions---
|
||||
|
||||
@ -905,7 +905,7 @@ messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector<int> = me
|
||||
messages.receivedMessages#5a954c0 max_id:int = Vector<ReceivedNotifyMessage>;
|
||||
messages.setTyping#a3825e50 peer:InputPeer action:SendMessageAction = Bool;
|
||||
messages.sendMessage#fa88427a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> = Updates;
|
||||
messages.sendMedia#c8f16791 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia random_id:long reply_markup:flags.2?ReplyMarkup = Updates;
|
||||
messages.sendMedia#b8d1262b flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true peer:InputPeer reply_to_msg_id:flags.0?int media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> = Updates;
|
||||
messages.forwardMessages#708e0195 flags:# silent:flags.5?true background:flags.6?true with_my_score:flags.8?true grouped:flags.9?true from_peer:InputPeer id:Vector<int> random_id:Vector<long> to_peer:InputPeer = Updates;
|
||||
messages.reportSpam#cf1592db peer:InputPeer = Bool;
|
||||
messages.hideReportSpam#a8f1709b peer:InputPeer = Bool;
|
||||
@ -917,7 +917,6 @@ messages.editChatPhoto#ca4c79d8 chat_id:int photo:InputChatPhoto = Updates;
|
||||
messages.addChatUser#f9a0aa09 chat_id:int user_id:InputUser fwd_limit:int = Updates;
|
||||
messages.deleteChatUser#e0611f16 chat_id:int user_id:InputUser = Updates;
|
||||
messages.createChat#9cb126e users:Vector<InputUser> title:string = Updates;
|
||||
messages.forwardMessage#33963bf9 peer:InputPeer id:int random_id:long = Updates;
|
||||
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
|
||||
messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat;
|
||||
messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long = EncryptedChat;
|
||||
@ -930,8 +929,9 @@ messages.sendEncryptedService#32d439a4 peer:InputEncryptedChat random_id:long da
|
||||
messages.receivedQueue#55a5bb66 max_qts:int = Vector<long>;
|
||||
messages.reportEncryptedSpam#4b0c8c0f peer:InputEncryptedChat = Bool;
|
||||
messages.readMessageContents#36a73f77 id:Vector<int> = messages.AffectedMessages;
|
||||
messages.getStickers#ae22e045 emoticon:string hash:string = messages.Stickers;
|
||||
messages.getAllStickers#1c9618b1 hash:int = messages.AllStickers;
|
||||
messages.getWebPagePreview#25223e24 message:string = MessageMedia;
|
||||
messages.getWebPagePreview#8b68b0cc flags:# message:string entities:flags.3?Vector<MessageEntity> = MessageMedia;
|
||||
messages.exportChatInvite#7d885289 chat_id:int = ExportedChatInvite;
|
||||
messages.checkChatInvite#3eadb1bb hash:string = ChatInvite;
|
||||
messages.importChatInvite#6c50051c hash:string = Updates;
|
||||
|
Binary file not shown.
@ -257,17 +257,16 @@ void AnimationsManager::create_animation(FileId file_id, PhotoSize thumbnail, st
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
||||
FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail, const string &caption) const {
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const {
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), caption,
|
||||
0);
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), caption, 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -296,7 +295,7 @@ tl_object_ptr<telegram_api::InputMedia> AnimationsManager::get_input_media(
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
||||
caption, vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -42,8 +42,7 @@ class AnimationsManager : public Actor {
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
||||
const string &caption) const;
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const;
|
||||
|
||||
SecretInputMedia get_secret_input_media(FileId animation_file_id,
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||
|
@ -220,17 +220,16 @@ SecretInputMedia AudiosManager::get_secret_input_media(FileId audio_file_id,
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
||||
FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail, const string &caption) const {
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const {
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), caption,
|
||||
0);
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), caption, 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -255,7 +254,7 @@ tl_object_ptr<telegram_api::InputMedia> AudiosManager::get_input_media(
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
||||
caption, vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -37,8 +37,7 @@ class AudiosManager {
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
||||
const string &caption) const;
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const;
|
||||
|
||||
SecretInputMedia get_secret_input_media(FileId audio_file_id,
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||
|
@ -375,17 +375,16 @@ SecretInputMedia DocumentsManager::get_secret_input_media(FileId document_file_i
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
||||
FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail, const string &caption) const {
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const {
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), caption,
|
||||
0);
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), caption, 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -403,7 +402,7 @@ tl_object_ptr<telegram_api::InputMedia> DocumentsManager::get_input_media(
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), document->mime_type,
|
||||
std::move(attributes), caption, vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -75,8 +75,7 @@ class DocumentsManager {
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
||||
const string &caption) const;
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail) const;
|
||||
|
||||
FileId get_document_thumbnail_file_id(FileId file_id) const;
|
||||
|
||||
|
@ -83,14 +83,13 @@ UserId Game::get_bot_user_id() const {
|
||||
return bot_user_id_;
|
||||
}
|
||||
|
||||
void Game::set_message_text(string text, vector<MessageEntity> &&entities) {
|
||||
void Game::set_message_text(FormattedText &&text) {
|
||||
text_ = std::move(text);
|
||||
entities_ = std::move(entities);
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::game> Game::get_game_object(const Td *td) const {
|
||||
return make_tl_object<td_api::game>(
|
||||
id_, short_name_, title_, text_, get_text_entities_object(entities_), description_,
|
||||
id_, short_name_, title_, get_formatted_text_object(text_), description_,
|
||||
get_photo_object(td->file_manager_.get(), &photo_),
|
||||
td->animations_manager_->get_animation_object(animation_file_id_, "get_game_object"));
|
||||
}
|
||||
@ -105,8 +104,7 @@ tl_object_ptr<telegram_api::inputMediaGame> Game::get_input_media_game(const Td
|
||||
bool operator==(const Game &lhs, const Game &rhs) {
|
||||
return lhs.id_ == rhs.id_ && lhs.access_hash_ == rhs.access_hash_ && lhs.bot_user_id_ == rhs.bot_user_id_ &&
|
||||
lhs.short_name_ == rhs.short_name_ && lhs.title_ == rhs.title_ && lhs.description_ == rhs.description_ &&
|
||||
lhs.photo_ == rhs.photo_ && lhs.animation_file_id_ == rhs.animation_file_id_ && lhs.text_ == rhs.text_ &&
|
||||
lhs.entities_ == rhs.entities_;
|
||||
lhs.photo_ == rhs.photo_ && lhs.animation_file_id_ == rhs.animation_file_id_ && lhs.text_ == rhs.text_;
|
||||
}
|
||||
|
||||
bool operator!=(const Game &lhs, const Game &rhs) {
|
||||
|
@ -32,8 +32,7 @@ class Game {
|
||||
Photo photo_;
|
||||
FileId animation_file_id_;
|
||||
|
||||
string text_;
|
||||
vector<MessageEntity> entities_;
|
||||
FormattedText text_;
|
||||
|
||||
friend bool operator==(const Game &lhs, const Game &rhs);
|
||||
friend bool operator!=(const Game &lhs, const Game &rhs);
|
||||
@ -56,7 +55,7 @@ class Game {
|
||||
|
||||
UserId get_bot_user_id() const;
|
||||
|
||||
void set_message_text(string text, vector<MessageEntity> &&entities);
|
||||
void set_message_text(FormattedText &&text);
|
||||
|
||||
tl_object_ptr<td_api::game> get_game_object(const Td *td) const;
|
||||
|
||||
|
@ -33,7 +33,6 @@ void Game::store(StorerT &storer) const {
|
||||
storer.context()->td().get_actor_unsafe()->animations_manager_->store_animation(animation_file_id_, storer);
|
||||
}
|
||||
store(text_, storer);
|
||||
store(entities_, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
@ -56,7 +55,6 @@ void Game::parse(ParserT &parser) {
|
||||
animation_file_id_ = parser.context()->td().get_actor_unsafe()->animations_manager_->parse_animation(parser);
|
||||
}
|
||||
parse(text_, parser);
|
||||
parse(entities_, parser);
|
||||
}
|
||||
|
||||
} // namespace td
|
||||
|
@ -5,7 +5,6 @@
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
#include "td/telegram/InlineQueriesManager.h"
|
||||
|
||||
#include "td/telegram/td_api.h"
|
||||
#include "td/telegram/td_api.hpp"
|
||||
#include "td/telegram/telegram_api.h"
|
||||
@ -210,6 +209,27 @@ string InlineQueriesManager::get_inline_message_id(
|
||||
return base64url_encode(serialize(*input_bot_inline_message_id));
|
||||
}
|
||||
|
||||
Result<FormattedText> InlineQueriesManager::process_input_caption(
|
||||
td_api::object_ptr<td_api::formattedText> &&caption) const {
|
||||
return td_->messages_manager_->process_input_caption(DialogId(), std::move(caption), true);
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::inputBotInlineMessageMediaAuto>
|
||||
InlineQueriesManager::get_input_bot_inline_message_media_auto(
|
||||
const FormattedText &caption, tl_object_ptr<telegram_api::ReplyMarkup> &&input_reply_markup) const {
|
||||
int32 flags = 0;
|
||||
if (input_reply_markup != nullptr) {
|
||||
flags |= telegram_api::inputBotInlineMessageText::REPLY_MARKUP_MASK;
|
||||
}
|
||||
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities);
|
||||
if (!entities.empty()) {
|
||||
flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK;
|
||||
}
|
||||
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(flags, caption.text, std::move(entities),
|
||||
std::move(input_reply_markup));
|
||||
}
|
||||
|
||||
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager::get_inline_message(
|
||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr, int32 allowed_media_content_id) const {
|
||||
@ -231,12 +251,12 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
|
||||
if (input_message_text.disable_web_page_preview) {
|
||||
flags |= telegram_api::inputBotInlineMessageText::NO_WEBPAGE_MASK;
|
||||
}
|
||||
if (!input_message_text.entities.empty()) {
|
||||
if (!input_message_text.text.entities.empty()) {
|
||||
flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageText>(
|
||||
flags, false /*ignored*/, std::move(input_message_text.text),
|
||||
get_input_message_entities(td_->contacts_manager_.get(), input_message_text.entities),
|
||||
flags, false /*ignored*/, std::move(input_message_text.text.text),
|
||||
get_input_message_entities(td_->contacts_manager_.get(), input_message_text.text.entities),
|
||||
std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageContact::ID) {
|
||||
@ -255,61 +275,38 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
|
||||
if (constructor_id == allowed_media_content_id) {
|
||||
if (constructor_id == td_api::inputMessageAnimation::ID) {
|
||||
auto input_message_animation = static_cast<td_api::inputMessageAnimation *>(input_message_content.get());
|
||||
if (!clean_input_string(input_message_animation->caption_)) {
|
||||
return Status::Error(400, "Animation caption must be encoded in UTF-8");
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(
|
||||
flags, strip_empty_characters(input_message_animation->caption_, MAX_CAPTION_LENGTH),
|
||||
std::move(input_reply_markup));
|
||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_animation->caption_)));
|
||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageAudio::ID) {
|
||||
auto input_message_audio = static_cast<td_api::inputMessageAudio *>(input_message_content.get());
|
||||
if (!clean_input_string(input_message_audio->caption_)) {
|
||||
return Status::Error(400, "Audio caption must be encoded in UTF-8");
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(
|
||||
flags, strip_empty_characters(input_message_audio->caption_, MAX_CAPTION_LENGTH),
|
||||
std::move(input_reply_markup));
|
||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_audio->caption_)));
|
||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageDocument::ID) {
|
||||
auto input_message_document = static_cast<td_api::inputMessageDocument *>(input_message_content.get());
|
||||
if (!clean_input_string(input_message_document->caption_)) {
|
||||
return Status::Error(400, "Document caption must be encoded in UTF-8");
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(
|
||||
flags, strip_empty_characters(input_message_document->caption_, MAX_CAPTION_LENGTH),
|
||||
std::move(input_reply_markup));
|
||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_document->caption_)));
|
||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessagePhoto::ID) {
|
||||
auto input_message_photo = static_cast<td_api::inputMessagePhoto *>(input_message_content.get());
|
||||
if (!clean_input_string(input_message_photo->caption_)) {
|
||||
return Status::Error(400, "Photo caption must be encoded in UTF-8");
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(
|
||||
flags, strip_empty_characters(input_message_photo->caption_, MAX_CAPTION_LENGTH),
|
||||
std::move(input_reply_markup));
|
||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_photo->caption_)));
|
||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageSticker::ID) {
|
||||
// auto input_message_sticker = static_cast<const td_api::inputMessageSticker *>(input_message_content.get());
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(flags, "", std::move(input_reply_markup));
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(flags, "", Auto(),
|
||||
std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageVideo::ID) {
|
||||
auto input_message_video = static_cast<td_api::inputMessageVideo *>(input_message_content.get());
|
||||
if (!clean_input_string(input_message_video->caption_)) {
|
||||
return Status::Error(400, "Video caption must be encoded in UTF-8");
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(
|
||||
flags, strip_empty_characters(input_message_video->caption_, MAX_CAPTION_LENGTH),
|
||||
std::move(input_reply_markup));
|
||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_video->caption_)));
|
||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
||||
}
|
||||
if (constructor_id == td_api::inputMessageVoiceNote::ID) {
|
||||
auto input_message_voice_note = static_cast<td_api::inputMessageVoiceNote *>(input_message_content.get());
|
||||
if (!clean_input_string(input_message_voice_note->caption_)) {
|
||||
return Status::Error(400, "Voice note caption must be encoded in UTF-8");
|
||||
}
|
||||
return make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(
|
||||
flags, strip_empty_characters(input_message_voice_note->caption_, MAX_CAPTION_LENGTH),
|
||||
std::move(input_reply_markup));
|
||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_voice_note->caption_)));
|
||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
||||
}
|
||||
}
|
||||
return Status::Error(400, "Unallowed inline message content type");
|
||||
@ -334,7 +331,7 @@ bool InlineQueriesManager::register_inline_message_content(
|
||||
auto inline_message_text = move_tl_object_as<telegram_api::botInlineMessageText>(inline_message);
|
||||
auto entities = get_message_entities(td_->contacts_manager_.get(), std::move(inline_message_text->entities_));
|
||||
auto status =
|
||||
MessagesManager::fix_text_message(inline_message_text->message_, entities, nullptr, false, true, true, false);
|
||||
MessagesManager::fix_text_message(inline_message_text->message_, entities, false, true, true, false);
|
||||
if (status.is_error()) {
|
||||
LOG(ERROR) << "Receive error " << status << " while parsing botInlineMessageText "
|
||||
<< inline_message_text->message_;
|
||||
@ -348,8 +345,8 @@ bool InlineQueriesManager::register_inline_message_content(
|
||||
web_page_id =
|
||||
td_->web_pages_manager_->get_web_page_by_url(get_first_url(inline_message_text->message_, entities));
|
||||
}
|
||||
message_content =
|
||||
make_unique<MessageText>(std::move(inline_message_text->message_), std::move(entities), web_page_id);
|
||||
message_content = make_unique<MessageText>(
|
||||
FormattedText{std::move(inline_message_text->message_), std::move(entities)}, web_page_id);
|
||||
reply_markup = std::move(inline_message_text->reply_markup_);
|
||||
break;
|
||||
}
|
||||
@ -382,40 +379,33 @@ bool InlineQueriesManager::register_inline_message_content(
|
||||
break;
|
||||
}
|
||||
case telegram_api::botInlineMessageMediaAuto::ID: {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
auto caption = td_->messages_manager_->get_message_text(input_message_media_auto->message_,
|
||||
std::move(input_message_media_auto->entities_), 0);
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
|
||||
if (allowed_media_content_id == td_api::inputMessageAnimation::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessageAnimation>(file_id, std::move(input_message_media_auto->caption_));
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
message_content = make_unique<MessageAnimation>(file_id, std::move(caption));
|
||||
} else if (allowed_media_content_id == td_api::inputMessageAudio::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessageAudio>(file_id, std::move(input_message_media_auto->caption_));
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
message_content = make_unique<MessageAudio>(file_id, std::move(caption));
|
||||
} else if (allowed_media_content_id == td_api::inputMessageDocument::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessageDocument>(file_id, std::move(input_message_media_auto->caption_));
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
message_content = make_unique<MessageDocument>(file_id, std::move(caption));
|
||||
} else if (allowed_media_content_id == td_api::inputMessageGame::ID) {
|
||||
CHECK(game != nullptr);
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
// TODO game->set_short_name(std::move(input_message_media_auto->caption_));
|
||||
// TODO game->set_short_name(std::move(caption));
|
||||
message_content = make_unique<MessageGame>(std::move(*game));
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
} else if (allowed_media_content_id == td_api::inputMessagePhoto::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessagePhoto>(std::move(*photo), std::move(input_message_media_auto->caption_));
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
message_content = make_unique<MessagePhoto>(std::move(*photo), std::move(caption));
|
||||
} else if (allowed_media_content_id == td_api::inputMessageSticker::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessageSticker>(file_id);
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
} else if (allowed_media_content_id == td_api::inputMessageVideo::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessageVideo>(file_id, std::move(input_message_media_auto->caption_));
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
message_content = make_unique<MessageVideo>(file_id, std::move(caption));
|
||||
} else if (allowed_media_content_id == td_api::inputMessageVoiceNote::ID) {
|
||||
auto input_message_media_auto = move_tl_object_as<telegram_api::botInlineMessageMediaAuto>(inline_message);
|
||||
message_content = make_unique<MessageVoiceNote>(file_id, std::move(input_message_media_auto->caption_), true);
|
||||
reply_markup = std::move(input_message_media_auto->reply_markup_);
|
||||
message_content = make_unique<MessageVoiceNote>(file_id, std::move(caption), true);
|
||||
} else {
|
||||
input_message_media_auto->reply_markup_ = std::move(reply_markup);
|
||||
input_message_media_auto->message_ = std::move(caption.text);
|
||||
inline_message = std::move(input_message_media_auto);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1055,11 +1045,16 @@ tl_object_ptr<td_api::venue> copy(const td_api::venue &obj) {
|
||||
return make_tl_object<td_api::venue>(copy(obj.location_), obj.title_, obj.address_, obj.provider_, obj.id_);
|
||||
}
|
||||
|
||||
template <>
|
||||
tl_object_ptr<td_api::formattedText> copy(const td_api::formattedText &obj) {
|
||||
// there is no entities in the game text
|
||||
return make_tl_object<td_api::formattedText>(obj.text_, vector<tl_object_ptr<td_api::textEntity>>());
|
||||
}
|
||||
|
||||
template <>
|
||||
tl_object_ptr<td_api::game> copy(const td_api::game &obj) {
|
||||
return make_tl_object<td_api::game>(obj.id_, obj.short_name_, obj.title_, obj.text_,
|
||||
vector<tl_object_ptr<td_api::textEntity>>(), obj.description_, copy(obj.photo_),
|
||||
copy(obj.animation_));
|
||||
return make_tl_object<td_api::game>(obj.id_, obj.short_name_, obj.title_, copy(obj.text_), obj.description_,
|
||||
copy(obj.photo_), copy(obj.animation_));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "td/telegram/DialogId.h"
|
||||
#include "td/telegram/files/FileId.h"
|
||||
#include "td/telegram/Location.h"
|
||||
#include "td/telegram/MessageEntity.h"
|
||||
#include "td/telegram/net/NetQuery.h"
|
||||
#include "td/telegram/Photo.h"
|
||||
#include "td/telegram/ReplyMarkup.h"
|
||||
@ -78,7 +79,6 @@ class InlineQueriesManager : public Actor {
|
||||
|
||||
private:
|
||||
static constexpr int32 MAX_RECENT_INLINE_BOTS = 20; // some reasonable value
|
||||
static constexpr int32 MAX_CAPTION_LENGTH = 200; // server side limit
|
||||
static constexpr int32 INLINE_QUERY_DELAY_MS = 400; // server side limit
|
||||
|
||||
static constexpr int32 BOT_INLINE_MEDIA_RESULT_FLAG_HAS_PHOTO = 1 << 0;
|
||||
@ -86,6 +86,11 @@ class InlineQueriesManager : public Actor {
|
||||
static constexpr int32 BOT_INLINE_MEDIA_RESULT_FLAG_HAS_TITLE = 1 << 2;
|
||||
static constexpr int32 BOT_INLINE_MEDIA_RESULT_FLAG_HAS_DESCRIPTION = 1 << 3;
|
||||
|
||||
Result<FormattedText> process_input_caption(td_api::object_ptr<td_api::formattedText> &&caption) const;
|
||||
|
||||
tl_object_ptr<telegram_api::inputBotInlineMessageMediaAuto> get_input_bot_inline_message_media_auto(
|
||||
const FormattedText &caption, tl_object_ptr<telegram_api::ReplyMarkup> &&input_reply_markup) const;
|
||||
|
||||
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> get_inline_message(
|
||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
||||
|
@ -128,8 +128,6 @@ vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<
|
||||
return result;
|
||||
}
|
||||
|
||||
// 0 means nothing
|
||||
|
||||
static bool is_word_character(uint32 a) {
|
||||
switch (get_unicode_simple_category(a)) {
|
||||
case UnicodeSimpleCategory::Letter:
|
||||
@ -141,6 +139,10 @@ static bool is_word_character(uint32 a) {
|
||||
}
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text) {
|
||||
return td_api::make_object<td_api::formattedText>(text.text, get_text_entities_object(text.entities));
|
||||
}
|
||||
|
||||
/*
|
||||
static bool is_word_boundary(uint32 a, uint32 b) {
|
||||
return is_word_character(a) ^ is_word_character(b);
|
||||
@ -1573,6 +1575,75 @@ vector<tl_object_ptr<secret_api::MessageEntity>> get_input_secret_message_entiti
|
||||
return result;
|
||||
}
|
||||
|
||||
Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contacts_manager,
|
||||
const vector<tl_object_ptr<td_api::textEntity>> &input_entities) {
|
||||
vector<MessageEntity> entities;
|
||||
for (auto &entity : input_entities) {
|
||||
if (entity == nullptr || entity->type_ == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (entity->type_->get_id()) {
|
||||
case td_api::textEntityTypeMention::ID:
|
||||
return Status::Error(400, "EntityMention can't be used in outgoing messages");
|
||||
case td_api::textEntityTypeHashtag::ID:
|
||||
return Status::Error(400, "EntityHashtag can't be used in outgoing messages");
|
||||
case td_api::textEntityTypeBotCommand::ID:
|
||||
return Status::Error(400, "EntityBotCommand can't be used in outgoing messages");
|
||||
case td_api::textEntityTypeUrl::ID:
|
||||
return Status::Error(400, "EntityUrl can't be used in outgoing messages");
|
||||
case td_api::textEntityTypeEmailAddress::ID:
|
||||
return Status::Error(400, "EntityEmailAddress can't be used in outgoing messages");
|
||||
case td_api::textEntityTypeBold::ID:
|
||||
entities.emplace_back(MessageEntity::Type::Bold, entity->offset_, entity->length_);
|
||||
break;
|
||||
case td_api::textEntityTypeItalic::ID:
|
||||
entities.emplace_back(MessageEntity::Type::Italic, entity->offset_, entity->length_);
|
||||
break;
|
||||
case td_api::textEntityTypeCode::ID:
|
||||
entities.emplace_back(MessageEntity::Type::Code, entity->offset_, entity->length_);
|
||||
break;
|
||||
case td_api::textEntityTypePre::ID:
|
||||
entities.emplace_back(MessageEntity::Type::Pre, entity->offset_, entity->length_);
|
||||
break;
|
||||
case td_api::textEntityTypePreCode::ID: {
|
||||
auto entity_pre_code = static_cast<td_api::textEntityTypePreCode *>(entity->type_.get());
|
||||
if (!clean_input_string(entity_pre_code->language_)) {
|
||||
return Status::Error(400, "MessageEntityPreCode.language must be encoded in UTF-8");
|
||||
}
|
||||
entities.emplace_back(MessageEntity::Type::PreCode, entity->offset_, entity->length_,
|
||||
entity_pre_code->language_);
|
||||
break;
|
||||
}
|
||||
case td_api::textEntityTypeTextUrl::ID: {
|
||||
auto entity_text_url = static_cast<td_api::textEntityTypeTextUrl *>(entity->type_.get());
|
||||
if (!clean_input_string(entity_text_url->url_)) {
|
||||
return Status::Error(400, "MessageEntityTextUrl.url must be encoded in UTF-8");
|
||||
}
|
||||
auto r_http_url = parse_url(entity_text_url->url_);
|
||||
if (r_http_url.is_error()) {
|
||||
return Status::Error(400, PSTRING() << "Wrong message entity: " << r_http_url.error().message());
|
||||
}
|
||||
entities.emplace_back(MessageEntity::Type::TextUrl, entity->offset_, entity->length_,
|
||||
r_http_url.ok().get_url());
|
||||
break;
|
||||
}
|
||||
case td_api::textEntityTypeMentionName::ID: {
|
||||
auto entity_mention_name = static_cast<td_api::textEntityTypeMentionName *>(entity->type_.get());
|
||||
UserId user_id(entity_mention_name->user_id_);
|
||||
if (!contacts_manager->have_input_user(user_id)) {
|
||||
return Status::Error(7, "Have no access to the user");
|
||||
}
|
||||
entities.emplace_back(entity->offset_, entity->length_, user_id);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
||||
vector<MessageEntity> get_message_entities(const ContactsManager *contacts_manager,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities) {
|
||||
vector<MessageEntity> entities;
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
namespace td {
|
||||
|
||||
class ContactsManager;
|
||||
|
||||
class MessageEntity {
|
||||
tl_object_ptr<td_api::TextEntityType> get_text_entity_type_object() const;
|
||||
|
||||
@ -104,10 +106,40 @@ class MessageEntity {
|
||||
|
||||
StringBuilder &operator<<(StringBuilder &string_builder, const MessageEntity &message_entity);
|
||||
|
||||
struct FormattedText {
|
||||
string text;
|
||||
vector<MessageEntity> entities;
|
||||
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
td::store(text, storer);
|
||||
td::store(entities, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
void parse(ParserT &parser) {
|
||||
td::parse(text, parser);
|
||||
td::parse(entities, parser);
|
||||
}
|
||||
};
|
||||
|
||||
inline bool operator==(const FormattedText &lhs, const FormattedText &rhs) {
|
||||
return lhs.text == rhs.text && lhs.entities == rhs.entities;
|
||||
}
|
||||
|
||||
inline bool operator!=(const FormattedText &lhs, const FormattedText &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
const std::unordered_set<Slice, SliceHash> &get_valid_short_usernames();
|
||||
|
||||
Result<vector<MessageEntity>> get_message_entities(const ContactsManager *contacts_manager,
|
||||
const vector<tl_object_ptr<td_api::textEntity>> &input_entities);
|
||||
|
||||
vector<tl_object_ptr<td_api::textEntity>> get_text_entities_object(const vector<MessageEntity> &entities);
|
||||
|
||||
td_api::object_ptr<td_api::formattedText> get_formatted_text_object(const FormattedText &text);
|
||||
|
||||
// sorts entities, removes intersecting and empty entities
|
||||
void fix_entities(vector<MessageEntity> &entities);
|
||||
|
||||
@ -127,8 +159,6 @@ Result<vector<MessageEntity>> parse_markdown(string &text);
|
||||
|
||||
Result<vector<MessageEntity>> parse_html(string &text);
|
||||
|
||||
class ContactsManager;
|
||||
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> get_input_message_entities(const ContactsManager *contacts_manager,
|
||||
const vector<MessageEntity> &entities);
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -76,13 +76,11 @@ class MessageContent {
|
||||
|
||||
class MessageText : public MessageContent {
|
||||
public:
|
||||
string text;
|
||||
vector<MessageEntity> entities;
|
||||
FormattedText text;
|
||||
WebPageId web_page_id;
|
||||
|
||||
MessageText() = default;
|
||||
MessageText(string text, vector<MessageEntity> &&entities, WebPageId web_page_id)
|
||||
: text(std::move(text)), entities(std::move(entities)), web_page_id(web_page_id) {
|
||||
MessageText(FormattedText text, WebPageId web_page_id) : text(std::move(text)), web_page_id(web_page_id) {
|
||||
}
|
||||
|
||||
static const int32 ID = 0;
|
||||
@ -95,10 +93,10 @@ class MessageAnimation : public MessageContent {
|
||||
public:
|
||||
FileId file_id;
|
||||
|
||||
string caption;
|
||||
FormattedText caption;
|
||||
|
||||
MessageAnimation() = default;
|
||||
MessageAnimation(FileId file_id, string &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
MessageAnimation(FileId file_id, FormattedText &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
}
|
||||
|
||||
static const int32 ID = 1;
|
||||
@ -111,10 +109,10 @@ class MessageAudio : public MessageContent {
|
||||
public:
|
||||
FileId file_id;
|
||||
|
||||
string caption;
|
||||
FormattedText caption;
|
||||
|
||||
MessageAudio() = default;
|
||||
MessageAudio(FileId file_id, string &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
MessageAudio(FileId file_id, FormattedText &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
}
|
||||
|
||||
static const int32 ID = 2;
|
||||
@ -127,10 +125,10 @@ class MessageDocument : public MessageContent {
|
||||
public:
|
||||
FileId file_id;
|
||||
|
||||
string caption;
|
||||
FormattedText caption;
|
||||
|
||||
MessageDocument() = default;
|
||||
MessageDocument(FileId file_id, string &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
MessageDocument(FileId file_id, FormattedText &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
}
|
||||
|
||||
static const int32 ID = 3;
|
||||
@ -143,10 +141,10 @@ class MessagePhoto : public MessageContent {
|
||||
public:
|
||||
Photo photo;
|
||||
|
||||
string caption;
|
||||
FormattedText caption;
|
||||
|
||||
MessagePhoto() = default;
|
||||
MessagePhoto(Photo &&photo, string &&caption) : photo(std::move(photo)), caption(std::move(caption)) {
|
||||
MessagePhoto(Photo &&photo, FormattedText &&caption) : photo(std::move(photo)), caption(std::move(caption)) {
|
||||
}
|
||||
|
||||
static const int32 ID = 4;
|
||||
@ -173,10 +171,10 @@ class MessageVideo : public MessageContent {
|
||||
public:
|
||||
FileId file_id;
|
||||
|
||||
string caption;
|
||||
FormattedText caption;
|
||||
|
||||
MessageVideo() = default;
|
||||
MessageVideo(FileId file_id, string &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
MessageVideo(FileId file_id, FormattedText &&caption) : file_id(file_id), caption(std::move(caption)) {
|
||||
}
|
||||
|
||||
static const int32 ID = 6;
|
||||
@ -189,11 +187,11 @@ class MessageVoiceNote : public MessageContent {
|
||||
public:
|
||||
FileId file_id;
|
||||
|
||||
string caption;
|
||||
FormattedText caption;
|
||||
bool is_listened;
|
||||
|
||||
MessageVoiceNote() = default;
|
||||
MessageVoiceNote(FileId file_id, string &&caption, bool is_listened)
|
||||
MessageVoiceNote(FileId file_id, FormattedText &&caption, bool is_listened)
|
||||
: file_id(file_id), caption(std::move(caption)), is_listened(is_listened) {
|
||||
}
|
||||
|
||||
@ -616,16 +614,12 @@ class MessageCustomServiceAction : public MessageContent {
|
||||
|
||||
class InputMessageText {
|
||||
public:
|
||||
string text;
|
||||
FormattedText text;
|
||||
bool disable_web_page_preview = false;
|
||||
bool clear_draft = false;
|
||||
vector<MessageEntity> entities;
|
||||
InputMessageText() = default;
|
||||
InputMessageText(string text, bool disable_web_page_preview, bool clear_draft, vector<MessageEntity> entities)
|
||||
: text(std::move(text))
|
||||
, disable_web_page_preview(disable_web_page_preview)
|
||||
, clear_draft(clear_draft)
|
||||
, entities(std::move(entities)) {
|
||||
InputMessageText(FormattedText text, bool disable_web_page_preview, bool clear_draft)
|
||||
: text(std::move(text)), disable_web_page_preview(disable_web_page_preview), clear_draft(clear_draft) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -958,6 +952,9 @@ class MessagesManager : public Actor {
|
||||
|
||||
DialogId search_public_dialog(const string &username_to_search, bool force, Promise<Unit> &&promise);
|
||||
|
||||
Result<FormattedText> process_input_caption(DialogId dialog_id, tl_object_ptr<td_api::formattedText> &&text,
|
||||
bool is_bot) const;
|
||||
|
||||
Result<InputMessageText> process_input_message_text(
|
||||
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content, bool is_bot,
|
||||
bool for_draft = false) const TD_WARN_UNUSED_RESULT;
|
||||
@ -974,8 +971,13 @@ class MessagesManager : public Actor {
|
||||
Result<Game> process_input_message_game(tl_object_ptr<td_api::InputMessageContent> &&input_message_content) const
|
||||
TD_WARN_UNUSED_RESULT;
|
||||
|
||||
static Status fix_text_message(string &text, vector<MessageEntity> &entities,
|
||||
tl_object_ptr<td_api::TextParseMode> &&parse_mode, bool allow_empty,
|
||||
bool need_skip_bot_commands(DialogId dialog_id, bool is_bot) const;
|
||||
|
||||
FormattedText get_message_text(string message_text,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
|
||||
int32 send_date) const;
|
||||
|
||||
static Status fix_text_message(string &text, vector<MessageEntity> &entities, bool allow_empty,
|
||||
bool skip_new_entities, bool skip_bot_commands, bool for_draft) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
Result<MessageId> send_message(DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification,
|
||||
@ -1010,7 +1012,7 @@ class MessagesManager : public Actor {
|
||||
tl_object_ptr<td_api::location> &&input_location, Promise<Unit> &&promise);
|
||||
|
||||
void edit_message_caption(FullMessageId full_message_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
const string &caption, Promise<Unit> &&promise);
|
||||
tl_object_ptr<td_api::formattedText> &&input_caption, Promise<Unit> &&promise);
|
||||
|
||||
void edit_message_reply_markup(FullMessageId full_message_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
Promise<Unit> &&promise);
|
||||
@ -1024,7 +1026,7 @@ class MessagesManager : public Actor {
|
||||
tl_object_ptr<td_api::location> &&input_location, Promise<Unit> &&promise);
|
||||
|
||||
void edit_inline_message_caption(const string &inline_message_id, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||
const string &caption, Promise<Unit> &&promise);
|
||||
tl_object_ptr<td_api::formattedText> &&input_caption, Promise<Unit> &&promise);
|
||||
|
||||
void edit_inline_message_reply_markup(const string &inline_message_id,
|
||||
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup, Promise<Unit> &&promise);
|
||||
@ -2178,25 +2180,25 @@ class MessagesManager : public Actor {
|
||||
static unique_ptr<DraftMessage> get_draft_message(ContactsManager *contacts_manager,
|
||||
tl_object_ptr<telegram_api::DraftMessage> &&draft_message_ptr);
|
||||
|
||||
static string get_media_caption(const string &message_text, string &&caption);
|
||||
static FormattedText get_secret_media_caption(string &&message_text, string &&message_caption);
|
||||
|
||||
Photo get_web_document_photo(tl_object_ptr<telegram_api::webDocument> web_document, DialogId owner_dialog_id) const;
|
||||
|
||||
unique_ptr<MessageContent> get_secret_message_document(
|
||||
tl_object_ptr<telegram_api::encryptedFile> file,
|
||||
tl_object_ptr<secret_api::decryptedMessageMediaDocument> &&document,
|
||||
vector<tl_object_ptr<telegram_api::DocumentAttribute>> &&attributes, DialogId owner_dialog_id, string &&caption,
|
||||
bool is_opened) const;
|
||||
vector<tl_object_ptr<telegram_api::DocumentAttribute>> &&attributes, DialogId owner_dialog_id,
|
||||
FormattedText &&caption, bool is_opened) const;
|
||||
|
||||
unique_ptr<MessageContent> get_message_document(tl_object_ptr<telegram_api::document> &&document,
|
||||
DialogId owner_dialog_id, string &&caption, bool is_opened,
|
||||
DialogId owner_dialog_id, FormattedText &&caption, bool is_opened,
|
||||
MultiPromiseActor *load_data_multipromise_ptr) const;
|
||||
|
||||
unique_ptr<MessageContent> get_message_document(std::pair<DocumentsManager::DocumentType, FileId> &&parsed_document,
|
||||
string &&caption, bool is_opened) const;
|
||||
FormattedText &&caption, bool is_opened) const;
|
||||
|
||||
unique_ptr<MessagePhoto> get_message_photo(tl_object_ptr<telegram_api::photo> &&photo, DialogId owner_dialog_id,
|
||||
string &&caption) const;
|
||||
FormattedText &&caption) const;
|
||||
|
||||
unique_ptr<MessageContent> get_secret_message_content(
|
||||
string message_text, tl_object_ptr<telegram_api::encryptedFile> file,
|
||||
@ -2204,10 +2206,10 @@ class MessagesManager : public Actor {
|
||||
vector<tl_object_ptr<secret_api::MessageEntity>> &&secret_entities, DialogId owner_dialog_id,
|
||||
MultiPromiseActor &load_data_multipromise) const;
|
||||
|
||||
unique_ptr<MessageContent> get_message_content(string message_text, tl_object_ptr<telegram_api::MessageMedia> &&media,
|
||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities,
|
||||
unique_ptr<MessageContent> get_message_content(FormattedText message_text,
|
||||
tl_object_ptr<telegram_api::MessageMedia> &&media,
|
||||
DialogId owner_dialog_id, bool is_content_read, UserId via_bot_user_id,
|
||||
int32 *ttl, int32 send_date) const;
|
||||
int32 *ttl) const;
|
||||
|
||||
unique_ptr<MessageContent> dup_message_content(DialogId dialog_id, const MessageContent *content, bool for_forward);
|
||||
|
||||
@ -2216,7 +2218,7 @@ class MessagesManager : public Actor {
|
||||
|
||||
tl_object_ptr<td_api::MessageContent> get_message_content_object(const MessageContent *content) const;
|
||||
|
||||
static string get_message_content_caption(const MessageContent *content);
|
||||
static FormattedText get_message_content_caption(const MessageContent *content);
|
||||
|
||||
int32 get_message_content_duration(const MessageContent *content) const;
|
||||
|
||||
|
@ -397,7 +397,7 @@ bool photo_has_input_media(FileManager *file_manager, const Photo &photo, bool i
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_manager, const Photo &photo,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
const string &caption, int32 ttl) {
|
||||
int32 ttl) {
|
||||
if (!photo.photos.empty()) {
|
||||
auto file_id = photo.photos.back().file_id;
|
||||
auto file_view = file_manager->get_file_view(file_id);
|
||||
@ -409,17 +409,15 @@ tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_
|
||||
if (ttl != 0) {
|
||||
flags |= telegram_api::inputMediaPhoto::TTL_SECONDS_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaPhoto>(flags, file_view.remote_location().as_input_photo(), caption,
|
||||
ttl);
|
||||
return make_tl_object<telegram_api::inputMediaPhoto>(flags, file_view.remote_location().as_input_photo(), ttl);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
int32 flags = 0;
|
||||
if (ttl != 0) {
|
||||
flags |= telegram_api::inputMediaPhotoExternal::TTL_SECONDS_MASK;
|
||||
}
|
||||
LOG(INFO) << "Create inputMediaPhotoExternal with a URL " << file_view.url() << ", caption " << caption
|
||||
<< " and ttl " << ttl;
|
||||
return make_tl_object<telegram_api::inputMediaPhotoExternal>(flags, file_view.url(), caption, ttl);
|
||||
LOG(INFO) << "Create inputMediaPhotoExternal with a URL " << file_view.url() << " and ttl " << ttl;
|
||||
return make_tl_object<telegram_api::inputMediaPhotoExternal>(flags, file_view.url(), ttl);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
}
|
||||
@ -434,7 +432,7 @@ tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_
|
||||
flags |= telegram_api::inputMediaUploadedPhoto::TTL_SECONDS_MASK;
|
||||
}
|
||||
|
||||
return make_tl_object<telegram_api::inputMediaUploadedPhoto>(flags, std::move(input_file), caption,
|
||||
return make_tl_object<telegram_api::inputMediaUploadedPhoto>(flags, std::move(input_file),
|
||||
std::move(added_stickers), ttl);
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -104,7 +104,7 @@ SecretInputMedia photo_get_secret_input_media(FileManager *file_manager, const P
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_manager, const Photo &photo,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
const string &caption, int32 ttl);
|
||||
int32 ttl);
|
||||
|
||||
bool operator==(const Photo &lhs, const Photo &rhs);
|
||||
bool operator!=(const Photo &lhs, const Photo &rhs);
|
||||
|
@ -1319,10 +1319,10 @@ tl_object_ptr<telegram_api::InputMedia> StickersManager::get_input_media(
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), "", 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), "", 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -1344,7 +1344,7 @@ tl_object_ptr<telegram_api::InputMedia> StickersManager::get_input_media(
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "image/webp",
|
||||
std::move(attributes), "", vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
std::move(attributes), vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
@ -2832,7 +2832,7 @@ void StickersManager::create_new_sticker_set(UserId user_id, string &title, stri
|
||||
}
|
||||
|
||||
void StickersManager::upload_sticker_file(UserId user_id, FileId file_id, Promise<Unit> &&promise) {
|
||||
CHECK(td_->documents_manager_->get_input_media(file_id, nullptr, nullptr, "") == nullptr);
|
||||
CHECK(td_->documents_manager_->get_input_media(file_id, nullptr, nullptr) == nullptr);
|
||||
|
||||
auto upload_file_id = td_->documents_manager_->dup_document(td_->file_manager_->dup_file_id(file_id), file_id);
|
||||
|
||||
@ -2886,7 +2886,7 @@ void StickersManager::do_upload_sticker_file(UserId user_id, FileId file_id,
|
||||
return promise.set_error(Status::Error(3, "Have no access to the user"));
|
||||
}
|
||||
|
||||
auto input_media = td_->documents_manager_->get_input_media(file_id, std::move(input_file), nullptr, "");
|
||||
auto input_media = td_->documents_manager_->get_input_media(file_id, std::move(input_file), nullptr);
|
||||
CHECK(input_media != nullptr);
|
||||
|
||||
td_->create_handler<UploadStickerFileQuery>(std::move(promise))
|
||||
|
@ -1081,10 +1081,10 @@ class EditMessageLiveLocationRequest : public RequestOnceActor {
|
||||
class EditMessageCaptionRequest : public RequestOnceActor {
|
||||
FullMessageId full_message_id_;
|
||||
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
||||
string caption_;
|
||||
tl_object_ptr<td_api::formattedText> caption_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) override {
|
||||
td->messages_manager_->edit_message_caption(full_message_id_, std::move(reply_markup_), caption_,
|
||||
td->messages_manager_->edit_message_caption(full_message_id_, std::move(reply_markup_), std::move(caption_),
|
||||
std::move(promise));
|
||||
}
|
||||
|
||||
@ -1094,7 +1094,8 @@ class EditMessageCaptionRequest : public RequestOnceActor {
|
||||
|
||||
public:
|
||||
EditMessageCaptionRequest(ActorShared<Td> td, uint64 request_id, int64 dialog_id, int64 message_id,
|
||||
tl_object_ptr<td_api::ReplyMarkup> reply_markup, string caption)
|
||||
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
|
||||
tl_object_ptr<td_api::formattedText> caption)
|
||||
: RequestOnceActor(std::move(td), request_id)
|
||||
, full_message_id_(DialogId(dialog_id), MessageId(message_id))
|
||||
, reply_markup_(std::move(reply_markup))
|
||||
@ -1168,16 +1169,17 @@ class EditInlineMessageLiveLocationRequest : public RequestOnceActor {
|
||||
class EditInlineMessageCaptionRequest : public RequestOnceActor {
|
||||
string inline_message_id_;
|
||||
tl_object_ptr<td_api::ReplyMarkup> reply_markup_;
|
||||
string caption_;
|
||||
tl_object_ptr<td_api::formattedText> caption_;
|
||||
|
||||
void do_run(Promise<Unit> &&promise) override {
|
||||
td->messages_manager_->edit_inline_message_caption(inline_message_id_, std::move(reply_markup_), caption_,
|
||||
std::move(promise));
|
||||
td->messages_manager_->edit_inline_message_caption(inline_message_id_, std::move(reply_markup_),
|
||||
std::move(caption_), std::move(promise));
|
||||
}
|
||||
|
||||
public:
|
||||
EditInlineMessageCaptionRequest(ActorShared<Td> td, uint64 request_id, string inline_message_id,
|
||||
tl_object_ptr<td_api::ReplyMarkup> reply_markup, string caption)
|
||||
tl_object_ptr<td_api::ReplyMarkup> reply_markup,
|
||||
tl_object_ptr<td_api::formattedText> caption)
|
||||
: RequestOnceActor(std::move(td), request_id)
|
||||
, inline_message_id_(std::move(inline_message_id))
|
||||
, reply_markup_(std::move(reply_markup))
|
||||
@ -5233,7 +5235,6 @@ void Td::on_request(uint64 id, td_api::editMessageLiveLocation &request) {
|
||||
|
||||
void Td::on_request(uint64 id, td_api::editMessageCaption &request) {
|
||||
CHECK_AUTH();
|
||||
CLEAN_INPUT_STRING(request.caption_);
|
||||
CREATE_REQUEST(EditMessageCaptionRequest, request.chat_id_, request.message_id_, std::move(request.reply_markup_),
|
||||
std::move(request.caption_));
|
||||
}
|
||||
@ -5265,7 +5266,6 @@ void Td::on_request(uint64 id, td_api::editInlineMessageCaption &request) {
|
||||
CHECK_AUTH();
|
||||
CHECK_IS_BOT();
|
||||
CLEAN_INPUT_STRING(request.inline_message_id_);
|
||||
CLEAN_INPUT_STRING(request.caption_);
|
||||
CREATE_REQUEST(EditInlineMessageCaptionRequest, std::move(request.inline_message_id_),
|
||||
std::move(request.reply_markup_), std::move(request.caption_));
|
||||
}
|
||||
@ -6463,6 +6463,11 @@ void Td::on_request(uint64 id, const td_api::getTextEntities &request) {
|
||||
send_result(id, do_static_request(request));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, td_api::parseTextEntities &request) {
|
||||
// don't check authorization state
|
||||
send_result(id, do_static_request(request));
|
||||
}
|
||||
|
||||
void Td::on_request(uint64 id, const td_api::getFileMimeType &request) {
|
||||
// don't check authorization state
|
||||
send_result(id, do_static_request(request));
|
||||
@ -6486,6 +6491,33 @@ td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getTextEn
|
||||
return make_tl_object<td_api::textEntities>(get_text_entities_object(text_entities));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::Object> Td::do_static_request(td_api::parseTextEntities &request) {
|
||||
if (!check_utf8(request.text_)) {
|
||||
return create_error_raw(400, "Text must be encoded in UTF-8");
|
||||
}
|
||||
if (request.parse_mode_ == nullptr) {
|
||||
return create_error_raw(400, "Parse mode must be non-empty");
|
||||
}
|
||||
|
||||
Result<vector<MessageEntity>> r_entities;
|
||||
switch (request.parse_mode_->get_id()) {
|
||||
case td_api::textParseModeHTML::ID:
|
||||
r_entities = parse_html(request.text_);
|
||||
break;
|
||||
case td_api::textParseModeMarkdown::ID:
|
||||
r_entities = parse_markdown(request.text_);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
if (r_entities.is_error()) {
|
||||
return create_error_raw(400, PSLICE() << "Can't parse entities: " << r_entities.error().message());
|
||||
}
|
||||
|
||||
return make_tl_object<td_api::formattedText>(std::move(request.text_), get_text_entities_object(r_entities.ok()));
|
||||
}
|
||||
|
||||
td_api::object_ptr<td_api::Object> Td::do_static_request(const td_api::getFileMimeType &request) {
|
||||
// don't check file name UTF-8 correctness
|
||||
return make_tl_object<td_api::text>(MimeType::from_extension(PathView(request.file_name_).extension()));
|
||||
|
@ -189,7 +189,7 @@ class Td final : public NetQueryCallback {
|
||||
static td_api::object_ptr<td_api::Object> static_request(td_api::object_ptr<td_api::Function> function);
|
||||
|
||||
private:
|
||||
static constexpr const char *tdlib_version = "1.0.6";
|
||||
static constexpr const char *tdlib_version = "1.0.7";
|
||||
static constexpr int32 ONLINE_TIMEOUT = 240;
|
||||
|
||||
void send_result(uint64 id, tl_object_ptr<td_api::Object> object);
|
||||
@ -740,6 +740,8 @@ class Td final : public NetQueryCallback {
|
||||
|
||||
void on_request(uint64 id, const td_api::getTextEntities &request);
|
||||
|
||||
void on_request(uint64 id, td_api::parseTextEntities &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getFileMimeType &request);
|
||||
|
||||
void on_request(uint64 id, const td_api::getFileExtension &request);
|
||||
@ -761,6 +763,7 @@ class Td final : public NetQueryCallback {
|
||||
template <class T>
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const T &);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getTextEntities &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(td_api::parseTextEntities &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getFileMimeType &request);
|
||||
static td_api::object_ptr<td_api::Object> do_static_request(const td_api::getFileExtension &request);
|
||||
|
||||
|
@ -22,6 +22,7 @@ enum class Version : int32 {
|
||||
FixMinUsers,
|
||||
FixPageBlockAudioEmptyFile,
|
||||
AddMessageInvoiceProviderData,
|
||||
AddCaptionEntities,
|
||||
Next
|
||||
};
|
||||
|
||||
|
@ -201,10 +201,10 @@ tl_object_ptr<telegram_api::InputMedia> VideoNotesManager::get_input_media(
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), "", 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), "", 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -223,7 +223,7 @@ tl_object_ptr<telegram_api::InputMedia> VideoNotesManager::get_input_media(
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), "video/mp4", std::move(attributes),
|
||||
"", vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -215,7 +215,7 @@ SecretInputMedia VideosManager::get_secret_input_media(FileId video_file_id,
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
||||
FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail, const string &caption, int32 ttl) const {
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail, int32 ttl) const {
|
||||
if (!file_id.is_valid()) {
|
||||
LOG_IF(ERROR, ttl == 0) << "Video has invalid file_id";
|
||||
return nullptr;
|
||||
@ -230,14 +230,14 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
||||
flags |= telegram_api::inputMediaDocument::TTL_SECONDS_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(flags, file_view.remote_location().as_input_document(),
|
||||
caption, ttl);
|
||||
ttl);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
int32 flags = 0;
|
||||
if (ttl != 0) {
|
||||
flags |= telegram_api::inputMediaDocumentExternal::TTL_SECONDS_MASK;
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(flags, file_view.url(), caption, ttl);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(flags, file_view.url(), ttl);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -269,7 +269,7 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
flags, false /*ignored*/, std::move(input_file), std::move(input_thumbnail), mime_type, std::move(attributes),
|
||||
caption, std::move(added_stickers), ttl);
|
||||
std::move(added_stickers), ttl);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
|
@ -38,7 +38,7 @@ class VideosManager {
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
tl_object_ptr<telegram_api::InputFile> input_thumbnail,
|
||||
const string &caption, int32 ttl) const;
|
||||
int32 ttl) const;
|
||||
|
||||
SecretInputMedia get_secret_input_media(FileId video_file_id,
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||
|
@ -169,17 +169,16 @@ SecretInputMedia VoiceNotesManager::get_secret_input_media(FileId voice_file_id,
|
||||
}
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> VoiceNotesManager::get_input_media(
|
||||
FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file, const string &caption) const {
|
||||
FileId file_id, tl_object_ptr<telegram_api::InputFile> input_file) const {
|
||||
auto file_view = td_->file_manager_->get_file_view(file_id);
|
||||
if (file_view.is_encrypted()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (file_view.has_remote_location() && !file_view.remote_location().is_web()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), caption,
|
||||
0);
|
||||
return make_tl_object<telegram_api::inputMediaDocument>(0, file_view.remote_location().as_input_document(), 0);
|
||||
}
|
||||
if (file_view.has_url()) {
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), caption, 0);
|
||||
return make_tl_object<telegram_api::inputMediaDocumentExternal>(0, file_view.url(), 0);
|
||||
}
|
||||
CHECK(!file_view.has_remote_location());
|
||||
|
||||
@ -199,7 +198,7 @@ tl_object_ptr<telegram_api::InputMedia> VoiceNotesManager::get_input_media(
|
||||
mime_type = "audio/ogg";
|
||||
}
|
||||
return make_tl_object<telegram_api::inputMediaUploadedDocument>(
|
||||
0, false /*ignored*/, std::move(input_file), nullptr, mime_type, std::move(attributes), caption,
|
||||
0, false /*ignored*/, std::move(input_file), nullptr, mime_type, std::move(attributes),
|
||||
vector<tl_object_ptr<telegram_api::InputDocument>>(), 0);
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,7 @@ class VoiceNotesManager {
|
||||
void create_voice_note(FileId file_id, string mime_type, int32 duration, string waveform, bool replace);
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
const string &caption) const;
|
||||
tl_object_ptr<telegram_api::InputFile> input_file) const;
|
||||
|
||||
SecretInputMedia get_secret_input_media(FileId voice_file_id,
|
||||
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
||||
|
@ -60,7 +60,8 @@ class GetWebPagePreviewQuery : public Td::ResultHandler {
|
||||
|
||||
void send(const string &message_text) {
|
||||
message_text_ = message_text;
|
||||
send_query(G()->net_query_creator().create(create_storer(telegram_api::messages_getWebPagePreview(message_text))));
|
||||
send_query(G()->net_query_creator().create(
|
||||
create_storer(telegram_api::messages_getWebPagePreview(0, message_text, Auto()))));
|
||||
}
|
||||
|
||||
void on_result(uint64 id, BufferSlice packet) override {
|
||||
|
@ -293,7 +293,7 @@ class CliClient final : public Actor {
|
||||
for (auto &m : messages.messages_) {
|
||||
// LOG(PLAIN) << to_string(m);
|
||||
if (m->content_->get_id() == td_api::messageText::ID) {
|
||||
LOG(PLAIN) << td::oneline(static_cast<const td_api::messageText *>(m->content_.get())->text_) << "\n";
|
||||
LOG(PLAIN) << td::oneline(static_cast<const td_api::messageText *>(m->content_.get())->text_->text_) << "\n";
|
||||
}
|
||||
last_message_id = m->id_;
|
||||
}
|
||||
@ -539,7 +539,7 @@ class CliClient final : public Actor {
|
||||
case td_api::updateChatLastMessage::ID: {
|
||||
auto message = static_cast<const td_api::updateChatLastMessage *>(result.get())->last_message_.get();
|
||||
if (message != nullptr && message->content_->get_id() == td_api::messageText::ID) {
|
||||
// auto text = static_cast<const td_api::messageText *>(message->content_.get())->text_;
|
||||
// auto text = static_cast<const td_api::messageText *>(message->content_.get())->text_->text_;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -742,6 +742,20 @@ class CliClient final : public Actor {
|
||||
}
|
||||
#endif
|
||||
|
||||
static tl_object_ptr<td_api::formattedText> as_caption(string caption,
|
||||
vector<td_api::object_ptr<td_api::textEntity>> entities = {}) {
|
||||
if (entities.empty()) {
|
||||
auto parsed_caption =
|
||||
execute(make_tl_object<td_api::parseTextEntities>(caption, make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
if (parsed_caption->get_id() == td_api::formattedText::ID) {
|
||||
auto text = td_api::move_object_as<td_api::formattedText>(parsed_caption);
|
||||
caption = std::move(text->text_);
|
||||
entities = std::move(text->entities_);
|
||||
}
|
||||
}
|
||||
return make_tl_object<td_api::formattedText>(caption, std::move(entities));
|
||||
}
|
||||
|
||||
tl_object_ptr<td_api::NotificationSettingsScope> get_notification_settings_scope(Slice scope) const {
|
||||
if (scope == "users" || scope == "privateChats") {
|
||||
return make_tl_object<td_api::notificationSettingsScopePrivateChats>();
|
||||
@ -907,10 +921,10 @@ class CliClient final : public Actor {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto execute(tl_object_ptr<td_api::Function> f) {
|
||||
LOG(INFO) << "Execute " << tag("request", to_string(f));
|
||||
static td_api::object_ptr<td_api::Object> execute(tl_object_ptr<td_api::Function> f) {
|
||||
LOG(INFO) << "Execute request " << to_string(f);
|
||||
auto res = ClientActor::execute(std::move(f));
|
||||
LOG(INFO) << "Execute " << tag("response", to_string(res));
|
||||
LOG(INFO) << "Execute response" << to_string(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -927,10 +941,10 @@ class CliClient final : public Actor {
|
||||
}
|
||||
|
||||
void send_message(const string &chat_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||
bool disable_notification = false, bool from_background = false) {
|
||||
bool disable_notification = false, bool from_background = false, int64 reply_to_message_id = 0) {
|
||||
auto chat = as_chat_id(chat_id);
|
||||
auto id = send_request(make_tl_object<td_api::sendMessage>(chat, 0, disable_notification, from_background, nullptr,
|
||||
std::move(input_message_content)));
|
||||
auto id = send_request(make_tl_object<td_api::sendMessage>(
|
||||
chat, reply_to_message_id, disable_notification, from_background, nullptr, std::move(input_message_content)));
|
||||
query_id_to_send_message_info_[id].start_time = Time::now();
|
||||
}
|
||||
|
||||
@ -1916,6 +1930,10 @@ class CliClient final : public Actor {
|
||||
send_request(make_tl_object<td_api::getTextEntities>(args));
|
||||
} else if (op == "gtes") {
|
||||
execute(make_tl_object<td_api::getTextEntities>(args));
|
||||
} else if (op == "pte") {
|
||||
send_request(make_tl_object<td_api::parseTextEntities>(args, make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
} else if (op == "ptes") {
|
||||
execute(make_tl_object<td_api::parseTextEntities>(args, make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
} else if (op == "gfmt") {
|
||||
send_request(make_tl_object<td_api::getFileMimeType>(trim(args)));
|
||||
} else if (op == "gfe") {
|
||||
@ -1937,7 +1955,8 @@ class CliClient final : public Actor {
|
||||
|
||||
draft_message = make_tl_object<td_api::draftMessage>(
|
||||
as_message_id(reply_to_message_id),
|
||||
make_tl_object<td_api::inputMessageText>(message, true, false, std::move(entities), nullptr));
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(message, std::move(entities)), true, false));
|
||||
}
|
||||
send_request(make_tl_object<td_api::setChatDraftMessage>(as_chat_id(chat_id), std::move(draft_message)));
|
||||
} else if (op == "tcip") {
|
||||
@ -1962,13 +1981,15 @@ class CliClient final : public Actor {
|
||||
for (int i = 1; i <= 200; i++) {
|
||||
string message = PSTRING() << "#" << i;
|
||||
if (i == 6) {
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageText>(string(4097, 'a'), false, true,
|
||||
vector<tl_object_ptr<td_api::textEntity>>(), nullptr));
|
||||
} else {
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageText>(
|
||||
message, false, true, vector<tl_object_ptr<td_api::textEntity>>(),
|
||||
make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
make_tl_object<td_api::formattedText>(string(4097, 'a'),
|
||||
vector<tl_object_ptr<td_api::textEntity>>()),
|
||||
false, true));
|
||||
} else {
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(message, vector<tl_object_ptr<td_api::textEntity>>()),
|
||||
false, true));
|
||||
}
|
||||
}
|
||||
} else if (op == "ssm") {
|
||||
@ -1986,30 +2007,29 @@ class CliClient final : public Actor {
|
||||
send_request(
|
||||
make_tl_object<td_api::searchSecretMessages>(as_chat_id(chat_id), query, to_integer<int64>(from_search_id),
|
||||
to_integer<int32>(limit), get_search_messages_filter(filter)));
|
||||
} else if (op == "sm" || op == "sms") {
|
||||
string chat_id;
|
||||
string message;
|
||||
std::tie(chat_id, message) = split(args);
|
||||
send_message(
|
||||
chat_id,
|
||||
make_tl_object<td_api::inputMessageText>(message, false, true, vector<tl_object_ptr<td_api::textEntity>>(),
|
||||
make_tl_object<td_api::textParseModeMarkdown>()),
|
||||
op == "sms");
|
||||
} else if (op == "smr") {
|
||||
} else if (op == "sm" || op == "sms" || op == "smr" || op == "smf") {
|
||||
string chat_id;
|
||||
string reply_to_message_id;
|
||||
string message;
|
||||
std::tie(chat_id, args) = split(args);
|
||||
std::tie(reply_to_message_id, message) = split(args);
|
||||
send_request(make_tl_object<td_api::sendMessage>(
|
||||
as_chat_id(chat_id), as_message_id(reply_to_message_id), false, true, nullptr,
|
||||
make_tl_object<td_api::inputMessageText>(message, false, true, vector<tl_object_ptr<td_api::textEntity>>(),
|
||||
make_tl_object<td_api::textParseModeMarkdown>())));
|
||||
} else if (op == "smf") {
|
||||
const string &chat_id = args;
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageText>(string(1000097, 'a'), false, true,
|
||||
vector<tl_object_ptr<td_api::textEntity>>(),
|
||||
make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
|
||||
std::tie(chat_id, message) = split(args);
|
||||
if (op == "smr") {
|
||||
std::tie(reply_to_message_id, message) = split(message);
|
||||
}
|
||||
if (op == "smf") {
|
||||
message = string(1000097, 'a');
|
||||
}
|
||||
|
||||
auto parsed_text =
|
||||
execute(make_tl_object<td_api::parseTextEntities>(message, make_tl_object<td_api::textParseModeMarkdown>()));
|
||||
if (parsed_text->get_id() == td_api::error::ID) {
|
||||
parsed_text = make_tl_object<td_api::formattedText>(message, vector<tl_object_ptr<td_api::textEntity>>());
|
||||
}
|
||||
|
||||
send_message(
|
||||
chat_id,
|
||||
make_tl_object<td_api::inputMessageText>(move_tl_object_as<td_api::formattedText>(parsed_text), false, true),
|
||||
op == "sms", false, as_message_id(reply_to_message_id));
|
||||
} else if (op == "smap" || op == "smapr") {
|
||||
string chat_id;
|
||||
string reply_to_message_id;
|
||||
@ -2024,8 +2044,8 @@ class CliClient final : public Actor {
|
||||
send_request(make_tl_object<td_api::sendMessageAlbum>(
|
||||
as_chat_id(chat_id), as_message_id(reply_to_message_id), false, false,
|
||||
transform(photos, [](const string &photo_path) {
|
||||
tl_object_ptr<td_api::InputMessageContent> content =
|
||||
make_tl_object<td_api::inputMessagePhoto>(as_local_file(photo_path), nullptr, Auto(), 0, 0, "", 0);
|
||||
tl_object_ptr<td_api::InputMessageContent> content = make_tl_object<td_api::inputMessagePhoto>(
|
||||
as_local_file(photo_path), nullptr, Auto(), 0, 0, as_caption(""), 0);
|
||||
return content;
|
||||
})));
|
||||
} else if (op == "em") {
|
||||
@ -2036,8 +2056,9 @@ class CliClient final : public Actor {
|
||||
std::tie(message_id, message) = split(args);
|
||||
send_request(make_tl_object<td_api::editMessageText>(
|
||||
as_chat_id(chat_id), as_message_id(message_id), nullptr,
|
||||
make_tl_object<td_api::inputMessageText>(message, true, true, vector<tl_object_ptr<td_api::textEntity>>(),
|
||||
make_tl_object<td_api::textParseModeMarkdown>())));
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(message, vector<tl_object_ptr<td_api::textEntity>>()), true,
|
||||
true)));
|
||||
} else if (op == "emll") {
|
||||
string chat_id;
|
||||
string message_id;
|
||||
@ -2110,39 +2131,40 @@ class CliClient final : public Actor {
|
||||
std::tie(width, args) = split(args);
|
||||
std::tie(height, caption) = split(args);
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAnimation>(as_local_file(animation_path), nullptr, 60,
|
||||
to_integer<int32>(width),
|
||||
to_integer<int32>(height), caption));
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAnimation>(
|
||||
as_local_file(animation_path), nullptr, 60, to_integer<int32>(width),
|
||||
to_integer<int32>(height), as_caption(caption)));
|
||||
} else if (op == "sang") {
|
||||
string chat_id;
|
||||
string animation_path;
|
||||
string animation_conversion;
|
||||
std::tie(chat_id, args) = split(args);
|
||||
std::tie(animation_path, animation_conversion) = split(args);
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAnimation>(
|
||||
as_generated_file(animation_path, animation_conversion), nullptr, 60, 0, 0, ""));
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageAnimation>(
|
||||
as_generated_file(animation_path, animation_conversion), nullptr, 60, 0, 0, as_caption("")));
|
||||
} else if (op == "sanid") {
|
||||
string chat_id;
|
||||
string file_id;
|
||||
std::tie(chat_id, file_id) = split(args);
|
||||
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageAnimation>(as_input_file_id(file_id), nullptr, 0, 0, 0, ""));
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAnimation>(as_input_file_id(file_id), nullptr, 0, 0, 0,
|
||||
as_caption("")));
|
||||
} else if (op == "sanurl") {
|
||||
string chat_id;
|
||||
string url;
|
||||
std::tie(chat_id, url) = split(args);
|
||||
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageAnimation>(
|
||||
td_api::make_object<td_api::inputFileGenerated>(url, "#url#", 0), nullptr, 0, 0, 0, ""));
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAnimation>(
|
||||
td_api::make_object<td_api::inputFileGenerated>(url, "#url#", 0), nullptr, 0, 0, 0,
|
||||
as_caption("")));
|
||||
} else if (op == "sanurl2") {
|
||||
string chat_id;
|
||||
string url;
|
||||
std::tie(chat_id, url) = split(args);
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAnimation>(
|
||||
td_api::make_object<td_api::inputFileRemote>(url), nullptr, 0, 0, 0, ""));
|
||||
td_api::make_object<td_api::inputFileRemote>(url), nullptr, 0, 0, 0, as_caption("")));
|
||||
} else if (op == "sau") {
|
||||
string chat_id;
|
||||
string audio_path;
|
||||
@ -2156,14 +2178,14 @@ class CliClient final : public Actor {
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageAudio>(as_local_file(audio_path), nullptr,
|
||||
to_integer<int32>(duration), title, performer,
|
||||
"audio caption"));
|
||||
as_caption("audio caption")));
|
||||
} else if (op == "svoice") {
|
||||
string chat_id;
|
||||
string voice_path;
|
||||
std::tie(chat_id, voice_path) = split(args);
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageVoiceNote>(as_local_file(voice_path), 0, "abacaba",
|
||||
"voice caption"));
|
||||
as_caption("voice caption")));
|
||||
} else if (op == "SendContact" || op == "scontact") {
|
||||
string chat_id;
|
||||
string phone_number;
|
||||
@ -2190,33 +2212,34 @@ class CliClient final : public Actor {
|
||||
string chat_id;
|
||||
string document_path;
|
||||
std::tie(chat_id, document_path) = split(args);
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageDocument>(
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageDocument>(
|
||||
as_local_file(document_path), nullptr,
|
||||
Random::fast(0, 1) ? u8"\u1680\u180Etest \u180E\n\u180E\n\u180E\n cap\ttion\u180E\u180E"
|
||||
: u8"\u200C\u200D\u202E "
|
||||
Random::fast(0, 1)
|
||||
? as_caption(u8"\u1680\u180Etest \u180E\n\u180E\n\u180E\n cap\ttion\u180E\u180E")
|
||||
: as_caption(u8"\u200C\u200D\u202E "
|
||||
" "
|
||||
" "
|
||||
" "
|
||||
" abacaba"));
|
||||
" abacaba")));
|
||||
} else if (op == "sdt") {
|
||||
string chat_id;
|
||||
string document_path;
|
||||
string thumbnail_path;
|
||||
std::tie(chat_id, args) = split(args);
|
||||
std::tie(document_path, thumbnail_path) = split(args);
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageDocument>(
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageDocument>(
|
||||
as_local_file(document_path),
|
||||
make_tl_object<td_api::inputThumbnail>(as_local_file(thumbnail_path), 0, 0), "test caption"));
|
||||
make_tl_object<td_api::inputThumbnail>(as_local_file(thumbnail_path), 0, 0),
|
||||
as_caption("test caption")));
|
||||
} else if (op == "sdg") {
|
||||
string chat_id;
|
||||
string document_path;
|
||||
string document_conversion;
|
||||
std::tie(chat_id, args) = split(args);
|
||||
std::tie(document_path, document_conversion) = split(args);
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageDocument>(
|
||||
as_generated_file(document_path, document_conversion), nullptr, "test caption"));
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageDocument>(as_generated_file(document_path, document_conversion),
|
||||
nullptr, as_caption("test caption")));
|
||||
} else if (op == "sdtg") {
|
||||
string chat_id;
|
||||
string document_path;
|
||||
@ -2229,7 +2252,7 @@ class CliClient final : public Actor {
|
||||
as_local_file(document_path),
|
||||
make_tl_object<td_api::inputThumbnail>(
|
||||
as_generated_file(thumbnail_path, thumbnail_conversion), 0, 0),
|
||||
"test caption"));
|
||||
as_caption("test caption")));
|
||||
} else if (op == "sdgtg") {
|
||||
string chat_id;
|
||||
string document_path;
|
||||
@ -2244,12 +2267,13 @@ class CliClient final : public Actor {
|
||||
as_generated_file(document_path, document_conversion),
|
||||
make_tl_object<td_api::inputThumbnail>(
|
||||
as_generated_file(thumbnail_path, thumbnail_conversion), 0, 0),
|
||||
"test caption"));
|
||||
as_caption("test caption")));
|
||||
} else if (op == "sdid") {
|
||||
string chat_id;
|
||||
string file_id;
|
||||
std::tie(chat_id, file_id) = split(args);
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageDocument>(as_input_file_id(file_id), nullptr, ""));
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageDocument>(as_input_file_id(file_id), nullptr, as_caption("")));
|
||||
} else if (op == "sg") {
|
||||
string chat_id;
|
||||
string bot_user_id;
|
||||
@ -2290,15 +2314,16 @@ class CliClient final : public Actor {
|
||||
sticker_file_ids = to_integers<int32>(sticker_file_ids_str, ',');
|
||||
}
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessagePhoto>(as_local_file(photo_path), nullptr,
|
||||
std::move(sticker_file_ids), 0, 0, "", 0));
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessagePhoto>(as_local_file(photo_path), nullptr,
|
||||
std::move(sticker_file_ids), 0, 0, as_caption(""), 0));
|
||||
} else if (op == "spttl") {
|
||||
string chat_id;
|
||||
string photo_path;
|
||||
std::tie(chat_id, photo_path) = split(args);
|
||||
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessagePhoto>(as_local_file(photo_path), nullptr, Auto(), 0, 0, "", 10));
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessagePhoto>(as_local_file(photo_path), nullptr, Auto(), 0, 0,
|
||||
as_caption(""), 10));
|
||||
} else if (op == "spg") {
|
||||
string chat_id;
|
||||
string photo_path;
|
||||
@ -2306,8 +2331,9 @@ class CliClient final : public Actor {
|
||||
std::tie(chat_id, args) = split(args);
|
||||
std::tie(photo_path, conversion) = split(args);
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessagePhoto>(as_generated_file(photo_path, conversion),
|
||||
nullptr, vector<int32>(), 0, 0, "", 0));
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessagePhoto>(as_generated_file(photo_path, conversion), nullptr,
|
||||
vector<int32>(), 0, 0, as_caption(""), 0));
|
||||
} else if (op == "spt") {
|
||||
string chat_id;
|
||||
string photo_path;
|
||||
@ -2318,7 +2344,7 @@ class CliClient final : public Actor {
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessagePhoto>(
|
||||
as_local_file(photo_path),
|
||||
make_tl_object<td_api::inputThumbnail>(as_local_file(thumbnail_path), 90, 89),
|
||||
vector<int32>(), 0, 0, "", 0));
|
||||
vector<int32>(), 0, 0, as_caption(""), 0));
|
||||
} else if (op == "sptg") {
|
||||
string chat_id;
|
||||
string photo_path;
|
||||
@ -2332,7 +2358,7 @@ class CliClient final : public Actor {
|
||||
as_local_file(photo_path),
|
||||
make_tl_object<td_api::inputThumbnail>(
|
||||
as_generated_file(thumbnail_path, thumbnail_conversion), 90, 89),
|
||||
vector<int32>(), 0, 0, "", 0));
|
||||
vector<int32>(), 0, 0, as_caption(""), 0));
|
||||
} else if (op == "spgtg") {
|
||||
string chat_id;
|
||||
string photo_path;
|
||||
@ -2349,13 +2375,13 @@ class CliClient final : public Actor {
|
||||
as_generated_file(photo_path, conversion),
|
||||
make_tl_object<td_api::inputThumbnail>(
|
||||
as_generated_file(thumbnail_path, thumbnail_conversion), 90, 89),
|
||||
vector<int32>(), 0, 0, "", 0));
|
||||
vector<int32>(), 0, 0, as_caption(""), 0));
|
||||
} else if (op == "spid") {
|
||||
string chat_id;
|
||||
string file_id;
|
||||
std::tie(chat_id, file_id) = split(args);
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessagePhoto>(as_input_file_id(file_id), nullptr,
|
||||
vector<int32>(), 0, 0, "", 0));
|
||||
vector<int32>(), 0, 0, as_caption(""), 0));
|
||||
} else if (op == "ss") {
|
||||
string chat_id;
|
||||
string sticker_path;
|
||||
@ -2381,8 +2407,9 @@ class CliClient final : public Actor {
|
||||
sticker_file_ids = to_integers<int32>(sticker_file_ids_str, ',');
|
||||
}
|
||||
|
||||
send_message(chat_id, make_tl_object<td_api::inputMessageVideo>(as_local_file(video_path), nullptr,
|
||||
std::move(sticker_file_ids), 1, 2, 3, "", 0));
|
||||
send_message(chat_id,
|
||||
make_tl_object<td_api::inputMessageVideo>(as_local_file(video_path), nullptr,
|
||||
std::move(sticker_file_ids), 1, 2, 3, as_caption(""), 0));
|
||||
} else if (op == "svn") {
|
||||
string chat_id;
|
||||
string video_path;
|
||||
|
@ -18,7 +18,7 @@ class HeaderStorer {
|
||||
}
|
||||
template <class StorerT>
|
||||
void store(StorerT &storer) const {
|
||||
constexpr int32 LAYER = 74;
|
||||
constexpr int32 LAYER = 75;
|
||||
|
||||
using td::store;
|
||||
// invokeWithLayer#da9b0d0d {X:Type} layer:int query:!X = X;
|
||||
|
@ -97,8 +97,10 @@ using tl_object_ptr = std::unique_ptr<Type>;
|
||||
* Usage example:
|
||||
* \code
|
||||
* auto get_authorization_state_request = td::make_tl_object<td::td_api::getAuthorizationState>();
|
||||
* auto message_text = td::make_tl_object<td::td_api::formattedText>("Hello, world!!!",
|
||||
* std::vector<td::tl_object_ptr<td::td_api::textEntities>>());
|
||||
* auto send_message_request = td::make_tl_object<td::td_api::sendMessage>(chat_id, 0, false, false, nullptr,
|
||||
* td::make_tl_object<td::td_api::inputMessageText>("Hello, world!!!", false, true, {}, nullptr));
|
||||
* td::make_tl_object<td::td_api::inputMessageText>(std::move(message_text), false, true));
|
||||
* \endcode
|
||||
*
|
||||
* \tparam Type Type of the TL-object to construct.
|
||||
|
@ -307,7 +307,8 @@ class SetUsername : public Task {
|
||||
this->send_query(
|
||||
make_tl_object<td_api::sendMessage>(
|
||||
chat->id_, 0, false, false, nullptr,
|
||||
make_tl_object<td_api::inputMessageText>(PSTRING() << tag_ << " INIT", false, false, Auto(), nullptr)),
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " INIT", Auto()), false, false)),
|
||||
[](auto res) {});
|
||||
});
|
||||
}
|
||||
@ -321,7 +322,7 @@ class SetUsername : public Task {
|
||||
auto &message = updateNewMessage->message_;
|
||||
if (message->content_->get_id() == td_api::messageText::ID) {
|
||||
auto messageText = move_tl_object_as<td_api::messageText>(message->content_);
|
||||
auto text = messageText->text_;
|
||||
auto text = messageText->text_->text_;
|
||||
if (text.substr(0, tag_.size()) == tag_) {
|
||||
LOG(INFO) << "GOT SELF MESSAGE";
|
||||
return stop();
|
||||
@ -347,7 +348,7 @@ class CheckTestA : public Task {
|
||||
auto &message = updateNewMessage->message_;
|
||||
if (message->content_->get_id() == td_api::messageText::ID) {
|
||||
auto messageText = move_tl_object_as<td_api::messageText>(message->content_);
|
||||
auto text = messageText->text_;
|
||||
auto text = messageText->text_->text_;
|
||||
if (text.substr(0, tag_.size()) == tag_) {
|
||||
CHECK(text > previous_text_) << tag("now", text) << tag("previous", previous_text_);
|
||||
previous_text_ = text;
|
||||
@ -373,14 +374,11 @@ class TestA : public Task {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
this->send_query(make_tl_object<td_api::sendMessage>(
|
||||
chat->id_, 0, false, false, nullptr,
|
||||
make_tl_object<td_api::inputMessageText>(PSTRING() << tag_ << " " << (1000 + i), false,
|
||||
false, Auto(), nullptr)),
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " " << (1000 + i), Auto()),
|
||||
false, false)),
|
||||
[&](auto res) { this->stop(); });
|
||||
}
|
||||
// sendMessage chat_id:long reply_to_message_id:int disable_notification:Bool from_background:Bool
|
||||
// reply_markup:ReplyMarkup input_message_content:InputMessageContent = Message;
|
||||
// inputMessageText text:string disable_web_page_preview:Bool clear_draft:Bool entities:vector<MessageEntity>
|
||||
// parse_mode:TextParseMode = InputMessageContent;
|
||||
});
|
||||
}
|
||||
|
||||
@ -424,8 +422,9 @@ class TestSecretChat : public Task {
|
||||
for (int i = 0; i < 20; i++) {
|
||||
send_query(make_tl_object<td_api::sendMessage>(
|
||||
chat_id_, 0, false, false, nullptr,
|
||||
make_tl_object<td_api::inputMessageText>(PSTRING() << tag_ << " " << (1000 + i), false, false,
|
||||
Auto(), nullptr)),
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " " << (1000 + i), Auto()), false,
|
||||
false)),
|
||||
[](auto res) {});
|
||||
}
|
||||
}
|
||||
@ -456,7 +455,7 @@ class TestFileGenerated : public Task {
|
||||
chat_id_ = message->chat_id_;
|
||||
if (message->content_->get_id() == td_api::messageText::ID) {
|
||||
auto messageText = move_tl_object_as<td_api::messageText>(message->content_);
|
||||
auto text = messageText->text_;
|
||||
auto text = messageText->text_->text_;
|
||||
if (text.substr(0, tag_.size()) == tag_) {
|
||||
if (text.substr(tag_.size() + 1) == "ONE_FILE") {
|
||||
return one_file();
|
||||
@ -489,13 +488,14 @@ class TestFileGenerated : public Task {
|
||||
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0),
|
||||
make_tl_object<td_api::inputThumbnail>(
|
||||
make_tl_object<td_api::inputFileGenerated>(file_path, "thumbnail", 0), 0, 0),
|
||||
tag_)),
|
||||
make_tl_object<td_api::formattedText>(tag_, Auto()))),
|
||||
[](auto res) { check_td_error(res); });
|
||||
|
||||
this->send_query(make_tl_object<td_api::sendMessage>(
|
||||
chat_id_, 0, false, false, nullptr,
|
||||
this->send_query(
|
||||
make_tl_object<td_api::sendMessage>(chat_id_, 0, false, false, nullptr,
|
||||
make_tl_object<td_api::inputMessageDocument>(
|
||||
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0), nullptr, tag_)),
|
||||
make_tl_object<td_api::inputFileGenerated>(file_path, "square", 0),
|
||||
nullptr, make_tl_object<td_api::formattedText>(tag_, Auto()))),
|
||||
[](auto res) { check_td_error(res); });
|
||||
}
|
||||
|
||||
@ -599,7 +599,8 @@ class CheckTestC : public Task {
|
||||
this->send_query(
|
||||
make_tl_object<td_api::sendMessage>(
|
||||
chat_id_, 0, false, false, nullptr,
|
||||
make_tl_object<td_api::inputMessageText>(PSTRING() << tag_ << " ONE_FILE", false, false, Auto(), nullptr)),
|
||||
make_tl_object<td_api::inputMessageText>(
|
||||
make_tl_object<td_api::formattedText>(PSTRING() << tag_ << " ONE_FILE", Auto()), false, false)),
|
||||
[](auto res) { check_td_error(res); });
|
||||
}
|
||||
|
||||
@ -612,7 +613,7 @@ class CheckTestC : public Task {
|
||||
auto &message = updateNewMessage->message_;
|
||||
if (message->content_->get_id() == td_api::messageDocument::ID) {
|
||||
auto messageDocument = move_tl_object_as<td_api::messageDocument>(message->content_);
|
||||
auto text = messageDocument->caption_;
|
||||
auto text = messageDocument->caption_->text_;
|
||||
if (text.substr(0, tag_.size()) == tag_) {
|
||||
file_id_to_check_ = messageDocument->document_->document_->id_;
|
||||
LOG(ERROR) << "GOT FILE " << to_string(messageDocument->document_->document_);
|
||||
|
Reference in New Issue
Block a user