1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use types::*;
use requests::*;
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize)]
#[must_use = "requests do nothing unless sent"]
pub struct RestrictChatMember {
chat_id: ChatRef,
user_id: UserId,
until_date: Option<i32>,
can_send_messages: Option<bool>,
can_send_media_messages: Option<bool>,
can_send_other_messages: Option<bool>,
can_add_web_page_previews: Option<bool>,
}
impl Request for RestrictChatMember {
type Type = JsonRequestType<Self>;
type Response = JsonTrueToUnitResponse;
fn serialize(&self) -> Result<HttpRequest, Error> {
Self::Type::serialize(RequestUrl::method("restrictChatMember"), self)
}
}
impl RestrictChatMember {
pub fn new<C, U>(chat: C, user: U) -> Self where C: ToChatRef, U: ToUserId {
RestrictChatMember {
chat_id: chat.to_chat_ref(),
user_id: user.to_user_id(),
until_date: None,
can_send_messages: None,
can_send_media_messages: None,
can_send_other_messages: None,
can_add_web_page_previews: None,
}
}
pub fn until_date(&mut self, value: i32) -> &mut Self {
self.until_date = Some(value);
self
}
pub fn can_send_messages(&mut self, value: bool) -> &mut Self {
self.can_send_messages = Some(value);
self
}
pub fn can_send_media_messages(&mut self, value: bool) -> &mut Self {
self.can_send_media_messages = Some(value);
self
}
pub fn can_send_other_messages(&mut self, value: bool) -> &mut Self {
self.can_send_other_messages = Some(value);
self
}
pub fn can_add_web_page_previews(&mut self, value: bool) -> &mut Self {
self.can_add_web_page_previews = Some(value);
self
}
}
pub trait CanRestrictChatMemberForChat {
fn restrict<O>(&self, other: O) -> RestrictChatMember where O: ToUserId;
}
impl<C> CanRestrictChatMemberForChat for C where C: ToChatRef {
fn restrict<O>(&self, other: O) -> RestrictChatMember where O: ToUserId {
RestrictChatMember::new(self, other)
}
}
pub trait CanRestrictChatMemberForUser {
fn restrict_from<O>(&self, other: O) -> RestrictChatMember where O: ToChatRef;
}
impl<U> CanRestrictChatMemberForUser for U where U: ToUserId {
fn restrict_from<O>(&self, other: O) -> RestrictChatMember where O: ToChatRef {
RestrictChatMember::new(other, self)
}
}