tgbotxx 1.2.9.2
Telegram Bot C++ Library
Loading...
Searching...
No Matches
ChatMember.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace tgbotxx {
15 struct ChatMember {
16 ChatMember() = default;
17 explicit ChatMember(const nl::json& json) {
19 }
20 virtual ~ChatMember() = default;
22 std::string status;
23
26
29 [[nodiscard]] virtual nl::json toJson() const {
30 nl::json json = nl::json::object();
33 return json;
34 }
35
37 virtual void fromJson(const nl::json& json) {
38 OBJECT_DESERIALIZE_FIELD(json, "status", status, "", false);
39 OBJECT_DESERIALIZE_FIELD_PTR(json, "user", user, false);
40 }
41 };
42
47 status = "creator";
48 }
49 explicit ChatMemberOwner(const nl::json& json) {
51 }
52
55
57 std::string customTitle;
58
61 [[nodiscard]] nl::json toJson() const override {
62 nl::json json = ChatMember::toJson();
63 OBJECT_SERIALIZE_FIELD(json, "is_anonymous", isAnonymous);
64 OBJECT_SERIALIZE_FIELD(json, "custom_title", customTitle);
65 return json;
66 }
67
69 void fromJson(const nl::json& json) override {
71 OBJECT_DESERIALIZE_FIELD(json, "is_anonymous", isAnonymous, false, false);
72 OBJECT_DESERIALIZE_FIELD(json, "custom_title", customTitle, "", true);
73 }
74 };
75
76
81 status = "administrator";
82 }
86
89
92
97
100
103
106
110
113
116
119
122
125
128
131
134
137
139 std::string customTitle;
140
141
144 [[nodiscard]] nl::json toJson() const override {
145 nl::json json = ChatMember::toJson();
146 OBJECT_SERIALIZE_FIELD(json, "can_be_edited", canBeEdited);
147 OBJECT_SERIALIZE_FIELD(json, "is_anonymous", isAnonymous);
148 OBJECT_SERIALIZE_FIELD(json, "can_manage_chat", canManageChat);
149 OBJECT_SERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages);
150 OBJECT_SERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats);
151 OBJECT_SERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers);
152 OBJECT_SERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers);
153 OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
154 OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
155 OBJECT_SERIALIZE_FIELD(json, "can_post_messages", canPostMessages);
156 OBJECT_SERIALIZE_FIELD(json, "can_edit_messages", canEditMessages);
157 OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
158 OBJECT_SERIALIZE_FIELD(json, "can_post_stories", canPostStories);
159 OBJECT_SERIALIZE_FIELD(json, "can_edit_stories", canEditStories);
160 OBJECT_SERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories);
161 OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
162 OBJECT_SERIALIZE_FIELD(json, "custom_title", customTitle);
163 return json;
164 }
165
167 void fromJson(const nl::json& json) override {
169 OBJECT_DESERIALIZE_FIELD(json, "can_be_edited", canBeEdited, false, false);
170 OBJECT_DESERIALIZE_FIELD(json, "is_anonymous", isAnonymous, false, false);
171 OBJECT_DESERIALIZE_FIELD(json, "can_manage_chat", canManageChat, false, false);
172 OBJECT_DESERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages, false, false);
173 OBJECT_DESERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats, false, false);
174 OBJECT_DESERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers, false, false);
175 OBJECT_DESERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers, false, false);
176 OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
177 OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
178 OBJECT_DESERIALIZE_FIELD(json, "can_post_messages", canPostMessages, false, true);
179 OBJECT_DESERIALIZE_FIELD(json, "can_edit_messages", canEditMessages, false, true);
180 OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, true);
181 OBJECT_DESERIALIZE_FIELD(json, "can_post_stories", canPostStories, false, true);
182 OBJECT_DESERIALIZE_FIELD(json, "can_edit_stories", canEditStories, false, true);
183 OBJECT_DESERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories, false, true);
184 OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, true);
185 OBJECT_DESERIALIZE_FIELD(json, "custom_title", customTitle, "", true);
186 }
187 };
188
189
194 status = "member";
195 }
196 explicit ChatMemberMember(const nl::json& json) {
198 }
199
202 [[nodiscard]] nl::json toJson() const override {
203 nl::json json = ChatMember::toJson();
204 return json;
205 }
206
208 void fromJson(const nl::json& json) override {
210 }
211 };
212
213
218 status = "restricted";
219 }
220 explicit ChatMemberRestricted(const nl::json& json) {
222 }
223
225 bool isMember{};
226
229
232
235
238
241
244
247
250
253
256
259
262
265
268
270 std::time_t untilDate{};
271
272
275 [[nodiscard]] nl::json toJson() const override {
276 nl::json json = ChatMember::toJson();
277 OBJECT_SERIALIZE_FIELD(json, "is_member", isMember);
278 OBJECT_SERIALIZE_FIELD(json, "can_send_messages", canSendMessages);
279 OBJECT_SERIALIZE_FIELD(json, "can_send_audios", canSendAudios);
280 OBJECT_SERIALIZE_FIELD(json, "can_send_documents", canSendDocuments);
281 OBJECT_SERIALIZE_FIELD(json, "can_send_photos", canSendPhotos);
282 OBJECT_SERIALIZE_FIELD(json, "can_send_videos", canSendVideos);
283 OBJECT_SERIALIZE_FIELD(json, "can_send_video_notes", canSendVideoNotes);
284 OBJECT_SERIALIZE_FIELD(json, "can_send_voice_notes", canSendVoiceNotes);
285 OBJECT_SERIALIZE_FIELD(json, "can_send_polls", canSendPolls);
286 OBJECT_SERIALIZE_FIELD(json, "can_send_other_messages", canSendOtherMessages);
287 OBJECT_SERIALIZE_FIELD(json, "can_add_web_page_previews", canAddWebPagePreviews);
288 OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
289 OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
290 OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
291 OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
292 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
293 return json;
294 }
295
297 void fromJson(const nl::json& json) override {
299 OBJECT_DESERIALIZE_FIELD(json, "is_member", isMember, false, false);
300 OBJECT_DESERIALIZE_FIELD(json, "can_send_messages", canSendMessages, false, false);
301 OBJECT_DESERIALIZE_FIELD(json, "can_send_audios", canSendAudios, false, false);
302 OBJECT_DESERIALIZE_FIELD(json, "can_send_documents", canSendDocuments, false, false);
303 OBJECT_DESERIALIZE_FIELD(json, "can_send_photos", canSendPhotos, false, false);
304 OBJECT_DESERIALIZE_FIELD(json, "can_send_videos", canSendVideos, false, false);
305 OBJECT_DESERIALIZE_FIELD(json, "can_send_video_notes", canSendVideoNotes, false, false);
306 OBJECT_DESERIALIZE_FIELD(json, "can_send_voice_notes", canSendVoiceNotes, false, false);
307 OBJECT_DESERIALIZE_FIELD(json, "can_send_polls", canSendPolls, false, false);
308 OBJECT_DESERIALIZE_FIELD(json, "can_send_other_messages", canSendOtherMessages, false, false);
309 OBJECT_DESERIALIZE_FIELD(json, "can_add_web_page_previews", canAddWebPagePreviews, false, false);
310 OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
311 OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
312 OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, false);
313 OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, false);
314 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, false);
315 }
316 };
317
318
323 status = "left";
324 }
325 explicit ChatMemberLeft(const nl::json& json) {
327 }
328
331 [[nodiscard]] nl::json toJson() const override {
332 nl::json json = ChatMember::toJson();
333 return json;
334 }
335
337 void fromJson(const nl::json& json) override {
339 }
340 };
341
342
347 status = "kicked";
348 }
349 explicit ChatMemberBanned(const nl::json& json) {
351 }
352
354 std::time_t untilDate{};
355
358 [[nodiscard]] nl::json toJson() const override {
359 nl::json json = ChatMember::toJson();
360 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
361 return json;
362 }
363
365 void fromJson(const nl::json& json) override {
367 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, false);
368 }
369 };
370
371}
#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 chat member that has some additional privileges. https://core.telegram....
bool canManageVideoChats
True, if the administrator can manage video chats.
bool canRestrictMembers
True, if the administrator can restrict, ban or unban chat members.
ChatMemberAdministrator(const nl::json &json)
bool canBeEdited
True, if the bot is allowed to edit administrator privileges of that user.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
bool canDeleteStories
Optional. True, if the administrator can delete stories posted by other users; channels only.
bool canManageChat
True, if the administrator can access the chat event log, chat statistics, boost list in channels,...
nl::json toJson() const override
Serializes this object to JSON.
bool canEditMessages
Optional. True, if the administrator can edit messages of other users and can pin messages; channels ...
bool canDeleteMessages
True, if the administrator can delete messages of other users.
std::string customTitle
Optional. Custom title for this user.
bool canChangeInfo
True, if the user is allowed to change the chat title, photo and other settings.
bool canPinMessages
Optional. True, if the user is allowed to pin messages; groups and supergroups only.
bool canPromoteMembers
True, if the administrator can add new administrators with a subset of their own privileges or demote...
bool canInviteUsers
True, if the user is allowed to invite new users to the chat.
bool canEditStories
Optional. True, if the administrator can edit stories posted by other users; channels only.
bool isAnonymous
True, if the user's presence in the chat is hidden.
bool canManageTopics
Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups...
bool canPostStories
Optional. True, if the administrator can post stories in the channel; channels only.
bool canPostMessages
Optional. True, if the administrator can post messages in the channel; channels only.
Represents a chat member that was banned in the chat and can't return to the chat or view chat messag...
std::time_t untilDate
Date when restrictions will be lifted for this user; Unix time. If 0, then the user is banned forever...
ChatMemberBanned(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.
The base class of all chat members objects. This object contains information about one member of a ch...
ChatMember(const nl::json &json)
virtual void fromJson(const nl::json &json)
Deserializes this object from JSON.
virtual ~ChatMember()=default
virtual nl::json toJson() const
Serializes this object to JSON.
Ptr< User > user
Information about the user.
std::string status
The member's status in the chat.
Represents a chat member that isn't currently a member of the chat, but may join it themselves....
nl::json toJson() const override
Serializes this object to JSON.
ChatMemberLeft(const nl::json &json)
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
Represents a chat member that has no additional privileges or restrictions. https://core....
ChatMemberMember(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 a chat member that owns the chat and has all administrator privileges. https://core....
ChatMemberOwner(const nl::json &json)
bool isAnonymous
True, if the user's presence in the chat is hidden.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
nl::json toJson() const override
Serializes this object to JSON.
std::string customTitle
Optional. Custom title for this user.
Represents a chat member that is under certain restrictions in the chat. Supergroups only....
bool canSendMessages
True, if the user is allowed to send text messages, contacts, invoices, locations and venues.
bool canSendAudios
True, if the user is allowed to send audios.
bool canAddWebPagePreviews
True, if the user is allowed to add web page previews to their messages.
bool canSendVideos
True, if the user is allowed to send videos.
bool canManageTopics
True, if the user is allowed to create forum topics.
bool canChangeInfo
True, if the user is allowed to change the chat title, photo and other settings.
nl::json toJson() const override
Serializes this object to JSON.
bool canSendDocuments
True, if the user is allowed to send documents.
bool canSendVideoNotes
True, if the user is allowed to send video notes.
bool isMember
True, if the user is a member of the chat at the moment of the request.
void fromJson(const nl::json &json) override
Deserializes this object from JSON.
bool canSendPhotos
True, if the user is allowed to send photos.
bool canSendOtherMessages
True, if the user is allowed to send animations, games, stickers and use inline bots.
std::time_t untilDate
Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted for...
bool canSendVoiceNotes
True, if the user is allowed to send voice notes.
bool canSendPolls
True, if the user is allowed to send polls.
bool canInviteUsers
True, if the user is allowed to invite new users to the chat.
bool canPinMessages
True, if the user is allowed to pin messages.
ChatMemberRestricted(const nl::json &json)