# Configuration System ## Overview Echoion uses a unified JSON-based configuration shared between all components. The configuration is stored in a platform-specific location and can be reloaded at runtime without restart. ## Configuration File Location | Platform | Path | |----------|------| | Linux | `~/.config/echoion/config.json` | | macOS | `~/Library/Application Support/echoion/config.json` | | Windows | `%APPDATA%/echoion/config.json` | ## Configuration Architecture ```mermaid flowchart TB subgraph "Configuration System" CM[ConfigManager
Singleton] subgraph "Sources" File[Config File
JSON] Env[Environment
Variables] Default[Default
Values] end subgraph "Consumers" Core[EchoionCore] Plugin[EchoionPlugin] Desktop[EchoionDesktop] end end File -->|Load| CM Env -->|Override| CM Default -->|Fallback| CM CM -->|Get Config| Core CM -->|Get Config| Plugin CM -->|Get Config| Desktop CM -->|Notify| Core CM -->|Notify| Plugin ``` ## Configuration Structure ```mermaid classDiagram class AppConfig { +BotConfig bot +ServerConfig server +SecurityConfig security } class BotConfig { +string commandPrefix +float defaultVolume +bool autoReconnect +int maxQueueSize +string preferredQuality } class ServerConfig { +string address +int port +string nickname +int[] adminGroups +int[] djGroups } class SecurityConfig { +bool requireAuthForAdmin +int maxLoginAttempts +int lockoutDuration +bool enableAuditLog } AppConfig --> BotConfig AppConfig --> ServerConfig AppConfig --> SecurityConfig ``` ## Configuration Sections ### Bot Configuration Controls bot behavior and music playback: | Field | Description | Default | |-------|-------------|---------| | `commandPrefix` | Prefix for chat commands | `!` | | `defaultVolume` | Initial playback volume (0.0-1.0) | `0.5` | | `autoReconnect` | Reconnect on disconnect | `true` | | `maxQueueSize` | Maximum tracks in queue | `100` | | `preferredQuality` | Audio quality preference | `High` | ### Server Configuration TeamSpeak server connection settings: | Field | Description | Default | |-------|-------------|---------| | `address` | Server hostname or IP | `localhost` | | `port` | Server port | `9987` | | `nickname` | Bot display name | `EchoionBot` | | `adminGroups` | Server group IDs with admin rights | `[6, 7]` | | `djGroups` | Server group IDs with DJ rights | `[8]` | ### Security Configuration Authentication and protection settings: | Field | Description | Default | |-------|-------------|---------| | `requireAuthForAdmin` | Require password for admin commands | `true` | | `maxLoginAttempts` | Failed attempts before lockout | `5` | | `lockoutDuration` | Lockout time in milliseconds | `300000` (5 min) | | `sessionTimeout` | Session expiration in milliseconds | `3600000` (1 hour) | ## Access Pattern ```mermaid flowchart LR Request[Config Request] --> CM[ConfigManager] CM --> Check{Cached?} Check -->|Yes| Return[Return Config] Check -->|No| Load[Load from Disk] Load --> Parse[Parse JSON] Parse --> Validate[Validate Values] Validate --> Cache[Cache Config] Cache --> Return Return --> Use[Use Values] ``` ## Configuration Reload ```mermaid sequenceDiagram participant User participant CM as ConfigManager participant File as Config File participant Core participant Plugin User->>CM: Trigger reload CM->>File: Read config.json File-->>CM: JSON content CM->>CM: Parse & validate CM->>CM: Update cache CM->>Core: onConfigChanged event CM->>Plugin: onConfigChanged event Core->>Core: Apply new settings Plugin->>Plugin: Apply new settings CM-->>User: Reload success ``` ### Reload Triggers ```mermaid flowchart TB subgraph "Reload Triggers" Chat["Chat Command
!reloadconfig"] Menu["TS Menu
Right-click → Reload"] Code["Programmatic
reload()"] Auto["File Watcher
Auto-detect changes"] end Chat --> CM[ConfigManager] Menu --> CM Code --> CM Auto --> CM CM --> Reload[Reload Config] Reload --> Notify[Notify Subscribers] ``` ## Permission Groups ### Group Hierarchy ```mermaid flowchart TB subgraph "Permission Groups" Admin[Admin Groups
Full Control] DJ[DJ Groups
Queue Management] User[Regular Users
Basic Commands] Banned[Banned Groups
No Access] end Admin --> DJ DJ --> User Banned -.->|Blocked| User ``` ### Permission Matrix | Capability | Admin | DJ | User | Banned | |------------|-------|-----|------|--------| | Play/Pause | ✓ | ✓ | ✓ | ✗ | | Skip Track | ✓ | ✓ | ✓ | ✗ | | Queue Management | ✓ | ✓ | ✗ | ✗ | | Volume Control | ✓ | ✓ | ✓ | ✗ | | Reload Core | ✓ | ✗ | ✗ | ✗ | | Reload Config | ✓ | ✗ | ✗ | ✗ | ## YouTube Authentication For accessing age-restricted or region-blocked content: ```mermaid flowchart LR subgraph "Authentication Methods" Cookies[Cookie File
cookies.txt] Browser[Browser Cookies
chrome/firefox/edge] ApiKey[YouTube API Key
Optional] end Cookies --> YT[YouTube Access] Browser --> YT ApiKey -.->|Alternative| YT ``` | Method | Use Case | |--------|----------| | **Cookie File** | Export cookies from browser to file | | **Browser** | Directly use browser's cookies | | **API Key** | Higher rate limits (optional) | ## Proxy Configuration ```mermaid flowchart LR Bot[Echoion Bot] --> Proxy{Proxy?} Proxy -->|Yes| HTTP[HTTP Proxy] Proxy -->|Yes| SOCKS[SOCKS5 Proxy] Proxy -->|No| Direct[Direct Connection] HTTP --> YouTube SOCKS --> YouTube Direct --> YouTube ``` ## Configuration Lifecycle ```mermaid stateDiagram-v2 [*] --> Default: First start [*] --> Loading: Config exists Default --> Create: Create default Create --> Save: Write to disk Loading --> Validate: Parse JSON Validate --> Active: Valid Validate --> Error: Invalid Error --> Default: Use defaults Active --> Reload: Trigger reload Reload --> Validate: Re-parse Active --> [*]: Shutdown ``` ## Environment Overrides | Variable | Overrides | |----------|-----------| | `ECHOION_CONFIG_PATH` | Config file location | | `ECHOION_RPC_PORT` | RPC server port | | `ECHOION_LOG_LEVEL` | Logging verbosity | ## Validation Flow ```mermaid flowchart TB Load[Load Config] --> Required{Required
Fields?} Required -->|Missing| Error1[Error: Missing Field] Required -->|OK| Range{Value
Ranges?} Range -->|Invalid| Error2[Error: Out of Range] Range -->|OK| Type{Correct
Types?} Type -->|Invalid| Error3[Error: Type Mismatch] Type -->|OK| Success[Config Valid] Error1 --> Backup[Restore from Backup] Error2 --> Backup Error3 --> Backup ```