package channels import ( "context" "encoding/json" "git.aiterp.net/rpdata/logbot3/internal/api" "git.aiterp.net/rpdata/logbot3/internal/models" ) type findResult struct { Channel models.Channel `json:"channel"` } var findGQL = ` query FindChannel($name: String!) { channel(name: $name) { name logged eventName locationName } } ` // Find finds a channel by name func Find(ctx context.Context, name string) (models.Channel, error) { data, err := api.Global().Query(ctx, findGQL, map[string]interface{}{"name": name}, nil) if err != nil { return models.Channel{}, err } result := findResult{} err = json.Unmarshal(data, &result) if err != nil { return models.Channel{}, err } return result.Channel, nil }