From 49a2195df98b5a22a332e976fdf0e95931d20857 Mon Sep 17 00:00:00 2001 From: Waffle Date: Tue, 31 Dec 2019 20:58:01 +0300 Subject: [PATCH 1/8] Bot API 4.5 (December 31, 2019) updates --- src/bot/api.rs | 27 +++- src/requests/form_builder.rs | 2 + src/requests/mod.rs | 2 + .../set_chat_administrator_custom_title.rs | 76 ++++++++++ src/types/animation.rs | 9 ++ src/types/audio.rs | 9 ++ src/types/chat.rs | 6 + src/types/chat_member.rs | 5 + src/types/chat_photo.rs | 10 ++ src/types/document.rs | 5 + src/types/file.rs | 5 + src/types/inline_query_result.rs | 4 +- src/types/message.rs | 9 ++ src/types/message_entity.rs | 2 + src/types/parse_mode.rs | 136 +++++++++++++----- src/types/passport_file.rs | 5 + src/types/photo_size.rs | 8 +- src/types/sticker.rs | 5 + src/types/video.rs | 5 + src/types/video_note.rs | 5 + src/types/voice.rs | 5 + 21 files changed, 297 insertions(+), 43 deletions(-) create mode 100644 src/requests/payloads/set_chat_administrator_custom_title.rs diff --git a/src/bot/api.rs b/src/bot/api.rs index 71eda735..58ca5496 100644 --- a/src/bot/api.rs +++ b/src/bot/api.rs @@ -18,7 +18,8 @@ use crate::{ RestrictChatMember, SendAnimation, SendAudio, SendChatAction, SendContact, SendDocument, SendGame, SendInvoice, SendLocation, SendMediaGroup, SendMessage, SendPhoto, SendPoll, SendSticker, - SendVenue, SendVideo, SendVideoNote, SendVoice, SetChatDescription, + SendVenue, SendVideo, SendVideoNote, SendVoice, + SetChatAdministratorCustomTitle, SetChatDescription, SetChatPermission, SetChatPhoto, SetChatStickerSet, SetChatTitle, SetGameScore, SetGameScoreInline, SetStickerPositionInSet, SetWebhook, StopMessageLiveLocation, StopMessageLiveLocationInline, @@ -1150,4 +1151,28 @@ impl Bot { GetGameHighScore::new(chat_id, message_id, user_id), ) } + + /// For tg-method documentation see [`SetChatAdministratorCustomTitle`] + /// + /// [`SetChatAdministratorCustomTitle`]: + /// crate::requests::payloads::SetChatAdministratorCustomTitle + pub fn set_chat_administrator_custom_title( + &self, + chat_id: C, + user_id: i32, + custom_title: CT, + ) -> json::Request + where + C: Into, + CT: Into, + { + json::Request::new( + self, + SetChatAdministratorCustomTitle::new( + chat_id, + user_id, + custom_title, + ), + ) + } } diff --git a/src/requests/form_builder.rs b/src/requests/form_builder.rs index 8a6256f7..cd048dba 100644 --- a/src/requests/form_builder.rs +++ b/src/requests/form_builder.rs @@ -123,7 +123,9 @@ impl IntoFormValue for str { impl IntoFormValue for ParseMode { fn into_form_value(&self) -> Option { let string = match self { + ParseMode::MarkdownV2 => String::from("MarkdownV2"), ParseMode::HTML => String::from("HTML"), + #[allow(deprecated)] ParseMode::Markdown => String::from("Markdown"), }; Some(FormValue::Str(string)) diff --git a/src/requests/mod.rs b/src/requests/mod.rs index 16de1a29..c72e94b0 100644 --- a/src/requests/mod.rs +++ b/src/requests/mod.rs @@ -115,6 +115,7 @@ pub mod payloads { mod set_game_score; mod get_game_high_scores; mod get_game_high_scores_inline; + mod set_chat_administrator_custom_title; pub use { get_updates::{GetUpdates, AllowedUpdate}, @@ -189,5 +190,6 @@ pub mod payloads { set_game_score::SetGameScore, get_game_high_scores_inline::GetGameHighScoreInline, get_game_high_scores::GetGameHighScore, + set_chat_administrator_custom_title::SetChatAdministratorCustomTitle, }; } diff --git a/src/requests/payloads/set_chat_administrator_custom_title.rs b/src/requests/payloads/set_chat_administrator_custom_title.rs new file mode 100644 index 00000000..a118e648 --- /dev/null +++ b/src/requests/payloads/set_chat_administrator_custom_title.rs @@ -0,0 +1,76 @@ +use serde::{Deserialize, Serialize}; + +use crate::{ + requests::{dynamic, json, Method}, + types::{True, ChatId}, +}; + +/// Use this method to set a custom title for an administrator in a supergroup +/// promoted by the bot. +#[serde_with_macros::skip_serializing_none] +#[derive(Debug, PartialEq, Eq, Hash, Clone, Deserialize, Serialize)] +pub struct SetChatAdministratorCustomTitle { + /// Unique identifier for the target chat or username of the target + /// supergroup (in the format `@supergroupusername`) + pub chat_id: ChatId, + + /// Unique identifier of the target user + pub user_id: i32, + + /// New custom title for the administrator; 0-16 characters, emoji are not + /// allowed + pub custom_title: String, +} + +impl Method for SetChatAdministratorCustomTitle { + type Output = True; + + const NAME: &'static str = "setChatAdministratorCustomTitle"; +} + +impl json::Payload for SetChatAdministratorCustomTitle {} + +impl dynamic::Payload for SetChatAdministratorCustomTitle { + fn kind(&self) -> dynamic::Kind { + dynamic::Kind::Json(serde_json::to_string(self).unwrap()) + } +} + +impl SetChatAdministratorCustomTitle { + pub fn new(chat_id: C, user_id: i32, custom_title: CT) -> Self + where + C: Into, + CT: Into, + { + let chat_id = chat_id.into(); + let custom_title = custom_title.into(); + Self { + chat_id, + user_id, + custom_title, + } + } +} + +impl json::Request<'_, SetChatAdministratorCustomTitle> { + pub fn chat_id(mut self, val: T) -> Self + where + T: Into, + { + self.payload.chat_id = val.into(); + self + } + + pub fn user_id(mut self, val: i32) -> Self { + self.payload.user_id = val; + self + } + + pub fn custom_title(mut self, val: T) -> Self + where + T: Into, + { + self.payload.custom_title = val.into(); + self + } +} diff --git a/src/types/animation.rs b/src/types/animation.rs index 9920f0fd..c754c1ca 100644 --- a/src/types/animation.rs +++ b/src/types/animation.rs @@ -12,6 +12,11 @@ pub struct Animation { /// An identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// A video width as defined by a sender. pub width: u32, @@ -42,11 +47,13 @@ mod tests { fn deserialize() { let json = r#"{ "file_id":"id", + "file_unique_id":"", "width":320, "height":320, "duration":59, "thumb":{ "file_id":"id", + "file_unique_id":"", "width":320, "height":320, "file_size":3452 @@ -56,11 +63,13 @@ mod tests { "file_size":6500}"#; let expected = Animation { file_id: "id".to_string(), + file_unique_id: "".to_string(), width: 320, height: 320, duration: 59, thumb: Some(PhotoSize { file_id: "id".to_string(), + file_unique_id: "".to_string(), width: 320, height: 320, file_size: Some(3452), diff --git a/src/types/audio.rs b/src/types/audio.rs index 9b2b2567..23ae1c1f 100644 --- a/src/types/audio.rs +++ b/src/types/audio.rs @@ -12,6 +12,11 @@ pub struct Audio { /// An identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// A duration of the audio in seconds as defined by a sender. pub duration: u32, @@ -39,6 +44,7 @@ mod tests { fn deserialize() { let json = r#"{ "file_id":"id", + "file_unique_id":"", "duration":60, "performer":"Performer", "title":"Title", @@ -46,6 +52,7 @@ mod tests { "file_size":123456, "thumb":{ "file_id":"id", + "file_unique_id":"", "width":320, "height":320, "file_size":3452 @@ -53,6 +60,7 @@ mod tests { }"#; let expected = Audio { file_id: "id".to_string(), + file_unique_id: "".to_string(), duration: 60, performer: Some("Performer".to_string()), title: Some("Title".to_string()), @@ -60,6 +68,7 @@ mod tests { file_size: Some(123_456), thumb: Some(PhotoSize { file_id: "id".to_string(), + file_unique_id: "".to_string(), width: 320, height: 320, file_size: Some(3452), diff --git a/src/types/chat.rs b/src/types/chat.rs index 2df5dda7..27220caf 100644 --- a/src/types/chat.rs +++ b/src/types/chat.rs @@ -117,6 +117,12 @@ pub enum NonPrivateChatKind { /// /// [`Bot::get_chat`]: crate::Bot::get_chat permissions: Option, + + /// The minimum allowed delay between consecutive messages sent by each + /// unpriviledged user. Returned only in [`Bot::get_chat`]. + /// + /// [`Bot::get_chat`]: crate::Bot::get_chat + slow_mode_delay: Option, }, } diff --git a/src/types/chat_member.rs b/src/types/chat_member.rs index 71c24c09..599d842a 100644 --- a/src/types/chat_member.rs +++ b/src/types/chat_member.rs @@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize}; use crate::types::User; +// TODO: ChatMemberKind?... /// This object contains information about one member of the chat. /// /// [The official docs](https://core.telegram.org/bots/api#chatmember). @@ -13,6 +14,9 @@ pub struct ChatMember { /// The member's status in the chat. pub status: ChatMemberStatus, + /// Owner and administrators only. Custom title for this user + pub custom_title: Option, + /// Restricted and kicked only. Date when restrictions will be lifted for /// this user, unix time. pub until_date: Option, @@ -123,6 +127,7 @@ mod tests { language_code: None, }, status: ChatMemberStatus::Creator, + custom_title: None, until_date: Some(123_456), can_be_edited: Some(true), can_change_info: Some(true), diff --git a/src/types/chat_photo.rs b/src/types/chat_photo.rs index f7e5a9ec..29e78664 100644 --- a/src/types/chat_photo.rs +++ b/src/types/chat_photo.rs @@ -10,8 +10,18 @@ pub struct ChatPhoto { /// not changed. pub small_file_id: String, + /// Unique file identifier of small (160x160) chat photo, which is supposed + /// to be the same over time and for different bots. Can't be used to + /// download or reuse the file. + pub small_file_unique_id: String, + /// A file identifier of big (640x640) chat photo. This file_id can be used /// only for photo download and only for as long as the photo is not /// changed. pub big_file_id: String, + + /// Unique file identifier of big (640x640) chat photo, which is supposed + /// to be the same over time and for different bots. Can't be used to + /// download or reuse the file. + pub big_file_unique_id: String, } diff --git a/src/types/document.rs b/src/types/document.rs index f51701fa..1d385f7b 100644 --- a/src/types/document.rs +++ b/src/types/document.rs @@ -16,6 +16,11 @@ pub struct Document { /// An identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// A document thumbnail as defined by a sender. pub thumb: Option, diff --git a/src/types/file.rs b/src/types/file.rs index 30851263..388f3c5d 100644 --- a/src/types/file.rs +++ b/src/types/file.rs @@ -13,6 +13,11 @@ pub struct File { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// File size, if known. pub file_size: u32, diff --git a/src/types/inline_query_result.rs b/src/types/inline_query_result.rs index c1c63c6c..15ff2018 100644 --- a/src/types/inline_query_result.rs +++ b/src/types/inline_query_result.rs @@ -91,12 +91,12 @@ mod tests { reply_markup: Some(InlineKeyboardMarkup::new()), input_message_content: Some(InputMessageContent::Text { message_text: String::from("message_text"), - parse_mode: Some(ParseMode::Markdown), + parse_mode: Some(ParseMode::MarkdownV2), disable_web_page_preview: Some(true), }), }); - let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"Markdown","disable_web_page_preview":true}}"#; + let expected_json = r#"{"type":"audio","id":"id","audio_file_id":"audio_file_id","caption":"caption","parse_mode":"HTML","reply_markup":{"inline_keyboard":[]},"input_message_content":{"message_text":"message_text","parse_mode":"MarkdownV2","disable_web_page_preview":true}}"#; let actual_json = serde_json::to_string(&structure).unwrap(); assert_eq!(expected_json, actual_json); diff --git a/src/types/message.rs b/src/types/message.rs index 439c0da0..c815abea 100644 --- a/src/types/message.rs +++ b/src/types/message.rs @@ -827,11 +827,13 @@ mod tests { "mime_type": "video/mp4", "thumb": { "file_id": "AAQCAAOmBAACBf2oS53pByA-I4CWWCObDwAEAQAHbQADMWcAAhYE", + "file_unique_id":"", "file_size": 10339, "width": 256, "height": 320 }, "file_id": "BAADAgADpgQAAgX9qEud6QcgPiOAlhYE", + "file_unique_id":"", "file_size": 1381334 } }"#; @@ -867,11 +869,13 @@ mod tests { "mime_type": "video/mp4", "thumb": { "file_id": "AAQCAAOmBAACBf2oS53pByA-I4CWWCObDwAEAQAHbQADMWcAAhYE", + "file_unique_id":"", "file_size": 10339, "width": 256, "height": 320 }, "file_id": "BAADAgADpgQAAgX9qEud6QcgPiOAlhYE", + "file_unique_id":"", "file_size": 1381334 } }"#; @@ -933,11 +937,13 @@ mod tests { "is_animated": true, "thumb": { "file_id": "AAQCAAMjAAOw0PgMaabKAcaXKCBLubkPAAQBAAdtAAPGKwACFgQ", + "file_unique_id":"", "file_size": 4118, "width": 128, "height": 128 }, "file_id": "CAADAgADIwADsND4DGmmygHGlyggFgQ", + "file_unique_id":"", "file_size": 16639 } }"#; @@ -968,18 +974,21 @@ mod tests { "photo": [ { "file_id": "AgADAgAD36sxG-PX0UvQSXIn9rccdw-ACA4ABAEAAwIAA20AAybcBAABFgQ", + "file_unique_id":"", "file_size": 18188, "width": 320, "height": 239 }, { "file_id": "AgADAgAD36sxG-PX0UvQSXIn9rccdw-ACA4ABAEAAwIAA3gAAyfcBAABFgQ", + "file_unique_id":"", "file_size": 62123, "width": 800, "height": 598 }, { "file_id": "AgADAgAD36sxG-PX0UvQSXIn9rccdw-ACA4ABAEAAwIAA3kAAyTcBAABFgQ", + "file_unique_id":"", "file_size": 75245, "width": 962, "height": 719 diff --git a/src/types/message_entity.rs b/src/types/message_entity.rs index d6372a4c..19d37fe2 100644 --- a/src/types/message_entity.rs +++ b/src/types/message_entity.rs @@ -35,6 +35,8 @@ pub enum MessageEntityKind { Pre, TextLink { url: String }, TextMention { user: User }, + Underline, + Strikethrough, } #[test] diff --git a/src/types/parse_mode.rs b/src/types/parse_mode.rs index 32a9eace..4892e908 100644 --- a/src/types/parse_mode.rs +++ b/src/types/parse_mode.rs @@ -1,81 +1,139 @@ +// see https://github.com/rust-lang/rust/issues/38832 +// (for built ins there no warnings, but for (De)Serialize, there are) +#![allow(deprecated)] + use serde::{Deserialize, Serialize}; /// ## Formatting options -/// The Bot API supports basic formatting for messages. -/// You can use **bold** and *italic* text, as well as [inline links](https://example.com) -/// and `pre-formatted code` in your bots' messages. Telegram clients will -/// render them accordingly. You can use either markdown-style or HTML-style +/// The Bot API supports basic formatting for messages. You can use bold, +/// italic, underlined and strikethrough text, as well as inline links and +/// pre-formatted code in your bots' messages. Telegram clients will render +/// them accordingly. You can use either markdown-style or HTML-style /// formatting. /// -/// Note that Telegram clients will display an alert to the user before opening -/// an inline link (‘Open this link?’ together with the full URL). +/// Note that Telegram clients will display an **alert** to the user before +/// opening an inline link (‘Open this link?’ together with the full URL). /// -/// Links `tg://user?id=` can be used to mention a user by their id +/// Links `tg://user?id=` can be used to mention a user by their ID /// without using a username. Please note: /// -/// - These links will work only if they are used inside an inline link. For +/// - These links will work **only** if they are used inside an inline link. For /// example, they will not work, when used in an inline keyboard button or in /// a message text. -/// - The mentions are only guaranteed to work if: **A**. the user is a member -/// in the group where he was mentioned or **B**. the user has contacted the -/// bot in the past or has sent a callback query to the bot via inline button -/// and has not restricted linking to their account in `Settings > Privacy & -/// Security > Forwarded Messages`. +/// - These mentions are only guaranteed to work if the user has contacted the +/// bot in the past, has sent a callback query to the bot via inline button or +/// is a member in the group where he was mentioned. /// -/// ## Markdown style -/// To use this mode, pass [Markdown] in the `parse_mode` field when using -/// [SendMessage] (or other methods). +/// ## MarkdownV2 style /// +/// To use this mode, pass [`MarkdownV2`] in the `parse_mode` field. /// Use the following syntax in your message: -/// -///
-/// *bold text*
-/// _italic text_
+/// ````text
+/// *bold \*text*
+/// _italic \*text_
+/// __underline__
+/// ~strikethrough~
+/// *bold _italic bold ~italic bold strikethrough~ __underline italic bold___ bold*
 /// [inline URL](http://www.example.com/)
 /// [inline mention of a user](tg://user?id=123456789)
