2020-08-09 13:18:08 +02:00
|
|
|
//
|
2022-12-31 22:28:08 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
|
2020-08-09 13:18:08 +02:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
2020-08-11 09:35:19 +02:00
|
|
|
#include "td/telegram/MessageEntity.h"
|
2020-09-24 18:15:42 +02:00
|
|
|
#include "td/telegram/MessageId.h"
|
2023-06-08 16:27:24 +02:00
|
|
|
#include "td/telegram/MessageInputReplyTo.h"
|
2020-08-11 10:52:38 +02:00
|
|
|
#include "td/telegram/ReplyMarkup.h"
|
2020-08-11 09:35:19 +02:00
|
|
|
|
2020-08-09 13:18:08 +02:00
|
|
|
#include "td/utils/common.h"
|
|
|
|
#include "td/utils/StringBuilder.h"
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
struct MessageCopyOptions {
|
|
|
|
bool send_copy = false;
|
2020-08-11 09:35:19 +02:00
|
|
|
bool replace_caption = false;
|
|
|
|
FormattedText new_caption;
|
2023-06-08 16:27:24 +02:00
|
|
|
MessageInputReplyTo input_reply_to;
|
2020-08-11 10:52:38 +02:00
|
|
|
unique_ptr<ReplyMarkup> reply_markup;
|
2020-08-09 13:18:08 +02:00
|
|
|
|
|
|
|
MessageCopyOptions() = default;
|
2020-08-11 09:35:19 +02:00
|
|
|
MessageCopyOptions(bool send_copy, bool remove_caption) : send_copy(send_copy), replace_caption(remove_caption) {
|
2020-08-09 13:18:08 +02:00
|
|
|
}
|
2022-05-08 22:54:04 +02:00
|
|
|
|
|
|
|
bool is_supported_server_side() const {
|
|
|
|
if (!send_copy) {
|
|
|
|
return true;
|
|
|
|
}
|
2023-06-08 16:27:24 +02:00
|
|
|
if ((replace_caption && !new_caption.text.empty()) || input_reply_to.is_valid() || reply_markup != nullptr) {
|
2022-05-08 22:54:04 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2020-08-09 13:18:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline StringBuilder &operator<<(StringBuilder &string_builder, MessageCopyOptions copy_options) {
|
|
|
|
if (copy_options.send_copy) {
|
2020-08-11 09:35:19 +02:00
|
|
|
string_builder << "CopyOptions[replace_caption = " << copy_options.replace_caption;
|
2020-09-12 21:24:04 +02:00
|
|
|
if (copy_options.replace_caption) {
|
|
|
|
string_builder << ", new_caption = " << copy_options.new_caption;
|
|
|
|
}
|
2023-06-08 16:27:24 +02:00
|
|
|
if (copy_options.input_reply_to.is_valid()) {
|
|
|
|
string_builder << ", in reply to " << copy_options.input_reply_to;
|
2020-09-12 21:24:04 +02:00
|
|
|
}
|
|
|
|
if (copy_options.reply_markup != nullptr) {
|
|
|
|
string_builder << ", with reply markup";
|
|
|
|
}
|
2020-08-11 09:35:19 +02:00
|
|
|
string_builder << "]";
|
2020-08-09 13:18:08 +02:00
|
|
|
}
|
|
|
|
return string_builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace td
|