tgbot/types/chat/sender_chat/
mod.rs

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