Cppgram  1.0.0
Easy and modern C++14 Telegram Bot API wrapper
game.hpp
1 #ifndef CPPGRAM_GAME_HPP
2 #define CPPGRAM_GAME_HPP
3 
4 #include "animation.hpp"
5 #include "message_entity.hpp"
6 #include "photo_size.hpp"
7 
8 namespace cppgram
9 {
10 namespace types
11 {
18 class Game
19 {
20  public:
22  std::string title,
23 
26 
28  std::vector<PhotoSize> photo;
33  std::experimental::optional<std::string> text;
36  std::vector<MessageEntity> text_entities;
39  std::experimental::optional<Animation> animation;
40 
41  Game( Json::Value &json_game )
42  : title( json_game["title"].asString() )
43  , description( json_game["description"].asString() )
44  {
45  photo.reserve( json_game["photo"].size() );
46  for ( Json::Value &json_photo : json_game["photo"] )
47  {
48  photo.push_back( PhotoSize( json_photo ) );
49  }
50 
51  if ( !json_game["text"].isNull() )
52  {
53  text.emplace( json_game["text"].asString() );
54  }
55 
56  text_entities.reserve( json_game["text_entities"].size() );
57  for ( Json::Value &json_entity : json_game["text_entities"] )
58  {
59  text_entities.push_back( MessageEntity( json_entity ) );
60  }
61 
62  if ( !json_game["animation"].isNull() )
63  {
64  animation.emplace( Animation( json_game["animation"] ) );
65  }
66  }
67 };
68 }
69 }
70 
71 #endif
std::string title
Title of the game.
Definition: game.hpp:22
This object represents an animation file to be displayed in the message containing a game...
Definition: animation.hpp:13
std::experimental::optional< Animation > animation
Optional. Animation that will be displayed in the game message in chats. Upload via BotFather...
Definition: game.hpp:39
std::string description
Description of the game.
Definition: game.hpp:22
A photo or thumbnail.
Definition: photo_size.hpp:20
std::vector< PhotoSize > photo
Photo that will be displayed in the game message in chats.
Definition: game.hpp:28
Entity in the message.
Definition: message_entity.hpp:24
std::vector< MessageEntity > text_entities
Optional. Special entities that appear in text, such as usernames, URLs, bot commands, etc.
Definition: game.hpp:36
This object represents a game.
Definition: game.hpp:18
std::experimental::optional< std::string > text
Optional. Brief description of the game or high scores included in the game message. Can be automatically edited to include current high scores for the game when the bot calls setGameScore, or manually edited using editMessageText. 0-4096 characters.
Definition: game.hpp:33
main namespace for Cppgram