mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Fix bot's inability to respond in long time periods
Closes https://github.com/teloxide/teloxide/issues/223.
This commit is contained in:
parent
fdfb95d0c7
commit
3866fd0d7e
2 changed files with 5 additions and 2 deletions
|
@ -120,11 +120,11 @@ pub trait UpdateListener<E>: Stream<Item = Result<Update, E>> {
|
|||
}
|
||||
impl<S, E> UpdateListener<E> for S where S: Stream<Item = Result<Update, E>> {}
|
||||
|
||||
/// Returns a long polling update listener with `timeout` of 1 minute.
|
||||
/// Returns a long polling update listener with `timeout` of 10 seconds.
|
||||
///
|
||||
/// See also: [`polling`](polling).
|
||||
pub fn polling_default(bot: Arc<Bot>) -> impl UpdateListener<RequestError> {
|
||||
polling(bot, Some(Duration::from_secs(60)), None, None)
|
||||
polling(bot, Some(Duration::from_secs(10)), None, None)
|
||||
}
|
||||
|
||||
/// Returns a long/short polling update listener with some additional options.
|
||||
|
|
|
@ -4,6 +4,7 @@ use serde::{de::DeserializeOwned, Serialize};
|
|||
use crate::{requests::ResponseResult, RequestError};
|
||||
|
||||
use super::{TelegramResponse, TELEGRAM_API_URL};
|
||||
use reqwest::header::CONNECTION;
|
||||
|
||||
pub async fn request_multipart<T>(
|
||||
client: &Client,
|
||||
|
@ -16,6 +17,7 @@ where
|
|||
{
|
||||
let response = client
|
||||
.post(&super::method_url(TELEGRAM_API_URL, token, method_name))
|
||||
.header(CONNECTION, "keep-alive")
|
||||
.multipart(params)
|
||||
.send()
|
||||
.await
|
||||
|
@ -36,6 +38,7 @@ where
|
|||
{
|
||||
let response = client
|
||||
.post(&super::method_url(TELEGRAM_API_URL, token, method_name))
|
||||
.header(CONNECTION, "keep-alive")
|
||||
.json(params)
|
||||
.send()
|
||||
.await
|
||||
|
|
Loading…
Reference in a new issue