From 5a0d5e2aa1db122ca502e47a13d09bd9115958df Mon Sep 17 00:00:00 2001 From: ayn2op Date: Mon, 9 Jan 2023 18:48:55 +0530 Subject: [PATCH] Revert previous commit --- config/config.go => config.go | 62 ++++++++++++++++++++++++++++++++--- config/keys.go | 30 ----------------- config/theme.go | 26 --------------- main.go | 11 +++---- state.go | 5 ++- 5 files changed, 65 insertions(+), 69 deletions(-) rename config/config.go => config.go (55%) delete mode 100644 config/keys.go delete mode 100644 config/theme.go diff --git a/config/config.go b/config.go similarity index 55% rename from config/config.go rename to config.go index c9c1348..57bb153 100644 --- a/config/config.go +++ b/config.go @@ -1,4 +1,4 @@ -package config +package main import ( "os" @@ -7,7 +7,61 @@ import ( "gopkg.in/yaml.v3" ) -const Name = "discordo" +const name = "discordo" + +type ( + MessagesTextKeysConfig struct { + CopyContent string `yaml:"copy_content"` + + Reply string `yaml:"reply"` + ReplyMention string `yaml:"reply_mention"` + SelectReply string `yaml:"select_reply"` + + SelectPrevious string `yaml:"select_previous"` + SelectNext string `yaml:"select_next"` + SelectFirst string `yaml:"select_first"` + SelectLast string `yaml:"select_last"` + } + + MessageInputKeysConfig struct { + Send string `yaml:"send"` + Paste string `yaml:"paste"` + + LaunchEditor string `yaml:"launch_editor"` + } + + KeysConfig struct { + Cancel string `yaml:"cancel"` + + MessagesText MessagesTextKeysConfig `yaml:"messages_text"` + MessageInput MessageInputKeysConfig `yaml:"message_input"` + } +) + +type ( + GuildsTreeThemeConfig struct { + Graphics bool `yaml:"graphics"` + } + + MessagesTextThemeConfig struct { + AuthorColor string `yaml:"author_color"` + } + + MessageInputThemeConfig struct{} + + ThemeConfig struct { + Border bool `yaml:"border"` + BorderColor string `yaml:"border_color"` + BorderPadding [4]int `yaml:"border_padding,flow"` + + TitleColor string `yaml:"title_color"` + BackgroundColor string `yaml:"background_color"` + + GuildsTree GuildsTreeThemeConfig `yaml:"guilds_tree"` + MessagesText MessagesTextThemeConfig `yaml:"messages_text"` + MessageInput MessageInputThemeConfig `yaml:"message_input"` + } +) type Config struct { Mouse bool `yaml:"mouse"` @@ -19,13 +73,13 @@ type Config struct { Theme ThemeConfig `yaml:"theme"` } -func New() (*Config, error) { +func newConfig() (*Config, error) { path, err := os.UserConfigDir() if err != nil { return nil, err } - path = filepath.Join(path, Name) + path = filepath.Join(path, name) err = os.MkdirAll(path, os.ModePerm) if err != nil { return nil, err diff --git a/config/keys.go b/config/keys.go deleted file mode 100644 index 42c0ae7..0000000 --- a/config/keys.go +++ /dev/null @@ -1,30 +0,0 @@ -package config - -type ( - MessagesTextKeysConfig struct { - CopyContent string `yaml:"copy_content"` - - Reply string `yaml:"reply"` - ReplyMention string `yaml:"reply_mention"` - SelectReply string `yaml:"select_reply"` - - SelectPrevious string `yaml:"select_previous"` - SelectNext string `yaml:"select_next"` - SelectFirst string `yaml:"select_first"` - SelectLast string `yaml:"select_last"` - } - - MessageInputKeysConfig struct { - Send string `yaml:"send"` - Paste string `yaml:"paste"` - - LaunchEditor string `yaml:"launch_editor"` - } - - KeysConfig struct { - Cancel string `yaml:"cancel"` - - MessagesText MessagesTextKeysConfig `yaml:"messages_text"` - MessageInput MessageInputKeysConfig `yaml:"message_input"` - } -) diff --git a/config/theme.go b/config/theme.go deleted file mode 100644 index bee8573..0000000 --- a/config/theme.go +++ /dev/null @@ -1,26 +0,0 @@ -package config - -type ( - GuildsTreeThemeConfig struct { - Graphics bool `yaml:"graphics"` - } - - MessagesTextThemeConfig struct { - AuthorColor string `yaml:"author_color"` - } - - MessageInputThemeConfig struct{} - - ThemeConfig struct { - Border bool `yaml:"border"` - BorderColor string `yaml:"border_color"` - BorderPadding [4]int `yaml:"border_padding,flow"` - - TitleColor string `yaml:"title_color"` - BackgroundColor string `yaml:"background_color"` - - GuildsTree GuildsTreeThemeConfig `yaml:"guilds_tree"` - MessagesText MessagesTextThemeConfig `yaml:"messages_text"` - MessageInput MessageInputThemeConfig `yaml:"message_input"` - } -) diff --git a/main.go b/main.go index f1436a9..085c23a 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,6 @@ import ( "os" "path/filepath" - "github.com/ayn2op/discordo/config" "github.com/rivo/tview" "github.com/zalando/go-keyring" ) @@ -15,7 +14,7 @@ import ( var ( token string - cfg *config.Config + cfg *Config discordState *State app = tview.NewApplication() @@ -34,7 +33,7 @@ func init() { log.Fatal(err) } - path = filepath.Join(path, config.Name) + path = filepath.Join(path, name) err = os.MkdirAll(path, os.ModePerm) if err != nil { log.Fatal(err) @@ -56,16 +55,16 @@ func main() { var err error // If the token is passed via the flag, set it in the keyring. if token != "" { - go keyring.Set(config.Name, "token", token) + go keyring.Set(name, "token", token) } else { - token, err = keyring.Get(config.Name, "token") + token, err = keyring.Get(name, "token") if err != nil { log.Println(err) return } } - cfg, err = config.New() + cfg, err = newConfig() if err != nil { log.Fatal(err) } diff --git a/state.go b/state.go index adbec3a..509a39c 100644 --- a/state.go +++ b/state.go @@ -5,7 +5,6 @@ import ( "log" "runtime" - "github.com/ayn2op/discordo/config" "github.com/diamondburned/arikawa/v3/api" "github.com/diamondburned/arikawa/v3/gateway" "github.com/diamondburned/arikawa/v3/state" @@ -13,10 +12,10 @@ import ( ) func init() { - api.UserAgent = fmt.Sprintf("%s/%s %s/%s", config.Name, "0.1", "arikawa", "v3") + api.UserAgent = fmt.Sprintf("%s/%s %s/%s", name, "0.1", "arikawa", "v3") gateway.DefaultIdentity = gateway.IdentifyProperties{ OS: runtime.GOOS, - Browser: config.Name, + Browser: name, Device: "", } }