From df416079f04741428542cb9fcdebed1603268078 Mon Sep 17 00:00:00 2001 From: Akshett Rai Jindal Date: Tue, 20 Aug 2024 19:39:47 +0530 Subject: [PATCH] Add `request_*` fields to `KeyboardButtonRequestUsers` struct Added fields: `request_name`, `request_username` and `request_photo` --- .../types/keyboard_button_request_users.rs | 44 +++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/crates/teloxide-core/src/types/keyboard_button_request_users.rs b/crates/teloxide-core/src/types/keyboard_button_request_users.rs index 6f126622..7b873c3b 100644 --- a/crates/teloxide-core/src/types/keyboard_button_request_users.rs +++ b/crates/teloxide-core/src/types/keyboard_button_request_users.rs @@ -2,8 +2,8 @@ use serde::{Deserialize, Serialize}; use crate::types::RequestId; -/// This object defines the criteria used to request a suitable users. The -/// identifiers of the selected users will be shared with the bot when the +/// This object defines the criteria used to request a suitable users. +/// Information about the selected users will be shared with the bot when the /// corresponding button is pressed. More about requesting users » /// /// [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. #[serde(default = "one", skip_serializing_if = "is_one")] 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, + + /// Pass `true` to request the users' username + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request_username: Option, + + /// Pass `true` to request the users' photos + #[serde(default, skip_serializing_if = "Option::is_none")] + pub request_photo: Option, } impl KeyboardButtonRequestUsers { /// Creates a new [`KeyboardButtonRequestUsers`]. 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 @@ -57,6 +77,24 @@ impl KeyboardButtonRequestUsers { self.max_quantity = value; 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 {