appservice.go 661 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package config
  2. type appservice struct {
  3. Address string `yaml:"address"`
  4. Hostname string `yaml:"hostname"`
  5. Port uint16 `yaml:"port"`
  6. ID string `yaml:"id"`
  7. Bot bot `yaml:"bot"`
  8. ASToken string `yaml:"as_token"`
  9. HSToken string `yaml:"hs_token"`
  10. }
  11. func (a *appservice) setDefaults() error {
  12. if a.ID == "" {
  13. a.ID = "discord"
  14. }
  15. if err := a.Bot.setDefaults(); err != nil {
  16. return err
  17. }
  18. return nil
  19. }
  20. func (a *appservice) UnmarshalYAML(unmarshal func(interface{}) error) error {
  21. type rawAppservice appservice
  22. raw := rawAppservice{}
  23. if err := unmarshal(&raw); err != nil {
  24. return err
  25. }
  26. *a = appservice(raw)
  27. return a.setDefaults()
  28. }