Function for checks for the existence of target user have been implemented for enum TargetUser

This commit is contained in:
doryan 2024-06-08 03:09:17 +04:00
parent 89119936c8
commit 0ec0c94501

View File

@ -15,6 +15,21 @@ pub enum TargetUser {
}
impl TargetUser {
pub fn exist(&self) -> bool {
match self {
Self::Id(_id) => true,
Self::Reply(msg) => {
if let Some(replied_msg) = msg.reply_to_message() {
return replied_msg.from().map(|user| user.id).is_some();
} else {
false
}
}
Self::CurrentMessage(msg) => msg.from().map(|user| user.id).is_some(),
Self::None => false,
}
}
pub fn get_id(&self) -> Option<i64> {
match self {
Self::Id(id) => Some(*id),