mirror of
https://github.com/teloxide/teloxide.git
synced 2024-12-22 22:46:39 +01:00
Add setters to ChatMember
This commit is contained in:
parent
30696d3e29
commit
50db42ffb6
1 changed files with 112 additions and 0 deletions
|
@ -77,6 +77,118 @@ pub struct ChatMember {
|
|||
pub can_add_web_page_previews: Option<bool>,
|
||||
}
|
||||
|
||||
impl ChatMember {
|
||||
pub fn new(user: User, status: ChatMemberStatus) -> Self {
|
||||
Self {
|
||||
user,
|
||||
status,
|
||||
custom_title: None,
|
||||
until_date: None,
|
||||
can_be_edited: None,
|
||||
can_change_info: None,
|
||||
can_post_messages: None,
|
||||
can_edit_messages: None,
|
||||
can_delete_messages: None,
|
||||
can_invite_users: None,
|
||||
can_restrict_members: None,
|
||||
can_pin_messages: None,
|
||||
can_promote_members: None,
|
||||
can_send_messages: None,
|
||||
can_send_media_messages: None,
|
||||
can_send_other_messages: None,
|
||||
can_add_web_page_previews: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn user(mut self, val: User) -> Self {
|
||||
self.user = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn status(mut self, val: ChatMemberStatus) -> Self {
|
||||
self.status = val;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn custom_title<S>(mut self, val: S) -> Self
|
||||
where
|
||||
S: Into<String>,
|
||||
{
|
||||
self.custom_title = Some(val.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub fn until_date(mut self, val: i32) -> Self {
|
||||
self.until_date = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_be_edited(mut self, val: bool) -> Self {
|
||||
self.can_be_edited = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_change_info(mut self, val: bool) -> Self {
|
||||
self.can_change_info = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_post_messages(mut self, val: bool) -> Self {
|
||||
self.can_post_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_edit_messages(mut self, val: bool) -> Self {
|
||||
self.can_edit_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_delete_messages(mut self, val: bool) -> Self {
|
||||
self.can_delete_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_invite_users(mut self, val: bool) -> Self {
|
||||
self.can_invite_users = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_restrict_members(mut self, val: bool) -> Self {
|
||||
self.can_restrict_members = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_pin_messages(mut self, val: bool) -> Self {
|
||||
self.can_pin_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_promote_members(mut self, val: bool) -> Self {
|
||||
self.can_promote_members = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_send_messages(mut self, val: bool) -> Self {
|
||||
self.can_send_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_send_media_messages(mut self, val: bool) -> Self {
|
||||
self.can_send_media_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_send_other_messages(mut self, val: bool) -> Self {
|
||||
self.can_send_other_messages = Some(val);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn can_add_web_page_previews(mut self, val: bool) -> Self {
|
||||
self.can_add_web_page_previews = Some(val);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ChatMemberStatus {
|
||||
|
|
Loading…
Reference in a new issue