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