tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
MenuButton.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
14 struct MenuButton {
15 MenuButton() = default;
16 explicit MenuButton(const nl::json& json) {
18 }
19 virtual ~MenuButton() = default;
20
22 std::string type;
23
26 virtual nl::json toJson() const {
27 nl::json json = nl::json::object();
29 return json;
30 }
31
33 virtual void fromJson(const nl::json& json) {
34 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
35 }
36 };
37
42 type = "default";
43 }
44 explicit MenuButtonDefault(const nl::json& json) {
46 }
47 nl::json toJson() const override {
48 nl::json json = MenuButton::toJson();
49 return json;
50 }
51
52 void fromJson(const nl::json& json) override {
54 }
55 };
56
61 type = "web_app";
62 }
63 explicit MenuButtonWebApp(const nl::json& json) {
65 }
66
68 std::string text;
69
73
74 nl::json toJson() const override {
75 nl::json json = MenuButton::toJson();
78 return json;
79 }
80
81 void fromJson(const nl::json& json) override {
83 OBJECT_DESERIALIZE_FIELD(json, "text", text, "", false);
84 OBJECT_DESERIALIZE_FIELD_PTR(json, "web_app", webApp, false);
85 }
86 };
87
92 type = "commands";
93 }
94 explicit MenuButtonCommands(const nl::json& json) {
96 }
97
98 nl::json toJson() const override {
99 nl::json json = MenuButton::toJson();
100 return json;
101 }
102 void fromJson(const nl::json& json) override {
104 }
105 };
106
107}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:22
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:72
#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
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
Represents a menu button, which opens the bot's list of commands. https://core.telegram....
nl::json toJson() const override
Serializes this object to JSON.
MenuButtonCommands(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
Describes that no specific value for the menu button was set. https://core.telegram....
MenuButtonDefault(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
This object describes the bot's menu button in a private chat. It should be one of:
virtual nl::json toJson() const
Serializes this object to JSON.
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
std::string type
Type of the button.
MenuButton(const nl::json &json)
virtual ~MenuButton()=default
Represents a menu button, which launches a Web App. https://core.telegram.org/bots/webapps https://co...
std::string text
Text on the button.
Ptr< WebAppInfo > webApp
Description of the Web App that will be launched when the user presses the button....
MenuButtonWebApp(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.