tgbotxx 1.1.6.9
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) {
18 _fromJson(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();
27 OBJECT_SERIALIZE_FIELD(scope, "type", type);
28 return scope;
29 }
30
31 virtual void fromJson(const nl::json& json) {
32 OBJECT_DESERIALIZE_FIELD(json, "type", type, "", false);
33 }
34
35 private:
36 void _fromJson(const nl::json& json) {
37 fromJson(json);
38 }
39 };
40
47 explicit BotCommandScopeDefault(const nl::json& json) : BotCommandScope(json) {
48 BotCommandScope::type = "default";
49 }
50 };
51
55 BotCommandScope::type = "all_private_chats";
56 }
57 explicit BotCommandScopeAllPrivateChats(const nl::json& json) : BotCommandScope(json) {
58 BotCommandScope::type = "all_private_chats";
59 }
60 };
61
65 BotCommandScope::type = "all_group_chats";
66 }
67 explicit BotCommandScopeAllGroupChats(const nl::json& json) : BotCommandScope(json) {
68 BotCommandScope::type = "all_group_chats";
69 }
70 };
71
75 BotCommandScope::type = "all_chat_administrators";
76 }
77 explicit BotCommandScopeAllChatAdministrators(const nl::json& json) : BotCommandScope(json) {
78 BotCommandScope::type = "all_chat_administrators";
79 }
80 };
81
87 explicit BotCommandScopeChat(const nl::json& json) : BotCommandScope(json) {
88 BotCommandScope::type = "chat";
89 }
90
92 std::int64_t chatId{};
93
94 nl::json toJson() const override {
95 nl::json scope = BotCommandScope::toJson();
96 OBJECT_SERIALIZE_FIELD(scope, "chat_id", chatId);
97 return scope;
98 }
99
100 void fromJson(const nl::json& json) override {
102 OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, -1, false);
103 }
104 };
105
109 BotCommandScope::type = "chat_administrators";
110 }
111 explicit BotCommandScopeChatAdministrators(const nl::json& json) : BotCommandScope(json) {
112 BotCommandScope::type = "chat_administrators";
113 }
114
116 std::int64_t chatId{};
117
118 nl::json toJson() const override {
119 nl::json scope = BotCommandScope::toJson();
120 OBJECT_SERIALIZE_FIELD(scope, "chat_id", chatId);
121 return scope;
122 }
123
124 void fromJson(const nl::json& json) override {
126 OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, -1, false);
127 }
128 };
129
133 BotCommandScope::type = "chat_member";
134 }
135 explicit BotCommandScopeChatMember(const nl::json& json) : BotCommandScope(json) {
136 BotCommandScope::type = "chat_member";
137 }
138
140 std::int64_t chatId{};
142 std::int64_t userId{};
143
144 nl::json toJson() const override {
145 nl::json scope = BotCommandScope::toJson();
146 OBJECT_SERIALIZE_FIELD(scope, "chat_id", chatId);
147 OBJECT_SERIALIZE_FIELD(scope, "user_id", userId);
148 return scope;
149 }
150
151 void fromJson(const nl::json& json) override {
153 OBJECT_DESERIALIZE_FIELD(json, "chat_id", chatId, -1, false);
154 OBJECT_DESERIALIZE_FIELD(json, "user_id", userId, -1, false);
155 }
156 };
157}
#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
Represents the scope of bot commands, covering all group and supergroup chat administrators.
Represents the scope of bot commands, covering all group and supergroup chats.
BotCommandScopeAllGroupChats(const nl::json &json)
Represents the scope of bot commands, covering all private chats.
BotCommandScopeAllPrivateChats(const nl::json &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...
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.