aboutsummaryrefslogtreecommitdiff
path: root/discord
diff options
context:
space:
mode:
authorChristine Dodrill <me@christine.website>2018-10-04 20:06:42 -0700
committerChristine Dodrill <me@christine.website>2018-10-04 20:06:53 -0700
commitdef885cab56da5d4808185fd1feb80ea57fc0cbb (patch)
tree7772d5cef5612cd8e5bb106478fdda0ebfc2a2ad /discord
parenta49a42f602e301fc7d4137d98b75248285fd81da (diff)
downloadx-def885cab56da5d4808185fd1feb80ea57fc0cbb.tar.xz
x-def885cab56da5d4808185fd1feb80ea57fc0cbb.zip
web/switchcounter: use a new-style go api
Diffstat (limited to 'discord')
-rw-r--r--discord/ilo-kesi/parse.go21
1 files changed, 18 insertions, 3 deletions
diff --git a/discord/ilo-kesi/parse.go b/discord/ilo-kesi/parse.go
index ec83f1f..f2e8bd5 100644
--- a/discord/ilo-kesi/parse.go
+++ b/discord/ilo-kesi/parse.go
@@ -2,11 +2,13 @@ package main
import (
"bytes"
- "context"
+ "encoding/json"
"errors"
"fmt"
+ "net/http"
"time"
+ "github.com/Xe/x/web/switchcounter"
"github.com/Xe/x/web/tokiponatokens"
)
@@ -45,7 +47,16 @@ func (i ilo) parse(authorID, inp string) (*reply, error) {
switch req.Action {
case actionFront:
if req.Subject == actionWhat {
- st, err := i.sw.Status(context.Background())
+ req := i.sw.Status()
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ return nil, err
+ }
+ if resp.StatusCode/100 != 2 {
+ return nil, errors.New(resp.Status)
+ }
+ var st switchcounter.Status
+ err = json.NewDecoder(resp.Body).Decode(&st)
if err != nil {
return nil, err
}
@@ -61,10 +72,14 @@ func (i ilo) parse(authorID, inp string) (*reply, error) {
front := tokiToWithin[req.Subject]
- _, err := i.sw.Switch(context.Background(), front)
+ hreq := i.sw.Switch(front)
+ resp, err := http.DefaultClient.Do(hreq)
if err != nil {
return nil, err
}
+ if resp.StatusCode/100 != 2 {
+ return nil, errors.New(resp.Status)
+ }
fmt.Fprintf(buf, "tenpo ni la jan %s li lawa insa.\n", req.Subject)
goto ok