tgbotxx 1.2.9.5
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
140
143
145 std::string customTitle;
146
147
150 [[nodiscard]] nl::json toJson() const override {
151 nl::json json = ChatMember::toJson();
152 OBJECT_SERIALIZE_FIELD(json, "can_be_edited", canBeEdited);
153 OBJECT_SERIALIZE_FIELD(json, "is_anonymous", isAnonymous);
154 OBJECT_SERIALIZE_FIELD(json, "can_manage_chat", canManageChat);
155 OBJECT_SERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages);
156 OBJECT_SERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats);
157 OBJECT_SERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers);
158 OBJECT_SERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers);
159 OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
160 OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
161 OBJECT_SERIALIZE_FIELD(json, "can_post_messages", canPostMessages);
162 OBJECT_SERIALIZE_FIELD(json, "can_edit_messages", canEditMessages);
163 OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
164 OBJECT_SERIALIZE_FIELD(json, "can_post_stories", canPostStories);
165 OBJECT_SERIALIZE_FIELD(json, "can_edit_stories", canEditStories);
166 OBJECT_SERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories);
167 OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
168 OBJECT_SERIALIZE_FIELD(json, "can_manage_direct_messages", canManageDirectMessages);
169 OBJECT_SERIALIZE_FIELD(json, "can_manage_tags", canManageTags);
170 OBJECT_SERIALIZE_FIELD(json, "custom_title", customTitle);
171 return json;
172 }
173
175 void fromJson(const nl::json& json) override {
177 OBJECT_DESERIALIZE_FIELD(json, "can_be_edited", canBeEdited, false, false);
178 OBJECT_DESERIALIZE_FIELD(json, "is_anonymous", isAnonymous, false, false);
179 OBJECT_DESERIALIZE_FIELD(json, "can_manage_chat", canManageChat, false, false);
180 OBJECT_DESERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages, false, false);
181 OBJECT_DESERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats, false, false);
182 OBJECT_DESERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers, false, false);
183 OBJECT_DESERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers, false, false);
184 OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
185 OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
186 OBJECT_DESERIALIZE_FIELD(json, "can_post_messages", canPostMessages, false, true);
187 OBJECT_DESERIALIZE_FIELD(json, "can_edit_messages", canEditMessages, false, true);
188 OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, true);
189 OBJECT_DESERIALIZE_FIELD(json, "can_post_stories", canPostStories, false, true);
190 OBJECT_DESERIALIZE_FIELD(json, "can_edit_stories", canEditStories, false, true);
191 OBJECT_DESERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories, false, true);
192 OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, true);
193 OBJECT_DESERIALIZE_FIELD(json, "can_manage_direct_messages", canManageDirectMessages, false, true);
194 OBJECT_DESERIALIZE_FIELD(json, "can_manage_tags", canManageTags, false, true);
195 OBJECT_DESERIALIZE_FIELD(json, "custom_title", customTitle, "", true);
196 }
197 };
198
199
204 status = "member";
205 }
206 explicit ChatMemberMember(const nl::json& json) {
208 }
209
211 std::string tag;
212
214 std::time_t untilDate{};
215
218 [[nodiscard]] nl::json toJson() const override {
219 nl::json json = ChatMember::toJson();
221 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
222 return json;
223 }
224
226 void fromJson(const nl::json& json) override {
228 OBJECT_DESERIALIZE_FIELD(json, "tag", tag, "", true);
229 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, true);
230 }
231 };
232
233
238 status = "restricted";
239 }
240 explicit ChatMemberRestricted(const nl::json& json) {
242 }
243
245 std::string tag;
246
248 bool isMember{};
249
252
255
258
261
264
267
270
273
276
279
282
285
288
291
294
296 std::time_t untilDate{};
297
298
301 [[nodiscard]] nl::json toJson() const override {
302 nl::json json = ChatMember::toJson();
304 OBJECT_SERIALIZE_FIELD(json, "is_member", isMember);
305 OBJECT_SERIALIZE_FIELD(json, "can_send_messages", canSendMessages);
306 OBJECT_SERIALIZE_FIELD(json, "can_send_audios", canSendAudios);
307 OBJECT_SERIALIZE_FIELD(json, "can_send_documents", canSendDocuments);
308 OBJECT_SERIALIZE_FIELD(json, "can_send_photos", canSendPhotos);
309 OBJECT_SERIALIZE_FIELD(json, "can_send_videos", canSendVideos);
310 OBJECT_SERIALIZE_FIELD(json, "can_send_video_notes", canSendVideoNotes);
311 OBJECT_SERIALIZE_FIELD(json, "can_send_voice_notes", canSendVoiceNotes);
312 OBJECT_SERIALIZE_FIELD(json, "can_send_polls", canSendPolls);
313 OBJECT_SERIALIZE_FIELD(json, "can_send_other_messages", canSendOtherMessages);
314 OBJECT_SERIALIZE_FIELD(json, "can_add_web_page_previews", canAddWebPagePreviews);
315 OBJECT_SERIALIZE_FIELD(json, "can_edit_tag", canEditTag);
316 OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
317 OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
318 OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
319 OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
320 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
321 return json;
322 }
323
325 void fromJson(const nl::json& json) override {
327 OBJECT_DESERIALIZE_FIELD(json, "tag", tag, "", true);
328 OBJECT_DESERIALIZE_FIELD(json, "is_member", isMember, false, false);
329 OBJECT_DESERIALIZE_FIELD(json, "can_send_messages", canSendMessages, false, false);
330 OBJECT_DESERIALIZE_FIELD(json, "can_send_audios", canSendAudios, false, false);
331 OBJECT_DESERIALIZE_FIELD(json, "can_send_documents", canSendDocuments, false, false);
332 OBJECT_DESERIALIZE_FIELD(json, "can_send_photos", canSendPhotos, false, false);
333 OBJECT_DESERIALIZE_FIELD(json, "can_send_videos", canSendVideos, false, false);
334 OBJECT_DESERIALIZE_FIELD(json, "can_send_video_notes", canSendVideoNotes, false, false);
335 OBJECT_DESERIALIZE_FIELD(json, "can_send_voice_notes", canSendVoiceNotes, false, false);
336 OBJECT_DESERIALIZE_FIELD(json, "can_send_polls", canSendPolls, false, false);
337 OBJECT_DESERIALIZE_FIELD(json, "can_send_other_messages", canSendOtherMessages, false, false);
338 OBJECT_DESERIALIZE_FIELD(json, "can_add_web_page_previews", canAddWebPagePreviews, false, false);
339 OBJECT_DESERIALIZE_FIELD(json, "can_edit_tag", canEditTag, false, false);
340 OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
341 OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
342 OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, false);
343 OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, false);
344 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, false);
345 }
346 };
347
348
353 status = "left";
354 }
355 explicit ChatMemberLeft(const nl::json& json) {
357 }
358
361 [[nodiscard]] nl::json toJson() const override {
362 nl::json json = ChatMember::toJson();
363 return json;
364 }
365
367 void fromJson(const nl::json& json) override {
369 }
370 };
371
372
377 status = "kicked";
378 }
379 explicit ChatMemberBanned(const nl::json& json) {
381 }
382
384 std::time_t untilDate{};
385
388 [[nodiscard]] nl::json toJson() const override {
389 nl::json json = ChatMember::toJson();
390 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
391 return json;
392 }
393
395 void fromJson(const nl::json& json) override {
397 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, false);
398 }
399 };
400
401}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:32
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:92
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Serialize.
Definition Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:64
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 canManageTags
Optional. True, if the administrator can edit the tags of regular members; for groups and supergroups...
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 canManageDirectMessages
Optional. True, if the administrator can manage direct messages of the channel and decline suggested ...
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.
std::string tag
Optional. Tag of the member.
std::time_t untilDate
Optional. Date when the user's subscription will expire; Unix time.
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.
std::string tag
Optional. Tag of the member.
nl::json toJson() const override
Serializes this object to JSON.
bool canEditTag
True, if the user is allowed to edit their own tag.
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)