mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 06:51:01 +01:00
fmt
This commit is contained in:
parent
cadd781abf
commit
80a9ebebd2
3 changed files with 18 additions and 12 deletions
|
@ -31,10 +31,11 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
|
|||
/// use std::convert::Infallible;
|
||||
/// use teloxide::{dispatching::FilterDispatcher, RequestError};
|
||||
///
|
||||
/// let _ =
|
||||
/// FilterDispatcher::new(|err: Either<RequestError, Infallible>| async {
|
||||
/// let _ = FilterDispatcher::new(|err: Either<RequestError, Infallible>| {
|
||||
/// async {
|
||||
/// dbg!(err);
|
||||
/// });
|
||||
/// }
|
||||
/// });
|
||||
/// ```
|
||||
///
|
||||
/// Or you can do it even simpler by providing the built-in error handler
|
||||
|
@ -83,9 +84,11 @@ type FiltersWithHandlers<'a, T, E> = Vec<FilterWithHandler<'a, T, E>>;
|
|||
/// // error handler that just ignores all errors (that can't ever happen).
|
||||
/// let mut dp = FilterDispatcher::<Infallible, _>::new(|_| async {})
|
||||
/// // Add a handler, which handles all messages sent to the bot.
|
||||
/// .message_handler(true, |mes: Message| async move {
|
||||
/// println!("New message: {:?}", mes);
|
||||
/// Ok(())
|
||||
/// .message_handler(true, |mes: Message| {
|
||||
/// async move {
|
||||
/// println!("New message: {:?}", mes);
|
||||
/// Ok(())
|
||||
/// }
|
||||
/// })
|
||||
/// // Add a handler, which handles all messages edited in a chat
|
||||
/// // with the bot.
|
||||
|
|
|
@ -39,11 +39,13 @@ pub async fn download_file_stream(
|
|||
.await?
|
||||
.error_for_status()?;
|
||||
|
||||
Ok(futures::stream::unfold(res, |mut res| async {
|
||||
match res.chunk().await {
|
||||
Err(err) => Some((Err(err), res)),
|
||||
Ok(Some(c)) => Some((Ok(c), res)),
|
||||
Ok(None) => None,
|
||||
Ok(futures::stream::unfold(res, |mut res| {
|
||||
async {
|
||||
match res.chunk().await {
|
||||
Err(err) => Some((Err(err), res)),
|
||||
Ok(Some(c)) => Some((Ok(c), res)),
|
||||
Ok(None) => None,
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -121,7 +121,8 @@ mod tests {
|
|||
fn test_link() {
|
||||
assert_eq!(
|
||||
link("https://www.google.com/?q=foo&l=ru", "<google>"),
|
||||
"<a href=\"https://www.google.com/?q=foo&l=ru\"><google></a>",
|
||||
"<a href=\"https://www.google.com/?q=foo&l=ru\"><google>\
|
||||
</a>",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue