discordo/config/general.go
KodiCraft 7ef0f71b7b
feat: implement keybindings for opening and downloading attachments (#137)
* Added support for opening or downloading attachments

* Removed some debug statements

* Added close statements I forgot

* Added gitignore to ignore built executables

* Removed executables I accidentally added

* Fixed opening files not working on Windows

* Updated .gitignore to ignore .vscode

Co-authored-by: ayntgl <90600421+ayntgl@users.noreply.github.com>

* Deleted launch.json that doesn't need to be included

* Implemented suggestions on #137

Co-authored-by: ayntgl <90600421+ayntgl@users.noreply.github.com>
2022-03-13 22:22:10 +04:00

50 lines
1.3 KiB
Go

package config
import (
"os"
"runtime"
)
type IdentifyConfig struct {
Os string `toml:"os"`
Browser string `toml:"browser"`
}
type GeneralConfig struct {
UserAgent string `toml:"user_agent"`
FetchMessagesLimit int `toml:"fetch_messages_limit"`
Mouse bool `toml:"mouse"`
Timestamps bool `toml:"timestamps"`
Identify IdentifyConfig `toml:"identify"`
AttachmentDownloadsDir string `toml:"attachment_downloads_dir"`
}
func newGeneralConfig() GeneralConfig {
return GeneralConfig{
UserAgent: "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0",
FetchMessagesLimit: 50,
Mouse: true,
Timestamps: false,
AttachmentDownloadsDir: UserDownloadsDir(),
Identify: IdentifyConfig{
Os: "Linux",
Browser: "Firefox",
},
}
}
func UserDownloadsDir() string {
// We try to set the download folder location to the default Downloads folder
var dlloc string
if runtime.GOOS == "windows" {
h, _ := os.UserHomeDir()
dlloc = h + "\\Downloads"
} else if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
h, _ := os.UserHomeDir()
dlloc = h + "/Downloads"
} else {
dlloc = os.TempDir() // Very lame fallback, I know
}
return dlloc
}