diff --git a/sample_uberbot.toml b/sample_uberbot.toml index 5784662..95a847a 100644 --- a/sample_uberbot.toml +++ b/sample_uberbot.toml @@ -1,19 +1,11 @@ -# IRC config +[irc] host = "karx.xyz" port = 6697 username = "uberbot" channels = ["#main", "#no-normies"] mode = "+B" - -# Spotify config -spotify_client_id = "" -spotify_client_secret = "" - -# Bot config prefix = "!" -# Web service config -http_listen = "127.0.0.1:8080" - -# Git webhook config -git_channel = "#main" +[spotify] +spotify_client_id = "" +spotify_client_secret = "" diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..2578231 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,27 @@ +use std::net::SocketAddr; +use serde::Deserialize; + +#[derive(Deserialize)] +pub struct UberConfig { + pub irc: IrcConfig, + pub spotify: SpotifyConfig, // TODO: make optional + pub db_path: Option, +} + +#[derive(Deserialize)] +pub struct SpotifyConfig { + pub spotify_client_id: String, + pub spotify_client_secret: String, +} + +#[derive(Deserialize)] +pub struct IrcConfig { + pub channels: Vec, + pub host: String, + pub tls: bool, + pub mode: Option, + pub nickname: Option, + pub port: u16, + pub username: String, + pub prefix: String, +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 530daa0..010a900 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,6 +25,8 @@ use crate::database::{DbExecutor, ExecutorConnection, Quote}; mod bots; mod database; +mod bot; +mod config; // this will be displayed when the help command is used const HELP: &[&str] = &[ @@ -65,24 +67,6 @@ pub struct AppState { db: ExecutorConnection, } -#[derive(Deserialize)] -struct ClientConf { - channels: Vec, - host: String, - tls: bool, - mode: Option, - nickname: Option, - port: u16, - username: String, - spotify_client_id: String, - spotify_client_secret: String, - prefix: String, - db_path: Option, - // reserved for future - _http_listen: Option, - _git_channel: String, -} - #[tokio::main] async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt()