tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
BotCommandScope.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
16 BotCommandScope() = default;
17 explicit BotCommandScope(const nl::json& json) {
19 }
20 virtual ~BotCommandScope() = default;
21
23 std::string type;
24
25 virtual nl::json toJson() const {
26 nl::json scope = nl::json::object();
28 return scope;
29 }
30
31 virtual void fromJson(const nl::json& json) {
32 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
33 }
34 };
35
40 type = "default";
41 }
45
48 [[nodiscard]] nl::json toJson() const override {
49 nl::json json = BotCommandScope::toJson();
50 return json;
51 }
52
54 void fromJson(const nl::json& json) override {
56 }
57 };
58
62 type = "all_private_chats";
63 }
67
70 [[nodiscard]] nl::json toJson() const override {
71 nl::json json = BotCommandScope::toJson();
72 return json;
73 }
74
76 void fromJson(const nl::json& json) override {
78 }
79
80 };
81
85 type = "all_group_chats";
86 }
90
93 [[nodiscard]] nl::json toJson() const override {
94 nl::json json = BotCommandScope::toJson();
95 return json;
96 }
97
99 void fromJson(const nl::json& json) override {
101 }
102
103 };
104
108 type = "all_chat_administrators";
109 }
113
116 [[nodiscard]] nl::json toJson() const override {
117 nl::json json = BotCommandScope::toJson();
118 return json;
119 }
120
122 void fromJson(const nl::json& json) override {
124 }
125
126 };
127
131 type = "chat";
132 }
133 explicit BotCommandScopeChat(const nl::json& json) {
135 }
136
138 std::int64_t chatId{};
139
140 [[nodiscard]] nl::json toJson() const override {
141 nl::json scope = BotCommandScope::toJson();
143 return scope;
144 }
145
146 void fromJson(const nl::json& json) override {
148 OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, -1, false);
149 }
150 };
151
155 type = "chat_administrators";
156 }
160
162 std::int64_t chatId{};
163
164 [[nodiscard]] nl::json toJson() const override {
165 nl::json scope = BotCommandScope::toJson();
167 return scope;
168 }
169
170 void fromJson(const nl::json& json) override {
172 OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, -1, false);
173 }
174 };
175
179 type = "chat_member";
180 }
184
186 std::int64_t chatId{};
187
189 std::int64_t userId{};
190
191 [[nodiscard]] nl::json toJson() const override {
192 nl::json scope = BotCommandScope::toJson();
195 return scope;
196 }
197
198 void fromJson(const nl::json& json) override {
200 OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, -1, false);
201 OBJECT_DESERIALIZE_FIELD(json, "user_id", userId, -1, false);
202 }
203 };
204}
#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 the scope of bot commands, covering all group and supergroup chat administrators.
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
Represents the scope of bot commands, covering all group and supergroup chats.
BotCommandScopeAllGroupChats(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.
Represents the scope of bot commands, covering all private chats.
BotCommandScopeAllPrivateChats(const nl::json &json)
nl::json toJson() const override
Serializes this object to JSON.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
Represents the scope of bot commands, covering all administrators of a specific group or supergroup c...
void fromJson(const nl::json &json) override
std::int64_t chatId
Unique identifier for the target chat or username of the target supergroup (in the format @supergroup...
Represents the scope of bot commands, covering a specific chat.
std::int64_t chatId
Unique identifier for the target chat or username of the target supergroup (in the format @supergroup...
BotCommandScopeChat(const nl::json &json)
void fromJson(const nl::json &json) override
nl::json toJson() const override
Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
std::int64_t chatId
Unique identifier for the target chat or username of the target supergroup (in the format @supergroup...
std::int64_t userId
Unique identifier of the target user.
BotCommandScopeChatMember(const nl::json &json)
void fromJson(const nl::json &json) override
Represents the default scope of bot commands. Default commands are used if no commands with a narrowe...
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
BotCommandScopeDefault(const nl::json &json)
Base class of all bot commands scopes This object represents the scope to which bot commands are appl...
virtual void fromJson(const nl::json &json)
BotCommandScope(const nl::json &json)
virtual nl::json toJson() const
virtual ~BotCommandScope()=default
std::string type
Scope type.