mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
getChat
This commit is contained in:
parent
4cf17a4b68
commit
3b6b147b69
1 changed files with 43 additions and 0 deletions
43
src/core/requests/get_chat.rs
Normal file
43
src/core/requests/get_chat.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
use crate::core::requests::{ChatId, RequestContext, RequestFuture, ResponseResult, Request};
|
||||
use crate::core::types::Chat;
|
||||
use crate::core::network;
|
||||
|
||||
/// Use this method to get up to date information about the chat
|
||||
/// (current name of the user for one-on-one conversations,
|
||||
/// current username of a user, group or channel, etc.).
|
||||
/// Returns a Chat object on success.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct GetChat<'a> {
|
||||
#[serde(skip_serializing)]
|
||||
ctx: RequestContext<'a>,
|
||||
/// Unique identifier for the target chat or username
|
||||
/// of the target supergroup or channel (in the format @channelusername)
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
|
||||
impl<'a> Request<'a> for GetChat<'a> {
|
||||
type ReturnValue = Chat;
|
||||
|
||||
fn send(self) -> RequestFuture<'a, ResponseResult<Self::ReturnValue>> {
|
||||
Box::pin(async move {
|
||||
network::request_json(
|
||||
&self.ctx.client,
|
||||
&self.ctx.token,
|
||||
"getChat",
|
||||
&self,
|
||||
).await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl<'a> GetChat<'a>{
|
||||
pub fn chat_id<T>(mut self, chat_id: T) -> Self
|
||||
where
|
||||
T: Into<ChatId>,
|
||||
{
|
||||
self.chat_id = chat_id.into();
|
||||
self
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue