diff --git a/crates/teloxide-core/CHANGELOG.md b/crates/teloxide-core/CHANGELOG.md index 258f0d0e..0ed9a13a 100644 --- a/crates/teloxide-core/CHANGELOG.md +++ b/crates/teloxide-core/CHANGELOG.md @@ -117,10 +117,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [pr850]: https://github.com/teloxide/teloxide/pull/850 ### Removed + - Remove `can_send_media_messages` from `ChatPermissions` ([#954][pr954]) - Remove `can_send_media_messages` field from `Restricted` ([#954][pr954]) +- Previously deprecated items ([#1013][pr1013]) + - `AutoSend` bot adaptor [pr954]: https://github.com/teloxide/teloxide/pull/954 +[pr1013]: https://github.com/teloxide/teloxide/pull/1013 ### Fixed diff --git a/crates/teloxide-core/Cargo.toml b/crates/teloxide-core/Cargo.toml index ab9addb7..b68731fc 100644 --- a/crates/teloxide-core/Cargo.toml +++ b/crates/teloxide-core/Cargo.toml @@ -42,11 +42,8 @@ erased = [] # CacheMe bot adaptor cache_me = [] -# AutoSend bot adaptor -auto_send = [] - # All features except nightly and tls-related -full = ["throttle", "trace_adaptor", "erased", "cache_me", "auto_send"] +full = ["throttle", "trace_adaptor", "erased", "cache_me"] [dependencies] diff --git a/crates/teloxide-core/src/adaptors.rs b/crates/teloxide-core/src/adaptors.rs index c54a65ec..070c1a24 100644 --- a/crates/teloxide-core/src/adaptors.rs +++ b/crates/teloxide-core/src/adaptors.rs @@ -5,18 +5,6 @@ //! //! [`Requester`]: crate::requests::Requester -/// [`AutoSend`] bot adaptor which used to allow sending a request without -/// calling [`send`]. -/// -/// [`AutoSend`]: auto_send::AutoSend -/// [`send`]: crate::requests::Request::send -#[cfg(feature = "auto_send")] -#[deprecated( - since = "0.8.0", - note = "`AutoSend` is no longer required to `.await` requests and is now noop" -)] -pub mod auto_send; - /// [`CacheMe`] bot adaptor which caches [`GetMe`] requests. /// /// [`CacheMe`]: cache_me::CacheMe @@ -47,9 +35,6 @@ pub mod throttle; mod parse_mode; -#[cfg(feature = "auto_send")] -#[allow(deprecated)] -pub use auto_send::AutoSend; #[cfg(feature = "cache_me")] pub use cache_me::CacheMe; #[cfg(feature = "erased")] diff --git a/crates/teloxide-core/src/adaptors/auto_send.rs b/crates/teloxide-core/src/adaptors/auto_send.rs deleted file mode 100644 index f72a6e1b..00000000 --- a/crates/teloxide-core/src/adaptors/auto_send.rs +++ /dev/null @@ -1,233 +0,0 @@ -use std::future::IntoFuture; - -use url::Url; - -use crate::{ - requests::{HasPayload, Output, Request, Requester}, - types::*, -}; - -/// Previously was used to send requests automatically. -/// -/// Before addition of [`IntoFuture`] you could only `.await` [`Future`]s. -/// This adaptor turned requests into futures, allowing to `.await` them, -/// without calling `.send()`. -/// -/// Now, however, all requests are required to implement `IntoFuture`, allowing -/// you to `.await` them directly. This adaptor is noop, and shouldn't be used. -/// -/// [`Future`]: std::future::Future -#[derive(Clone, Debug)] -pub struct AutoSend { - bot: B, -} - -impl AutoSend { - /// Creates new `AutoSend`. - /// - /// Note: it's recommended to use [`RequesterExt::auto_send`] instead. - /// - /// [`RequesterExt::auto_send`]: crate::requests::RequesterExt::auto_send - pub fn new(inner: B) -> AutoSend { - Self { bot: inner } - } - - /// Allows to access the inner bot. - pub fn inner(&self) -> &B { - &self.bot - } - - /// Unwraps the inner bot. - pub fn into_inner(self) -> B { - self.bot - } -} - -macro_rules! f { - ($m:ident $this:ident ($($arg:ident : $T:ty),*)) => { - AutoRequest::new($this.inner().$m($($arg),*)) - }; -} - -macro_rules! fty { - ($T:ident) => { - AutoRequest - }; -} - -impl Requester for AutoSend -where - B: Requester, -{ - type Err = B::Err; - - requester_forward! { - get_me, - log_out, - close, - get_updates, - set_webhook, - delete_webhook, - get_webhook_info, - forward_message, - copy_message, - send_message, - send_photo, - send_audio, - send_document, - send_video, - send_animation, - send_voice, - send_video_note, - send_media_group, - send_location, - edit_message_live_location, - edit_message_live_location_inline, - stop_message_live_location, - stop_message_live_location_inline, - send_venue, - send_contact, - send_poll, - send_dice, - send_chat_action, - get_user_profile_photos, - get_file, - kick_chat_member, - ban_chat_member, - unban_chat_member, - restrict_chat_member, - promote_chat_member, - set_chat_administrator_custom_title, - ban_chat_sender_chat, - unban_chat_sender_chat, - set_chat_permissions, - export_chat_invite_link, - create_chat_invite_link, - edit_chat_invite_link, - revoke_chat_invite_link, - set_chat_photo, - delete_chat_photo, - set_chat_title, - set_chat_description, - pin_chat_message, - unpin_chat_message, - unpin_all_chat_messages, - leave_chat, - get_chat, - get_chat_administrators, - get_chat_members_count, - get_chat_member_count, - get_chat_member, - set_chat_sticker_set, - delete_chat_sticker_set, - get_forum_topic_icon_stickers, - create_forum_topic, - edit_forum_topic, - close_forum_topic, - reopen_forum_topic, - delete_forum_topic, - unpin_all_forum_topic_messages, - edit_general_forum_topic, - close_general_forum_topic, - reopen_general_forum_topic, - hide_general_forum_topic, - unhide_general_forum_topic, - answer_callback_query, - set_my_commands, - get_my_commands, - set_chat_menu_button, - get_chat_menu_button, - set_my_default_administrator_rights, - get_my_default_administrator_rights, - delete_my_commands, - answer_inline_query, - answer_web_app_query, - edit_message_text, - edit_message_text_inline, - edit_message_caption, - edit_message_caption_inline, - edit_message_media, - edit_message_media_inline, - edit_message_reply_markup, - edit_message_reply_markup_inline, - stop_poll, - delete_message, - send_sticker, - get_sticker_set, - get_custom_emoji_stickers, - upload_sticker_file, - create_new_sticker_set, - add_sticker_to_set, - set_sticker_position_in_set, - delete_sticker_from_set, - set_sticker_set_thumb, - send_invoice, - create_invoice_link, - answer_shipping_query, - answer_pre_checkout_query, - set_passport_data_errors, - send_game, - set_game_score, - set_game_score_inline, - get_game_high_scores, - approve_chat_join_request, - decline_chat_join_request - => f, fty - } -} - -download_forward! { - B - AutoSend - { this => this.inner() } -} - -#[must_use = "Futures are lazy and do nothing unless polled or awaited"] -pub struct AutoRequest(R); - -impl AutoRequest -where - R: Request, -{ - pub fn new(inner: R) -> Self { - Self(inner) - } -} - -impl Request for AutoRequest -where - R: Request, -{ - type Err = R::Err; - type Send = R::Send; - type SendRef = R::SendRef; - - fn send(self) -> Self::Send { - self.0.send() - } - - fn send_ref(&self) -> Self::SendRef { - self.0.send_ref() - } -} - -impl IntoFuture for AutoRequest { - type Output = Result, ::Err>; - type IntoFuture = ::Send; - - fn into_future(self) -> Self::IntoFuture { - self.send() - } -} - -impl HasPayload for AutoRequest { - type Payload = R::Payload; - - fn payload_mut(&mut self) -> &mut Self::Payload { - self.0.payload_mut() - } - - fn payload_ref(&self) -> &Self::Payload { - self.0.payload_ref() - } -} diff --git a/crates/teloxide-core/src/lib.rs b/crates/teloxide-core/src/lib.rs index 679a4859..9c5ae94c 100644 --- a/crates/teloxide-core/src/lib.rs +++ b/crates/teloxide-core/src/lib.rs @@ -47,7 +47,6 @@ //! - `nightly` — enables nightly-only features, currently: //! - Removes some future boxing using `#![feature(type_alias_impl_trait)]` //! - Used to built docs (`#![feature(doc_cfg, doc_notable_trait)]`) -//! - `auto_send` — enables [`AutoSend`] bot adaptor (deprecated) //! //! [`AutoSend`]: adaptors::AutoSend //! [`Trace`]: adaptors::Trace diff --git a/crates/teloxide-core/src/requests/requester_ext.rs b/crates/teloxide-core/src/requests/requester_ext.rs index 4f5c5751..a5726ff6 100644 --- a/crates/teloxide-core/src/requests/requester_ext.rs +++ b/crates/teloxide-core/src/requests/requester_ext.rs @@ -3,10 +3,6 @@ use crate::{adaptors::DefaultParseMode, requests::Requester, types::ParseMode}; #[cfg(feature = "cache_me")] use crate::adaptors::CacheMe; -#[cfg(feature = "auto_send")] -#[allow(deprecated)] -use crate::adaptors::AutoSend; - #[cfg(feature = "erased")] use crate::adaptors::ErasedRequester; @@ -28,21 +24,6 @@ pub trait RequesterExt: Requester { CacheMe::new(self) } - /// Send requests automatically, see [`AutoSend`] for more. - #[cfg(feature = "auto_send")] - #[must_use] - #[deprecated( - since = "0.8.0", - note = "`AutoSend` is no longer required to `.await` requests and is now noop" - )] - #[allow(deprecated)] - fn auto_send(self) -> AutoSend - where - Self: Sized, - { - AutoSend::new(self) - } - /// Erase requester type. #[cfg(feature = "erased")] #[must_use] diff --git a/crates/teloxide/Cargo.toml b/crates/teloxide/Cargo.toml index 7a708572..58dc3a6b 100644 --- a/crates/teloxide/Cargo.toml +++ b/crates/teloxide/Cargo.toml @@ -18,7 +18,7 @@ categories = ["web-programming", "api-bindings", "asynchronous"] [features] -default = ["native-tls", "ctrlc_handler", "teloxide-core/default", "auto-send"] +default = ["native-tls", "ctrlc_handler", "teloxide-core/default"] webhooks = ["rand"] webhooks-axum = ["webhooks", "axum", "tower", "tower-http"] @@ -39,7 +39,6 @@ ctrlc_handler = ["tokio/signal"] native-tls = ["teloxide-core/native-tls"] rustls = ["teloxide-core/rustls"] -auto-send = ["teloxide-core/auto_send"] throttle = ["teloxide-core/throttle"] cache-me = [ "teloxide-core/cache_me", @@ -65,7 +64,6 @@ full = [ "teloxide-core/full", "native-tls", "rustls", - "auto-send", "throttle", "cache-me", "trace-adaptor", diff --git a/crates/teloxide/src/features.md b/crates/teloxide/src/features.md index 50a28701..e8ab3339 100644 --- a/crates/teloxide/src/features.md +++ b/crates/teloxide/src/features.md @@ -6,7 +6,6 @@ | `webhooks-axum` | Enables webhook implementation based on axum framework. | | `macros` | Re-exports macros from [`teloxide-macros`]. | | `ctrlc_handler` | Enables the [`DispatcherBuilder::enable_ctrlc_handler`] function (**enabled by default**). | -| `auto-send` | Enables the [`AutoSend`](adaptors::AutoSend) bot adaptor (**enabled by default; DEPRECATED**). | | `throttle` | Enables the [`Throttle`](adaptors::Throttle) bot adaptor. | | `cache-me` | Enables the [`CacheMe`](adaptors::CacheMe) bot adaptor. | | `trace-adaptor` | Enables the [`Trace`](adaptors::Trace) bot adaptor. | diff --git a/crates/teloxide/src/prelude.rs b/crates/teloxide/src/prelude.rs index 00c7fb2e..78db754b 100644 --- a/crates/teloxide/src/prelude.rs +++ b/crates/teloxide/src/prelude.rs @@ -20,10 +20,6 @@ pub use teloxide_core::{ }, }; -#[cfg(feature = "auto-send")] -#[allow(deprecated)] -pub use crate::adaptors::AutoSend; - #[doc(no_inline)] pub use teloxide_core::prelude::*;