tgbotxx  1.1.6.9
Telegram Bot C++ Library
ChatAdministratorRights.hpp
Go to the documentation of this file.
1 #pragma once
3 
4 namespace tgbotxx {
9  explicit ChatAdministratorRights(const nl::json& json) {
10  fromJson(json);
11  }
12 
14  bool isAnonymous{};
15 
19  bool canManageChat{};
20 
23 
26 
29 
33 
35  bool canChangeInfo{};
36 
39 
42 
45 
48 
51 
54 
57 
60 
61 
64  nl::json toJson() const {
65  nl::json json = nl::json::object();
66  OBJECT_SERIALIZE_FIELD(json, "is_anonymous", isAnonymous);
67  OBJECT_SERIALIZE_FIELD(json, "can_manage_chat", canManageChat);
68  OBJECT_SERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages);
69  OBJECT_SERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats);
70  OBJECT_SERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers);
71  OBJECT_SERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers);
72  OBJECT_SERIALIZE_FIELD(json, "can_change_info", canChangeInfo);
73  OBJECT_SERIALIZE_FIELD(json, "can_invite_users", canInviteUsers);
74  OBJECT_SERIALIZE_FIELD(json, "can_post_messages", canPostMessages);
75  OBJECT_SERIALIZE_FIELD(json, "can_edit_messages", canEditMessages);
76  OBJECT_SERIALIZE_FIELD(json, "can_pin_messages", canPinMessages);
77  OBJECT_SERIALIZE_FIELD(json, "can_post_stories", canPostStories);
78  OBJECT_SERIALIZE_FIELD(json, "can_edit_stories", canEditStories);
79  OBJECT_SERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories);
80  OBJECT_SERIALIZE_FIELD(json, "can_manage_topics", canManageTopics);
81  return json;
82  }
83 
85  void fromJson(const nl::json& json) {
86  OBJECT_DESERIALIZE_FIELD(json, "is_anonymous", isAnonymous, false, false);
87  OBJECT_DESERIALIZE_FIELD(json, "can_manage_chat", canManageChat, false, false);
88  OBJECT_DESERIALIZE_FIELD(json, "can_delete_messages", canDeleteMessages, false, false);
89  OBJECT_DESERIALIZE_FIELD(json, "can_manage_video_chats", canManageVideoChats, false, false);
90  OBJECT_DESERIALIZE_FIELD(json, "can_restrict_members", canRestrictMembers, false, false);
91  OBJECT_DESERIALIZE_FIELD(json, "can_promote_members", canPromoteMembers, false, false);
92  OBJECT_DESERIALIZE_FIELD(json, "can_change_info", canChangeInfo, false, false);
93  OBJECT_DESERIALIZE_FIELD(json, "can_invite_users", canInviteUsers, false, false);
94  OBJECT_DESERIALIZE_FIELD(json, "can_post_messages", canPostMessages, false, true);
95  OBJECT_DESERIALIZE_FIELD(json, "can_edit_messages", canEditMessages, false, true);
96  OBJECT_DESERIALIZE_FIELD(json, "can_pin_messages", canPinMessages, false, true);
97  OBJECT_DESERIALIZE_FIELD(json, "can_post_stories", canPostStories, false, true);
98  OBJECT_DESERIALIZE_FIELD(json, "can_edit_stories", canEditStories, false, true);
99  OBJECT_DESERIALIZE_FIELD(json, "can_delete_stories", canDeleteStories, false, true);
100  OBJECT_DESERIALIZE_FIELD(json, "can_manage_topics", canManageTopics, false, true);
101  }
102  };
103 }
#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
Definition: Api.hpp:14
Represents the rights of an administrator in a chat. https://core.telegram.org/bots/api#chatadministr...
bool canManageChat
True, if the administrator can access the chat event log, boost list in channels, see channel members...
nl::json toJson() const
Serializes this object to JSON.
bool canManageTopics
Optional. True, if the user is allowed to create, rename, close, and reopen forum topics; supergroups...
bool isAnonymous
True, if the user's presence in the chat is hidden.
bool canChangeInfo
True, if the user is allowed to change the chat title, photo and other settings.
bool canPostStories
Optional. True, if the administrator can post stories in the channel; channels only.
bool canDeleteStories
Optional. True, if the administrator can delete stories posted by other users; channels only.
bool canDeleteMessages
True, if the administrator can delete messages of other users.
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 canEditStories
Optional. True, if the administrator can edit stories posted by other users; channels only.
bool canRestrictMembers
True, if the administrator can restrict, ban or unban chat members, or access supergroup statistics.
bool canPostMessages
Optional. True, if the administrator can post messages in the channel, or access channel statistics; ...
bool canPinMessages
Optional. True, if the user is allowed to pin messages; groups and supergroups only.
bool canManageVideoChats
True, if the administrator can manage video chats.
bool canEditMessages
Optional. True, if the administrator can edit messages of other users and can pin messages; channels ...
bool canInviteUsers
True, if the user is allowed to invite new users to the chat.