mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-03 09:49:07 +01:00
parent
cdd5ac94ef
commit
567cd9ced5
4 changed files with 20 additions and 8 deletions
|
@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- `UpdateListener` now has an associated type `Err` instead of a generic
|
- `UpdateListener` now has an associated type `Err` instead of a generic
|
||||||
- `AsUpdateStream` now has an associated type `StreamErr` instead of a generic
|
- `AsUpdateStream` now has an associated type `StreamErr` instead of a generic
|
||||||
- Rename `dispatching::stop_token::{AsyncStopToken, AsyncStopFlag}` => `stop::{StopToken, StopFlag}`
|
- Rename `dispatching::stop_token::{AsyncStopToken, AsyncStopFlag}` => `stop::{StopToken, StopFlag}`
|
||||||
|
- The following functions are now `#[must_use]`:
|
||||||
|
- `BotCommands::ty`.
|
||||||
|
- `CommandDescriptions::{new, global_description, username, username_from_me}`.
|
||||||
|
- `teloxide::filter_command`.
|
||||||
|
- `teloxide::dispatching::dialogue::enter`.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -211,6 +211,7 @@ where
|
||||||
/// - `Upd`
|
/// - `Upd`
|
||||||
///
|
///
|
||||||
/// [`HandlerExt::enter_dialogue`]: super::HandlerExt::enter_dialogue
|
/// [`HandlerExt::enter_dialogue`]: super::HandlerExt::enter_dialogue
|
||||||
|
#[must_use]
|
||||||
pub fn enter<Upd, S, D, Output>() -> Handler<'static, DependencyMap, Output, DpHandlerDescription>
|
pub fn enter<Upd, S, D, Output>() -> Handler<'static, DependencyMap, Output, DpHandlerDescription>
|
||||||
where
|
where
|
||||||
S: Storage<D> + ?Sized + Send + Sync + 'static,
|
S: Storage<D> + ?Sized + Send + Sync + 'static,
|
||||||
|
|
|
@ -82,6 +82,7 @@ where
|
||||||
///
|
///
|
||||||
/// - [`crate::types::Message`]
|
/// - [`crate::types::Message`]
|
||||||
/// - [`crate::types::Me`]
|
/// - [`crate::types::Me`]
|
||||||
|
#[must_use]
|
||||||
pub fn filter_command<C, Output>() -> Handler<'static, DependencyMap, Output, DpHandlerDescription>
|
pub fn filter_command<C, Output>() -> Handler<'static, DependencyMap, Output, DpHandlerDescription>
|
||||||
where
|
where
|
||||||
C: BotCommands + Send + Sync + 'static,
|
C: BotCommands + Send + Sync + 'static,
|
||||||
|
|
|
@ -235,6 +235,7 @@ pub trait BotCommands: Sized {
|
||||||
/// Returns `PhantomData<Self>` that is used as a param of [`commands_repl`]
|
/// Returns `PhantomData<Self>` that is used as a param of [`commands_repl`]
|
||||||
///
|
///
|
||||||
/// [`commands_repl`]: (crate::repls2::commands_repl)
|
/// [`commands_repl`]: (crate::repls2::commands_repl)
|
||||||
|
#[must_use]
|
||||||
fn ty() -> PhantomData<Self> {
|
fn ty() -> PhantomData<Self> {
|
||||||
PhantomData
|
PhantomData
|
||||||
}
|
}
|
||||||
|
@ -296,11 +297,13 @@ pub struct CommandDescription<'a> {
|
||||||
|
|
||||||
impl<'a> CommandDescriptions<'a> {
|
impl<'a> CommandDescriptions<'a> {
|
||||||
/// Creates new [`CommandDescriptions`] from a list of command descriptions.
|
/// Creates new [`CommandDescriptions`] from a list of command descriptions.
|
||||||
|
#[must_use]
|
||||||
pub fn new(descriptions: &'a [CommandDescription<'a>]) -> Self {
|
pub fn new(descriptions: &'a [CommandDescription<'a>]) -> Self {
|
||||||
Self { global_description: None, descriptions, bot_username: None }
|
Self { global_description: None, descriptions, bot_username: None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the global description of these commands.
|
/// Sets the global description of these commands.
|
||||||
|
#[must_use]
|
||||||
pub fn global_description(self, global_description: &'a str) -> Self {
|
pub fn global_description(self, global_description: &'a str) -> Self {
|
||||||
Self { global_description: Some(global_description), ..self }
|
Self { global_description: Some(global_description), ..self }
|
||||||
}
|
}
|
||||||
|
@ -328,6 +331,7 @@ impl<'a> CommandDescriptions<'a> {
|
||||||
/// message"
|
/// message"
|
||||||
/// );
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
|
#[must_use]
|
||||||
pub fn username(self, bot_username: &'a str) -> Self {
|
pub fn username(self, bot_username: &'a str) -> Self {
|
||||||
Self { bot_username: Some(bot_username), ..self }
|
Self { bot_username: Some(bot_username), ..self }
|
||||||
}
|
}
|
||||||
|
@ -338,6 +342,7 @@ impl<'a> CommandDescriptions<'a> {
|
||||||
/// method to get the username.
|
/// method to get the username.
|
||||||
///
|
///
|
||||||
/// [`username`]: self::CommandDescriptions::username
|
/// [`username`]: self::CommandDescriptions::username
|
||||||
|
#[must_use]
|
||||||
pub fn username_from_me(self, me: &'a Me) -> CommandDescriptions<'a> {
|
pub fn username_from_me(self, me: &'a Me) -> CommandDescriptions<'a> {
|
||||||
self.username(me.user.username.as_deref().expect("Bots must have usernames"))
|
self.username(me.user.username.as_deref().expect("Bots must have usernames"))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue