telegram_bot2/models/
chat_member.rs

1use crate::models::{Chat, ChatInviteLink, User};
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Clone, Debug)]
5#[serde(tag = "type")]
6/// This object contains information about one member of a chat
7pub enum ChatMember {
8    /// Represents a chat member that owns the chat and has all administrator privileges
9    Owner {
10        /// The member's status in the chat, always “creator”Debug, Builder, Default
11        status: String,
12        /// Information about the user
13        user: User,
14        /// True, if the user's presence in the chat is hidden
15        is_anonymous: bool,
16        /// . Custom title for this user
17        #[serde(default, skip_serializing_if = "Option::is_none")]
18        custom_title: Option<String>,
19    },
20
21    /// Represents a chat member that has some additional privileges.
22    Administrator {
23        /// The member's status in the chat, always “administrator”
24        status: String,
25        /// Information about the user
26        user: User,
27        /// True, if the bot is allowed to edit administrator privileges of that user
28        can_be_edited: bool,
29        /// True, if the user's presence in the chat is hidden
30        is_anonymous: bool,
31        /// True, if the administrator can access the chat event log, chat statistics, message statistics in channels, see channel members, see anonymous administrators in supergroups and ignore slow mode. Implied by any other administrator privilege
32        can_manage_chat: bool,
33        /// True, if the administrator can delete messages of other users
34        can_delete_messages: bool,
35        /// True, if the administrator can manage video chats
36        can_manage_video_chats: bool,
37        /// True, if the administrator can restrict, ban or unban chat members
38        can_restrict_members: bool,
39        /// True, if the administrator can add new administrators with a subset of their own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by the user)
40        can_promote_members: bool,
41        /// True, if the user is allowed to change the chat title, photo and other settings
42        can_change_info: bool,
43        /// True, if the user is allowed to invite new users to the chat
44        can_invite_users: bool,
45        /// . True, if the administrator can post in the channel; channels only
46        #[serde(default, skip_serializing_if = "Option::is_none")]
47        can_post_messages: Option<bool>,
48        /// . True, if the administrator can edit messages of other users and can pin messages; channels only
49        #[serde(default, skip_serializing_if = "Option::is_none")]
50        can_edit_messages: Option<bool>,
51        /// . True, if the user is allowed to pin messages; groups and supergroups only
52        #[serde(default, skip_serializing_if = "Option::is_none")]
53        can_pin_messages: Option<bool>,
54        /// . Custom title for this user
55        #[serde(default, skip_serializing_if = "Option::is_none")]
56        custom_title: Option<String>,
57        /// If the user is allowed to create, rename, close, and reopen forum topics; supergroups only
58        #[serde(default, skip_serializing_if = "Option::is_none")]
59        can_manage_topics: Option<bool>,
60    },
61
62    /// Represents a chat member that has no additional privileges or restrictions.
63    Member {
64        /// The member's status in the chat, always “member”
65        status: String,
66        /// Information about the user
67        user: User,
68    },
69
70    /// Represents a chat member that is under certain restrictions in the chat. Supergroups only.
71    Restricted {
72        /// The member's status in the chat, always “restricted”
73        status: String,
74        /// Information about the user
75        user: User,
76        /// True, if the user is a member of the chat at the moment of the request
77        is_member: bool,
78        /// True, if the user is allowed to change the chat title, photo and other settings
79        can_change_info: bool,
80        /// True, if the user is allowed to invite new users to the chat
81        can_invite_users: bool,
82        /// True, if the user is allowed to pin messages
83        can_pin_messages: bool,
84        /// True, if the user is allowed to send text messages, contacts, locations and venues
85        can_send_messages: bool,
86        /// True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes
87        can_send_media_messages: bool,
88        /// True, if the user is allowed to send polls
89        can_send_polls: bool,
90        /// True, if the user is allowed to send animations, games, stickers and use inline bots
91        can_send_other_messages: bool,
92        /// True, if the user is allowed to add web page previews to their messages
93        can_add_web_page_previews: bool,
94        /// Date when restrictions will be lifted for this user; unix time. If 0, then the user is restricted forever
95        until_date: i128,
96        /// If the user is allowed to create, rename, close, and reopen forum topics; supergroups only
97        #[serde(default, skip_serializing_if = "Option::is_none")]
98        can_manage_topics: Option<bool>,
99    },
100
101    /// Represents a chat member that isn't currently a member of the chat, but may join it themselves.
102    Left {
103        /// The member's status in the chat, always “left”
104        status: String,
105        /// Information about the user
106        user: User,
107    },
108
109    /// Represents a chat member that was banned in the chat and can't return to the chat or view chat messages.
110    Banned {
111        /// The member's status in the chat, always “kicked”
112        status: String,
113        /// Information about the user
114        user: User,
115        /// Date when restrictions will be lifted for this user; unix time. If 0, then the user is banned forever
116        until_date: i128,
117    },
118
119    /// This object represents changes in the status of a chat member.
120    Updated {
121        /// Chat the user belongs to
122        chat: Box<Chat>,
123        /// Performer of the action, which resulted in the change
124        from: User,
125        /// Date the change was done in Unix time
126        date: i128,
127        /// Previous information about the chat member
128        old_chat_member: Box<ChatMember>,
129        /// New information about the chat member
130        new_chat_member: Box<ChatMember>,
131        /// . Chat invite link, which was used by the user to join the chat; for joining by invite link events only.
132        #[serde(default, skip_serializing_if = "Option::is_none")]
133        invite_link: Option<ChatInviteLink>,
134    },
135}