mirror of
https://github.com/natsukagami/youmubot.git
synced 2025-04-19 16:58:55 +00:00
Manually fix the rest of the lints
This commit is contained in:
parent
508cf52e6f
commit
1125cac2a8
4 changed files with 39 additions and 46 deletions
|
@ -192,10 +192,9 @@ pub async fn save(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
|
|||
let scores = client
|
||||
.user_best(UserID::ID(u.id), |f| f.mode(*mode))
|
||||
.await?;
|
||||
match scores.into_iter().choose(&mut rand::thread_rng()) {
|
||||
Some(v) => return Ok(Some((v, *mode))),
|
||||
None => (),
|
||||
};
|
||||
if let Some(v) = scores.into_iter().choose(&mut rand::thread_rng()) {
|
||||
return Ok(Some((v, *mode)));
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
|
|
|
@ -430,15 +430,7 @@ impl Beatmap {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum UserEvent {
|
||||
Rank(UserEventRank),
|
||||
OtherV1 {
|
||||
display_html: String,
|
||||
date: DateTime<Utc>,
|
||||
epic_factor: u8,
|
||||
},
|
||||
OtherV2(rosu_v2::model::recent_event::RecentEvent),
|
||||
}
|
||||
pub struct UserEvent(pub rosu_v2::model::recent_event::RecentEvent);
|
||||
|
||||
/// Represents a "achieved rank #x on beatmap" event.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
@ -452,8 +444,29 @@ pub struct UserEventRank {
|
|||
impl UserEvent {
|
||||
/// Try to parse the event into a "rank" event.
|
||||
pub fn to_event_rank(&self) -> Option<UserEventRank> {
|
||||
match self {
|
||||
UserEvent::Rank(r) => Some(r.clone()),
|
||||
match &self.0.event_type {
|
||||
rosu_v2::model::recent_event::EventType::Rank {
|
||||
grade: _,
|
||||
rank,
|
||||
mode,
|
||||
beatmap,
|
||||
user: _,
|
||||
} => Some(UserEventRank {
|
||||
beatmap_id: {
|
||||
beatmap
|
||||
.url
|
||||
.trim_start_matches("/b/")
|
||||
.trim_end_matches("?m=0")
|
||||
.trim_end_matches("?m=1")
|
||||
.trim_end_matches("?m=2")
|
||||
.trim_end_matches("?m=3")
|
||||
.parse::<u64>()
|
||||
.unwrap()
|
||||
},
|
||||
rank: *rank as u16,
|
||||
mode: (*mode).into(),
|
||||
date: rosu::time_to_utc(self.0.created_at),
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ bitflags::bitflags! {
|
|||
/// The mods available to osu!
|
||||
#[derive(std::default::Default, Serialize, Deserialize)]
|
||||
pub struct Mods: u64 {
|
||||
const NOMOD = 0;
|
||||
const NF = 1 << 0;
|
||||
const EZ = 1 << 1;
|
||||
const TD = 1 << 2;
|
||||
|
@ -38,10 +37,6 @@ bitflags::bitflags! {
|
|||
const KEY3 = 1 << 27;
|
||||
const KEY2 = 1 << 28;
|
||||
const SCOREV2 = 1 << 29;
|
||||
const TOUCH_DEVICE = Self::TD.bits;
|
||||
const NOVIDEO = Self::TD.bits; /* never forget */
|
||||
const SPEED_CHANGING = Self::DT.bits | Self::HT.bits | Self::NC.bits;
|
||||
const MAP_CHANGING = Self::HR.bits | Self::EZ.bits | Self::SPEED_CHANGING.bits;
|
||||
|
||||
// Made up flags
|
||||
const LAZER = 1 << 59;
|
||||
|
@ -49,6 +44,16 @@ bitflags::bitflags! {
|
|||
}
|
||||
}
|
||||
|
||||
impl Mods {
|
||||
pub const NOMOD: Mods = Mods::empty();
|
||||
pub const TOUCH_DEVICE: Mods = Self::TD;
|
||||
pub const NOVIDEO: Mods = Self::TD; /* never forget */
|
||||
pub const SPEED_CHANGING: Mods =
|
||||
Mods::from_bits_truncate(Self::DT.bits | Self::HT.bits | Self::NC.bits);
|
||||
pub const MAP_CHANGING: Mods =
|
||||
Mods::from_bits_truncate(Self::HR.bits | Self::EZ.bits | Self::SPEED_CHANGING.bits);
|
||||
}
|
||||
|
||||
const MODS_WITH_NAMES: &[(Mods, &str)] = &[
|
||||
(Mods::NF, "NF"),
|
||||
(Mods::EZ, "EZ"),
|
||||
|
|
|
@ -23,7 +23,7 @@ impl ApprovalStatus {
|
|||
}
|
||||
}
|
||||
|
||||
fn time_to_utc(s: time::OffsetDateTime) -> DateTime<Utc> {
|
||||
pub(super) fn time_to_utc(s: time::OffsetDateTime) -> DateTime<Utc> {
|
||||
chrono::DateTime::from_timestamp(s.unix_timestamp(), 0).unwrap()
|
||||
}
|
||||
|
||||
|
@ -107,31 +107,7 @@ impl User {
|
|||
|
||||
impl From<rosu::recent_event::RecentEvent> for UserEvent {
|
||||
fn from(value: rosu::recent_event::RecentEvent) -> Self {
|
||||
match value.event_type {
|
||||
rosu::recent_event::EventType::Rank {
|
||||
grade: _,
|
||||
rank,
|
||||
mode,
|
||||
beatmap,
|
||||
user: _,
|
||||
} => Self::Rank(UserEventRank {
|
||||
beatmap_id: {
|
||||
beatmap
|
||||
.url
|
||||
.trim_start_matches("/b/")
|
||||
.trim_end_matches("?m=0")
|
||||
.trim_end_matches("?m=1")
|
||||
.trim_end_matches("?m=2")
|
||||
.trim_end_matches("?m=3")
|
||||
.parse::<u64>()
|
||||
.unwrap()
|
||||
},
|
||||
rank: rank as u16,
|
||||
mode: mode.into(),
|
||||
date: time_to_utc(value.created_at),
|
||||
}),
|
||||
_ => Self::OtherV2(value),
|
||||
}
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue