aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2026-05-05 18:29:57 +0300
committerlevlam <levlam@telegram.org>2026-05-05 18:29:57 +0300
commit7477330470bdabd0d406e432f6d83b301f3d4c93 (patch)
treef3ace3804e20d922d00e65f8e87279674d4d0efe
parent49d4b31cd2acd5ca44f37790b769aac03e8693bc (diff)
Add PaidMediaLivePhoto.
-rw-r--r--telegram-bot-api/Client.cpp32
-rw-r--r--telegram-bot-api/Client.h1
2 files changed, 31 insertions, 2 deletions
diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp
index 0d7fdac..021e226 100644
--- a/telegram-bot-api/Client.cpp
+++ b/telegram-bot-api/Client.cpp
@@ -1960,6 +1960,29 @@ class Client::JsonPhoto final : public td::Jsonable {
const Client *client_;
};
+class Client::JsonLivePhoto final : public td::Jsonable {
+ public:
+ JsonLivePhoto(const td_api::photo *photo, const td_api::video *video, const Client *client)
+ : photo_(photo), video_(video), client_(client) {
+ }
+ void store(td::JsonValueScope *scope) const {
+ auto object = scope->enter_object();
+ object("photo", JsonPhoto(photo_, client_));
+ object("duration", video_->duration_);
+ object("width", video_->width_);
+ object("height", video_->height_);
+ if (!video_->mime_type_.empty()) {
+ object("mime_type", video_->mime_type_);
+ }
+ client_->json_store_file(object, video_->video_.get());
+ }
+
+ private:
+ const td_api::photo *photo_;
+ const td_api::video *video_;
+ const Client *client_;
+};
+
class Client::JsonChatPhoto final : public td::Jsonable {
public:
JsonChatPhoto(const td_api::chatPhoto *photo, const Client *client) : photo_(photo), client_(client) {
@@ -2100,8 +2123,13 @@ class Client::JsonPaidMedia final : public td::Jsonable {
}
case td_api::paidMediaPhoto::ID: {
auto media = static_cast<const td_api::paidMediaPhoto *>(paid_media_);
- object("type", "photo");
- object("photo", JsonPhoto(media->photo_.get(), client_));
+ if (media->video_ != nullptr) {
+ object("type", "live_photo");
+ object("live_photo", JsonLivePhoto(media->photo_.get(), media->video_.get(), client_));
+ } else {
+ object("type", "photo");
+ object("photo", JsonPhoto(media->photo_.get(), client_));
+ }
break;
}
case td_api::paidMediaVideo::ID: {
diff --git a/telegram-bot-api/Client.h b/telegram-bot-api/Client.h
index 6a7437e..f1e8743 100644
--- a/telegram-bot-api/Client.h
+++ b/telegram-bot-api/Client.h
@@ -117,6 +117,7 @@ class Client final : public WebhookActor::Callback {
class JsonDocument;
class JsonPhotoSize;
class JsonPhoto;
+ class JsonLivePhoto;
class JsonChatPhoto;
class JsonThumbnail;
class JsonMaskPosition;