Add requests::respond

This commit is contained in:
Temirkhan Myrzamadi 2020-08-02 13:08:43 +06:00
parent 3703f2dff6
commit 05e32336fa
4 changed files with 8 additions and 3 deletions

View file

@ -103,7 +103,7 @@ async fn main() {
teloxide::repl(bot, |message| async move {
message.answer_dice().send().await?;
ResponseResult::<()>::Ok(())
respond(())
})
.await;
}

View file

@ -15,7 +15,7 @@ async fn run() {
teloxide::repl(bot, |message| async move {
message.answer_dice().send().await?;
ResponseResult::<()>::Ok(())
respond(())
})
.await;
}

View file

@ -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,
};

View file

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