Remove update_listeners::polling

This commit is contained in:
Maybe Waffle 2024-02-13 22:17:15 +01:00
parent 74b03664cf
commit d42d2b7812
4 changed files with 10 additions and 29 deletions

View file

@ -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

View file

@ -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

View file

@ -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<R>(
bot: R,
timeout: Option<Duration>,
limit: Option<u8>,
allowed_updates: Option<Vec<AllowedUpdate>>,
) -> Polling<R>
where
R: Requester + Send + 'static,
<R as Requester>::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<R>(requester: &R)
where
R: Requester,
@ -513,8 +494,8 @@ impl<B: Requester> 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());

View file

@ -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<St, Assf, Sf, Hauf> {
/// The state of the listener.