tgbot/types/definitions/chat/
sender_chat.rs

1use serde::Serialize;
2
3use crate::{
4    api::{Method, Payload},
5    types::{ChatId, Integer},
6};
7
8/// Bans a channel chat in a supergroup or a channel.
9///
10/// Until the chat is unbanned, the owner of the banned chat won't be able to send messages
11/// on behalf of any of their channels. The bot must be an administrator in the supergroup or
12/// channel for this to work and must have the appropriate administrator rights.
13#[derive(Clone, Debug, Serialize)]
14pub struct BanChatSenderChat {
15    chat_id: ChatId,
16    sender_chat_id: Integer,
17}
18
19impl BanChatSenderChat {
20    /// Creates a new `BanChatSenderChat`.
21    ///
22    /// # Arguments
23    ///
24    /// * `chat_id` - Unique identifier of the target chat.
25    /// * `sender_chat_id` - Unique identifier of the target sender chat.
26    pub fn new<T>(chat_id: T, sender_chat_id: Integer) -> Self
27    where
28        T: Into<ChatId>,
29    {
30        Self {
31            chat_id: chat_id.into(),
32            sender_chat_id,
33        }
34    }
35}
36
37impl Method for BanChatSenderChat {
38    type Response = bool;
39
40    fn into_payload(self) -> Payload {
41        Payload::json("banChatSenderChat", self)
42    }
43}
44
45/// Unbans a previously banned channel chat in a supergroup or channel.
46///
47/// The bot must be an administrator for this to work and must have
48/// the appropriate administrator rights.
49#[derive(Clone, Debug, Serialize)]
50pub struct UnbanChatSenderChat {
51    chat_id: ChatId,
52    sender_chat_id: Integer,
53}
54
55impl UnbanChatSenderChat {
56    /// Creates a new `UnbanChatSenderChat`.
57    ///
58    /// # Arguments
59    ///
60    /// * `chat_id` - Unique identifier of the target chat.
61    /// * `sender_chat_id` - Unique identifier of the target sender chat.
62    pub fn new<T>(chat_id: T, sender_chat_id: Integer) -> Self
63    where
64        T: Into<ChatId>,
65    {
66        Self {
67            chat_id: chat_id.into(),
68            sender_chat_id,
69        }
70    }
71}
72
73impl Method for UnbanChatSenderChat {
74    type Response = bool;
75
76    fn into_payload(self) -> Payload {
77        Payload::json("unbanChatSenderChat", self)
78    }
79}