8000 GitHub - jake-abed/bsgortp: A library for parsing rich text to create BlueSky FeedPosts in Go.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jake-abed/bsgortp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bsgortp - BlueSky Go Rich Text Parsing

Working on a ATProto project using Go and trying to create posts? It's kind of a drag, huh? Say hello to bsgortp! Now you can efficiently turn that little string into a full fledged *bsky.FeedPost with all the RichTextFacets correctly populated.

Installation

Getting started with bsgortp is very easy.

Prerequisites

  1. The Go toolchain
  2. Working knowledge of ATProto and BlueSky (optional?)

Inside of your project just run:

go get github.com/jake-abed/bsgortp

Now you can import github.com/jake-abed/bsgortp into any file you need!

Using bsgortp

Using bsgortp is comparably easy. Anywhere that you need a new bsky.FeedPost struct, you could do something like this:

post, err := bsgortp.GenPost(
    "Paging @jakeabed.dev... is this thing on? #test-post",
    []string{"en"},
)

If everything goes to plan, you'll get back the pointer to struct that looks like this:

bsky.FeedPost{
    LexiconTypeID: "app.bsky.feed.post",
	CreatedAt: "2025-03-11T04:20:00.156888Z",
	Facets []*RichtextFacet{ /* pointers to some RichtextFacets */ },
    Langs []string{"en"},
	Text "Paging @jakeabed.dev... is this thing on? #test-post",
}

The first Richtext Facet would look something like this:

// Keep in mind most of these this are actually pointers to structs, but you
// get the idea
bsky.RichtextFacet{
    Features: []*RichtextFacet_Features_Elem{
        *RichtextFacet_Features_Elem{
            RichtextFacet_Mention: *RichtextFacet_Mention{
                LexiconTypeID: "app.bsky.richtext.facet#mention",
                Did: "some_did_i_will_not_type",
            },
        },
        Index: *RichtextFacet_ByteSlice{
            ByteStart: 8,
            ByteEnd: 20,
        },
    },
}

To Do

  • Extend test coverage
  • Setup CI to run tests on merges to main
  • Add embed support possibly
  • Take in and modify/replace existing FeedPosts
  • Improve Regex where needed
  • Test & improve performance

Contributing

Please feel free to open up an issue. Please do not create pull requests without creatin an issue of some kind and discussing it first.

Eventually, CI will be setup to make sure all tests pass.

About

A library for parsing rich text to create BlueSky FeedPosts in Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0