tgbotxx  1.1.6.9
Telegram Bot C++ Library
ReplyKeyboardMarkup.hpp
Go to the documentation of this file.
1 #pragma once
5 
6 namespace tgbotxx {
10  ReplyKeyboardMarkup() = default;
11  explicit ReplyKeyboardMarkup(const nl::json& json) {
12  _fromJson(json);
13  }
14 
17  std::vector<std::vector<Ptr<KeyboardButton>>> keyboard;
18 
21  bool isPersistent{};
22 
27 
33 
35  std::string inputFieldPlaceholder;
36 
44  bool selective{};
45 
48  nl::json toJson() const override {
49  nl::json json = nl::json::object();
51  OBJECT_SERIALIZE_FIELD(json, "is_persistent", isPersistent);
52  OBJECT_SERIALIZE_FIELD(json, "resize_keyboard", resizeKeyboard);
53  OBJECT_SERIALIZE_FIELD(json, "one_time_keyboard", oneTimeKeyboard);
54  OBJECT_SERIALIZE_FIELD(json, "input_field_placeholder", inputFieldPlaceholder);
55  OBJECT_SERIALIZE_FIELD(json, "selective", selective);
56  return json;
57  }
58 
60  void fromJson(const nl::json& json) override {
61  OBJECT_DESERIALIZE_FIELD_PTR_ARRAY_ARRAY(json, "keyboard", keyboard, false);
62  OBJECT_DESERIALIZE_FIELD(json, "is_persistent", isPersistent, false, true);
63  OBJECT_DESERIALIZE_FIELD(json, "resize_keyboard", resizeKeyboard, false, true);
64  OBJECT_DESERIALIZE_FIELD(json, "one_time_keyboard", oneTimeKeyboard, false, true);
65  OBJECT_DESERIALIZE_FIELD(json, "input_field_placeholder", inputFieldPlaceholder, "", true);
66  OBJECT_DESERIALIZE_FIELD(json, "selective", selective, false, true);
67  }
68 
69  private:
71  void _fromJson(const nl::json& json) {
72  fromJson(json);
73  }
74  };
75 }
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition: Object.hpp:19
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY_ARRAY(json, json_field, array_array_field)
Definition: Object.hpp:32
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY_ARRAY(json, json_field, array_array_field, optional)
Definition: Object.hpp:108
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition: Object.hpp:44
Definition: Api.hpp:14
The interface of reply markup objects InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove ...
Definition: IReplyMarkup.hpp:7
This object represents a custom keyboard with reply options (see Introduction to bots for details and...
bool oneTimeKeyboard
Optional. Requests clients to hide the keyboard as soon as it's been used. The keyboard will still be...
bool resizeKeyboard
Optional. Requests clients to resize the keyboard vertically for optimal fit (e.g....
bool selective
Optional. Use this parameter if you want to show the keyboard to specific users only....
bool isPersistent
Optional. Requests clients to always show the keyboard when the regular keyboard is hidden....
std::vector< std::vector< Ptr< KeyboardButton > > > keyboard
Array of button rows, each represented by an Array of KeyboardButton objects @type Array of Array of ...
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
ReplyKeyboardMarkup(const nl::json &json)
std::string inputFieldPlaceholder
Optional. The placeholder to be shown in the input field when the keyboard is active; 1-64 characters...
nl::json toJson() const override
Serializes this object to JSON.