The new logbot, not committed from the wrong terminal window this time.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
519 B

6 years ago
  1. package channels
  2. import (
  3. "context"
  4. "time"
  5. "git.aiterp.net/rpdata/logbot3/internal/models"
  6. )
  7. // SubscribeLogged returns a channel that gets all the channel changes.
  8. func SubscribeLogged(ctx context.Context) (<-chan models.Channel, error) {
  9. channels, err := ListLogged(ctx)
  10. if err != nil {
  11. return nil, err
  12. }
  13. output := make(chan models.Channel, len(channels)+8)
  14. for _, channel := range channels {
  15. output <- channel
  16. }
  17. go func() {
  18. for {
  19. time.Sleep(time.Second * 20)
  20. }
  21. }()
  22. return output, nil
  23. }