tgbotxx 1.1.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) {
11 _fromJson(json);
12 }
13 virtual ~InputStoryContent() = default;
14
16 std::string type;
17
18 virtual nl::json toJson() const {
19 nl::json json = nl::json::object();
20 OBJECT_SERIALIZE_FIELD(json, "type", type);
21 return json;
22 }
23
24 virtual void fromJson(const nl::json& json) {
25 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
26 }
27
28 private:
29 void _fromJson(const nl::json& json) {
30 fromJson(json);
31 }
32 };
33
40 explicit InputStoryContentPhoto(const nl::json& json) : InputStoryContent(json) {
42 }
43
45 std::string photo;
46
49 nl::json toJson() const override {
50 nl::json json = InputStoryContent::toJson();
51 OBJECT_SERIALIZE_FIELD(json, "photo", photo);
52 return json;
53 }
54
56 void fromJson(const nl::json& json) override {
58 OBJECT_DESERIALIZE_FIELD(json, "photo", photo, "", false);
59 }
60 };
61
68 explicit InputStoryContentVideo(const nl::json& json) : InputStoryContent(json) {
70 }
71
73 std::string video;
74
76 double duration{0.0};
77
80
82 bool isAnimation{false};
83
86 nl::json toJson() const override {
87 nl::json json = InputStoryContent::toJson();
88 OBJECT_SERIALIZE_FIELD(json, "video", video);
89 OBJECT_SERIALIZE_FIELD(json, "duration", duration);
90 OBJECT_SERIALIZE_FIELD(json, "cover_frame_timestamp", coverFrameTimestamp);
91 OBJECT_SERIALIZE_FIELD(json, "is_animation", isAnimation);
92 return json;
93 }
94
96 void fromJson(const nl::json& json) override {
98 OBJECT_DESERIALIZE_FIELD(json, "video", video, "", false);
99 OBJECT_DESERIALIZE_FIELD(json, "duration", duration, 0.0, true);
100 OBJECT_DESERIALIZE_FIELD(json, "cover_frame_timestamp", coverFrameTimestamp, 0.0, true);
101 OBJECT_DESERIALIZE_FIELD(json, "is_animation", isAnimation, false, true);
102 }
103 };
104
105}
#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
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....