mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
commit
eb1ff32928
21 changed files with 57 additions and 34 deletions
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -9,16 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Updated `axum` to v0.6.0.
|
- Updated `axum` to v0.6.0.
|
||||||
|
- The module structure
|
||||||
|
- `teloxide::dispatching::update_listeners` => `teloxide::update_listeners`
|
||||||
|
- `teloxide::dispatching::repls` => `teloxide::repls`
|
||||||
|
- `CommandDescriptions::new` was made `const`
|
||||||
|
- The following functions were made `#[must_use]`:
|
||||||
|
- `DispatcherBuilder::{enable_ctrlc_handler, distribution_function}`
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- `rocksdb-storage` feature and associated items (See [PR #761](https://github.com/teloxide/teloxide/pull/761) for reasoning) [**BC**]
|
- `rocksdb-storage` feature and associated items (See [PR #761](https://github.com/teloxide/teloxide/pull/761) for reasoning) [**BC**]
|
||||||
|
|
||||||
## Changed
|
### Deprecated
|
||||||
|
|
||||||
- `CommandDescriptions::new` is made `const`
|
- `teloxide::dispatching::{update_listeners, repls}` (see in the "Changed" section)
|
||||||
- The following functions were made `#[must_use]`:
|
|
||||||
- `DispatcherBuilder::{enable_ctrlc_handler, distribution_function}`
|
|
||||||
|
|
||||||
## 0.11.3 - 2022-11-28
|
## 0.11.3 - 2022-11-28
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use teloxide::{dispatching::update_listeners::webhooks, prelude::*};
|
use teloxide::{prelude::*, update_listeners::webhooks};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// The version of ngrok ping-pong-bot, which uses a webhook to receive updates
|
// The version of ngrok ping-pong-bot, which uses a webhook to receive updates
|
||||||
// from Telegram, instead of long polling.
|
// from Telegram, instead of long polling.
|
||||||
|
|
||||||
use teloxide::{dispatching::update_listeners::webhooks, prelude::*};
|
use teloxide::{prelude::*, update_listeners::webhooks};
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|
|
@ -215,16 +215,30 @@
|
||||||
//! [`examples/dispatching_features.rs`]: https://github.com/teloxide/teloxide/blob/master/examples/dispatching_features.rs
|
//! [`examples/dispatching_features.rs`]: https://github.com/teloxide/teloxide/blob/master/examples/dispatching_features.rs
|
||||||
//! [`Update`]: crate::types::Update
|
//! [`Update`]: crate::types::Update
|
||||||
|
|
||||||
#[cfg(all(feature = "ctrlc_handler"))]
|
|
||||||
pub mod repls;
|
|
||||||
|
|
||||||
pub mod dialogue;
|
pub mod dialogue;
|
||||||
|
|
||||||
|
/// This module was moved to [`teloxide::update_listeners`].
|
||||||
|
///
|
||||||
|
/// [`teloxide::update_listeners`]: crate::update_listeners
|
||||||
|
#[deprecated = "This module was moved. Use `teloxide::update_listeners` instead."]
|
||||||
|
pub mod update_listeners {
|
||||||
|
pub use crate::update_listeners::*;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This module was moved to [`teloxide::repls`].
|
||||||
|
///
|
||||||
|
/// [`teloxide::repls`]: crate::repls
|
||||||
|
#[deprecated = "This module was moved. Use `teloxide::repls` instead."]
|
||||||
|
#[cfg(all(feature = "ctrlc_handler"))]
|
||||||
|
pub mod repls {
|
||||||
|
pub use crate::repls::*;
|
||||||
|
}
|
||||||
|
|
||||||
mod dispatcher;
|
mod dispatcher;
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod filter_ext;
|
mod filter_ext;
|
||||||
mod handler_description;
|
mod handler_description;
|
||||||
mod handler_ext;
|
mod handler_ext;
|
||||||
pub mod update_listeners;
|
|
||||||
|
|
||||||
pub use crate::utils::shutdown_token::{IdleShutdownError, ShutdownToken};
|
pub use crate::utils::shutdown_token::{IdleShutdownError, ShutdownToken};
|
||||||
pub use dispatcher::{Dispatcher, DispatcherBuilder, UpdateHandler};
|
pub use dispatcher::{Dispatcher, DispatcherBuilder, UpdateHandler};
|
||||||
|
|
|
@ -94,14 +94,15 @@
|
||||||
//! [`examples/dialogue.rs`]: https://github.com/teloxide/teloxide/blob/master/examples/dialogue.rs
|
//! [`examples/dialogue.rs`]: https://github.com/teloxide/teloxide/blob/master/examples/dialogue.rs
|
||||||
|
|
||||||
#[cfg(feature = "redis-storage")]
|
#[cfg(feature = "redis-storage")]
|
||||||
pub use crate::dispatching::dialogue::{RedisStorage, RedisStorageError};
|
pub use self::{RedisStorage, RedisStorageError};
|
||||||
|
|
||||||
#[cfg(feature = "sqlite-storage")]
|
#[cfg(feature = "sqlite-storage")]
|
||||||
pub use crate::dispatching::dialogue::{SqliteStorage, SqliteStorageError};
|
pub use self::{SqliteStorage, SqliteStorageError};
|
||||||
|
|
||||||
use dptree::{prelude::DependencyMap, Handler};
|
|
||||||
pub use get_chat_id::GetChatId;
|
pub use get_chat_id::GetChatId;
|
||||||
pub use storage::*;
|
pub use storage::*;
|
||||||
|
|
||||||
|
use dptree::{prelude::DependencyMap, Handler};
|
||||||
use teloxide_core::types::ChatId;
|
use teloxide_core::types::ChatId;
|
||||||
|
|
||||||
use std::{fmt::Debug, marker::PhantomData, sync::Arc};
|
use std::{fmt::Debug, marker::PhantomData, sync::Arc};
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::{
|
dispatching::{
|
||||||
distribution::default_distribution_function, update_listeners,
|
distribution::default_distribution_function, DefaultKey, DpHandlerDescription,
|
||||||
update_listeners::UpdateListener, DefaultKey, DpHandlerDescription, ShutdownToken,
|
ShutdownToken,
|
||||||
},
|
},
|
||||||
error_handlers::{ErrorHandler, LoggingErrorHandler},
|
error_handlers::{ErrorHandler, LoggingErrorHandler},
|
||||||
requests::{Request, Requester},
|
requests::{Request, Requester},
|
||||||
types::{Update, UpdateKind},
|
types::{Update, UpdateKind},
|
||||||
|
update_listeners::{self, UpdateListener},
|
||||||
utils::shutdown_token::shutdown_check_timeout_for,
|
utils::shutdown_token::shutdown_check_timeout_for,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -60,16 +60,19 @@
|
||||||
#![allow(clippy::nonstandard_macro_braces)]
|
#![allow(clippy::nonstandard_macro_braces)]
|
||||||
|
|
||||||
#[cfg(feature = "ctrlc_handler")]
|
#[cfg(feature = "ctrlc_handler")]
|
||||||
pub use dispatching::repls::{repl, repl_with_listener};
|
pub use repls::{repl, repl_with_listener};
|
||||||
|
|
||||||
#[cfg(feature = "ctrlc_handler")]
|
#[cfg(feature = "ctrlc_handler")]
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
pub use dispatching::repls::{commands_repl, commands_repl_with_listener};
|
pub use repls::{commands_repl, commands_repl_with_listener};
|
||||||
|
|
||||||
pub mod dispatching;
|
pub mod dispatching;
|
||||||
pub mod error_handlers;
|
pub mod error_handlers;
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
#[cfg(all(feature = "ctrlc_handler"))]
|
||||||
|
pub mod repls;
|
||||||
pub mod stop;
|
pub mod stop;
|
||||||
|
pub mod update_listeners;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
|
|
|
@ -10,7 +10,7 @@ pub use crate::dispatching::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "ctrlc_handler")]
|
#[cfg(feature = "ctrlc_handler")]
|
||||||
pub use crate::dispatching::repls::CommandReplExt as _;
|
pub use crate::repls::CommandReplExt as _;
|
||||||
|
|
||||||
pub use teloxide_core::{
|
pub use teloxide_core::{
|
||||||
requests::ResponseResult,
|
requests::ResponseResult,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::{
|
dispatching::{HandlerExt, UpdateFilterExt},
|
||||||
update_listeners, update_listeners::UpdateListener, HandlerExt, UpdateFilterExt,
|
|
||||||
},
|
|
||||||
error_handlers::LoggingErrorHandler,
|
error_handlers::LoggingErrorHandler,
|
||||||
requests::{Requester, ResponseResult},
|
requests::{Requester, ResponseResult},
|
||||||
types::Update,
|
types::Update,
|
||||||
|
update_listeners::{self, UpdateListener},
|
||||||
utils::command::BotCommands,
|
utils::command::BotCommands,
|
||||||
};
|
};
|
||||||
use dptree::di::{DependencyMap, Injectable};
|
use dptree::di::{DependencyMap, Injectable};
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::{update_listeners, update_listeners::UpdateListener, UpdateFilterExt},
|
dispatching::UpdateFilterExt,
|
||||||
error_handlers::LoggingErrorHandler,
|
error_handlers::LoggingErrorHandler,
|
||||||
requests::{Requester, ResponseResult},
|
requests::{Requester, ResponseResult},
|
||||||
types::Update,
|
types::Update,
|
||||||
|
update_listeners::{self, UpdateListener},
|
||||||
};
|
};
|
||||||
use dptree::di::{DependencyMap, Injectable};
|
use dptree::di::{DependencyMap, Injectable};
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
@ -65,7 +66,7 @@ where
|
||||||
#[doc = include_str!("preamble.md")]
|
#[doc = include_str!("preamble.md")]
|
||||||
///
|
///
|
||||||
/// [REPL]: https://en.wikipedia.org/wiki/Read-eval-print_loop
|
/// [REPL]: https://en.wikipedia.org/wiki/Read-eval-print_loop
|
||||||
/// [`UpdateListener`]: crate::dispatching::update_listeners::UpdateListener
|
/// [`UpdateListener`]: crate::update_listeners::UpdateListener
|
||||||
///
|
///
|
||||||
/// ## Signature
|
/// ## Signature
|
||||||
///
|
///
|
|
@ -1,6 +1,6 @@
|
||||||
//! Stopping asynchronous tasks, e.g., [listeners].
|
//! Stopping asynchronous tasks, e.g., [listeners].
|
||||||
//!
|
//!
|
||||||
//! [listeners]: crate::dispatching::update_listeners
|
//! [listeners]: crate::update_listeners
|
||||||
|
|
||||||
use std::{convert::Infallible, future::Future, pin::Pin, task};
|
use std::{convert::Infallible, future::Future, pin::Pin, task};
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,10 @@ use std::{
|
||||||
use futures::{ready, stream::Stream};
|
use futures::{ready, stream::Stream};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::update_listeners::{assert_update_listener, AsUpdateStream, UpdateListener},
|
|
||||||
requests::{HasPayload, Request, Requester},
|
requests::{HasPayload, Request, Requester},
|
||||||
stop::{mk_stop_token, StopFlag, StopToken},
|
stop::{mk_stop_token, StopFlag, StopToken},
|
||||||
types::{AllowedUpdate, Update},
|
types::{AllowedUpdate, Update},
|
||||||
|
update_listeners::{assert_update_listener, AsUpdateStream, UpdateListener},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Builder for polling update listener.
|
/// Builder for polling update listener.
|
||||||
|
@ -73,7 +73,7 @@ where
|
||||||
///
|
///
|
||||||
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
/// [`Dispatcher`]: crate::dispatching::Dispatcher
|
||||||
/// [`repl`]: fn@crate::repl
|
/// [`repl`]: fn@crate::repl
|
||||||
/// [`hint_allowed_updates`]: crate::dispatching::update_listeners::UpdateListener::hint_allowed_updates
|
/// [`hint_allowed_updates`]: crate::update_listeners::UpdateListener::hint_allowed_updates
|
||||||
pub fn allowed_updates(self, allowed_updates: Vec<AllowedUpdate>) -> Self {
|
pub fn allowed_updates(self, allowed_updates: Vec<AllowedUpdate>) -> Self {
|
||||||
Self { allowed_updates: Some(allowed_updates), ..self }
|
Self { allowed_updates: Some(allowed_updates), ..self }
|
||||||
}
|
}
|
|
@ -3,9 +3,9 @@ use std::time::Duration;
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::update_listeners::{AsUpdateStream, UpdateListener},
|
|
||||||
stop::StopToken,
|
stop::StopToken,
|
||||||
types::{AllowedUpdate, Update},
|
types::{AllowedUpdate, Update},
|
||||||
|
update_listeners::{AsUpdateStream, UpdateListener},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A listener created from functions.
|
/// A listener created from functions.
|
||||||
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
///
|
///
|
||||||
/// For an example of usage, see [`polling`].
|
/// For an example of usage, see [`polling`].
|
||||||
///
|
///
|
||||||
/// [`polling`]: crate::dispatching::update_listeners::polling()
|
/// [`polling`]: crate::update_listeners::polling()
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
pub struct StatefulListener<St, Assf, Sf, Hauf, Thf> {
|
pub struct StatefulListener<St, Assf, Sf, Hauf, Thf> {
|
||||||
/// The state of the listener.
|
/// The state of the listener.
|
|
@ -7,10 +7,10 @@ use axum::{
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::update_listeners::{webhooks::Options, UpdateListener},
|
|
||||||
requests::Requester,
|
requests::Requester,
|
||||||
stop::StopFlag,
|
stop::StopFlag,
|
||||||
types::Update,
|
types::Update,
|
||||||
|
update_listeners::{webhooks::Options, UpdateListener},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Webhook implementation based on the [mod@axum] framework.
|
/// Webhook implementation based on the [mod@axum] framework.
|
||||||
|
@ -118,7 +118,7 @@ where
|
||||||
R: Requester + Send,
|
R: Requester + Send,
|
||||||
<R as Requester>::DeleteWebhook: Send,
|
<R as Requester>::DeleteWebhook: Send,
|
||||||
{
|
{
|
||||||
use crate::{dispatching::update_listeners::webhooks::setup_webhook, requests::Request};
|
use crate::{requests::Request, update_listeners::webhooks::setup_webhook};
|
||||||
use futures::FutureExt;
|
use futures::FutureExt;
|
||||||
|
|
||||||
setup_webhook(&bot, &mut options).await?;
|
setup_webhook(&bot, &mut options).await?;
|
||||||
|
@ -156,8 +156,8 @@ pub fn axum_no_setup(
|
||||||
options: Options,
|
options: Options,
|
||||||
) -> (impl UpdateListener<Err = Infallible>, impl Future<Output = ()>, axum::Router) {
|
) -> (impl UpdateListener<Err = Infallible>, impl Future<Output = ()>, axum::Router) {
|
||||||
use crate::{
|
use crate::{
|
||||||
dispatching::update_listeners::{self, webhooks::tuple_first_mut},
|
|
||||||
stop::{mk_stop_token, StopToken},
|
stop::{mk_stop_token, StopToken},
|
||||||
|
update_listeners::{webhooks::tuple_first_mut, StatefulListener},
|
||||||
};
|
};
|
||||||
use axum::{response::IntoResponse, routing::post};
|
use axum::{response::IntoResponse, routing::post};
|
||||||
use tokio_stream::wrappers::UnboundedReceiverStream;
|
use tokio_stream::wrappers::UnboundedReceiverStream;
|
||||||
|
@ -218,7 +218,7 @@ pub fn axum_no_setup(
|
||||||
let stream = UnboundedReceiverStream::new(rx);
|
let stream = UnboundedReceiverStream::new(rx);
|
||||||
|
|
||||||
// FIXME: this should support `hint_allowed_updates()`
|
// FIXME: this should support `hint_allowed_updates()`
|
||||||
let listener = update_listeners::StatefulListener::new(
|
let listener = StatefulListener::new(
|
||||||
(stream, stop_token),
|
(stream, stop_token),
|
||||||
tuple_first_mut,
|
tuple_first_mut,
|
||||||
|state: &mut (_, StopToken)| state.1.clone(),
|
|state: &mut (_, StopToken)| state.1.clone(),
|
||||||
|
@ -276,7 +276,7 @@ impl<S> FromRequestParts<S> for XTelegramBotApiSecretToken {
|
||||||
'l1: 'at,
|
'l1: 'at,
|
||||||
Self: 'at,
|
Self: 'at,
|
||||||
{
|
{
|
||||||
use crate::dispatching::update_listeners::webhooks::check_secret;
|
use crate::update_listeners::webhooks::check_secret;
|
||||||
|
|
||||||
let res = req
|
let res = req
|
||||||
.headers
|
.headers
|
|
@ -10,7 +10,7 @@ use std::{
|
||||||
|
|
||||||
use tokio::sync::Notify;
|
use tokio::sync::Notify;
|
||||||
|
|
||||||
use crate::dispatching::update_listeners::UpdateListener;
|
use crate::update_listeners::UpdateListener;
|
||||||
|
|
||||||
/// A token which used to shutdown [`Dispatcher`].
|
/// A token which used to shutdown [`Dispatcher`].
|
||||||
///
|
///
|
||||||
|
|
Loading…
Reference in a new issue