From d42d2b78122944bd5d2c7be2f869b969934a5a2b Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Tue, 13 Feb 2024 22:17:15 +0100 Subject: [PATCH] Remove `update_listeners::polling` --- crates/teloxide-core/CHANGELOG.md | 1 + crates/teloxide/src/update_listeners.rs | 11 ++++----- .../teloxide/src/update_listeners/polling.rs | 23 ++----------------- .../src/update_listeners/stateful_listener.rs | 4 ++-- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/crates/teloxide-core/CHANGELOG.md b/crates/teloxide-core/CHANGELOG.md index cfb16151..9af978f6 100644 --- a/crates/teloxide-core/CHANGELOG.md +++ b/crates/teloxide-core/CHANGELOG.md @@ -137,6 +137,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `BotCommands::ty` and `repls::{commands_repl, commands_repl_with_listener}` (use `CommandsRepl::{repl, repl_with_listener}` instead) - `Message::chat_id` (use `.chat.id`) - `Update::user` (use `Update::from`) + - `update_listeners::polling` (use `Polling::builder` instead) [pr954]: https://github.com/teloxide/teloxide/pull/954 [pr1013]: https://github.com/teloxide/teloxide/pull/1013 diff --git a/crates/teloxide/src/update_listeners.rs b/crates/teloxide/src/update_listeners.rs index 6e03ef01..34f8a0de 100644 --- a/crates/teloxide/src/update_listeners.rs +++ b/crates/teloxide/src/update_listeners.rs @@ -5,7 +5,7 @@ //! //! - [`polling_default`] function, which returns a default long polling //! listener. -//! - [`polling`] function, which returns a long polling listener with your +//! - [`Polling`] function, which returns a long polling listener with your //! configuration. //! - Various functions in the [`webhooks`] module that return webhook listeners //! @@ -13,12 +13,11 @@ //! [`Dispatcher`]. //! //! Telegram supports two ways of [getting updates]: [long polling] and -//! [webhooks]. For the former see [`polling`] and [`polling_default`], for the +//! [webhooks]. For the former see [`Polling`] and [`polling_default`], for the //! latter see the [`webhooks`] module. //! //! [`UpdateListener`]: UpdateListener //! [`polling_default`]: polling_default -//! [`polling`]: polling() //! [`Dispatcher`]: crate::dispatching::Dispatcher //! [`Box::get_updates`]: crate::requests::Requester::get_updates //! [getting updates]: https://core.telegram.org/bots/api#getting-updates @@ -26,7 +25,7 @@ //! [webhooks]: https://en.wikipedia.org/wiki/Webhook /// Implementations of webhook update listeners - an alternative (to -/// [`fn@polling`]) way of receiving updates from telegram. +/// [`Polling`]) way of receiving updates from telegram. #[cfg(feature = "webhooks")] pub mod webhooks; @@ -42,7 +41,7 @@ mod stateful_listener; #[allow(deprecated)] pub use self::{ - polling::{polling, polling_default, Polling, PollingBuilder, PollingStream}, + polling::{polling_default, Polling, PollingBuilder, PollingStream}, stateful_listener::StatefulListener, }; @@ -80,7 +79,7 @@ pub trait UpdateListener: /// Hint which updates should the listener listen for. /// - /// For example [`polling()`] should send the hint as + /// For example [`Polling`] should send the hint as /// [`GetUpdates::allowed_updates`] /// /// Note however that this is a _hint_ and as such, it can be ignored. The diff --git a/crates/teloxide/src/update_listeners/polling.rs b/crates/teloxide/src/update_listeners/polling.rs index e39ba977..be035f90 100644 --- a/crates/teloxide/src/update_listeners/polling.rs +++ b/crates/teloxide/src/update_listeners/polling.rs @@ -147,25 +147,6 @@ where assert_update_listener(polling) } -/// Returns a long polling update listener with some additional options. -#[deprecated(since = "0.10.0", note = "use `Polling::builder()` instead")] -pub fn polling( - bot: R, - timeout: Option, - limit: Option, - allowed_updates: Option>, -) -> Polling -where - R: Requester + Send + 'static, - ::GetUpdates: Send, -{ - let mut builder = Polling::builder(bot); - builder.timeout = timeout; - builder.limit = limit; - builder.allowed_updates = allowed_updates; - assert_update_listener(builder.build()) -} - async fn delete_webhook_if_setup(requester: &R) where R: Requester, @@ -513,8 +494,8 @@ impl Stream for PollingStream<'_, B> { #[test] fn polling_is_send() { let bot = crate::Bot::new("TOKEN"); - #[allow(deprecated)] - let mut polling = polling(bot, None, None, None); + + let mut polling = Polling::builder(bot).build(); assert_send(&polling); assert_send(&polling.as_stream()); diff --git a/crates/teloxide/src/update_listeners/stateful_listener.rs b/crates/teloxide/src/update_listeners/stateful_listener.rs index 87ae492a..6c452f96 100644 --- a/crates/teloxide/src/update_listeners/stateful_listener.rs +++ b/crates/teloxide/src/update_listeners/stateful_listener.rs @@ -11,9 +11,9 @@ use crate::{ /// This type allows to turn a stream of updates (+ some additional functions) /// into an [`UpdateListener`]. /// -/// For an example of usage, see [`polling`]. +/// For an example of usage, see [`Polling`]. /// -/// [`polling`]: crate::update_listeners::polling() +/// [`Polling`]: crate::update_listeners::Polling #[non_exhaustive] pub struct StatefulListener { /// The state of the listener.