diff --git a/src/types/chat.rs b/src/types/chat.rs index aaedc5d2..e46f06ae 100644 --- a/src/types/chat.rs +++ b/src/types/chat.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; -use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message}; +use crate::types::{ChatLocation, ChatPermissions, ChatPhoto, Message, True}; /// This object represents a chat. /// @@ -95,6 +95,13 @@ pub struct ChatPrivate { /// /// [`GetChat`]: crate::payloads::GetChat pub bio: Option<String>, + + /// `True`, if privacy settings of the other party in the private chat + /// allows to use tg://user?id=<user_id> links only in chats with the + /// user. Returned only in [`GetChat`]. + /// + /// [`GetChat`]: crate::payloads::GetChat + pub has_private_forwards: Option<True>, } #[serde_with_macros::skip_serializing_none] @@ -407,6 +414,18 @@ impl Chat { _ => None, } } + + /// `True`, if privacy settings of the other party in the private chat + /// allows to use tg://user?id=<user_id> links only in chats with the + /// user. Returned only in [`GetChat`]. + /// + /// [`GetChat`]: crate::payloads::GetChat + pub fn has_private_forwards(&self) -> Option<True> { + match &self.kind { + ChatKind::Private(this) => this.has_private_forwards, + _ => None, + } + } } #[cfg(test)] @@ -447,6 +466,7 @@ mod tests { first_name: Some("Anon".into()), last_name: None, bio: None, + has_private_forwards: None }), photo: None, pinned_message: None, diff --git a/src/types/inline_keyboard_button.rs b/src/types/inline_keyboard_button.rs index 9da2182c..06a70850 100644 --- a/src/types/inline_keyboard_button.rs +++ b/src/types/inline_keyboard_button.rs @@ -41,7 +41,13 @@ impl InlineKeyboardButton { #[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] pub enum InlineKeyboardButtonKind { - /// HTTP or tg:// url to be opened when button is pressed. + /// HTTP or `tg://` url to be opened when button is pressed. + /// + /// Links in the form of `tg://user?id=<user_id>` can be used to mention a + /// user by their ID without using a username, if this is allowed by + /// their privacy settings. This will only work in Telegram versions + /// released after December 7, 2021. Older clients will display _unsupported + /// message_. Url(reqwest::Url), /// An HTTP URL used to automatically authorize the user. Can be used as a diff --git a/src/types/message.rs b/src/types/message.rs index 0afd73f4..99378eb4 100644 --- a/src/types/message.rs +++ b/src/types/message.rs @@ -90,6 +90,15 @@ pub struct MessageCommon { /// Inline keyboard attached to the message. `login_url` buttons are /// represented as ordinary `url` buttons. pub reply_markup: Option<InlineKeyboardMarkup>, + + /// `true`, if the message is a channel post that was automatically + /// forwarded to the connected discussion group. + #[serde(default)] + pub is_automatic_forward: bool, + + /// `true`, if the message can't be forwarded. + #[serde(default)] + pub has_protected_content: bool, } #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] @@ -1006,6 +1015,26 @@ mod getters { _ => None, } } + + pub fn is_automatic_forward(&self) -> bool { + match &self.kind { + Common(MessageCommon { + is_automatic_forward, + .. + }) => *is_automatic_forward, + _ => false, + } + } + + pub fn has_protected_content(&self) -> bool { + match &self.kind { + Common(MessageCommon { + has_protected_content, + .. + }) => *has_protected_content, + _ => false, + } + } } } diff --git a/src/types/update.rs b/src/types/update.rs index 56311400..a4ef8817 100644 --- a/src/types/update.rs +++ b/src/types/update.rs @@ -193,6 +193,7 @@ mod test { first_name: Some(String::from("Waffle")), last_name: None, bio: None, + has_private_forwards: None, }), photo: None, pinned_message: None, @@ -218,6 +219,8 @@ mod test { reply_markup: None, sender_chat: None, author_signature: None, + is_automatic_forward: false, + has_protected_content: false, }), }), };