Function for checks for the existence of target user have been implemented for enum TargetUser
This commit is contained in:
parent
89119936c8
commit
0ec0c94501
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue