mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-23 07:09:34 +01:00
TBA 6.2: Chat
and MessageEntity
changes
This commit is contained in:
parent
00165e64dc
commit
c544dae94c
3 changed files with 30 additions and 4 deletions
|
@ -99,6 +99,13 @@ pub struct ChatPrivate {
|
|||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub has_private_forwards: Option<True>,
|
||||
|
||||
/// `True`, if the privacy settings of the other party restrict sending
|
||||
/// voice and video note messages in the private chat. Returned only in
|
||||
/// [`GetChat`].
|
||||
///
|
||||
/// [`GetChat`]: crate::payloads::GetChat
|
||||
pub has_restricted_voice_and_video_messages: Option<True>,
|
||||
}
|
||||
|
||||
#[serde_with_macros::skip_serializing_none]
|
||||
|
@ -492,6 +499,7 @@ mod serde_helper {
|
|||
last_name: Option<String>,
|
||||
bio: Option<String>,
|
||||
has_private_forwards: Option<True>,
|
||||
has_restricted_voice_and_video_messages: Option<True>,
|
||||
}
|
||||
|
||||
impl From<ChatPrivate> for super::ChatPrivate {
|
||||
|
@ -503,6 +511,7 @@ mod serde_helper {
|
|||
last_name,
|
||||
bio,
|
||||
has_private_forwards,
|
||||
has_restricted_voice_and_video_messages,
|
||||
}: ChatPrivate,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -511,6 +520,7 @@ mod serde_helper {
|
|||
last_name,
|
||||
bio,
|
||||
has_private_forwards,
|
||||
has_restricted_voice_and_video_messages,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -523,6 +533,7 @@ mod serde_helper {
|
|||
last_name,
|
||||
bio,
|
||||
has_private_forwards,
|
||||
has_restricted_voice_and_video_messages,
|
||||
}: super::ChatPrivate,
|
||||
) -> Self {
|
||||
Self {
|
||||
|
@ -532,6 +543,7 @@ mod serde_helper {
|
|||
last_name,
|
||||
bio,
|
||||
has_private_forwards,
|
||||
has_restricted_voice_and_video_messages,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -576,6 +588,7 @@ mod tests {
|
|||
last_name: None,
|
||||
bio: None,
|
||||
has_private_forwards: None,
|
||||
has_restricted_voice_and_video_messages: None,
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
|
@ -596,6 +609,7 @@ mod tests {
|
|||
last_name: None,
|
||||
bio: None,
|
||||
has_private_forwards: None,
|
||||
has_restricted_voice_and_video_messages: None,
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
|
|
|
@ -139,7 +139,7 @@ impl MessageEntity {
|
|||
/// If you don't have a complete [`User`] value, please use
|
||||
/// [`MessageEntity::text_mention_id`] instead.
|
||||
#[must_use]
|
||||
pub fn text_mention(user: User, offset: usize, length: usize) -> Self {
|
||||
pub const fn text_mention(user: User, offset: usize, length: usize) -> Self {
|
||||
Self {
|
||||
kind: MessageEntityKind::TextMention { user },
|
||||
offset,
|
||||
|
@ -158,6 +158,16 @@ impl MessageEntity {
|
|||
}
|
||||
}
|
||||
|
||||
/// Create a message entity representing a custom emoji.
|
||||
#[must_use]
|
||||
pub const fn custom_emoji(custom_emoji_id: String, offset: usize, length: usize) -> Self {
|
||||
Self {
|
||||
kind: MessageEntityKind::CustomEmoji { custom_emoji_id },
|
||||
offset,
|
||||
length,
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn kind(mut self, val: MessageEntityKind) -> Self {
|
||||
self.kind = val;
|
||||
|
@ -300,13 +310,14 @@ pub enum MessageEntityKind {
|
|||
PhoneNumber,
|
||||
Bold,
|
||||
Italic,
|
||||
Underline,
|
||||
Strikethrough,
|
||||
Spoiler,
|
||||
Code,
|
||||
Pre { language: Option<String> },
|
||||
TextLink { url: reqwest::Url },
|
||||
TextMention { user: User },
|
||||
Underline,
|
||||
Strikethrough,
|
||||
Spoiler,
|
||||
CustomEmoji { custom_emoji_id: String }, // FIXME(waffle): newtype this
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -344,6 +344,7 @@ mod test {
|
|||
last_name: None,
|
||||
bio: None,
|
||||
has_private_forwards: None,
|
||||
has_restricted_voice_and_video_messages: None,
|
||||
}),
|
||||
photo: None,
|
||||
pinned_message: None,
|
||||
|
|
Loading…
Add table
Reference in a new issue