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.

40 lines
710 B

6 years ago
  1. package channels
  2. import (
  3. "context"
  4. "encoding/json"
  5. "git.aiterp.net/rpdata/logbot3/internal/api"
  6. "git.aiterp.net/rpdata/logbot3/internal/models"
  7. )
  8. type listLoggedResult struct {
  9. Channels []models.Channel `json:"channels"`
  10. }
  11. var listLoggedGQL = `
  12. query ListLogged {
  13. channels(filter: {logged: true}) {
  14. name
  15. logged
  16. eventName
  17. locationName
  18. }
  19. }
  20. `
  21. // ListLogged gets all open channels
  22. func ListLogged(ctx context.Context) ([]models.Channel, error) {
  23. data, err := api.Global().Query(ctx, listLoggedGQL, nil, nil)
  24. if err != nil {
  25. return nil, err
  26. }
  27. result := listLoggedResult{}
  28. err = json.Unmarshal(data, &result)
  29. if err != nil {
  30. return nil, err
  31. }
  32. return result.Channels, nil
  33. }