diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-07-30 10:40:03 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-07-30 10:40:03 -0400 |
| commit | 8b3c21be2f6c51e0e26e283d40439bb67fd1151c (patch) | |
| tree | 6c47737fb1ff922a883adce277d9739005b41214 /cmd | |
| parent | ef73e8be518293efddee401a7e0a01e72185605a (diff) | |
| download | x-8b3c21be2f6c51e0e26e283d40439bb67fd1151c.tar.xz x-8b3c21be2f6c51e0e26e283d40439bb67fd1151c.zip | |
various patches
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/robocadey2/main.go | 29 | ||||
| -rw-r--r-- | cmd/within.website/main.go | 2 | ||||
| -rw-r--r-- | cmd/within.website/tmpl/index.tmpl | 2 |
3 files changed, 15 insertions, 18 deletions
diff --git a/cmd/robocadey2/main.go b/cmd/robocadey2/main.go index cb1d841..432dbbb 100644 --- a/cmd/robocadey2/main.go +++ b/cmd/robocadey2/main.go @@ -17,12 +17,10 @@ import ( "time" "github.com/jaytaylor/html2text" + "golang.org/x/exp/slog" "tailscale.com/metrics" "tailscale.com/tsnet" "tailscale.com/tsweb" - "within.website/ln" - "within.website/ln/ex" - "within.website/ln/opname" "within.website/x/internal" "within.website/x/web/mastodon" "within.website/x/web/stablediffusion" @@ -63,12 +61,11 @@ func main() { os.MkdirAll(*dataDir, 0777) - ctx := opname.With(context.Background(), "main") rand.Seed(time.Now().Unix()) cli, err := mastodon.Authenticated("robocadey2", "https://within.website/.x.botinfo", *instance, *token) if err != nil { - ln.FatalErr(ctx, err) + log.Fatal(err) } expvar.Publish("gauge_robocadey_usage_by_user", &usageCount) @@ -81,15 +78,15 @@ func main() { } if err := srv.Start(); err != nil { - ln.FatalErr(ctx, err) + log.Fatal(err) } httpCli := srv.HTTPClient() if err != nil { - ln.FatalErr(ctx, err) + log.Fatal(err) } - ln.Log(ctx, ln.Info("waiting for messages")) + slog.Info("waiting for messages") b := &Bot{ cli: cli, @@ -99,21 +96,21 @@ func main() { go func() { lis, err := srv.Listen("tcp", ":80") if err != nil { - ln.FatalErr(ctx, err, ln.Action("tsnet listening")) + log.Fatalf("tsnet can't listen: %v", err) } http.DefaultServeMux.HandleFunc("/debug/varz", tsweb.VarzHandler) defer srv.Close() defer lis.Close() - ln.FatalErr(opname.With(ctx, "metrics-tsnet"), http.Serve(lis, ex.HTTPLog(http.DefaultServeMux))) + log.Fatal(http.Serve(lis, http.DefaultServeMux)) }() for { - ctx, cancel := context.WithCancel(ctx) + ctx, cancel := context.WithCancel(context.Background()) ch, err := cli.StreamMessages(ctx, mastodon.WSSubscribeRequest{Type: "subscribe", Stream: "user"}) if err != nil { - ln.FatalErr(ctx, err) + log.Fatal(err) } for msg := range ch { @@ -121,7 +118,7 @@ func main() { case "notification": var n mastodon.Notification if err := json.Unmarshal([]byte(msg.Payload), &n); err != nil { - ln.Error(ctx, err, ln.Info("can't parse notification")) + slog.Error("can't parse notification", "err", err) continue } @@ -130,7 +127,7 @@ func main() { } if err := b.handleNotification(n); err != nil { - ln.Error(ctx, err, ln.F{"content": n.Status.Content}) + slog.Error("can't handle notification", "err", err, "content", n.Status.Content) continue } } @@ -210,7 +207,7 @@ func (b *Bot) handleNotification(n mastodon.Notification) error { for tries != 0 { att, err = b.cli.UploadMedia(ctx, bytes.NewBuffer(imgs.Images[0]), "result.png", "prompt: "+text, "") if err != nil { - ln.Error(ctx, err, ln.F{"tries": tries}) + slog.Error("retrying", "err", err, "tries", tries) time.Sleep(time.Second) tries-- retries.Add(1) @@ -242,7 +239,7 @@ func (b *Bot) handleNotification(n mastodon.Notification) error { }); err != nil { return err } else { - ln.Log(ctx, ln.F{"url": st.URL, "responsible_party": n.Status.Account.Acct, "visibility": n.Status.Visibility}) + slog.Info("status created", "url", st.URL, "responsible_party", n.Status.Account.Acct, "visibility", n.Status.Visibility) } return nil diff --git a/cmd/within.website/main.go b/cmd/within.website/main.go index b87653d..1b782f6 100644 --- a/cmd/within.website/main.go +++ b/cmd/within.website/main.go @@ -26,7 +26,7 @@ var ( type Repo struct { Kind string `json:"kind"` Domain string `json:"domain"` - User string `json:"string"` + User string `json:"user"` Repo string `json:"repo"` Description string `json:"description"` } diff --git a/cmd/within.website/tmpl/index.tmpl b/cmd/within.website/tmpl/index.tmpl index d9ad01e..bc9da6b 100644 --- a/cmd/within.website/tmpl/index.tmpl +++ b/cmd/within.website/tmpl/index.tmpl @@ -11,7 +11,7 @@ This vanity domain houses a lot of <a href="https://xeiaso.net">Xe Iaso's</a> cu <img src="https://pride-badges.pony.workers.dev/static/v1?label=enbyware&labelColor=%23555&stripeWidth=8&stripeColors=FCF434%2CFFFFFF%2C9C59D1%2C2C2C2C" /> {{range .Repos}} -<h2>within.website/{{.Repo}}</h2> +<h2 id="{{.Repo}}">within.website/{{.Repo}}</h2> <p><a href="https://pkg.go.dev/within.website/{{.Repo}}"><img src="https://pkg.go.dev/badge/within.website/{{.Repo}}.svg" alt="Go Reference"></a> <a href="https://{{.Domain}}/{{.User}}/{{.Repo}}"><img alt="Source code link" src="https://img.shields.io/badge/source-link-green"></a></p> |
