修改了bot代码,基本实现了签到功能,还需实现定时统计

This commit is contained in:
:NoBody: committed 2026-04-05 22:49:47 +08:00
1 parent f86ed8c286
commit d358ed3ddc
15 files changed
+334 -25

No files matched your search

+24
View File
@@ -4,11 +4,27 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
pub struct UserState {
pub is_checkin_today: bool,
pub level: UserLevel,
pub checkin_unix_second: u64,
pub checkin_times_in_month: usize,
pub checkin_days: Vec<u32>, //每月在哪天签到了
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum UserLevel {
Super = 0, //表示不受限制的用户,直接享受最高权限,主要用于管理员账号
Bronze = 1,
Silver = 2,
Gold = 3,
Platinum = 4,
Diamond = 5,
}
impl Default for UserLevel {
fn default() -> Self {
UserLevel::Bronze
}
}
/*
key:用户id
value:UserState的json字符串
@@ -23,6 +39,7 @@ impl UserState {
checkin_unix_second: 0,
checkin_times_in_month: 0,
checkin_days: Vec::new(),
level: UserLevel::Bronze,
}
}
@@ -36,6 +53,13 @@ impl UserState {
if !self.checkin_days.contains(&day) {
self.checkin_days.push(day);
}
match self.checkin_times_in_month {
0..=14 => self.level = UserLevel::Bronze,
15..=30 => self.level = UserLevel::Silver,
31..=45 => self.level = UserLevel::Gold,
46..=60 => self.level = UserLevel::Platinum,
_ => self.level = UserLevel::Diamond,
}
}
pub fn reset_daily(&mut self) {