tgbot/types/chat/sticker_set/
mod.rs

1use serde::Serialize;
2
3use crate::{
4    api::{Method, Payload},
5    types::ChatId,
6};
7
8#[cfg(test)]
9mod tests;
10
11/// Deletes a group sticker set from a supergroup.
12///
13/// The bot must be an administrator in the chat
14/// for this to work and must have the appropriate admin rights.
15///
16/// Use the field `can_set_sticker_set` optionally returned
17/// in [`crate::types::GetChat`] requests to check if the bot can use this method.
18#[derive(Clone, Debug, Serialize)]
19pub struct DeleteChatStickerSet {
20    chat_id: ChatId,
21}
22
23impl DeleteChatStickerSet {
24    /// Creates a new `DeleteChatStickerSet`.
25    ///
26    /// # Arguments
27    ///
28    /// * `chat_id` - Unique identifier of the target chat.
29    pub fn new<T>(chat_id: T) -> Self
30    where
31        T: Into<ChatId>,
32    {
33        DeleteChatStickerSet {
34            chat_id: chat_id.into(),
35        }
36    }
37}
38
39impl Method for DeleteChatStickerSet {
40    type Response = bool;
41
42    fn into_payload(self) -> Payload {
43        Payload::json("deleteChatStickerSet", self)
44    }
45}
46
47/// Sets a new group sticker set for a supergroup.
48///
49/// The bot must be an administrator in the chat for this to work
50/// and must have the appropriate admin rights.
51///
52/// Use the field `can_set_sticker_set` optionally returned in [`crate::types::GetChat`] requests
53/// to check if the bot can use this method.
54#[derive(Clone, Debug, Serialize)]
55pub struct SetChatStickerSet {
56    chat_id: ChatId,
57    sticker_set_name: String,
58}
59
60impl SetChatStickerSet {
61    /// Creates a new `SetChatStickerSet`.
62    ///
63    /// # Arguments
64    ///
65    /// * `chat_id` - Unique identifier of the target chat.
66    /// * `sticker_set_name` - Name of the sticker set to be set as the group sticker set.
67    pub fn new<A, B>(chat_id: A, sticker_set_name: B) -> Self
68    where
69        A: Into<ChatId>,
70        B: Into<String>,
71    {
72        SetChatStickerSet {
73            chat_id: chat_id.into(),
74            sticker_set_name: sticker_set_name.into(),
75        }
76    }
77}
78
79impl Method for SetChatStickerSet {
80    type Response = bool;
81
82    fn into_payload(self) -> Payload {
83        Payload::json("setChatStickerSet", self)
84    }
85}