telegram_bot_fork_raw/requests/
unban_chat_member.rs

1use requests::*;
2use types::*;
3
4/// Use this method to unban a previously kicked user in a supergroup or channel.
5/// The user will not return to the group or channel automatically, but will be able to
6/// join via link, etc. The bot must be an administrator in the group for this to work.
7#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
8#[must_use = "requests do nothing unless sent"]
9pub struct UnbanChatMember {
10    chat_id: ChatRef,
11    user_id: UserId,
12}
13
14impl Request for UnbanChatMember {
15    type Type = JsonRequestType<Self>;
16    type Response = JsonTrueToUnitResponse;
17
18    fn serialize(&self) -> Result<HttpRequest, Error> {
19        Self::Type::serialize(RequestUrl::method("unbanChatMember"), self)
20    }
21}
22
23impl UnbanChatMember {
24    pub fn new<C, U>(chat: C, user: U) -> Self
25    where
26        C: ToChatRef,
27        U: ToUserId,
28    {
29        UnbanChatMember {
30            chat_id: chat.to_chat_ref(),
31            user_id: user.to_user_id(),
32        }
33    }
34}
35
36/// Unban a previously kicked user in a supergroup or channel.
37pub trait CanUnbanChatMemberForChat {
38    fn unban<O>(&self, other: O) -> UnbanChatMember
39    where
40        O: ToUserId;
41}
42
43impl<C> CanUnbanChatMemberForChat for C
44where
45    C: ToChatRef,
46{
47    fn unban<O>(&self, other: O) -> UnbanChatMember
48    where
49        O: ToUserId,
50    {
51        UnbanChatMember::new(self, other)
52    }
53}
54
55/// Unban a previously kicked user in a supergroup or channel.
56pub trait CanUnbanChatMemberForUser {
57    fn unban_in<O>(&self, other: O) -> UnbanChatMember
58    where
59        O: ToChatRef;
60}
61
62impl<U> CanUnbanChatMemberForUser for U
63where
64    U: ToUserId,
65{
66    fn unban_in<O>(&self, other: O) -> UnbanChatMember
67    where
68        O: ToChatRef,
69    {
70        UnbanChatMember::new(other, self)
71    }
72}