mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-23 15:01:45 +01:00
levaeChat
This commit is contained in:
parent
e0a278701d
commit
66147232e6
2 changed files with 52 additions and 0 deletions
50
src/requests/leave_chat.rs
Normal file
50
src/requests/leave_chat.rs
Normal file
|
@ -0,0 +1,50 @@
|
|||
use async_trait::async_trait;
|
||||
|
||||
use crate::{
|
||||
bot::Bot,
|
||||
network,
|
||||
requests::{Request, ResponseResult},
|
||||
types::ChatId,
|
||||
};
|
||||
|
||||
/// Use this method for your bot to leave a group, supergroup or channel.
|
||||
/// Returns True on success.
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct LeaveChat<'a> {
|
||||
#[serde(skip_serializing)]
|
||||
bot: &'a Bot,
|
||||
/// Unique identifier for the target chat or username
|
||||
/// of the target supergroup or channel (in the format @channelusername)
|
||||
chat_id: ChatId,
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Request for LeaveChat<'_> {
|
||||
type Output = bool;
|
||||
|
||||
async fn send_boxed(self) -> ResponseResult<Self::Output> {
|
||||
self.send().await
|
||||
}
|
||||
}
|
||||
|
||||
impl LeaveChat<'_> {
|
||||
pub async fn send(self) -> ResponseResult<bool> {
|
||||
network::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"leaveChat",
|
||||
&self,
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> LeaveChat<'a> {
|
||||
pub fn chat_id<C>(mut self, value: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
self.chat_id = value.into();
|
||||
self
|
||||
}
|
||||
}
|
|
@ -19,6 +19,7 @@ pub use get_me::*;
|
|||
pub use get_updates::*;
|
||||
pub use get_user_profile_photos::*;
|
||||
pub use kick_chat_member::*;
|
||||
pub use leave_chat::*;
|
||||
pub use pin_chat_message::*;
|
||||
pub use promote_chat_member::*;
|
||||
pub use restrict_chat_member::*;
|
||||
|
@ -64,6 +65,7 @@ mod get_me;
|
|||
mod get_updates;
|
||||
mod get_user_profile_photos;
|
||||
mod kick_chat_member;
|
||||
mod leave_chat;
|
||||
mod pin_chat_message;
|
||||
mod promote_chat_member;
|
||||
mod restrict_chat_member;
|
||||
|
|
Loading…
Reference in a new issue