Skip to content

Commit

Permalink
cmd/bikehfx-tweet,go.mod: bump indigo, link bsky hashtags
Browse files Browse the repository at this point in the history
  • Loading branch information
danp committed Apr 6, 2024
1 parent 4dff13f commit f037ffb
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 98 deletions.
20 changes: 20 additions & 0 deletions cmd/bikehfx-tweet/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"mime/multipart"
"net/http"
"os"
"regexp"
"sync"
"time"

Expand Down Expand Up @@ -362,12 +363,31 @@ func newBlueskyPoster(clientHost, handle, password string) (blueskyPoster, error
return blueskyPoster{client: xrpcc}, nil
}

var bskyHashtagRegex = regexp.MustCompile(`#[a-zA-Z0-9_]+`)

func (b blueskyPoster) post(ctx context.Context, p post) (string, error) {
post := &bsky.FeedPost{
CreatedAt: time.Now().Format(time.RFC3339),
Text: p.text,
}

for _, matches := range bskyHashtagRegex.FindAllIndex([]byte(p.text), -1) {
facet := &bsky.RichtextFacet{
Index: &bsky.RichtextFacet_ByteSlice{
ByteStart: int64(matches[0]),
ByteEnd: int64(matches[1]),
},
Features: []*bsky.RichtextFacet_Features_Elem{
{
RichtextFacet_Tag: &bsky.RichtextFacet_Tag{
Tag: p.text[matches[0]+1 : matches[1]], // +1 to skip the #
},
},
},
}
post.Facets = append(post.Facets, facet)
}

if p.inReplyTo != "" {
var ref atproto.RepoStrongRef
if err := json.Unmarshal([]byte(p.inReplyTo), &ref); err != nil {
Expand Down
57 changes: 33 additions & 24 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ module github.com/danp/bikehfx
go 1.22.0

require (
github.com/bluesky-social/indigo v0.0.0-20230830042519-9caaa233dc6b
github.com/bluesky-social/indigo v0.0.0-20240308030717-06c2c155d0ca
github.com/danp/counterbase v0.0.0-20240303171822-ec4a89e295ad
github.com/dghubble/oauth1 v0.7.2
github.com/dimchansky/utfbom v1.1.1
github.com/google/go-cmp v0.5.9
github.com/google/go-cmp v0.6.0
github.com/graxinc/errutil v0.0.0-20230615185726-b495a08a0537
github.com/hexops/gotextdiff v1.0.3
github.com/hexops/valast v1.4.4
github.com/mattn/go-mastodon v0.0.6
github.com/peterbourgon/ff/v3 v3.3.1
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/image v0.15.0
golang.org/x/text v0.14.0
gonum.org/v1/plot v0.14.0
Expand All @@ -23,53 +23,62 @@ require (
git.sr.ht/~sbinet/gg v0.5.0 // indirect
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect
github.com/campoy/embedmd v1.0.0 // indirect
github.com/carlmjohnson/versioninfo v0.22.5 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-fonts/liberation v0.3.1 // indirect
github.com/go-latex/latex v0.0.0-20230307184459-12ec69307ad9 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-pdf/fpdf v0.8.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-block-format v0.1.2 // indirect
github.com/ipfs/go-block-format v0.2.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipld-cbor v0.0.7-0.20230126201833-a73d038d90bc // indirect
github.com/ipfs/go-ipld-format v0.4.0 // indirect
github.com/ipfs/go-ipfs-blockstore v1.3.1 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.3 // indirect
github.com/ipfs/go-ipld-cbor v0.1.0 // indirect
github.com/ipfs/go-ipld-format v0.6.0 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-log/v2 v2.5.1 // indirect
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.3 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20230818171029-f91ae536ca25 // indirect
go.uber.org/atomic v1.10.0 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20240201211319-bf2168ca937c // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.20.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/tools v0.12.1-0.20230815132531-74c255bcf846 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
golang.org/x/tools v0.15.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
mvdan.cc/gofumpt v0.5.0 // indirect
rsc.io/pdf v0.1.1 // indirect
)
Loading

0 comments on commit f037ffb

Please sign in to comment.