Add extract_input_caption method.
GitOrigin-RevId: d49433b0d7d9313bf8f4814c90f28717678b8444
This commit is contained in:
parent
4f7a52fbb1
commit
00c10535a2
@ -212,28 +212,6 @@ string InlineQueriesManager::get_inline_message_id(
|
|||||||
return base64url_encode(serialize(*input_bot_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::process_input_caption(td_->contacts_manager_.get(), 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,
|
|
||||||
"get_input_bot_inline_message_media_auto");
|
|
||||||
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(
|
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::InputMessageContent> &&input_message_content,
|
||||||
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr, int32 allowed_media_content_id) const {
|
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr, int32 allowed_media_content_id) const {
|
||||||
@ -278,41 +256,15 @@ Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> InlineQueriesManager:
|
|||||||
return venue.get_input_bot_inline_message_media_venue(flags, std::move(input_reply_markup));
|
return venue.get_input_bot_inline_message_media_venue(flags, std::move(input_reply_markup));
|
||||||
}
|
}
|
||||||
if (constructor_id == allowed_media_content_id) {
|
if (constructor_id == allowed_media_content_id) {
|
||||||
if (constructor_id == td_api::inputMessageAnimation::ID) {
|
TRY_RESULT(caption, process_input_caption(td_->contacts_manager_.get(), DialogId(),
|
||||||
auto input_message_animation = static_cast<td_api::inputMessageAnimation *>(input_message_content.get());
|
extract_input_caption(input_message_content), true));
|
||||||
TRY_RESULT(caption, process_input_caption(std::move(input_message_animation->caption_)));
|
auto entities = get_input_message_entities(td_->contacts_manager_.get(), caption.entities, "get_inline_message");
|
||||||
return get_input_bot_inline_message_media_auto(caption, std::move(input_reply_markup));
|
if (!entities.empty()) {
|
||||||
}
|
flags |= telegram_api::inputBotInlineMessageText::ENTITIES_MASK;
|
||||||
if (constructor_id == td_api::inputMessageAudio::ID) {
|
|
||||||
auto input_message_audio = static_cast<td_api::inputMessageAudio *>(input_message_content.get());
|
|
||||||
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());
|
|
||||||
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());
|
|
||||||
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, "", 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());
|
|
||||||
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());
|
|
||||||
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 make_tl_object<telegram_api::inputBotInlineMessageMediaAuto>(flags, caption.text, std::move(entities),
|
||||||
|
std::move(input_reply_markup));
|
||||||
}
|
}
|
||||||
return Status::Error(400, "Unallowed inline message content type");
|
return Status::Error(400, "Unallowed inline message content type");
|
||||||
}
|
}
|
||||||
|
@ -84,11 +84,6 @@ 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_TITLE = 1 << 2;
|
||||||
static constexpr int32 BOT_INLINE_MEDIA_RESULT_FLAG_HAS_DESCRIPTION = 1 << 3;
|
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(
|
Result<tl_object_ptr<telegram_api::InputBotInlineMessage>> get_inline_message(
|
||||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content,
|
||||||
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
tl_object_ptr<td_api::ReplyMarkup> &&reply_markup_ptr,
|
||||||
|
@ -2230,15 +2230,47 @@ FormattedText get_message_text(const ContactsManager *contacts_manager, string m
|
|||||||
return FormattedText{std::move(message_text), std::move(entities)};
|
return FormattedText{std::move(message_text), std::move(entities)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::formattedText> extract_input_caption(
|
||||||
|
tl_object_ptr<td_api::InputMessageContent> &input_message_content) {
|
||||||
|
switch (input_message_content->get_id()) {
|
||||||
|
case td_api::inputMessageAnimation::ID: {
|
||||||
|
auto input_animation = static_cast<td_api::inputMessageAnimation *>(input_message_content.get());
|
||||||
|
return std::move(input_animation->caption_);
|
||||||
|
}
|
||||||
|
case td_api::inputMessageAudio::ID: {
|
||||||
|
auto input_audio = static_cast<td_api::inputMessageAudio *>(input_message_content.get());
|
||||||
|
return std::move(input_audio->caption_);
|
||||||
|
}
|
||||||
|
case td_api::inputMessageDocument::ID: {
|
||||||
|
auto input_document = static_cast<td_api::inputMessageDocument *>(input_message_content.get());
|
||||||
|
return std::move(input_document->caption_);
|
||||||
|
}
|
||||||
|
case td_api::inputMessagePhoto::ID: {
|
||||||
|
auto input_photo = static_cast<td_api::inputMessagePhoto *>(input_message_content.get());
|
||||||
|
return std::move(input_photo->caption_);
|
||||||
|
}
|
||||||
|
case td_api::inputMessageVideo::ID: {
|
||||||
|
auto input_video = static_cast<td_api::inputMessageVideo *>(input_message_content.get());
|
||||||
|
return std::move(input_video->caption_);
|
||||||
|
}
|
||||||
|
case td_api::inputMessageVoiceNote::ID: {
|
||||||
|
auto input_voice_note = static_cast<td_api::inputMessageVoiceNote *>(input_message_content.get());
|
||||||
|
return std::move(input_voice_note->caption_);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Result<FormattedText> process_input_caption(const ContactsManager *contacts_manager, DialogId dialog_id,
|
Result<FormattedText> process_input_caption(const ContactsManager *contacts_manager, DialogId dialog_id,
|
||||||
tl_object_ptr<td_api::formattedText> &&text, bool is_bot) {
|
tl_object_ptr<td_api::formattedText> &&caption, bool is_bot) {
|
||||||
if (text == nullptr) {
|
if (caption == nullptr) {
|
||||||
return FormattedText();
|
return FormattedText();
|
||||||
}
|
}
|
||||||
TRY_RESULT(entities, get_message_entities(contacts_manager, std::move(text->entities_)));
|
TRY_RESULT(entities, get_message_entities(contacts_manager, std::move(caption->entities_)));
|
||||||
TRY_STATUS(fix_formatted_text(text->text_, entities, true, false,
|
TRY_STATUS(fix_formatted_text(caption->text_, entities, true, false,
|
||||||
need_skip_bot_commands(contacts_manager, dialog_id, is_bot), false));
|
need_skip_bot_commands(contacts_manager, dialog_id, is_bot), false));
|
||||||
return FormattedText{std::move(text->text_), std::move(entities)};
|
return FormattedText{std::move(caption->text_), std::move(entities)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText *text) {
|
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText *text) {
|
||||||
|
@ -154,8 +154,11 @@ FormattedText get_message_text(const ContactsManager *contacts_manager, string m
|
|||||||
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities, int32 send_date,
|
vector<tl_object_ptr<telegram_api::MessageEntity>> &&server_entities, int32 send_date,
|
||||||
const char *source);
|
const char *source);
|
||||||
|
|
||||||
|
td_api::object_ptr<td_api::formattedText> extract_input_caption(
|
||||||
|
tl_object_ptr<td_api::InputMessageContent> &input_message_content);
|
||||||
|
|
||||||
Result<FormattedText> process_input_caption(const ContactsManager *contacts_manager, DialogId dialog_id,
|
Result<FormattedText> process_input_caption(const ContactsManager *contacts_manager, DialogId dialog_id,
|
||||||
tl_object_ptr<td_api::formattedText> &&text, bool is_bot);
|
tl_object_ptr<td_api::formattedText> &&caption, bool is_bot);
|
||||||
|
|
||||||
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText *text);
|
void add_formatted_text_dependencies(Dependencies &dependencies, const FormattedText *text);
|
||||||
|
|
||||||
|
@ -14983,41 +14983,6 @@ Result<MessageId> MessagesManager::send_message(DialogId dialog_id, MessageId re
|
|||||||
return message_id;
|
return message_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<FormattedText> MessagesManager::get_input_caption(
|
|
||||||
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &input_message_content, bool is_bot) const {
|
|
||||||
switch (input_message_content->get_id()) {
|
|
||||||
case td_api::inputMessageAnimation::ID: {
|
|
||||||
auto input_animation = static_cast<td_api::inputMessageAnimation *>(input_message_content.get());
|
|
||||||
return process_input_caption(td_->contacts_manager_.get(), dialog_id, std::move(input_animation->caption_),
|
|
||||||
is_bot);
|
|
||||||
}
|
|
||||||
case td_api::inputMessageAudio::ID: {
|
|
||||||
auto input_audio = static_cast<td_api::inputMessageAudio *>(input_message_content.get());
|
|
||||||
return process_input_caption(td_->contacts_manager_.get(), dialog_id, std::move(input_audio->caption_), is_bot);
|
|
||||||
}
|
|
||||||
case td_api::inputMessageDocument::ID: {
|
|
||||||
auto input_document = static_cast<td_api::inputMessageDocument *>(input_message_content.get());
|
|
||||||
return process_input_caption(td_->contacts_manager_.get(), dialog_id, std::move(input_document->caption_),
|
|
||||||
is_bot);
|
|
||||||
}
|
|
||||||
case td_api::inputMessagePhoto::ID: {
|
|
||||||
auto input_photo = static_cast<td_api::inputMessagePhoto *>(input_message_content.get());
|
|
||||||
return process_input_caption(td_->contacts_manager_.get(), dialog_id, std::move(input_photo->caption_), is_bot);
|
|
||||||
}
|
|
||||||
case td_api::inputMessageVideo::ID: {
|
|
||||||
auto input_video = static_cast<td_api::inputMessageVideo *>(input_message_content.get());
|
|
||||||
return process_input_caption(td_->contacts_manager_.get(), dialog_id, std::move(input_video->caption_), is_bot);
|
|
||||||
}
|
|
||||||
case td_api::inputMessageVoiceNote::ID: {
|
|
||||||
auto input_voice_note = static_cast<td_api::inputMessageVoiceNote *>(input_message_content.get());
|
|
||||||
return process_input_caption(td_->contacts_manager_.get(), dialog_id, std::move(input_voice_note->caption_),
|
|
||||||
is_bot);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
return FormattedText();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<InputMessageContent> MessagesManager::process_input_message_content(
|
Result<InputMessageContent> MessagesManager::process_input_message_content(
|
||||||
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content) const {
|
DialogId dialog_id, tl_object_ptr<td_api::InputMessageContent> &&input_message_content) const {
|
||||||
if (input_message_content == nullptr) {
|
if (input_message_content == nullptr) {
|
||||||
@ -15129,7 +15094,9 @@ Result<InputMessageContent> MessagesManager::process_input_message_content(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY_RESULT(caption, get_input_caption(dialog_id, input_message_content, td_->auth_manager_->is_bot()));
|
TRY_RESULT(caption,
|
||||||
|
process_input_caption(td_->contacts_manager_.get(), dialog_id,
|
||||||
|
extract_input_caption(input_message_content), td_->auth_manager_->is_bot()));
|
||||||
TRY_RESULT(content, create_input_message_content(dialog_id, std::move(input_message_content), td_, std::move(caption),
|
TRY_RESULT(content, create_input_message_content(dialog_id, std::move(input_message_content), td_, std::move(caption),
|
||||||
file_id, std::move(thumbnail), std::move(sticker_file_ids)));
|
file_id, std::move(thumbnail), std::move(sticker_file_ids)));
|
||||||
|
|
||||||
|
@ -316,10 +316,6 @@ class MessagesManager : public Actor {
|
|||||||
|
|
||||||
DialogId search_public_dialog(const string &username_to_search, bool force, Promise<Unit> &&promise);
|
DialogId search_public_dialog(const string &username_to_search, bool force, Promise<Unit> &&promise);
|
||||||
|
|
||||||
Result<FormattedText> get_input_caption(DialogId dialog_id,
|
|
||||||
tl_object_ptr<td_api::InputMessageContent> &input_message_content,
|
|
||||||
bool is_bot) const;
|
|
||||||
|
|
||||||
Result<MessageId> send_message(DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification,
|
Result<MessageId> send_message(DialogId dialog_id, MessageId reply_to_message_id, bool disable_notification,
|
||||||
bool from_background, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
bool from_background, tl_object_ptr<td_api::ReplyMarkup> &&reply_markup,
|
||||||
tl_object_ptr<td_api::InputMessageContent> &&input_message_content)
|
tl_object_ptr<td_api::InputMessageContent> &&input_message_content)
|
||||||
|
Reference in New Issue
Block a user