mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Add requests::respond
This commit is contained in:
parent
3703f2dff6
commit
05e32336fa
4 changed files with 8 additions and 3 deletions
|
@ -103,7 +103,7 @@ async fn main() {
|
|||
|
||||
teloxide::repl(bot, |message| async move {
|
||||
message.answer_dice().send().await?;
|
||||
ResponseResult::<()>::Ok(())
|
||||
respond(())
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ async fn run() {
|
|||
|
||||
teloxide::repl(bot, |message| async move {
|
||||
message.answer_dice().send().await?;
|
||||
ResponseResult::<()>::Ok(())
|
||||
respond(())
|
||||
})
|
||||
.await;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ pub use crate::{
|
|||
Dispatcher, DispatcherHandlerRx, DispatcherHandlerRxExt, UpdateWithCx,
|
||||
},
|
||||
error_handlers::{LoggingErrorHandler, OnError},
|
||||
requests::{Request, ResponseResult},
|
||||
requests::{respond, Request, ResponseResult},
|
||||
types::{Message, Update},
|
||||
Bot, RequestError,
|
||||
};
|
||||
|
|
|
@ -9,6 +9,11 @@ pub use all::*;
|
|||
/// A type that is returned after making a request to Telegram.
|
||||
pub type ResponseResult<T> = Result<T, crate::RequestError>;
|
||||
|
||||
/// A shortcut for `ResponseResult::Ok(val)`.
|
||||
pub fn respond<T>(val: T) -> ResponseResult<T> {
|
||||
ResponseResult::Ok(val)
|
||||
}
|
||||
|
||||
/// Designates an API request.
|
||||
#[async_trait::async_trait]
|
||||
pub trait Request {
|
||||
|
|
Loading…
Reference in a new issue