-/// `inline fixed-width code`
-/// ```block_language
+/// `inline fixed-width code`
+/// ```
 /// pre-formatted fixed-width code block
-/// ```
-/// 
+/// ``` +/// ```rust +/// pre-formatted fixed-width code block written in the Rust programming +/// language ``` +/// ```` +/// +/// Please note: +/// - Any character between 1 and 126 inclusively can be escaped anywhere with a +/// preceding '\' character, in which case it is treated as an ordinary +/// character and not a part of the markup. +/// - Inside `pre` and `code` entities, all '`‘ and ’\‘ characters must be +/// escaped with a preceding ’\' character. +/// - Inside `(...)` part of inline link definition, all ')‘ and ’\‘ must be +/// escaped with a preceding ’\' character. +/// - In all other places characters ’_‘, ’*‘, ’[‘, ’]‘, ’(‘, ’)‘, ’~‘, ’`‘, +/// ’>‘, ’#‘, ’+‘, ’+‘, ’-‘, ’|‘, ’{‘, ’}‘, ’.‘, ’!‘ must be escaped with the +/// preceding character ’\'. +/// - In case of ambiguity between `italic` and `underline` entities ‘__’ is +/// always greadily treated from left to right as beginning or end of +/// `underline` entity, so instead of `___italic underline___` use `___italic +/// underline_\r__`, where `\r` is a character with code `13`, which will be +/// ignored. /// /// ## HTML style -/// To use this mode, pass [HTML] in the `parse_mode` field when using -/// [SendMessage] (or other methods). -/// +/// To use this mode, pass [`HTML`] in the `parse_mode` field. /// The following tags are currently supported: /// -///
-/// <b>bold</b>, <strong>bold</strong>
-/// <i>italic</i>, <em>italic</em>
-/// <a href="http://www.example.com/">inline URL</a>
-/// <a href="tg://user?id=123456789">inline mention of a user</a>
-/// <code>inline fixed-width code</code>
-/// <pre>pre-formatted fixed-width code block</pre>
-/// 
+/// ````text +/// bold, bold +/// italic, italic +/// underline, underline +/// strikethrough, strikethrough, strikethrough +/// bold italic bold italic bold strikethrough underline italic bold bold +/// inline URL +/// inline mention of a user +/// inline fixed-width code +///
pre-formatted fixed-width code block
+///
pre-formatted fixed-width code block written in the Rust programming language
+/// ```` /// /// Please note: /// /// - Only the tags mentioned above are currently supported. -/// - Tags must not be nested. /// - All `<`, `>` and `&` symbols that are not a part of a tag or an HTML /// entity must be replaced with the corresponding HTML entities (`<` with /// `<`, `>` with `>` and `&` with `&`). /// - All numerical HTML entities are supported. /// - The API currently supports only the following named HTML entities: `<`, /// `>`, `&` and `"`. +/// - Use nested `pre` and `code` tags, to define programming language for `pre` +/// entity. +/// - Programming language can't be specified for standalone `code` tags. /// -/// [Markdown]: crate::types::ParseMode::Markdown -/// [HTML]: crate::types::ParseMode::HTML -/// [SendMessage]: crate::requests::payloads::SendMessage +/// ## Markdown style +/// This is a legacy mode, retained for backward compatibility. To use this +/// mode, pass [`Markdown`] in the `parse_mode` field. +/// Use the following syntax in your message: +/// +/// ````text +/// *bold text* +/// _italic text_ +/// [inline URL](http://www.example.com/) +/// [inline mention of a user](tg://user?id=123456789) +/// `inline fixed-width code` +/// ```rust +/// pre-formatted fixed-width code block written in the Rust programming +/// language ``` +/// ```` +/// +/// Please note: +/// - Entities must not be nested, use parse mode [`MarkdownV2`] instead. +/// - There is no way to specify underline and strikethrough entities, use parse +/// mode [`MarkdownV2`] instead. +/// - To escape characters ’_‘, ’*‘, ’`‘, ’[‘ outside of an entity, prepend the +/// characters ’\' before them. +/// - Escaping inside entities is not allowed, so entity must be closed first +/// and reopened again: use `_snake_\__case_` for italic `snake_case` and +/// `*2*\**2=4*` for bold `2*2=4`. +/// +/// [`MarkdownV2`]: ParseMode::MarkdownV2 +/// [`HTML`]: ParseMode::HTML +/// [`Markdown`]: ParseMode::Markdown #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] pub enum ParseMode { + MarkdownV2, HTML, + #[deprecated = "This is a legacy mode, retained for backward \ + compatibility. Use `MarkdownV2` instead."] Markdown, } #[cfg(test)] mod tests { + #![allow(deprecated)] + use super::*; #[test] diff --git a/src/types/passport_file.rs b/src/types/passport_file.rs index cc5228c7..fa81a1bd 100644 --- a/src/types/passport_file.rs +++ b/src/types/passport_file.rs @@ -10,6 +10,11 @@ pub struct PassportFile { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// File size. pub file_size: u64, diff --git a/src/types/photo_size.rs b/src/types/photo_size.rs index 7d8c2f13..00297b9b 100644 --- a/src/types/photo_size.rs +++ b/src/types/photo_size.rs @@ -10,6 +10,11 @@ pub struct PhotoSize { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// Photo width. pub width: i32, @@ -26,10 +31,11 @@ mod tests { #[test] fn deserialize() { - let json = r#"{"file_id":"id","width":320,"height":320, + let json = r#"{"file_id":"id","file_unique_id":"","width":320,"height":320, "file_size":3452}"#; let expected = PhotoSize { file_id: "id".to_string(), + file_unique_id: "".to_string(), width: 320, height: 320, file_size: Some(3452), diff --git a/src/types/sticker.rs b/src/types/sticker.rs index 4fb139f8..8f213133 100644 --- a/src/types/sticker.rs +++ b/src/types/sticker.rs @@ -11,6 +11,11 @@ pub struct Sticker { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// Sticker width. pub width: u16, diff --git a/src/types/video.rs b/src/types/video.rs index 2b9fae08..d649176d 100644 --- a/src/types/video.rs +++ b/src/types/video.rs @@ -11,6 +11,11 @@ pub struct Video { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// Video width as defined by sender. pub width: u32, diff --git a/src/types/video_note.rs b/src/types/video_note.rs index 096170f8..bce58fa3 100644 --- a/src/types/video_note.rs +++ b/src/types/video_note.rs @@ -15,6 +15,11 @@ pub struct VideoNote { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// Video width and height (diameter of the video message) as defined by /// sender. pub length: u32, diff --git a/src/types/voice.rs b/src/types/voice.rs index 77ff8c5f..43abe5fd 100644 --- a/src/types/voice.rs +++ b/src/types/voice.rs @@ -9,6 +9,11 @@ pub struct Voice { /// Identifier for this file. pub file_id: String, + /// Unique identifier for this file, which is supposed to be the same over + /// time and for different bots. Can't be used to download or reuse the + /// file. + pub file_unique_id: String, + /// Duration of the audio in seconds as defined by sender. pub duration: u32, From 663e33d56b5be3d5de74638469289fbd0f6c05fa Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 00:15:48 +0600 Subject: [PATCH 2/8] Fix rustfmt --- src/types/parse_mode.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/types/parse_mode.rs b/src/types/parse_mode.rs index 4892e908..c6e6ebd3 100644 --- a/src/types/parse_mode.rs +++ b/src/types/parse_mode.rs @@ -44,7 +44,7 @@ use serde::{Deserialize, Serialize}; /// pre-formatted fixed-width code block written in the Rust programming /// language ``` /// ```` -/// +/// /// Please note: /// - Any character between 1 and 126 inclusively can be escaped anywhere with a /// preceding '\' character, in which case it is treated as an ordinary @@ -65,20 +65,19 @@ use serde::{Deserialize, Serialize}; /// ## HTML style /// To use this mode, pass [`HTML`] in the `parse_mode` field. /// The following tags are currently supported: -/// /// ````text /// bold, bold /// italic, italic /// underline, underline -/// strikethrough, strikethrough, strikethrough -/// bold italic bold italic bold strikethrough underline italic bold bold -/// inline URL +/// strikethrough, strikethrough, +/// strikethrough bold italic bold italic bold +/// strikethrough underline italic bold bold inline URL /// inline mention of a user /// inline fixed-width code ///
pre-formatted fixed-width code block
-///
pre-formatted fixed-width code block written in the Rust programming language
-/// ```` -/// +///
pre-formatted fixed-width code block
+/// written in the Rust programming language
```` +/// /// Please note: /// /// - Only the tags mentioned above are currently supported. @@ -96,7 +95,6 @@ use serde::{Deserialize, Serialize}; /// This is a legacy mode, retained for backward compatibility. To use this /// mode, pass [`Markdown`] in the `parse_mode` field. /// Use the following syntax in your message: -/// /// ````text /// *bold text* /// _italic text_ From e4b094416018abfad5c442d9f8aee0a5acb01d59 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 00:35:44 +0600 Subject: [PATCH 3/8] Fix rustfmt again! --- src/types/parse_mode.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/types/parse_mode.rs b/src/types/parse_mode.rs index c6e6ebd3..cef3b02f 100644 --- a/src/types/parse_mode.rs +++ b/src/types/parse_mode.rs @@ -77,7 +77,7 @@ use serde::{Deserialize, Serialize}; ///
pre-formatted fixed-width code block
///
pre-formatted fixed-width code block
 /// written in the Rust programming language
```` -/// +/// /// Please note: /// /// - Only the tags mentioned above are currently supported. @@ -105,7 +105,7 @@ use serde::{Deserialize, Serialize}; /// pre-formatted fixed-width code block written in the Rust programming /// language ``` /// ```` -/// +/// /// Please note: /// - Entities must not be nested, use parse mode [`MarkdownV2`] instead. /// - There is no way to specify underline and strikethrough entities, use parse From 52938f2f9e2fccea51de429adcd843c8723d75a5 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 00:44:03 +0600 Subject: [PATCH 4/8] Don't fail on warnings --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e273fcb..8ef783a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,11 +62,11 @@ jobs: if: matrix.rust == 'stable' || matrix.rust == 'beta' with: command: clippy - args: --all-targets --features "" -- -D warnings + args: --all-targets --features "" - name: nightly clippy uses: actions-rs/cargo@v1 if: matrix.rust == 'nightly' with: command: clippy - args: --all-targets --all-features -- -D warnings + args: --all-targets --all-features From 46f29736de722d764d47937521016ea338e72480 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 01:00:25 +0600 Subject: [PATCH 5/8] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ef783a2..5e273fcb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,11 +62,11 @@ jobs: if: matrix.rust == 'stable' || matrix.rust == 'beta' with: command: clippy - args: --all-targets --features "" + args: --all-targets --features "" -- -D warnings - name: nightly clippy uses: actions-rs/cargo@v1 if: matrix.rust == 'nightly' with: command: clippy - args: --all-targets --all-features + args: --all-targets --all-features -- -D warnings From 1b89289de69a204fdbc425e578404f0be985034c Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 01:16:47 +0600 Subject: [PATCH 6/8] Fix Clippy --- src/types/encrypted_passport_element.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/encrypted_passport_element.rs b/src/types/encrypted_passport_element.rs index 4e99494b..1efa94bd 100644 --- a/src/types/encrypted_passport_element.rs +++ b/src/types/encrypted_passport_element.rs @@ -22,6 +22,7 @@ pub struct EncryptedPassportElement { #[serde_with_macros::skip_serializing_none] #[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] #[serde(rename_all = "snake_case")] +#[allow(clippy::large_enum_variant)] pub enum EncryptedPassportElementKind { PersonalDetails { /// Base64-encoded encrypted Telegram Passport element data provided From 2d5079ae3740a8ec61d20b32cf3af3b2e2a0d913 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 03:20:57 +0600 Subject: [PATCH 7/8] Fix the links --- src/dispatching/filter_dp.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/dispatching/filter_dp.rs b/src/dispatching/filter_dp.rs index e94e9bc7..9983f488 100644 --- a/src/dispatching/filter_dp.rs +++ b/src/dispatching/filter_dp.rs @@ -28,7 +28,7 @@ type FiltersWithHandlers<'a, T, E> = Vec>; /// acts: /// ///
-/// +/// ///
/// /// ## Examples @@ -69,8 +69,10 @@ type FiltersWithHandlers<'a, T, E> = Vec>; /// ``` /// /// [`std::fmt::Debug`]: std::fmt::Debug -/// [updater]: crate::dispatching::updater /// [`.dispatch(updater)`]: FilterDispatcher::dispatch +/// [`ErrorHandler`]: crate::dispatching::error_handlers::ErrorHandler +/// [`Updater`]: crate::dispatching::updaters::Updater +/// [`Handler`]: crate::dispatching::Handler pub struct FilterDispatcher<'a, E, Eh> { message_handlers: FiltersWithHandlers<'a, Message, E>, edited_message_handlers: FiltersWithHandlers<'a, Message, E>, From e4e46d8df1f668e88cd3d7027e476b856bc8d772 Mon Sep 17 00:00:00 2001 From: Temirkhan Myrzamadi Date: Wed, 1 Jan 2020 03:26:30 +0600 Subject: [PATCH 8/8] Fix teloxide::dispatching layout --- src/dispatching/{filter_dp.rs => dispatchers/filter.rs} | 0 src/dispatching/dispatchers/mod.rs | 1 + src/dispatching/mod.rs | 4 ++-- 3 files changed, 3 insertions(+), 2 deletions(-) rename src/dispatching/{filter_dp.rs => dispatchers/filter.rs} (100%) create mode 100644 src/dispatching/dispatchers/mod.rs diff --git a/src/dispatching/filter_dp.rs b/src/dispatching/dispatchers/filter.rs similarity index 100% rename from src/dispatching/filter_dp.rs rename to src/dispatching/dispatchers/filter.rs diff --git a/src/dispatching/dispatchers/mod.rs b/src/dispatching/dispatchers/mod.rs new file mode 100644 index 00000000..34d102d7 --- /dev/null +++ b/src/dispatching/dispatchers/mod.rs @@ -0,0 +1 @@ +pub mod filter; diff --git a/src/dispatching/mod.rs b/src/dispatching/mod.rs index f738757d..8cdd83ae 100644 --- a/src/dispatching/mod.rs +++ b/src/dispatching/mod.rs @@ -1,13 +1,13 @@ //! Update dispatching. +mod dispatchers; pub mod error_handlers; -mod filter_dp; pub mod filters; mod handler; pub mod updaters; +pub use dispatchers::filter::FilterDispatcher; pub use error_handlers::ErrorHandler; -pub use filter_dp::FilterDispatcher; pub use filters::Filter; pub use handler::Handler; pub use updaters::Updater;