tgbot/types/definitions/chat/
sticker_set.rs

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