bot: Bot setup and teardown done: Connect w/retry, join/leave, full config, and logging.

This commit is contained in:
2018-11-14 21:01:29 +01:00
parent 112c29694d
commit 7336ea2b47
9 changed files with 236 additions and 76 deletions
+61
View File
@@ -0,0 +1,61 @@
package changes
import (
"context"
"encoding/json"
"time"
"git.aiterp.net/rpdata/logbot3/internal/api"
"git.aiterp.net/rpdata/logbot3/internal/models"
)
// The Filter for List.
type Filter struct {
Keys []models.ChangeKey `json:"keys,omitempty"`
EarliestDate *time.Time `json:"earliestDate,omitempty"`
Limit int `json:"limit,omitempty"`
}
// List lists all changes according to the filter.
func List(ctx context.Context, filter *Filter) ([]models.Change, error) {
data, err := api.Global().Query(ctx, listGQL, map[string]interface{}{"filter": filter}, nil)
if err != nil {
return nil, err
}
res := listResult{}
err = json.Unmarshal(data, &res)
return res.Changes, err
}
type listResult struct {
Changes []models.Change `json:"changes"`
}
var listGQL = `
query ListChanges($filter:ChangesFilter) {
changes(filter:$filter) {
id
model
op
author
listed
date
keys {
model
id
}
objects {
__typename
...on Channel {
name
logged
hub
eventName
locationName
}
}
}
}
`