mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +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 {
|
teloxide::repl(bot, |message| async move {
|
||||||
message.answer_dice().send().await?;
|
message.answer_dice().send().await?;
|
||||||
ResponseResult::<()>::Ok(())
|
respond(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ async fn run() {
|
||||||
|
|
||||||
teloxide::repl(bot, |message| async move {
|
teloxide::repl(bot, |message| async move {
|
||||||
message.answer_dice().send().await?;
|
message.answer_dice().send().await?;
|
||||||
ResponseResult::<()>::Ok(())
|
respond(())
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ pub use crate::{
|
||||||
Dispatcher, DispatcherHandlerRx, DispatcherHandlerRxExt, UpdateWithCx,
|
Dispatcher, DispatcherHandlerRx, DispatcherHandlerRxExt, UpdateWithCx,
|
||||||
},
|
},
|
||||||
error_handlers::{LoggingErrorHandler, OnError},
|
error_handlers::{LoggingErrorHandler, OnError},
|
||||||
requests::{Request, ResponseResult},
|
requests::{respond, Request, ResponseResult},
|
||||||
types::{Message, Update},
|
types::{Message, Update},
|
||||||
Bot, RequestError,
|
Bot, RequestError,
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,6 +9,11 @@ pub use all::*;
|
||||||
/// A type that is returned after making a request to Telegram.
|
/// A type that is returned after making a request to Telegram.
|
||||||
pub type ResponseResult<T> = Result<T, crate::RequestError>;
|
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.
|
/// Designates an API request.
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
pub trait Request {
|
pub trait Request {
|
||||||
|
|
Loading…
Reference in a new issue