[Clean]
This commit is contained in:
parent
6dd479982d
commit
a6c986d56b
2 changed files with 21 additions and 27 deletions
|
|
@ -1,33 +1,27 @@
|
||||||
#[derive(Clone, Copy)]
|
use strum::IntoEnumIterator;
|
||||||
#[allow(non_camel_case_types)]
|
use strum_macros::EnumIter;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, EnumIter, Eq)]
|
||||||
|
#[allow(unused)]
|
||||||
pub enum UserStatus {
|
pub enum UserStatus {
|
||||||
online,
|
Online,
|
||||||
do_not_disturb,
|
PhoneOnline,
|
||||||
wc,
|
Away,
|
||||||
away,
|
DoNotDisturb,
|
||||||
user_offline,
|
UserOffline,
|
||||||
iota_offline,
|
IotaOffline,
|
||||||
}
|
}
|
||||||
|
#[allow(unused)]
|
||||||
impl UserStatus {
|
impl UserStatus {
|
||||||
pub fn to_string(self) -> String {
|
pub fn to_string(&self) -> String {
|
||||||
match self {
|
format!("{:?}", self)
|
||||||
UserStatus::online => "online".to_string(),
|
}
|
||||||
UserStatus::do_not_disturb => "do_not_disturb".to_string(),
|
pub fn from_str(s: &str) -> Option<UserStatus> {
|
||||||
UserStatus::wc => "wc".to_string(),
|
for sel in UserStatus::iter() {
|
||||||
UserStatus::away => "away".to_string(),
|
if &sel.to_string() == s {
|
||||||
UserStatus::user_offline => "user_offline".to_string(),
|
return Some(sel);
|
||||||
UserStatus::iota_offline => "iota_offline".to_string(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn from_string(status_str: &str) -> Result<Self, String> {
|
None
|
||||||
match status_str.to_lowercase().as_str() {
|
|
||||||
"online" => Ok(UserStatus::online),
|
|
||||||
"do_not_disturb" => Ok(UserStatus::do_not_disturb),
|
|
||||||
"wc" => Ok(UserStatus::wc),
|
|
||||||
"away" => Ok(UserStatus::away),
|
|
||||||
"user_offline" => Ok(UserStatus::user_offline),
|
|
||||||
"iota_offline" => Ok(UserStatus::iota_offline),
|
|
||||||
_ => Err(format!("Invalid user status: {}", status_str)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,7 @@ impl OmegaConnection {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cloned_self.send_ping().await;
|
cloned_self.send_ping().await;
|
||||||
sleep(Duration::from_secs(1)).await;
|
sleep(Duration::from_secs(5)).await;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue