use std::path::PathBuf; use clap::Parser; #[derive(Clone, Parser, Debug)] pub struct ServerConfig { /// Server's host. #[arg( name = "server-host", long, default_value = "0.0.0.0", env = "BOT_SERVER_HOST" )] /// Port that server is listening to. pub host: String, #[arg( name = "server-port", long, default_value = "8000", env = "BOT_SERVER_PORT" )] pub port: u16, /// This password is used to authenticate /// along with telegram code. #[arg( name = "server-pass", long, default_value = "pass", env = "BOT_SERVER_PASS" )] pub server_pass: String, /// This name is displayed on password page. #[arg( name = "server-username", long, default_value = "s3rius_san", env = "BOT_SERVER_USERNAME" )] pub username: String, #[arg( name = "server-static-dir", long, default_value = "static", env = "BOT_SERVER_STATIC_DIR" )] pub static_dir: PathBuf, } #[derive(Clone, Parser, Debug)] pub struct BotConfig { /// Telegram APP id. How to get it: https://core.telegram.org/api/obtaining_api_id #[arg(name = "bot-app-id", long, env = "BOT_APP_ID")] pub app_id: i32, /// Telegram API hash. #[arg(name = "bot-api-hash", long, env = "BOT_API_HASH")] pub api_hash: String, /// Your account's phone. #[arg(name = "bot-phone", long, env = "BOT_ACCOUNT_PHONE")] pub phone: String, /// Password for two-factor authentication. #[arg(name = "bot-tfa", long, env = "BOT_TFA_PASSWORD")] pub tfa_password: Option, /// Name of a file to save session to. #[arg( name = "bot-session-file", long, default_value = "saved.session", env = "BOT_SESSION_FILE" )] pub session_file: String, #[arg( name = "bot-excluded-chats", long, env = "BOT_EXCLUDED_CHATS", value_delimiter = ',' )] pub excluded_chats: Vec, #[arg( name = "bot-currency-excluded-chats", long, env = "BOT_CURRENCY_EXCLUDED_CHATS", value_delimiter = ',' )] pub currency_excluded_chats: Vec, } #[derive(Clone, Parser, Debug)] #[command(author, version, about)] pub struct Arguments { /// Application log level. #[arg(long, default_value = "INFO", env = "BOT_LOG_LEVEL")] pub log_level: log::LevelFilter, #[command(flatten)] pub server: ServerConfig, #[command(flatten)] pub bot: BotConfig, }