tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
InputStoryContent.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
5
9 InputStoryContent() = default;
10 explicit InputStoryContent(const nl::json& json) {
12 }
13 virtual ~InputStoryContent() = default;
14
16 std::string type;
17
18 [[nodiscard]] virtual nl::json toJson() const {
19 nl::json json = nl::json::object();
21 return json;
22 }
23
24 virtual void fromJson(const nl::json& json) {
25 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
26 }
27 };
28
33 type = "photo";
34 }
38
40 std::string photo;
41
44 [[nodiscard]] nl::json toJson() const override {
47 return json;
48 }
49
51 void fromJson(const nl::json& json) override {
53 OBJECT_DESERIALIZE_FIELD(json, "photo", photo, "", false);
54 }
55 };
56
61 type = "video";
62 }
66
68 std::string video;
69
71 double duration{0.0};
72
75
77 bool isAnimation{false};
78
81 [[nodiscard]] nl::json toJson() const override {
85 OBJECT_SERIALIZE_FIELD(json, "cover_frame_timestamp", coverFrameTimestamp);
86 OBJECT_SERIALIZE_FIELD(json, "is_animation", isAnimation);
87 return json;
88 }
89
91 void fromJson(const nl::json& json) override {
93 OBJECT_DESERIALIZE_FIELD(json, "video", video, "", false);
94 OBJECT_DESERIALIZE_FIELD(json, "duration", duration, 0.0, true);
95 OBJECT_DESERIALIZE_FIELD(json, "cover_frame_timestamp", coverFrameTimestamp, 0.0, true);
96 OBJECT_DESERIALIZE_FIELD(json, "is_animation", isAnimation, false, true);
97 }
98 };
99
100}
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:46
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Base class for story content to post https://core.telegram.org/bots/api#inputstorycontentphoto.
std::string type
Type of the story content.
InputStoryContent(const nl::json &json)
virtual nl::json toJson() const
virtual void fromJson(const nl::json &json)
virtual ~InputStoryContent()=default
InputStoryContent()=default
Describes a photo to post as a story https://core.telegram.org/bots/api#inputstorycontentphoto.
std::string photo
The photo to post as a story. Must be 1080x1920 and <= 10MB. Can't be reused.
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
InputStoryContentPhoto()
InputStoryContentPhoto(const nl::json &json)
Describes a video to post as a story https://core.telegram.org/bots/api#inputstorycontentvideo.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
bool isAnimation
Optional. True if the video has no sound.
InputStoryContentVideo()
double duration
Optional. Precise duration of the video in seconds; 0-60.
std::string video
The video to post as a story. Must be 720x1280, H.265, streamable, <= 30MB. Can't be reused.
InputStoryContentVideo(const nl::json &json)
nl::json toJson() const override
Serializes this object to JSON.
double coverFrameTimestamp
Optional. Timestamp in seconds of the frame that will be used as the static cover for the story....