mirror of
https://github.com/teloxide/teloxide.git
synced 2025-03-24 23:57:38 +01:00
Remove update_listeners::polling
This commit is contained in:
parent
74b03664cf
commit
d42d2b7812
4 changed files with 10 additions and 29 deletions
|
@ -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)
|
- `BotCommands::ty` and `repls::{commands_repl, commands_repl_with_listener}` (use `CommandsRepl::{repl, repl_with_listener}` instead)
|
||||||
- `Message::chat_id` (use `.chat.id`)
|
- `Message::chat_id` (use `.chat.id`)
|
||||||
- `Update::user` (use `Update::from`)
|
- `Update::user` (use `Update::from`)
|
||||||
|
- `update_listeners::polling` (use `Polling::builder` instead)
|
||||||
|
|
||||||
[pr954]: https://github.com/teloxide/teloxide/pull/954
|
[pr954]: https://github.com/teloxide/teloxide/pull/954
|
||||||
[pr1013]: https://github.com/teloxide/teloxide/pull/1013
|
[pr1013]: https://github.com/teloxide/teloxide/pull/1013
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//!
|
//!
|
||||||
//! - [`polling_default`] function, which returns a default long polling
|
//! - [`polling_default`] function, which returns a default long polling
|
||||||
//! listener.
|
//! listener.
|
||||||
//! - [`polling`] function, which returns a long polling listener with your
|
//! - [`Polling`] function, which returns a long polling listener with your
|
||||||
//! configuration.
|
//! configuration.
|
||||||
//! - Various functions in the [`webhooks`] module that return webhook listeners
|
//! - Various functions in the [`webhooks`] module that return webhook listeners
|
||||||
//!
|
//!
|
||||||
|
@ -13,12 +13,11 @@
|
||||||
//! [`Dispatcher`].
|
//! [`Dispatcher`].
|
||||||
//!
|
//!
|
||||||
//! Telegram supports two ways of [getting updates]: [long polling] and
|
//! 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.
|
//! latter see the [`webhooks`] module.
|
||||||
//!
|
//!
|
||||||
//! [`UpdateListener`]: UpdateListener
|
//! [`UpdateListener`]: UpdateListener
|
||||||
//! [`polling_default`]: polling_default
|
//! [`polling_default`]: polling_default
|
||||||
//! [`polling`]: polling()
|
|
||||||
//! [`Dispatcher`]: crate::dispatching::Dispatcher
|
//! [`Dispatcher`]: crate::dispatching::Dispatcher
|
||||||
//! [`Box::get_updates`]: crate::requests::Requester::get_updates
|
//! [`Box::get_updates`]: crate::requests::Requester::get_updates
|
||||||
//! [getting updates]: https://core.telegram.org/bots/api#getting-updates
|
//! [getting updates]: https://core.telegram.org/bots/api#getting-updates
|
||||||
|
@ -26,7 +25,7 @@
|
||||||
//! [webhooks]: https://en.wikipedia.org/wiki/Webhook
|
//! [webhooks]: https://en.wikipedia.org/wiki/Webhook
|
||||||
|
|
||||||
/// Implementations of webhook update listeners - an alternative (to
|
/// 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")]
|
#[cfg(feature = "webhooks")]
|
||||||
pub mod webhooks;
|
pub mod webhooks;
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ mod stateful_listener;
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
pub use self::{
|
pub use self::{
|
||||||
polling::{polling, polling_default, Polling, PollingBuilder, PollingStream},
|
polling::{polling_default, Polling, PollingBuilder, PollingStream},
|
||||||
stateful_listener::StatefulListener,
|
stateful_listener::StatefulListener,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ pub trait UpdateListener:
|
||||||
|
|
||||||
/// Hint which updates should the listener listen for.
|
/// 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`]
|
/// [`GetUpdates::allowed_updates`]
|
||||||
///
|
///
|
||||||
/// Note however that this is a _hint_ and as such, it can be ignored. The
|
/// Note however that this is a _hint_ and as such, it can be ignored. The
|
||||||
|
|
|
@ -147,25 +147,6 @@ where
|
||||||
assert_update_listener(polling)
|
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)
|
async fn delete_webhook_if_setup<R>(requester: &R)
|
||||||
where
|
where
|
||||||
R: Requester,
|
R: Requester,
|
||||||
|
@ -513,8 +494,8 @@ impl<B: Requester> Stream for PollingStream<'_, B> {
|
||||||
#[test]
|
#[test]
|
||||||
fn polling_is_send() {
|
fn polling_is_send() {
|
||||||
let bot = crate::Bot::new("TOKEN");
|
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);
|
||||||
assert_send(&polling.as_stream());
|
assert_send(&polling.as_stream());
|
||||||
|
|
|
@ -11,9 +11,9 @@ use crate::{
|
||||||
/// This type allows to turn a stream of updates (+ some additional functions)
|
/// This type allows to turn a stream of updates (+ some additional functions)
|
||||||
/// into an [`UpdateListener`].
|
/// 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]
|
#[non_exhaustive]
|
||||||
pub struct StatefulListener<St, Assf, Sf, Hauf> {
|
pub struct StatefulListener<St, Assf, Sf, Hauf> {
|
||||||
/// The state of the listener.
|
/// The state of the listener.
|
||||||
|
|
Loading…
Add table
Reference in a new issue