conogram/entities/
chat_member_restricted.rs

1use serde::{Deserialize, Serialize};
2
3use crate::entities::user::User;
4
5/// Represents a [chat member](https://core.telegram.org/bots/api/#chatmember) that is under certain restrictions in the chat. Supergroups only.
6///
7/// API Reference: [link](https://core.telegram.org/bots/api/#chatmemberrestricted)
8#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
9pub struct ChatMemberRestricted {
10    /// Information about the user
11    pub user: User,
12
13    /// *True*, if the user is a member of the chat at the moment of the request
14    pub is_member: bool,
15
16    /// *True*, if the user is allowed to send text messages, contacts, giveaways, giveaway winners, invoices, locations and venues
17    pub can_send_messages: bool,
18
19    /// *True*, if the user is allowed to send audios
20    pub can_send_audios: bool,
21
22    /// *True*, if the user is allowed to send documents
23    pub can_send_documents: bool,
24
25    /// *True*, if the user is allowed to send photos
26    pub can_send_photos: bool,
27
28    /// *True*, if the user is allowed to send videos
29    pub can_send_videos: bool,
30
31    /// *True*, if the user is allowed to send video notes
32    pub can_send_video_notes: bool,
33
34    /// *True*, if the user is allowed to send voice notes
35    pub can_send_voice_notes: bool,
36
37    /// *True*, if the user is allowed to send polls
38    pub can_send_polls: bool,
39
40    /// *True*, if the user is allowed to send animations, games, stickers and use inline bots
41    pub can_send_other_messages: bool,
42
43    /// *True*, if the user is allowed to add web page previews to their messages
44    pub can_add_web_page_previews: bool,
45
46    /// *True*, if the user is allowed to change the chat title, photo and other settings
47    pub can_change_info: bool,
48
49    /// *True*, if the user is allowed to invite new users to the chat
50    pub can_invite_users: bool,
51
52    /// *True*, if the user is allowed to pin messages
53    pub can_pin_messages: bool,
54
55    /// *True*, if the user is allowed to create forum topics
56    pub can_manage_topics: bool,
57
58    /// Date when restrictions will be lifted for this user; Unix time. If 0, then the user is restricted forever
59    pub until_date: i64,
60}
61
62// Divider: all content below this line will be preserved after code regen
63use super::chat_permissions::ChatPermissions;
64
65impl ChatMemberRestricted {
66    pub const fn permissions(&self) -> ChatPermissions {
67        ChatPermissions {
68            can_send_messages: self.can_send_messages,
69            can_send_audios: self.can_send_audios,
70            can_send_documents: self.can_send_documents,
71            can_send_photos: self.can_send_photos,
72            can_send_videos: self.can_send_videos,
73            can_send_video_notes: self.can_send_video_notes,
74            can_send_voice_notes: self.can_send_voice_notes,
75            can_send_polls: self.can_send_polls,
76            can_send_other_messages: self.can_send_other_messages,
77            can_add_web_page_previews: self.can_add_web_page_previews,
78            can_change_info: self.can_change_info,
79            can_invite_users: self.can_invite_users,
80            can_pin_messages: self.can_pin_messages,
81            can_manage_topics: self.can_manage_topics,
82        }
83    }
84}