Skip to content

Commit 3271d27

Browse files
committed
Add td_api::inputAudio.
1 parent bf8b079 commit 3271d27

3 files changed

Lines changed: 29 additions & 25 deletions

File tree

td/generate/scheme/td_api.tl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5648,11 +5648,19 @@ inputThumbnail thumbnail:InputFile width:int32 height:int32 = InputThumbnail;
56485648
//@animation Animation file to be sent
56495649
//@thumbnail Animation thumbnail; pass null to skip thumbnail uploading
56505650
//@added_sticker_file_ids File identifiers of the stickers added to the animation, if applicable
5651-
//@duration Duration of the animation, in seconds
5651+
//@duration Duration of the animation, in seconds; may be replaced by the server
56525652
//@width Width of the animation; may be replaced by the server
56535653
//@height Height of the animation; may be replaced by the server
56545654
inputAnimation animation:InputFile thumbnail:inputThumbnail added_sticker_file_ids:vector<int32> duration:int32 width:int32 height:int32 = InputAnimation;
56555655

5656+
//@description An audio to be sent
5657+
//@audio Audio file to be sent
5658+
//@album_cover_thumbnail Thumbnail of the cover for the album; pass null to skip thumbnail uploading
5659+
//@duration Duration of the audio, in seconds; may be replaced by the server
5660+
//@title Title of the audio; 0-64 characters; may be replaced by the server
5661+
//@performer Performer of the audio; 0-64 characters, may be replaced by the server
5662+
inputAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string = InputAudio;
5663+
56565664

56575665
//@class InputPaidMediaType @description Describes type of paid media to sent
56585666

@@ -5732,13 +5740,8 @@ messageCopyOptions send_copy:Bool replace_caption:Bool new_caption:formattedText
57325740
//@description An animation @animation The animation to be sent
57335741
inputPollMediaAnimation animation:inputAnimation = InputPollMedia;
57345742

5735-
//@description An audio
5736-
//@audio Audio file to be sent
5737-
//@album_cover_thumbnail Thumbnail of the cover for the album; pass null to skip thumbnail uploading
5738-
//@duration Duration of the audio, in seconds; may be replaced by the server
5739-
//@title Title of the audio; 0-64 characters; may be replaced by the server
5740-
//@performer Performer of the audio; 0-64 characters, may be replaced by the server
5741-
inputPollMediaAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string = InputPollMedia;
5743+
//@description An audio @audio The audio to be sent
5744+
inputPollMediaAudio audio:inputAudio = InputPollMedia;
57425745

57435746
//@description A document (general file)
57445747
//@document Document to be sent
@@ -5803,13 +5806,9 @@ inputMessageRichMessage message:inputRichMessage clear_draft:Bool = InputMessage
58035806
inputMessageAnimation animation:inputAnimation caption:formattedText show_caption_above_media:Bool has_spoiler:Bool = InputMessageContent;
58045807

58055808
//@description An audio message
5806-
//@audio Audio file to be sent
5807-
//@album_cover_thumbnail Thumbnail of the cover for the album; pass null to skip thumbnail uploading
5808-
//@duration Duration of the audio, in seconds; may be replaced by the server
5809-
//@title Title of the audio; 0-64 characters; may be replaced by the server
5810-
//@performer Performer of the audio; 0-64 characters, may be replaced by the server
5809+
//@audio Audio to be sent
58115810
//@caption Audio caption; pass null to use an empty caption; 0-getOption("message_caption_length_max") characters
5812-
inputMessageAudio audio:InputFile album_cover_thumbnail:inputThumbnail duration:int32 title:string performer:string caption:formattedText = InputMessageContent;
5811+
inputMessageAudio audio:inputAudio caption:formattedText = InputMessageContent;
58135812

58145813
//@description A document message (general file)
58155814
//@document Document to be sent

td/telegram/MessageContent.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4747,16 +4747,17 @@ static Result<InputMessageContent> create_input_message_content(
47474747
case td_api::inputMessageAudio::ID: {
47484748
auto input_audio = static_cast<td_api::inputMessageAudio *>(input_message_content.get());
47494749

4750-
if (!clean_input_string(input_audio->title_)) {
4750+
if (!clean_input_string(input_audio->audio_->title_)) {
47514751
return Status::Error(400, "Audio title must be encoded in UTF-8");
47524752
}
4753-
if (!clean_input_string(input_audio->performer_)) {
4753+
if (!clean_input_string(input_audio->audio_->performer_)) {
47544754
return Status::Error(400, "Audio performer must be encoded in UTF-8");
47554755
}
47564756

47574757
td->audios_manager_->create_audio(file_id, string(), std::move(thumbnail), std::move(file_name),
4758-
std::move(mime_type), input_audio->duration_, std::move(input_audio->title_),
4759-
std::move(input_audio->performer_), 0, false);
4758+
std::move(mime_type), input_audio->audio_->duration_,
4759+
std::move(input_audio->audio_->title_),
4760+
std::move(input_audio->audio_->performer_), 0, false);
47604761

47614762
content = make_unique<MessageAudio>(file_id, std::move(caption));
47624763
break;
@@ -5081,9 +5082,13 @@ Result<InputMessageContent> get_input_message_content(
50815082
}
50825083
case td_api::inputMessageAudio::ID: {
50835084
auto input_message = static_cast<td_api::inputMessageAudio *>(input_message_content.get());
5085+
auto *audio = input_message->audio_.get();
5086+
if (audio == nullptr) {
5087+
return Status::Error(400, "Audio must be non-empty");
5088+
}
50845089
file_type = FileType::Audio;
5085-
input_file = std::move(input_message->audio_);
5086-
input_thumbnail = std::move(input_message->album_cover_thumbnail_);
5090+
input_file = std::move(audio->audio_);
5091+
input_thumbnail = std::move(audio->album_cover_thumbnail_);
50875092
break;
50885093
}
50895094
case td_api::inputMessageDocument::ID: {
@@ -5192,9 +5197,7 @@ Result<unique_ptr<MessageContent>> get_input_poll_media(DialogId dialog_id,
51925197
}
51935198
case td_api::inputPollMediaAudio::ID: {
51945199
auto content = td_api::move_object_as<td_api::inputPollMediaAudio>(input_poll_media);
5195-
return td_api::make_object<td_api::inputMessageAudio>(
5196-
std::move(content->audio_), std::move(content->album_cover_thumbnail_), content->duration_, content->title_,
5197-
content->performer_, nullptr);
5200+
return td_api::make_object<td_api::inputMessageAudio>(std::move(content->audio_), nullptr);
51985201
}
51995202
case td_api::inputPollMediaDocument::ID: {
52005203
auto content = td_api::move_object_as<td_api::inputPollMediaDocument>(input_poll_media);

td/telegram/cli.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6829,8 +6829,10 @@ class CliClient final : public Actor {
68296829
string title;
68306830
string performer;
68316831
get_args(args, chat_id, audio, duration, title, performer);
6832-
send_message(chat_id, td_api::make_object<td_api::inputMessageAudio>(as_input_file(audio), get_input_thumbnail(),
6833-
duration, title, performer, get_caption()));
6832+
send_message(chat_id, td_api::make_object<td_api::inputMessageAudio>(
6833+
td_api::make_object<td_api::inputAudio>(as_input_file(audio), get_input_thumbnail(),
6834+
duration, title, performer),
6835+
get_caption()));
68346836
} else if (op == "svoice") {
68356837
ChatId chat_id;
68366838
string voice;

0 commit comments

Comments
 (0)