mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 14:35:36 +01:00
Merge pull request #1095 from shdwchn10/support-tba-6.9
Add TBA 6.9 support
This commit is contained in:
commit
5091c2ca98
8 changed files with 124 additions and 3 deletions
|
@ -13,7 +13,7 @@
|
||||||
<img src="https://img.shields.io/crates/v/teloxide.svg">
|
<img src="https://img.shields.io/crates/v/teloxide.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://core.telegram.org/bots/api">
|
<a href="https://core.telegram.org/bots/api">
|
||||||
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.8%20(inclusively)-green.svg">
|
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.9%20(inclusively)-green.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://t.me/teloxide">
|
<a href="https://t.me/teloxide">
|
||||||
<img src="https://img.shields.io/badge/support-t.me%2Fteloxide-blueviolet">
|
<img src="https://img.shields.io/badge/support-t.me%2Fteloxide-blueviolet">
|
||||||
|
|
|
@ -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
|
- `PollAnswer::voter` to support anonymous poll answers in chats
|
||||||
- `emoji_status_expiration_date` to `Chat` as part of the future `ChatFullInfo` type TBA type
|
- `emoji_status_expiration_date` to `Chat` as part of the future `ChatFullInfo` type TBA type
|
||||||
- Add the `unpin_all_general_forum_topic_messages` method
|
- 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
|
[pr851]: https://github.com/teloxide/teloxide/pull/851
|
||||||
[pr887]: https://github.com/teloxide/teloxide/pull/887
|
[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
|
[pr1040]: https://github.com/teloxide/teloxide/pull/1040
|
||||||
[pr1086]: https://github.com/teloxide/teloxide/pull/1086
|
[pr1086]: https://github.com/teloxide/teloxide/pull/1086
|
||||||
[pr1087]: https://github.com/teloxide/teloxide/pull/1087
|
[pr1087]: https://github.com/teloxide/teloxide/pull/1087
|
||||||
|
[pr1095]: https://github.com/teloxide/teloxide/pull/1095
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
|
<img src="https://img.shields.io/badge/license-MIT-blue.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://core.telegram.org/bots/api">
|
<a href="https://core.telegram.org/bots/api">
|
||||||
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.8%20(inclusively)-green.svg">
|
<img src="https://img.shields.io/badge/API%20coverage-Up%20to%206.9%20(inclusively)-green.svg">
|
||||||
</a>
|
</a>
|
||||||
<a href="https://crates.io/crates/teloxide_core">
|
<a href="https://crates.io/crates/teloxide_core">
|
||||||
<img src="https://img.shields.io/crates/v/teloxide_core.svg">
|
<img src="https://img.shields.io/crates/v/teloxide_core.svg">
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
//! [github]: https://github.com/WaffleLapkin/tg-methods-schema
|
//! [github]: https://github.com/WaffleLapkin/tg-methods-schema
|
||||||
|
|
||||||
Schema(
|
Schema(
|
||||||
api_version: ApiVersion(ver: "6.8", date: "August 18, 2023"),
|
api_version: ApiVersion(ver: "6.9", date: "September 22, 2023"),
|
||||||
methods: [
|
methods: [
|
||||||
Method(
|
Method(
|
||||||
names: ("getUpdates", "GetUpdates", "get_updates"),
|
names: ("getUpdates", "GetUpdates", "get_updates"),
|
||||||
|
@ -2041,6 +2041,21 @@ Schema(
|
||||||
ty: Option(bool),
|
ty: Option(bool),
|
||||||
descr: Doc(md: "Pass True, if the administrator can delete messages of other users")
|
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(
|
Param(
|
||||||
name: "can_manage_video_chats",
|
name: "can_manage_video_chats",
|
||||||
ty: Option(bool),
|
ty: Option(bool),
|
||||||
|
|
|
@ -25,6 +25,12 @@ impl_payload! {
|
||||||
pub can_edit_messages: bool,
|
pub can_edit_messages: bool,
|
||||||
/// Pass True, if the administrator can delete messages of other users
|
/// Pass True, if the administrator can delete messages of other users
|
||||||
pub can_delete_messages: bool,
|
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
|
/// Pass True, if the administrator can manage video chats, supergroups only
|
||||||
pub can_manage_video_chats: bool,
|
pub can_manage_video_chats: bool,
|
||||||
/// Pass True, if the administrator can restrict, ban or unban chat members
|
/// Pass True, if the administrator can restrict, ban or unban chat members
|
||||||
|
|
|
@ -47,6 +47,18 @@ pub struct ChatAdministratorRights {
|
||||||
/// supergroups only
|
/// supergroups only
|
||||||
pub can_pin_messages: Option<bool>,
|
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
|
/// `true`, if the user is allowed to create, rename, close, and reopen
|
||||||
/// forum topics; supergroups only
|
/// forum topics; supergroups only
|
||||||
pub can_manage_topics: Option<bool>,
|
pub can_manage_topics: Option<bool>,
|
||||||
|
|
|
@ -80,6 +80,21 @@ pub struct Administrator {
|
||||||
/// `true` if the administrator can delete messages of other users.
|
/// `true` if the administrator can delete messages of other users.
|
||||||
pub can_delete_messages: bool,
|
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.
|
/// `true` if the administrator can manage video chats.
|
||||||
pub can_manage_video_chats: bool,
|
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.
|
/// Returns `true` if the user can manage video chats.
|
||||||
///
|
///
|
||||||
/// I.e. returns `true` if the user
|
/// I.e. returns `true` if the user
|
||||||
|
@ -639,6 +714,9 @@ mod tests {
|
||||||
can_post_messages: false,
|
can_post_messages: false,
|
||||||
can_edit_messages: false,
|
can_edit_messages: false,
|
||||||
can_delete_messages: true,
|
can_delete_messages: true,
|
||||||
|
can_post_stories: false,
|
||||||
|
can_edit_stories: false,
|
||||||
|
can_delete_stories: false,
|
||||||
can_manage_video_chats: true,
|
can_manage_video_chats: true,
|
||||||
can_invite_users: true,
|
can_invite_users: true,
|
||||||
can_restrict_members: true,
|
can_restrict_members: true,
|
||||||
|
|
|
@ -10,4 +10,10 @@ use serde::{Deserialize, Serialize};
|
||||||
pub struct WriteAccessAllowed {
|
pub struct WriteAccessAllowed {
|
||||||
/// Name of the Web App which was launched from a link
|
/// Name of the Web App which was launched from a link
|
||||||
pub web_app_name: Option<String>,
|
pub web_app_name: Option<String>,
|
||||||
|
/// `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<bool>,
|
||||||
|
/// `true`, if the access was granted when the bot was added to the
|
||||||
|
/// attachment or side menu
|
||||||
|
pub from_attachment_menu: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue