添加了一些每日统计的辅助函数

This commit is contained in:
:NoBody: committed 2026-04-08 22:51:34 +08:00
1 parent 47c3e908ec
commit 7096384161
6 files changed
+87 -11

No files matched your search

+14 -1
View File
@@ -22,6 +22,16 @@ pub struct MatrixBot {
pub password: String,
pub rooms: Vec<Room>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum RoomType {
MainRoom, //主房间,用于签到和汇报
SubRoom, //子房间,用于自动踢出,统计(默认)
RecoveryRoom, //恢复房间,用于被踢出用户的恢复,被踢出的用户会自动被邀请到这里
}
fn default_room_type() -> RoomType {
RoomType::SubRoom
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Room {
@@ -32,6 +42,8 @@ pub struct Room {
pub kick_long_time: Option<isize>,
#[serde(skip_serializing_if = "Option::is_none")]
pub white_list: Option<Vec<OwnedUserId>>,
#[serde(default = "default_room_type")]
pub room_type: RoomType,
}
use thiserror::Error;
#[derive(Debug, Error)]
@@ -48,7 +60,7 @@ impl Config {
#[cfg(test)]
mod tests {
use crate::config::Room;
use crate::config::{Room, RoomType};
#[test]
fn room_test() {
@@ -60,5 +72,6 @@ white_list=["@example:foo.bar"]
dbg!(&cfg);
let a: Room = toml::from_str::<Room>(cfg).unwrap();
dbg!(&a);
assert!(matches!(a.room_type, RoomType::SubRoom));
}
}