tgbotxx  1.1.6.9
Telegram Bot C++ Library
Dice.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
7  struct Dice {
8  Dice() = default;
9  explicit Dice(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  std::string emoji;
15 
17  std::int32_t value{};
18 
19 
22  nl::json toJson() const {
23  nl::json json = nl::json::object();
24  OBJECT_SERIALIZE_FIELD(json, "emoji", emoji);
25  OBJECT_SERIALIZE_FIELD(json, "value", value);
26  return json;
27  }
28 
30  void fromJson(const nl::json& json) {
31  OBJECT_DESERIALIZE_FIELD(json, "emoji", emoji, "", false);
32  OBJECT_DESERIALIZE_FIELD(json, "value", value, 0, false);
33  }
34  };
35 }
#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
Definition: Api.hpp:14
This object represents an animated emoji that displays a random value. https://core....
Definition: Dice.hpp:7
Dice(const nl::json &json)
Definition: Dice.hpp:9
nl::json toJson() const
Serializes this object to JSON.
Definition: Dice.hpp:22
Dice()=default
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition: Dice.hpp:30
std::string emoji
Emoji on which the dice throw animation is based.
Definition: Dice.hpp:14
std::int32_t value
Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji,...
Definition: Dice.hpp:17