refactor(config): move common fields into single table
This commit is contained in:
parent
9c0e2bd1d7
commit
b395d938c4
2 changed files with 31 additions and 24 deletions
10
cmd/state.go
10
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{
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue