Add SharedUser struct and add to UsersShared

This commit is contained in:
Akshett Rai Jindal 2024-08-20 20:11:32 +05:30
parent a48d071456
commit cc8df7a32e
4 changed files with 34 additions and 3 deletions

View file

@ -122,6 +122,7 @@ pub use reply_parameters::*;
pub use request_id::*; pub use request_id::*;
pub use response_parameters::*; pub use response_parameters::*;
pub use sent_web_app_message::*; pub use sent_web_app_message::*;
pub use shared_user::*;
pub use shipping_address::*; pub use shipping_address::*;
pub use shipping_option::*; pub use shipping_option::*;
pub use shipping_query::*; pub use shipping_query::*;
@ -248,6 +249,7 @@ mod reply_parameters;
mod request_id; mod request_id;
mod response_parameters; mod response_parameters;
mod sent_web_app_message; mod sent_web_app_message;
mod shared_user;
mod shipping_address; mod shipping_address;
mod shipping_option; mod shipping_option;
mod shipping_query; mod shipping_query;

View file

@ -63,7 +63,7 @@ pub struct KeyboardButtonRequestChat {
#[serde(default, skip_serializing_if = "std::ops::Not::not")] #[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_username: bool, pub request_username: bool,
/// Pass `true` to request the chat's photos. /// Pass `true` to request the chat's photo.
#[serde(default, skip_serializing_if = "std::ops::Not::not")] #[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub request_photo: bool, pub request_photo: bool,
} }

View file

@ -0,0 +1,29 @@
use serde::{Deserialize, Serialize};
use crate::types::{PhotoSize, UserId};
/// This object contains information about a user that was shared with the bot
/// using a [`KeyboardButtonRequestUsers`] button.
///
/// [`KeyboardButtonRequestUsers`]: crate::types::KeyboardButtonRequestUsers
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize, Deserialize)]
pub struct SharedUser {
/// Identifier of the shared user
pub user_id: UserId,
/// First name of the user, if it was requested by the bot
#[serde(default)]
pub first_name: Option<String>,
/// Last name of the user, if it was requested by the bot
#[serde(default)]
pub last_name: Option<String>,
/// Username of the user, if it was requested by the bot
#[serde(default)]
pub username: Option<String>,
/// Available sizes of the chat photo, if it was requested
#[serde(default)]
pub photo: Option<Vec<PhotoSize>>,
}

View file

@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::types::{RequestId, UserId}; use crate::types::{RequestId, SharedUser};
/// This object contains information about the users whose identifiers were /// This object contains information about the users whose identifiers were
/// shared with the bot using a [KeyboardButtonRequestUsers] button. /// shared with the bot using a [KeyboardButtonRequestUsers] button.
@ -11,5 +11,5 @@ pub struct UsersShared {
/// Identifier of the request /// Identifier of the request
pub request_id: RequestId, pub request_id: RequestId,
/// Identifiers of the shared users /// Identifiers of the shared users
pub user_ids: Vec<UserId>, pub users: Vec<SharedUser>,
} }