Add request_* fields to KeyboardButtonRequestUsers struct

Added fields: `request_name`, `request_username` and `request_photo`
This commit is contained in:
Akshett Rai Jindal 2024-08-20 19:39:47 +05:30
parent cb8ff44b09
commit df416079f0

View file

@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize};
use crate::types::RequestId; use crate::types::RequestId;
/// This object defines the criteria used to request a suitable users. The /// This object defines the criteria used to request a suitable users.
/// identifiers of the selected users will be shared with the bot when the /// Information about the selected users will be shared with the bot when the
/// corresponding button is pressed. More about requesting users » /// corresponding button is pressed. More about requesting users »
/// ///
/// [More about requesting users »]: https://core.telegram.org/bots/features#chat-and-user-selection /// [More about requesting users »]: https://core.telegram.org/bots/features#chat-and-user-selection
@ -30,12 +30,32 @@ pub struct KeyboardButtonRequestUsers {
/// The maximum number of users to be selected; 1-10. Defaults to 1. /// The maximum number of users to be selected; 1-10. Defaults to 1.
#[serde(default = "one", skip_serializing_if = "is_one")] #[serde(default = "one", skip_serializing_if = "is_one")]
pub max_quantity: u8, pub max_quantity: u8,
/// Pass `true` to request the users' first and last names
#[serde(default, skip_serializing_if = "Option::is_none")]
pub request_name: Option<bool>,
/// Pass `true` to request the users' username
#[serde(default, skip_serializing_if = "Option::is_none")]
pub request_username: Option<bool>,
/// Pass `true` to request the users' photos
#[serde(default, skip_serializing_if = "Option::is_none")]
pub request_photo: Option<bool>,
} }
impl KeyboardButtonRequestUsers { impl KeyboardButtonRequestUsers {
/// Creates a new [`KeyboardButtonRequestUsers`]. /// Creates a new [`KeyboardButtonRequestUsers`].
pub fn new(request_id: RequestId) -> Self { pub fn new(request_id: RequestId) -> Self {
Self { request_id, user_is_bot: None, user_is_premium: None, max_quantity: 1 } Self {
request_id,
user_is_bot: None,
user_is_premium: None,
max_quantity: 1,
request_name: None,
request_username: None,
request_photo: None,
}
} }
/// Setter for `user_is_bot` field /// Setter for `user_is_bot` field
@ -57,6 +77,24 @@ impl KeyboardButtonRequestUsers {
self.max_quantity = value; self.max_quantity = value;
self self
} }
/// Setter for `request_name` field
pub fn request_name(mut self, value: bool) -> Self {
self.request_name = Some(value);
self
}
/// Setter for `request_username` field
pub fn request_username(mut self, value: bool) -> Self {
self.request_username = Some(value);
self
}
/// Setter for `request_photo` field
pub fn request_photo(mut self, value: bool) -> Self {
self.request_photo = Some(value);
self
}
} }
fn one() -> u8 { fn one() -> u8 {