tgbotxx 1.1.6.9
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) {
18 fromJson(json);
19 }
20
22 std::string status;
23
26
29 nl::json toJson() const {
30 nl::json json = nl::json::object();
31 OBJECT_SERIALIZE_FIELD(json, "status", status);
32 OBJECT_SERIALIZE_FIELD_PTR(json, "user", user);
33 return json;
34 }
35
37 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
46 ChatMemberOwner() = default;
47 explicit ChatMemberOwner(const nl::json& json) : ChatMember(json) {
48 fromJson(json);
49 ChatMember::status = "creator";
50 }
51
54
56 std::string customTitle;
57
60 nl::json toJson() const {
61 nl::json json = ChatMember::toJson();
62 OBJECT_SERIALIZE_FIELD(json, "is_anonymous", isAnonymous);
63 OBJECT_SERIALIZE_FIELD(json, "custom_title", customTitle);
64 return json;
65 }
66
68 void fromJson(const nl::json& json) {
70 OBJECT_DESERIALIZE_FIELD(json, "is_anonymous", isAnonymous, false, false);
71 OBJECT_DESERIALIZE_FIELD(json, "custom_title", customTitle, "", true);
72 }
73 };
74
75
80 explicit ChatMemberAdministrator(const nl::json& json) : ChatMember(json) {
81 fromJson(json);
82 ChatMember::status = "administrator";
83 }
84
87
90
95
98
101
104
108
111
114
117
120
123
126
129
132
135
137 std::string customTitle;
138
139
142 nl::json toJson() const {
143 nl::json json = ChatMember::toJson();
144 OBJECT_SERIALIZE_FIELD(json, "can_be_edited", canBeEdited);
145 OBJECT_SERIALIZE_FIELD(json, "is_anonymous", isAnonymous);
146 OBJECT_SERIALIZE_FIELD(json, "can_manage_chat", canManageChat);
147 OBJECT_SERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages);
148 OBJECT_SERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats);
149 OBJECT_SERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers);
150 OBJECT_SERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers);
151 OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
152 OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
153 OBJECT_SERIALIZE_FIELD(json, "can_post_messages", canPostMessages);
154 OBJECT_SERIALIZE_FIELD(json, "can_edit_messages", canEditMessages);
155 OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
156 OBJECT_SERIALIZE_FIELD(json, "can_post_stories", canPostStories);
157 OBJECT_SERIALIZE_FIELD(json, "can_edit_stories", canEditStories);
158 OBJECT_SERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories);
159 OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
160 OBJECT_SERIALIZE_FIELD(json, "custom_title", customTitle);
161 return json;
162 }
163
165 void fromJson(const nl::json& json) {
167 OBJECT_DESERIALIZE_FIELD(json, "can_be_edited", canBeEdited, false, false);
168 OBJECT_DESERIALIZE_FIELD(json, "is_anonymous", isAnonymous, false, false);
169 OBJECT_DESERIALIZE_FIELD(json, "can_manage_chat", canManageChat, false, false);
170 OBJECT_DESERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages, false, false);
171 OBJECT_DESERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats, false, false);
172 OBJECT_DESERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers, false, false);
173 OBJECT_DESERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers, false, false);
174 OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
175 OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
176 OBJECT_DESERIALIZE_FIELD(json, "can_post_messages", canPostMessages, false, true);
177 OBJECT_DESERIALIZE_FIELD(json, "can_edit_messages", canEditMessages, false, true);
178 OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, true);
179 OBJECT_DESERIALIZE_FIELD(json, "can_post_stories", canPostStories, false, true);
180 OBJECT_DESERIALIZE_FIELD(json, "can_edit_stories", canEditStories, false, true);
181 OBJECT_DESERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories, false, true);
182 OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, true);
183 OBJECT_DESERIALIZE_FIELD(json, "custom_title", customTitle, "", true);
184 }
185 };
186
187
191 ChatMemberMember() = default;
192 explicit ChatMemberMember(const nl::json& json) : ChatMember(json) {
193 ChatMember::status = "member";
194 }
195 };
196
197
202 explicit ChatMemberRestricted(const nl::json& json) : ChatMember(json) {
203 fromJson(json);
204 ChatMember::status = "restricted";
205 }
206
208 bool isMember{};
209
212
215
218
221
224
227
230
233
236
239
242
245
248
251
253 std::time_t untilDate{};
254
255
258 nl::json toJson() const {
259 nl::json json = ChatMember::toJson();
260 OBJECT_SERIALIZE_FIELD(json, "is_member", isMember);
261 OBJECT_SERIALIZE_FIELD(json, "can_send_messages", canSendMessages);
262 OBJECT_SERIALIZE_FIELD(json, "can_send_audios", canSendAudios);
263 OBJECT_SERIALIZE_FIELD(json, "can_send_documents", canSendDocuments);
264 OBJECT_SERIALIZE_FIELD(json, "can_send_photos", canSendPhotos);
265 OBJECT_SERIALIZE_FIELD(json, "can_send_videos", canSendVideos);
266 OBJECT_SERIALIZE_FIELD(json, "can_send_video_notes", canSendVideoNotes);
267 OBJECT_SERIALIZE_FIELD(json, "can_send_voice_notes", canSendVoiceNotes);
268 OBJECT_SERIALIZE_FIELD(json, "can_send_polls", canSendPolls);
269 OBJECT_SERIALIZE_FIELD(json, "can_send_other_messages", canSendOtherMessages);
270 OBJECT_SERIALIZE_FIELD(json, "can_add_web_page_previews", canAddWebPagePreviews);
271 OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
272 OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
273 OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
274 OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
275 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
276 return json;
277 }
278
280 void fromJson(const nl::json& json) {
282 OBJECT_DESERIALIZE_FIELD(json, "is_member", isMember, false, false);
283 OBJECT_DESERIALIZE_FIELD(json, "can_send_messages", canSendMessages, false, false);
284 OBJECT_DESERIALIZE_FIELD(json, "can_send_audios", canSendAudios, false, false);
285 OBJECT_DESERIALIZE_FIELD(json, "can_send_documents", canSendDocuments, false, false);
286 OBJECT_DESERIALIZE_FIELD(json, "can_send_photos", canSendPhotos, false, false);
287 OBJECT_DESERIALIZE_FIELD(json, "can_send_videos", canSendVideos, false, false);
288 OBJECT_DESERIALIZE_FIELD(json, "can_send_video_notes", canSendVideoNotes, false, false);
289 OBJECT_DESERIALIZE_FIELD(json, "can_send_voice_notes", canSendVoiceNotes, false, false);
290 OBJECT_DESERIALIZE_FIELD(json, "can_send_polls", canSendPolls, false, false);
291 OBJECT_DESERIALIZE_FIELD(json, "can_send_other_messages", canSendOtherMessages, false, false);
292 OBJECT_DESERIALIZE_FIELD(json, "can_add_web_page_previews", canAddWebPagePreviews, false, false);
293 OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
294 OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
295 OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, false);
296 OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, false);
297 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, false);
298 }
299 };
300
301
305 ChatMemberLeft() = default;
306 explicit ChatMemberLeft(const nl::json& json) : ChatMember(json) {
307 ChatMember::status = "left";
308 }
309 };
310
311
315 ChatMemberBanned() = default;
316 explicit ChatMemberBanned(const nl::json& json) : ChatMember(json) {
317 ChatMember::status = "left";
318 }
319
321 std::time_t untilDate{};
322
325 nl::json toJson() const {
326 nl::json json = ChatMember::toJson();
327 OBJECT_SERIALIZE_FIELD(json, "until_date", untilDate);
328 return json;
329 }
330
332 void fromJson(const nl::json& json) {
334 OBJECT_DESERIALIZE_FIELD(json, "until_date", untilDate, 0, false);
335 }
336 };
337
338}
#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:70
#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
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.
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,...
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.
nl::json toJson() const
Serializes this object to JSON.
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.
void fromJson(const nl::json &json)
Deserializes this object from JSON.
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...
void fromJson(const nl::json &json)
Deserializes this object from JSON.
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
Serializes this object to JSON.
The base class of all chat members objects. This object contains information about one member of a ch...
ChatMember(const nl::json &json)
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Ptr< User > user
Information about the user.
std::string status
The member's status in the chat.
nl::json toJson() const
Serializes this object to JSON.
Represents a chat member that isn't currently a member of the chat, but may join it themselves....
ChatMemberLeft(const nl::json &json)
Represents a chat member that has no additional privileges or restrictions. https://core....
ChatMemberMember(const nl::json &json)
Represents a chat member that owns the chat and has all administrator privileges. https://core....
void fromJson(const nl::json &json)
Deserializes this object from JSON.
nl::json toJson() const
Serializes this object to JSON.
ChatMemberOwner(const nl::json &json)
bool isAnonymous
True, if the user's presence in the chat is hidden.
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
Serializes this object to JSON.
void fromJson(const nl::json &json)
Deserializes this object from 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.
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)