main.go 643 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package main
  2. import (
  3. "os"
  4. "github.com/ayntgl/discordo/ui"
  5. "github.com/zalando/go-keyring"
  6. )
  7. func main() {
  8. app := ui.NewApp()
  9. app.Config.Load()
  10. token := os.Getenv("DISCORDO_TOKEN")
  11. if token == "" {
  12. token, _ = keyring.Get("discordo", "token")
  13. }
  14. if token != "" {
  15. err := app.Connect(token)
  16. if err != nil {
  17. panic(err)
  18. }
  19. app.
  20. SetRoot(ui.NewMainFlex(app), true).
  21. SetFocus(app.GuildsList)
  22. } else {
  23. ui.NewLoginForm(app, func() {
  24. ui.OnLoginFormLoginButtonSelected(app)
  25. }, false)
  26. app.SetRoot(app.LoginForm, true)
  27. }
  28. if err := app.EnableMouse(app.Config.General.Mouse).Run(); err != nil {
  29. panic(err)
  30. }
  31. }