45 lines
1.1 KiB
Rust
45 lines
1.1 KiB
Rust
use chrono::Duration;
|
|
use serde::{Deserialize, Serialize};
|
|
use serde_with::{serde_as, DurationSeconds};
|
|
use crate::app::FullUserToken;
|
|
|
|
#[derive(Deserialize, Serialize, Default)]
|
|
pub struct Config {
|
|
#[serde(default)]
|
|
pub bot_token: Option<FullUserToken>,
|
|
#[serde(default)]
|
|
pub user_token: Option<FullUserToken>,
|
|
pub commands: Vec<Command>,
|
|
pub redemptions: Vec<Redemption>,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub struct Command {
|
|
pub name: String,
|
|
pub aliases: Vec<String>,
|
|
pub cooldowns: Cooldowns,
|
|
pub executor: CommandExecutor,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub enum CommandExecutor {
|
|
Text(String),
|
|
Rhai(String),
|
|
}
|
|
|
|
#[serde_as]
|
|
#[derive(Deserialize, Serialize, Default, Clone)]
|
|
pub struct Cooldowns {
|
|
#[serde_as(as = "Option<DurationSeconds<f64>>")]
|
|
pub global: Option<Duration>,
|
|
#[serde_as(as = "Option<DurationSeconds<f64>>")]
|
|
pub user: Option<Duration>,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Clone)]
|
|
pub struct Redemption {
|
|
pub name: String,
|
|
pub twitch_id: twitch_api2::types::RewardId,
|
|
pub rhai: String,
|
|
}
|