Move config to a separate module
This commit is contained in:
parent
2968081358
commit
3299807172
|
@ -1,19 +1,11 @@
|
||||||
# IRC config
|
[irc]
|
||||||
host = "karx.xyz"
|
host = "karx.xyz"
|
||||||
port = 6697
|
port = 6697
|
||||||
username = "uberbot"
|
username = "uberbot"
|
||||||
channels = ["#main", "#no-normies"]
|
channels = ["#main", "#no-normies"]
|
||||||
mode = "+B"
|
mode = "+B"
|
||||||
|
|
||||||
# Spotify config
|
|
||||||
spotify_client_id = ""
|
|
||||||
spotify_client_secret = ""
|
|
||||||
|
|
||||||
# Bot config
|
|
||||||
prefix = "!"
|
prefix = "!"
|
||||||
|
|
||||||
# Web service config
|
[spotify]
|
||||||
http_listen = "127.0.0.1:8080"
|
spotify_client_id = ""
|
||||||
|
spotify_client_secret = ""
|
||||||
# Git webhook config
|
|
||||||
git_channel = "#main"
|
|
||||||
|
|
27
src/config.rs
Normal file
27
src/config.rs
Normal file
|
@ -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<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct SpotifyConfig {
|
||||||
|
pub spotify_client_id: String,
|
||||||
|
pub spotify_client_secret: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
pub struct IrcConfig {
|
||||||
|
pub channels: Vec<String>,
|
||||||
|
pub host: String,
|
||||||
|
pub tls: bool,
|
||||||
|
pub mode: Option<String>,
|
||||||
|
pub nickname: Option<String>,
|
||||||
|
pub port: u16,
|
||||||
|
pub username: String,
|
||||||
|
pub prefix: String,
|
||||||
|
}
|
20
src/main.rs
20
src/main.rs
|
@ -25,6 +25,8 @@ use crate::database::{DbExecutor, ExecutorConnection, Quote};
|
||||||
|
|
||||||
mod bots;
|
mod bots;
|
||||||
mod database;
|
mod database;
|
||||||
|
mod bot;
|
||||||
|
mod config;
|
||||||
|
|
||||||
// this will be displayed when the help command is used
|
// this will be displayed when the help command is used
|
||||||
const HELP: &[&str] = &[
|
const HELP: &[&str] = &[
|
||||||
|
@ -65,24 +67,6 @@ pub struct AppState {
|
||||||
db: ExecutorConnection,
|
db: ExecutorConnection,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
|
||||||
struct ClientConf {
|
|
||||||
channels: Vec<String>,
|
|
||||||
host: String,
|
|
||||||
tls: bool,
|
|
||||||
mode: Option<String>,
|
|
||||||
nickname: Option<String>,
|
|
||||||
port: u16,
|
|
||||||
username: String,
|
|
||||||
spotify_client_id: String,
|
|
||||||
spotify_client_secret: String,
|
|
||||||
prefix: String,
|
|
||||||
db_path: Option<String>,
|
|
||||||
// reserved for future
|
|
||||||
_http_listen: Option<SocketAddr>,
|
|
||||||
_git_channel: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
tracing_subscriber::fmt()
|
tracing_subscriber::fmt()
|
||||||
|
|
Loading…
Reference in a new issue