mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
Add can_post_stories
, can_edit_stories
and can_delete_stories
privileges
to ChatMemberKind::Administrator and ChatAdministratorRights
This commit is contained in:
parent
959ce390ea
commit
02f023cfb6
2 changed files with 90 additions and 0 deletions
|
@ -47,6 +47,18 @@ pub struct ChatAdministratorRights {
|
|||
/// supergroups only
|
||||
pub can_pin_messages: Option<bool>,
|
||||
|
||||
/// `true`, if the administrator can post stories in the channel;
|
||||
/// channels only
|
||||
pub can_post_stories: Option<bool>,
|
||||
|
||||
/// `true`, if the administrator can edit stories posted by other users;
|
||||
/// channels only
|
||||
pub can_edit_stories: Option<bool>,
|
||||
|
||||
/// `true`, if the administrator can delete stories posted by other users;
|
||||
/// channels only
|
||||
pub can_delete_stories: Option<bool>,
|
||||
|
||||
/// `true`, if the user is allowed to create, rename, close, and reopen
|
||||
/// forum topics; supergroups only
|
||||
pub can_manage_topics: Option<bool>,
|
||||
|
|
|
@ -80,6 +80,21 @@ pub struct Administrator {
|
|||
/// `true` if the administrator can delete messages of other users.
|
||||
pub can_delete_messages: bool,
|
||||
|
||||
/// `true` if the administrator can post stories in the channel, channels
|
||||
/// only.
|
||||
#[serde(default)]
|
||||
pub can_post_stories: bool,
|
||||
|
||||
/// `true` if the administrator can edit stories posted by other users,
|
||||
/// channels only.
|
||||
#[serde(default)]
|
||||
pub can_edit_stories: bool,
|
||||
|
||||
/// `true` if the administrator can delete stories posted by other users,
|
||||
/// channels only.
|
||||
#[serde(default)]
|
||||
pub can_delete_stories: bool,
|
||||
|
||||
/// `true` if the administrator can manage video chats.
|
||||
pub can_manage_video_chats: bool,
|
||||
|
||||
|
@ -432,6 +447,66 @@ impl ChatMemberKind {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the user can post stories in the channel, channels
|
||||
/// only.
|
||||
///
|
||||
/// I.e. returns `true` if the user
|
||||
/// - is the owner of the chat (even if the chat is not a channel)
|
||||
/// - is an administrator in the given chat and has [`can_post_stories`]
|
||||
/// privilege.
|
||||
///
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
/// [`can_post_stories`]: Administrator::can_post_stories
|
||||
#[must_use]
|
||||
pub fn can_post_stories(&self) -> bool {
|
||||
match self {
|
||||
Self::Owner(_) => true,
|
||||
Self::Administrator(Administrator { can_post_stories, .. }) => *can_post_stories,
|
||||
Self::Member | Self::Restricted(_) | Self::Left | Self::Banned(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the user can edit stories posted by other users,
|
||||
/// channels only.
|
||||
///
|
||||
/// I.e. returns `true` if the user
|
||||
/// - is the owner of the chat (even if the chat is not a channel)
|
||||
/// - is an administrator in the given chat and has the [`can_edit_stories`]
|
||||
/// privilege.
|
||||
///
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
/// [`can_edit_stories`]: Administrator::can_edit_stories
|
||||
#[must_use]
|
||||
pub fn can_edit_stories(&self) -> bool {
|
||||
match self {
|
||||
Self::Owner(_) => true,
|
||||
Self::Administrator(Administrator { can_edit_stories, .. }) => *can_edit_stories,
|
||||
Self::Member | Self::Restricted(_) | Self::Left | Self::Banned(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the user can delete stories posted by other users,
|
||||
/// channels only.
|
||||
///
|
||||
/// I.e. returns `true` if the user
|
||||
/// - is the owner of the chat
|
||||
/// - is an administrator in the given chat and has the
|
||||
/// [`can_delete_stories`] privilege.
|
||||
///
|
||||
/// Returns `false` otherwise.
|
||||
///
|
||||
/// [`can_delete_stories`]: Administrator::can_delete_stories
|
||||
#[must_use]
|
||||
pub fn can_delete_stories(&self) -> bool {
|
||||
match self {
|
||||
Self::Owner(_) => true,
|
||||
Self::Administrator(Administrator { can_delete_stories, .. }) => *can_delete_stories,
|
||||
Self::Member | Self::Restricted(_) | Self::Left | Self::Banned(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if the user can manage video chats.
|
||||
///
|
||||
/// I.e. returns `true` if the user
|
||||
|
@ -639,6 +714,9 @@ mod tests {
|
|||
can_post_messages: false,
|
||||
can_edit_messages: false,
|
||||
can_delete_messages: true,
|
||||
can_post_stories: false,
|
||||
can_edit_stories: false,
|
||||
can_delete_stories: false,
|
||||
can_manage_video_chats: true,
|
||||
can_invite_users: true,
|
||||
can_restrict_members: true,
|
||||
|
|
Loading…
Reference in a new issue