mirror of
https://github.com/teloxide/teloxide.git
synced 2025-01-11 04:21:12 +01:00
added method deleteChatPhoto
This commit is contained in:
parent
351229a6c0
commit
2a3d7cfbfb
3 changed files with 83 additions and 1 deletions
|
@ -9,7 +9,7 @@ use crate::{
|
|||
SendLocation, SendMediaGroup, SendMessage, SendPhoto, SendPoll,
|
||||
SendVenue, SendVideo, SendVideoNote, SendVoice, SetChatDescription,
|
||||
SetChatStickerSet, StopMessageLiveLocation, UnbanChatMember,
|
||||
UnpinChatMessage, SetChatTitle
|
||||
UnpinChatMessage, SetChatTitle, DeleteChatPhoto
|
||||
},
|
||||
types::{ChatAction, ChatId, ChatPermissions, InputFile, InputMedia},
|
||||
};
|
||||
|
@ -368,4 +368,14 @@ impl Bot {
|
|||
{
|
||||
SetChatTitle::new(self, chat_id, title)
|
||||
}
|
||||
|
||||
pub fn delete_chat_photo<C>(
|
||||
&self,
|
||||
chat_id: C,
|
||||
) -> DeleteChatPhoto
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
DeleteChatPhoto::new(self, chat_id)
|
||||
}
|
||||
}
|
||||
|
|
70
src/requests/delete_chat_photo.rs
Normal file
70
src/requests/delete_chat_photo.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
use async_trait::async_trait;
|
||||
|
||||
use crate::bot::Bot;
|
||||
use crate::types::{ChatId, True};
|
||||
use crate::requests::{ResponseResult, Request};
|
||||
use crate::network;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct DeleteChatPhoto<'a> {
|
||||
#[serde(skip_serializing)]
|
||||
bot: &'a Bot,
|
||||
|
||||
chat_id: ChatId
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl Request for DeleteChatPhoto<'_> {
|
||||
type Output = True;
|
||||
|
||||
async fn send_boxed(self) -> ResponseResult<Self::Output> {
|
||||
self.send().await
|
||||
}
|
||||
}
|
||||
|
||||
impl DeleteChatPhoto<'_> {
|
||||
async fn send(self) -> ResponseResult<True> {
|
||||
network::request_json(
|
||||
self.bot.client(),
|
||||
self.bot.token(),
|
||||
"deleteChatPhoto",
|
||||
&self
|
||||
).await
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> DeleteChatPhoto<'a> {
|
||||
pub(crate) fn new<C>(bot: &'a Bot, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>
|
||||
{
|
||||
Self {
|
||||
bot,
|
||||
chat_id: chat_id.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn chat_id<C>(mut self, chat_id: C) -> Self
|
||||
where
|
||||
C: Into<ChatId>,
|
||||
{
|
||||
self.chat_id = chat_id.into();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn serialize() {
|
||||
let bot = Bot::new("token");
|
||||
let chat_id = 123;
|
||||
let method = DeleteChatPhoto::new(&bot, chat_id);
|
||||
|
||||
let expected = r#"{"chat_id":123}"#;
|
||||
let actual = serde_json::to_string::<DeleteChatPhoto>(&method).unwrap();
|
||||
assert_eq!(actual, expected);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ use serde::de::DeserializeOwned;
|
|||
pub use answer_callback_query::*;
|
||||
pub use answer_pre_checkout_query::*;
|
||||
pub use answer_shipping_query::*;
|
||||
pub use delete_chat_photo::*;
|
||||
pub use delete_chat_sticker_set::*;
|
||||
pub use edit_message_live_location::*;
|
||||
pub use forward_message::*;
|
||||
|
@ -47,6 +48,7 @@ mod utils;
|
|||
mod answer_callback_query;
|
||||
mod answer_pre_checkout_query;
|
||||
mod answer_shipping_query;
|
||||
mod delete_chat_photo;
|
||||
mod delete_chat_sticker_set;
|
||||
mod edit_message_live_location;
|
||||
mod forward_message;
|
||||
|
|
Loading…
Reference in a new issue