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
745 B

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
}