registration.go 624 B

123456789101112131415161718192021222324252627282930313233
  1. package config
  2. import (
  3. "fmt"
  4. "regexp"
  5. as "maunium.net/go/mautrix/appservice"
  6. )
  7. func (cfg *Config) CopyToRegistration(registration *as.Registration) error {
  8. registration.ID = cfg.Appservice.ID
  9. registration.URL = cfg.Appservice.Address
  10. falseVal := false
  11. registration.RateLimited = &falseVal
  12. registration.SenderLocalpart = cfg.Appservice.Bot.Username
  13. pattern := fmt.Sprintf(
  14. "^@%s:%s$",
  15. cfg.Bridge.FormatUsername("[0-9]+"),
  16. cfg.Homeserver.Domain,
  17. )
  18. userIDRegex, err := regexp.Compile(pattern)
  19. if err != nil {
  20. return err
  21. }
  22. registration.Namespaces.RegisterUserIDs(userIDRegex, true)
  23. return nil
  24. }