Skip to content

Commit 3a19584

Browse files
committed
Update: initial checkin
a little bluesky bot which uses larry
1 parent e2a9d85 commit 3a19584

File tree

7 files changed

+692
-0
lines changed

7 files changed

+692
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.envrc

cmd/bot/main.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"errors"
6+
"os"
7+
"time"
8+
9+
"log/slog"
10+
11+
bk "github.com/tailscale/go-bluesky"
12+
"github.com/till/golangoss-bluesky/internal/bluesky"
13+
"github.com/till/golangoss-bluesky/internal/content"
14+
)
15+
16+
var (
17+
blueskyHandle string = "[email protected]"
18+
blueskyAppKey string = ""
19+
20+
ctx context.Context
21+
)
22+
23+
func init() {
24+
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
25+
Level: slog.LevelDebug,
26+
})))
27+
28+
ctx = context.Background()
29+
30+
if _, status := os.LookupEnv("BLUESKY_APP_KEY"); !status {
31+
slog.ErrorContext(ctx, "no app key")
32+
os.Exit(1)
33+
}
34+
35+
blueskyAppKey = os.Getenv("BLUESKY_APP_KEY")
36+
}
37+
38+
func main() {
39+
client, err := bk.Dial(ctx, bk.ServerBskySocial)
40+
if err != nil {
41+
panic(err)
42+
}
43+
defer client.Close()
44+
45+
if err := client.Login(ctx, blueskyHandle, blueskyAppKey); err != nil {
46+
switch {
47+
case errors.Is(err, bk.ErrMasterCredentials):
48+
panic("You're not allowed to use your full-access credentials, please create an appkey")
49+
case errors.Is(err, bk.ErrLoginUnauthorized):
50+
panic("Username of application password seems incorrect, please double check")
51+
case err != nil:
52+
panic("Something else went wrong, please look at the returned error")
53+
}
54+
}
55+
56+
c := bluesky.Client{
57+
Client: client,
58+
}
59+
60+
if err := content.Start(); err != nil {
61+
panic(err)
62+
}
63+
64+
for {
65+
slog.DebugContext(ctx, "checking...")
66+
if err := content.Do(ctx, c); err != nil {
67+
slog.ErrorContext(ctx, err.Error())
68+
os.Exit(1)
69+
}
70+
71+
time.Sleep(5 * time.Minute)
72+
}
73+
}

go.mod

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
module github.com/till/golangoss-bluesky
2+
3+
go 1.23.0
4+
5+
require github.com/tailscale/go-bluesky v0.0.0-20241115170709-693553a07285
6+
7+
require (
8+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
9+
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
10+
github.com/go-redis/redis/v8 v8.11.5 // indirect
11+
github.com/golang/protobuf v1.5.3 // indirect
12+
github.com/google/go-github/v39 v39.2.0 // indirect
13+
github.com/google/go-querystring v1.1.0 // indirect
14+
golang.org/x/net v0.10.0 // indirect
15+
golang.org/x/oauth2 v0.8.0 // indirect
16+
google.golang.org/appengine v1.6.7 // indirect
17+
google.golang.org/protobuf v1.30.0 // indirect
18+
)
19+
20+
require (
21+
github.com/bluesky-social/indigo v0.0.0-20230504025040-8915cccc3319 // indirect
22+
github.com/btcsuite/btcd v0.0.0-20190824003749-130ea5bddde3 // indirect
23+
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
24+
github.com/ethereum/go-ethereum v1.9.3 // indirect
25+
github.com/ezeoleaf/larry v0.10.0
26+
github.com/gogo/protobuf v1.3.2 // indirect
27+
github.com/golang-jwt/jwt/v5 v5.0.0 // indirect
28+
github.com/google/uuid v1.3.0 // indirect
29+
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
30+
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
31+
github.com/hashicorp/golang-lru v0.5.4 // indirect
32+
github.com/ipfs/bbloom v0.0.4 // indirect
33+
github.com/ipfs/go-block-format v0.1.2 // indirect
34+
github.com/ipfs/go-cid v0.4.0 // indirect
35+
github.com/ipfs/go-datastore v0.6.0 // indirect
36+
github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect
37+
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
38+
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
39+
github.com/ipfs/go-ipld-cbor v0.0.7-0.20230126201833-a73d038d90bc // indirect
40+
github.com/ipfs/go-ipld-format v0.4.0 // indirect
41+
github.com/ipfs/go-log v1.0.5 // indirect
42+
github.com/ipfs/go-log/v2 v2.5.1 // indirect
43+
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
44+
github.com/jbenet/goprocess v0.1.4 // indirect
45+
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
46+
github.com/mattn/go-isatty v0.0.18 // indirect
47+
github.com/minio/sha256-simd v1.0.0 // indirect
48+
github.com/mr-tron/base58 v1.2.0 // indirect
49+
github.com/multiformats/go-base32 v0.1.0 // indirect
50+
github.com/multiformats/go-base36 v0.2.0 // indirect
51+
github.com/multiformats/go-multibase v0.2.0 // indirect
52+
github.com/multiformats/go-multihash v0.2.1 // indirect
53+
github.com/multiformats/go-varint v0.0.7 // indirect
54+
github.com/opentracing/opentracing-go v1.2.0 // indirect
55+
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect
56+
github.com/spaolacci/murmur3 v1.1.0 // indirect
57+
github.com/ureeves/jwt-go-secp256k1 v0.2.0 // indirect
58+
github.com/whyrusleeping/cbor-gen v0.0.0-20230331140348-1f892b517e70 // indirect
59+
go.uber.org/atomic v1.10.0 // indirect
60+
go.uber.org/multierr v1.11.0 // indirect
61+
go.uber.org/zap v1.24.0 // indirect
62+
golang.org/x/crypto v0.7.0 // indirect
63+
golang.org/x/sys v0.8.0 // indirect
64+
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
65+
lukechampine.com/blake3 v1.1.7 // indirect
66+
)

0 commit comments

Comments
 (0)