Add class TextQuote.

This commit is contained in:
levlam 2023-12-04 14:18:57 +03:00 committed by David Guillen Fandos
parent aa0f369132
commit 5dce30bc20
2 changed files with 23 additions and 4 deletions

View File

@ -2294,6 +2294,27 @@ class Client::JsonExternalReplyInfo final : public td::Jsonable {
} }
}; };
class Client::JsonTextQuote final : public td::Jsonable {
public:
JsonTextQuote(const td_api::textQuote *quote, const Client *client) : quote_(quote), client_(client) {
}
void store(td::JsonValueScope *scope) const {
auto object = scope->enter_object();
object("text", quote_->text_->text_);
if (!quote_->text_->entities_.empty()) {
object("entities", JsonVectorEntities(quote_->text_->entities_, client_));
}
object("position", quote_->position_);
if (quote_->is_manual_) {
object("is_manual", td::JsonTrue());
}
}
private:
const td_api::textQuote *quote_;
const Client *client_;
};
void Client::JsonMessage::store(td::JsonValueScope *scope) const { void Client::JsonMessage::store(td::JsonValueScope *scope) const {
CHECK(message_ != nullptr); CHECK(message_ != nullptr);
auto object = scope->enter_object(); auto object = scope->enter_object();
@ -2390,10 +2411,7 @@ void Client::JsonMessage::store(td::JsonValueScope *scope) const {
object("external_reply", JsonExternalReplyInfo(message_->reply_to_message.get(), client_)); object("external_reply", JsonExternalReplyInfo(message_->reply_to_message.get(), client_));
} }
if (message_->reply_to_message != nullptr && message_->reply_to_message->quote_ != nullptr) { if (message_->reply_to_message != nullptr && message_->reply_to_message->quote_ != nullptr) {
object("quote", message_->reply_to_message->quote_->text_->text_); object("quote", JsonTextQuote(message_->reply_to_message->quote_.get(), client_));
if (!message_->reply_to_message->quote_->text_->entities_.empty()) {
object("quote_entities", JsonVectorEntities(message_->reply_to_message->quote_->text_->entities_, client_));
}
} }
if (message_->media_album_id != 0) { if (message_->media_album_id != 0) {
object("media_group_id", td::to_string(message_->media_album_id)); object("media_group_id", td::to_string(message_->media_album_id));

View File

@ -112,6 +112,7 @@ class Client final : public WebhookActor::Callback {
class JsonMessageSender; class JsonMessageSender;
class JsonMessageOrigin; class JsonMessageOrigin;
class JsonExternalReplyInfo; class JsonExternalReplyInfo;
class JsonTextQuote;
class JsonLinkPreviewOptions; class JsonLinkPreviewOptions;
class JsonAnimation; class JsonAnimation;
class JsonAudio; class JsonAudio;