tgbotxx  1.1.6.9
Telegram Bot C++ Library
Game.hpp
Go to the documentation of this file.
1 #pragma once
5 
6 namespace tgbotxx {
9  struct Game {
10  Game() = default;
11  explicit Game(const nl::json& json) {
12  fromJson(json);
13  }
14 
16  std::string title;
17 
19  std::string description;
20 
22  std::vector<Ptr<PhotoSize>> photo;
23 
28  std::string text;
29 
31  std::vector<Ptr<MessageEntity>> textEntities;
32 
36 
37 
40  nl::json toJson() const {
41  nl::json json = nl::json::object();
42  OBJECT_SERIALIZE_FIELD(json, "title", title);
43  OBJECT_SERIALIZE_FIELD(json, "description", description);
45  OBJECT_SERIALIZE_FIELD(json, "text", text);
46  OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, "text_entities", textEntities);
47  OBJECT_SERIALIZE_FIELD_PTR(json, "animation", animation);
48  return json;
49  }
50 
52  void fromJson(const nl::json& json) {
53  OBJECT_DESERIALIZE_FIELD(json, "title", title, "", false);
54  OBJECT_DESERIALIZE_FIELD(json, "description", description, "", false);
55  OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "photo", photo, false);
56  OBJECT_DESERIALIZE_FIELD(json, "text", text, "", true);
57  OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, "text_entities", textEntities, true);
58  OBJECT_DESERIALIZE_FIELD_PTR(json, "animation", animation, true);
59  }
60  };
61 }
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition: Object.hpp:22
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition: Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition: Object.hpp:70
#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:44
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition: Object.hpp:87
Definition: Api.hpp:14
std::shared_ptr< T > Ptr
Definition: Ptr.hpp:6
This object represents a game. Use BotFather to create and edit games, their short names will act as ...
Definition: Game.hpp:9
Game(const nl::json &json)
Definition: Game.hpp:11
std::vector< Ptr< PhotoSize > > photo
Photo that will be displayed in the game message in chats.
Definition: Game.hpp:22
std::string description
Description of the game.
Definition: Game.hpp:19
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: Game.hpp:52
Ptr< Animation > animation
Optional. Animation that will be displayed in the game message in chats. Upload via BotFather https:/...
Definition: Game.hpp:35
std::string text
Optional. Brief description of the game or high scores included in the game message....
Definition: Game.hpp:28
nl::json toJson() const
Serializes this object to JSON.
Definition: Game.hpp:40
Game()=default
std::vector< Ptr< MessageEntity > > textEntities
Optional. Special entities that appear in text, such as usernames, URLs, bot commands,...
Definition: Game.hpp:31
std::string title
Title of the game.
Definition: Game.hpp:16