general.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package config
  2. import (
  3. "os"
  4. "runtime"
  5. )
  6. type IdentifyConfig struct {
  7. Os string `toml:"os"`
  8. Browser string `toml:"browser"`
  9. }
  10. type GeneralConfig struct {
  11. UserAgent string `toml:"user_agent"`
  12. FetchMessagesLimit int `toml:"fetch_messages_limit"`
  13. Mouse bool `toml:"mouse"`
  14. Timestamps bool `toml:"timestamps"`
  15. Identify IdentifyConfig `toml:"identify"`
  16. AttachmentDownloadsDir string `toml:"attachment_downloads_dir"`
  17. }
  18. func newGeneralConfig() GeneralConfig {
  19. return GeneralConfig{
  20. UserAgent: "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0",
  21. FetchMessagesLimit: 50,
  22. Mouse: true,
  23. Timestamps: false,
  24. AttachmentDownloadsDir: UserDownloadsDir(),
  25. Identify: IdentifyConfig{
  26. Os: "Linux",
  27. Browser: "Firefox",
  28. },
  29. }
  30. }
  31. func UserDownloadsDir() string {
  32. // We try to set the download folder location to the default Downloads folder
  33. var dlloc string
  34. if runtime.GOOS == "windows" {
  35. h, _ := os.UserHomeDir()
  36. dlloc = h + "\\Downloads"
  37. } else if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
  38. h, _ := os.UserHomeDir()
  39. dlloc = h + "/Downloads"
  40. } else {
  41. dlloc = os.TempDir() // Very lame fallback, I know
  42. }
  43. return dlloc
  44. }