#pragma once #include #include #include #include namespace Echoion::Core { // JSON structures for configuration (public for use by Core) struct BotConfigJson { std::string botName = "Echoion"; std::string commandPrefix = "!"; float defaultVolume = 0.5f; uint32_t maxQueueSize = 100; uint32_t trackTimeout = 30000; bool autoReconnect = true; uint32_t reconnectDelay = 5000; uint32_t maxReconnectAttempts = 5; std::string preferredQuality = "High"; bool allowPlaylistImports = true; }; struct YouTubeConfigJson { std::optional youtubeApiKey; std::optional youtubeCookiesPath; std::optional cookiesFromBrowser; uint32_t ytDlpMaxConcurrent = 4; bool ytDlpAsyncEnabled = true; bool enableUrlShortening = true; }; struct NetworkConfigJson { // Proxy settings (flat structure for backward compatibility) std::string proxyType = "HTTP"; std::optional proxyHost; std::optional proxyPort; std::optional proxyUsername; std::optional proxyPassword; // RPC settings bool rpcEnabled = true; uint16_t rpcPort = 8765; std::string rpcBindAddress = "127.0.0.1"; }; struct TeamSpeakConfigJson { std::string address = "localhost"; uint16_t port = 9987; std::string serverPassword = ""; std::string nickname = "EchoionBot"; std::optional defaultChannelId; std::optional channelPassword; std::vector adminGroups; std::vector djGroups; std::vector bannedGroups; }; struct SecurityConfigJson { bool requireAuthForAdmin = true; uint32_t maxLoginAttempts = 5; uint32_t lockoutDuration = 300000; uint32_t sessionTimeout = 3600000; bool enableAuditLog = true; std::optional apiKey; bool allowCors = false; std::vector corsOrigins; }; struct FeaturesConfigJson { bool enableHotReload = true; bool enableAutoReload = false; bool enableAutoUpdateCheck = true; bool autoStartOnSubscribe = true; bool pauseOnEmptySubscribers = true; bool resumeOnSubscriberReturn = true; std::string shuffleMode = "random"; std::string repeatMode = "off"; uint32_t maxHistorySize = 50; }; struct AdvancedConfigJson { uint32_t sampleRate = 192000; uint32_t channels = 2; uint32_t bufferSize = 7680; uint32_t commandThreadPoolSize = 4; uint32_t networkThreadPoolSize = 4; uint32_t decoderThreads = 2; bool cacheEnabled = true; std::string cacheMaxSize = "1GB"; uint32_t cacheTTL = 86400; uint32_t tempCleanupInterval = 3600; }; struct AppConfigJson { BotConfigJson bot; YouTubeConfigJson youtube; NetworkConfigJson network; TeamSpeakConfigJson teamspeak; SecurityConfigJson security; FeaturesConfigJson features; AdvancedConfigJson advanced; }; // Configuration loader for JSON config files (internal to Core) class ConfigLoader { public: // Load configuration from JSON file [[nodiscard]] static Api::Result loadFromFile(const std::filesystem::path& path); // Save configuration to JSON file [[nodiscard]] static Api::Result saveToFile(const std::filesystem::path& path, const Api::AppConfig& config); // Get default configuration path [[nodiscard]] static std::filesystem::path getDefaultConfigPath(); // Create default configuration [[nodiscard]] static Api::AppConfig createDefaultConfig(); // Parse quality string to enum [[nodiscard]] static Api::AudioQuality parseQuality(const std::string& str); [[nodiscard]] static std::string qualityToString(Api::AudioQuality quality); }; } // namespace Echoion::Core