diff --git a/cmd/state.go b/cmd/state.go index eaf3582..dd79501 100644 --- a/cmd/state.go +++ b/cmd/state.go @@ -20,18 +20,18 @@ type State struct { } func openState(token string) error { - api.UserAgent = app.cfg.UserAgent + api.UserAgent = app.cfg.Identify.UserAgent gateway.DefaultIdentity = gateway.IdentifyProperties{ OS: runtime.GOOS, Device: "", - Browser: app.cfg.Browser, - BrowserVersion: app.cfg.BrowserVersion, - BrowserUserAgent: app.cfg.UserAgent, + Browser: app.cfg.Identify.Browser, + BrowserVersion: app.cfg.Identify.BrowserVersion, + BrowserUserAgent: app.cfg.Identify.UserAgent, } gateway.DefaultPresence = &gateway.UpdatePresenceCommand{ - Status: app.cfg.Status, + Status: app.cfg.Identify.Status, } discordState = &State{ diff --git a/internal/config/config.go b/internal/config/config.go index 9fcef03..3b6d82c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -13,25 +13,30 @@ import ( const fileName = "config.toml" -type Config struct { - Mouse bool `toml:"mouse"` - Editor string `toml:"editor"` +type ( + Identify struct { + Status discord.Status `toml:"status"` + Browser string `toml:"browser"` + BrowserVersion string `toml:"browser_version"` + UserAgent string `toml:"user_agent"` + } - HideBlockedUsers bool `toml:"hide_blocked_users"` - ShowAttachmentLinks bool `toml:"show_attachment_links"` - MessagesLimit uint8 `toml:"messages_limit"` + Config struct { + Mouse bool `toml:"mouse"` + Editor string `toml:"editor"` - Timestamps bool `toml:"timestamps"` - TimestampsFormat string `toml:"timestamps_format"` + HideBlockedUsers bool `toml:"hide_blocked_users"` + ShowAttachmentLinks bool `toml:"show_attachment_links"` + MessagesLimit uint8 `toml:"messages_limit"` - Status discord.Status `toml:"status"` - Browser string `toml:"browser"` - BrowserVersion string `toml:"browser_version"` - UserAgent string `toml:"user_agent"` + Timestamps bool `toml:"timestamps"` + TimestampsFormat string `toml:"timestamps_format"` - Keys Keys `toml:"keys"` - Theme Theme `toml:"theme"` -} + Identify Identify `toml:"identify"` + Keys Keys `toml:"keys"` + Theme Theme `toml:"theme"` + } +) func defaultConfig() *Config { return &Config{ @@ -45,10 +50,12 @@ func defaultConfig() *Config { Timestamps: false, TimestampsFormat: time.Kitchen, - Status: discord.OnlineStatus, - Browser: consts.Browser, - BrowserVersion: consts.BrowserVersion, - UserAgent: consts.UserAgent, + Identify: Identify{ + Status: discord.OnlineStatus, + Browser: consts.Browser, + BrowserVersion: consts.BrowserVersion, + UserAgent: consts.UserAgent, + }, Keys: defaultKeys(), Theme: defaultTheme(),