diff --git a/README.md b/README.md index 6eda6f18..66e81040 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ - + diff --git a/crates/teloxide-core/CHANGELOG.md b/crates/teloxide-core/CHANGELOG.md index 951ca6b0..ac40fb82 100644 --- a/crates/teloxide-core/CHANGELOG.md +++ b/crates/teloxide-core/CHANGELOG.md @@ -85,6 +85,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `PollAnswer::voter` to support anonymous poll answers in chats - `emoji_status_expiration_date` to `Chat` as part of the future `ChatFullInfo` type TBA type - Add the `unpin_all_general_forum_topic_messages` method +- Support for TBA 6.9 ([#1095](pr1095)) + - Add `can_post_stories`, `can_edit_stories` and `can_delete_stories` fields to `ChatMemberKind::Administrator`, `ChatAdministratorRights` and `PromoteChatMember` + - Add `from_request` and `from_attachment_menu` fields to `WriteAccessAllowed` [pr851]: https://github.com/teloxide/teloxide/pull/851 [pr887]: https://github.com/teloxide/teloxide/pull/887 @@ -93,6 +96,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [pr1040]: https://github.com/teloxide/teloxide/pull/1040 [pr1086]: https://github.com/teloxide/teloxide/pull/1086 [pr1087]: https://github.com/teloxide/teloxide/pull/1087 +[pr1095]: https://github.com/teloxide/teloxide/pull/1095 ### Fixed diff --git a/crates/teloxide-core/README.md b/crates/teloxide-core/README.md index 6a382bb3..d4748be4 100644 --- a/crates/teloxide-core/README.md +++ b/crates/teloxide-core/README.md @@ -12,7 +12,7 @@ - + diff --git a/crates/teloxide-core/schema.ron b/crates/teloxide-core/schema.ron index cc649e5d..0f311684 100644 --- a/crates/teloxide-core/schema.ron +++ b/crates/teloxide-core/schema.ron @@ -39,7 +39,7 @@ //! [github]: https://github.com/WaffleLapkin/tg-methods-schema Schema( - api_version: ApiVersion(ver: "6.8", date: "August 18, 2023"), + api_version: ApiVersion(ver: "6.9", date: "September 22, 2023"), methods: [ Method( names: ("getUpdates", "GetUpdates", "get_updates"), @@ -2041,6 +2041,21 @@ Schema( ty: Option(bool), descr: Doc(md: "Pass True, if the administrator can delete messages of other users") ), + Param( + name: "can_post_stories", + ty: Option(bool), + descr: Doc(md: "Pass True, if the administrator can post stories in the channel, channels only") + ), + Param( + name: "can_edit_stories", + ty: Option(bool), + descr: Doc(md: "Pass True, if the administrator can edit stories posted by other users, channels only") + ), + Param( + name: "can_delete_stories", + ty: Option(bool), + descr: Doc(md: "Pass True, if the administrator can delete stories posted by other users, channels only") + ), Param( name: "can_manage_video_chats", ty: Option(bool), diff --git a/crates/teloxide-core/src/payloads/promote_chat_member.rs b/crates/teloxide-core/src/payloads/promote_chat_member.rs index 9b8bac40..851abdd4 100644 --- a/crates/teloxide-core/src/payloads/promote_chat_member.rs +++ b/crates/teloxide-core/src/payloads/promote_chat_member.rs @@ -25,6 +25,12 @@ impl_payload! { pub can_edit_messages: bool, /// Pass True, if the administrator can delete messages of other users pub can_delete_messages: bool, + /// Pass True, if the administrator can post stories in the channel, channels only + pub can_post_stories: bool, + /// Pass True, if the administrator can edit stories posted by other users, channels only + pub can_edit_stories: bool, + /// Pass True, if the administrator can delete stories posted by other users, channels only + pub can_delete_stories: bool, /// Pass True, if the administrator can manage video chats, supergroups only pub can_manage_video_chats: bool, /// Pass True, if the administrator can restrict, ban or unban chat members diff --git a/crates/teloxide-core/src/types/chat_administrator_rights.rs b/crates/teloxide-core/src/types/chat_administrator_rights.rs index 6c5168a6..c3e9c62c 100644 --- a/crates/teloxide-core/src/types/chat_administrator_rights.rs +++ b/crates/teloxide-core/src/types/chat_administrator_rights.rs @@ -47,6 +47,18 @@ pub struct ChatAdministratorRights { /// supergroups only pub can_pin_messages: Option, + /// `true`, if the administrator can post stories in the channel; + /// channels only + pub can_post_stories: Option, + + /// `true`, if the administrator can edit stories posted by other users; + /// channels only + pub can_edit_stories: Option, + + /// `true`, if the administrator can delete stories posted by other users; + /// channels only + pub can_delete_stories: Option, + /// `true`, if the user is allowed to create, rename, close, and reopen /// forum topics; supergroups only pub can_manage_topics: Option, diff --git a/crates/teloxide-core/src/types/chat_member.rs b/crates/teloxide-core/src/types/chat_member.rs index 1e195548..5aec15ee 100644 --- a/crates/teloxide-core/src/types/chat_member.rs +++ b/crates/teloxide-core/src/types/chat_member.rs @@ -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, diff --git a/crates/teloxide-core/src/types/write_access_allowed.rs b/crates/teloxide-core/src/types/write_access_allowed.rs index 7c6b3629..36f29b4a 100644 --- a/crates/teloxide-core/src/types/write_access_allowed.rs +++ b/crates/teloxide-core/src/types/write_access_allowed.rs @@ -10,4 +10,10 @@ use serde::{Deserialize, Serialize}; pub struct WriteAccessAllowed { /// Name of the Web App which was launched from a link pub web_app_name: Option, + /// `true`, if the access was granted after the user accepted an explicit + /// request from a Web App sent by the method [requestWriteAccess](https://core.telegram.org/bots/webapps#initializing-mini-apps) + pub from_request: Option, + /// `true`, if the access was granted when the bot was added to the + /// attachment or side menu + pub from_attachment_menu: Option, }