add files
This commit is contained in:
commit
04e29ed525
7 changed files with 1337 additions and 0 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.env
|
||||
*.json
|
||||
*_test.go
|
227
bsky/bluesky.go
Normal file
227
bsky/bluesky.go
Normal file
|
@ -0,0 +1,227 @@
|
|||
package bsky
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/dghubble/sling"
|
||||
)
|
||||
|
||||
type BlueskyConfig struct {
|
||||
PDSURL string `json:"pds-url"`
|
||||
Repo string `json:"repo"`
|
||||
Handle string `json:"handle"`
|
||||
DID string `json:"did"`
|
||||
AppPassword string `json:"app-password"`
|
||||
AccessJWT string `json:"access-jwt"`
|
||||
RefreshJWT string `json:"refresh-jwt"`
|
||||
Cursor int64 `json:"cursor"`
|
||||
}
|
||||
|
||||
type DIDResponse struct {
|
||||
Context []string `json:"@context"`
|
||||
ID string `json:"id"`
|
||||
AlsoKnownAs []string `json:"alsoKnownAs"`
|
||||
VerificationMethod []struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
Controller string `json:"controller"`
|
||||
PublicKeyMultibase string `json:"publicKeyMultibase"`
|
||||
} `json:"verificationMethod"`
|
||||
Service []struct {
|
||||
ID string `json:"id"`
|
||||
Type string `json:"type"`
|
||||
ServiceEndpoint string `json:"serviceEndpoint"`
|
||||
} `json:"service"`
|
||||
}
|
||||
|
||||
type BSkySessionResponse struct {
|
||||
AccessJWT string `json:"accessJwt,omitempty"`
|
||||
RefreshJWT string `json:"refreshJwt,omitempty"`
|
||||
Handle string `json:"handle"`
|
||||
DID string `json:"did"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
type CommitResponse struct {
|
||||
URI string `json:"uri"`
|
||||
Cid string `json:"cid"`
|
||||
Commit struct {
|
||||
Cid string `json:"cid"`
|
||||
Rev string `json:"rev"`
|
||||
} `json:"commit"`
|
||||
Error string `json:"error"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (c *CommitResponse) GetRKey() string {
|
||||
s := strings.SplitN(c.URI, "/", 5)
|
||||
if len(s) == 5 {
|
||||
return s[4]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type Link struct {
|
||||
Cid string `json:"cid"`
|
||||
URI string `json:"uri"`
|
||||
}
|
||||
|
||||
type Bluesky struct {
|
||||
Cfg *BlueskyConfig
|
||||
HttpClient *http.Client
|
||||
Logger *log.Logger
|
||||
sling *sling.Sling
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) CreateSession(cfg *BlueskyConfig) error {
|
||||
body := struct {
|
||||
Identifier string `json:"identifier"`
|
||||
Password string `json:"password"`
|
||||
}{
|
||||
Identifier: cfg.Handle,
|
||||
Password: cfg.AppPassword,
|
||||
}
|
||||
resp := new(BSkySessionResponse)
|
||||
|
||||
bluesky.sling.New().Post("/xrpc/com.atproto.server.createSession").BodyJSON(body).ReceiveSuccess(resp)
|
||||
if resp.AccessJWT != "" {
|
||||
cfg.AccessJWT = resp.AccessJWT
|
||||
cfg.RefreshJWT = resp.RefreshJWT
|
||||
return nil
|
||||
}
|
||||
|
||||
bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT))
|
||||
return errors.New("unable to authenticate, check handle/password")
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) RefreshSession() error {
|
||||
resp := new(BSkySessionResponse)
|
||||
|
||||
bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.RefreshJWT)).
|
||||
Post("/xrpc/com.atproto.server.refreshSession").Receive(resp, resp)
|
||||
if resp.AccessJWT != "" {
|
||||
bluesky.Cfg.AccessJWT = resp.AccessJWT
|
||||
bluesky.Cfg.RefreshJWT = resp.RefreshJWT
|
||||
PersistAuthSession(bluesky.Cfg)
|
||||
bluesky.sling.Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT))
|
||||
return nil
|
||||
}
|
||||
|
||||
return bluesky.CreateSession(bluesky.Cfg)
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) CheckSessionValid() {
|
||||
resp := new(BSkySessionResponse)
|
||||
|
||||
bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT)).
|
||||
Get("/xrpc/app.bsky.actor.getProfile").Receive(resp, resp)
|
||||
if resp.Error == "ExpiredToken" {
|
||||
bluesky.RefreshSession()
|
||||
}
|
||||
}
|
||||
|
||||
type TelegramRecord struct {
|
||||
ChannelID int64 `json:"channel_id"`
|
||||
MessageID int `json:"message_id"`
|
||||
Link *Link `json:"link"`
|
||||
Error string `json:"error"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) CommitTelegramResponse(data *TelegramRecord, rkey string) *CommitResponse {
|
||||
bluesky.CheckSessionValid()
|
||||
|
||||
resp := new(CommitResponse)
|
||||
|
||||
record := struct {
|
||||
Repo string `json:"repo"`
|
||||
Collection string `json:"collection"`
|
||||
RKey string `json:"rkey"`
|
||||
Record TelegramRecord `json:"record"`
|
||||
}{
|
||||
Repo: bluesky.Cfg.DID,
|
||||
Collection: "blue.zio.bsky2tg.post",
|
||||
RKey: rkey,
|
||||
Record: TelegramRecord{
|
||||
ChannelID: data.ChannelID,
|
||||
MessageID: data.MessageID,
|
||||
Link: &Link{
|
||||
Cid: data.Link.Cid,
|
||||
URI: data.Link.URI,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT)).
|
||||
Post("/xrpc/com.atproto.repo.createRecord").BodyJSON(&record).Receive(resp, resp)
|
||||
return resp
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) GetTelegramData(rkey string) (*TelegramRecord, string) {
|
||||
resp := &struct {
|
||||
Value *TelegramRecord `json:"value"`
|
||||
URI string `json:"uri"`
|
||||
Cid string `json:"cid"`
|
||||
Error string `json:"error"`
|
||||
Message string `json:"message"`
|
||||
}{}
|
||||
|
||||
params := struct {
|
||||
Repo string `url:"repo"`
|
||||
Collection string `url:"collection"`
|
||||
RKey string `url:"rkey"`
|
||||
}{
|
||||
Repo: bluesky.Cfg.DID,
|
||||
Collection: "blue.zio.bsky2tg.post",
|
||||
RKey: rkey,
|
||||
}
|
||||
|
||||
bluesky.sling.New().Get("/xrpc/com.atproto.repo.getRecord").QueryStruct(¶ms).Receive(resp, resp)
|
||||
return resp.Value, resp.Message
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) GetPost(uri string) *Post {
|
||||
bluesky.CheckSessionValid()
|
||||
var post = struct {
|
||||
URI string `json:"uri"`
|
||||
CID string `json:"cid"`
|
||||
Value *Post `json:"value"`
|
||||
}{}
|
||||
|
||||
args := strings.SplitN(uri, "/", 5)
|
||||
params := struct {
|
||||
RKey string `url:"rkey"`
|
||||
Repo string `url:"repo"`
|
||||
Collection string `url:"collection"`
|
||||
}{
|
||||
RKey: args[4],
|
||||
Repo: args[2],
|
||||
Collection: args[3],
|
||||
}
|
||||
bluesky.sling.New().Get("/xrpc/com.atproto.repo.getRecord").QueryStruct(params).ReceiveSuccess(&post)
|
||||
|
||||
return post.Value
|
||||
}
|
||||
|
||||
func (bluesky *Bluesky) DeleteRecord(args []string) *CommitResponse {
|
||||
bluesky.CheckSessionValid()
|
||||
|
||||
resp := new(CommitResponse)
|
||||
params := struct {
|
||||
RKey string `url:"rkey"`
|
||||
Repo string `url:"repo"`
|
||||
Collection string `url:"collection"`
|
||||
}{
|
||||
RKey: args[0],
|
||||
Repo: args[1],
|
||||
Collection: args[2],
|
||||
}
|
||||
bluesky.sling.New().Set("Authorization", fmt.Sprintf("Bearer %s", bluesky.Cfg.AccessJWT)).
|
||||
Get("/xrpc/com.atproto.repo.deleteRecord").QueryStruct(params).ReceiveSuccess(resp)
|
||||
return resp
|
||||
}
|
149
bsky/client.go
Normal file
149
bsky/client.go
Normal file
|
@ -0,0 +1,149 @@
|
|||
package bsky
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dghubble/sling"
|
||||
)
|
||||
|
||||
type BSky struct {
|
||||
Bluesky *Bluesky
|
||||
DID string
|
||||
}
|
||||
|
||||
func NewBSky() *BSky {
|
||||
return &BSky{
|
||||
Bluesky: &Bluesky{
|
||||
Cfg: &BlueskyConfig{},
|
||||
HttpClient: &http.Client{},
|
||||
sling: sling.New().Client(&http.Client{Timeout: time.Second * 3}),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BSky) getPDS() error {
|
||||
httpClient := &http.Client{Timeout: 3 * time.Second}
|
||||
resp := new(BSkySessionResponse)
|
||||
errResp := &struct {
|
||||
Message string `json:"message"`
|
||||
Error string `json:"error"`
|
||||
}{}
|
||||
params := struct {
|
||||
Handle string `url:"handle"`
|
||||
}{
|
||||
Handle: b.Bluesky.Cfg.Handle,
|
||||
}
|
||||
sling.New().Base("https://public.api.bsky.app/").Client(httpClient).
|
||||
Get("/xrpc/com.atproto.identity.resolveHandle").QueryStruct(params).
|
||||
Receive(resp, errResp)
|
||||
|
||||
if errResp.Error != "" {
|
||||
return errors.New(errResp.Message)
|
||||
}
|
||||
|
||||
var didURL url.URL
|
||||
if strings.HasPrefix(resp.DID, "did:web:") {
|
||||
didURL.Host = "https://" + resp.DID[8:]
|
||||
didURL.Path = "/.well-known/did.json"
|
||||
} else if strings.HasPrefix(resp.DID, "did:plc:") {
|
||||
didURL.Host = "https://plc.directory"
|
||||
didURL.Path = "/" + resp.DID
|
||||
} else {
|
||||
return errors.New("DID is not supported")
|
||||
}
|
||||
|
||||
didResp := new(DIDResponse)
|
||||
sling.New().Base(didURL.Host).Get(didURL.Path).ReceiveSuccess(didResp)
|
||||
if didResp.ID == "" {
|
||||
return errors.New("unable to resolve DID")
|
||||
}
|
||||
|
||||
b.Bluesky.Cfg.DID = didResp.ID
|
||||
b.Bluesky.Cfg.PDSURL = didResp.Service[0].ServiceEndpoint
|
||||
b.Bluesky.sling.Base(didResp.Service[0].ServiceEndpoint)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *BSky) GetHandleFromDID(did string) (handle string, err error) {
|
||||
var didURL url.URL
|
||||
if strings.HasPrefix(did, "did:web:") {
|
||||
didURL.Host = "https://" + did[8:]
|
||||
didURL.Path = "/.well-known/did.json"
|
||||
} else if strings.HasPrefix(did, "did:plc:") {
|
||||
didURL.Host = "https://plc.directory"
|
||||
didURL.Path = "/" + did
|
||||
} else {
|
||||
return "", errors.New("DID is not supported")
|
||||
}
|
||||
|
||||
didResp := new(DIDResponse)
|
||||
sling.New().Base(didURL.Host).Get(didURL.Path).ReceiveSuccess(didResp)
|
||||
if didResp.ID == "" {
|
||||
return "", errors.New("unable to resolve DID")
|
||||
}
|
||||
|
||||
return didResp.AlsoKnownAs[0][5:], nil
|
||||
}
|
||||
|
||||
func (b *BSky) GetPDS(handle string) string {
|
||||
return b.Bluesky.Cfg.PDSURL
|
||||
}
|
||||
|
||||
func (b *BSky) Auth(authData []string) error {
|
||||
b.Bluesky.Cfg.Handle = authData[0]
|
||||
b.getPDS()
|
||||
auth, err := loadAuth()
|
||||
if err != nil { // no auth session found
|
||||
b.Bluesky.Cfg.AppPassword = authData[1]
|
||||
err = b.Bluesky.CreateSession(b.Bluesky.Cfg)
|
||||
if err != nil {
|
||||
return errors.New("unable to auth")
|
||||
}
|
||||
b.Bluesky.Cfg.AppPassword = "" // we don't need to save this
|
||||
PersistAuthSession(b.Bluesky.Cfg)
|
||||
} else {
|
||||
b.Bluesky.Cfg.Cursor = auth.Cursor
|
||||
b.Bluesky.Cfg.AccessJWT = auth.AccessJWT
|
||||
b.Bluesky.Cfg.RefreshJWT = auth.RefreshJWT
|
||||
// b.RefreshSession()
|
||||
b.Bluesky.CheckSessionValid()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func PersistAuthSession(sess *BlueskyConfig) error {
|
||||
f, err := os.OpenFile("auth-session.json", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
authBytes, err := json.MarshalIndent(sess, "", " ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = f.Write(authBytes)
|
||||
return err
|
||||
}
|
||||
|
||||
func loadAuth() (*BlueskyConfig, error) {
|
||||
fBytes, err := os.ReadFile("auth-session.json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(fBytes) == 0 {
|
||||
return nil, errors.New("no auth file found")
|
||||
}
|
||||
|
||||
var auth *BlueskyConfig
|
||||
json.Unmarshal(fBytes, &auth)
|
||||
return auth, nil
|
||||
}
|
274
bsky/parse.go
Normal file
274
bsky/parse.go
Normal file
|
@ -0,0 +1,274 @@
|
|||
package bsky
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Post struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
Type string `json:"$type,omitempty"`
|
||||
Embed *Embed `json:"embed,omitempty"`
|
||||
Langs []string `json:"langs,omitempty"`
|
||||
Labels *Labels `json:"labels,omitempty"`
|
||||
Reply *Reply `json:"reply,omitempty"`
|
||||
Facets *[]Facets `json:"facets,omitempty"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
}
|
||||
type Ref struct {
|
||||
Link string `json:"$link,omitempty"`
|
||||
}
|
||||
type Thumb struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
Ref *Ref `json:"ref,omitempty"`
|
||||
MimeType string `json:"mimeType,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
}
|
||||
type External struct {
|
||||
URI string `json:"uri,omitempty"`
|
||||
Thumb *Thumb `json:"thumb,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
type Video struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
Ref *Ref `json:"ref,omitempty"`
|
||||
MimeType string `json:"mimeType,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
}
|
||||
type Image struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
Ref *Ref `json:"ref,omitempty"`
|
||||
MimeType string `json:"mimeType,omitempty"`
|
||||
Size int `json:"size,omitempty"`
|
||||
}
|
||||
type AspectRatio struct {
|
||||
Width int `json:"width,omitempty"`
|
||||
Height int `json:"height,omitempty"`
|
||||
}
|
||||
type Images struct {
|
||||
Alt string `json:"alt,omitempty"`
|
||||
Image *Image `json:"image,omitempty"`
|
||||
AspectRatio *AspectRatio `json:"aspectRatio,omitempty"`
|
||||
}
|
||||
type Media struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
External *External `json:"external,omitempty"`
|
||||
Video *Video `json:"video,omitempty"`
|
||||
Images *[]Images `json:"images,omitempty"`
|
||||
AspectRatio *AspectRatio `json:"aspectRatio,omitempty"`
|
||||
}
|
||||
type Record struct {
|
||||
Cid string `json:"cid,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
}
|
||||
type PostRecord struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
Cid string `json:"cid,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
Record *Record `json:"record,omitempty"`
|
||||
}
|
||||
type Embed struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
Media *Media `json:"media,omitempty"`
|
||||
Images *[]Images `json:"images,omitempty"`
|
||||
Video *Video `json:"video,omitempty"`
|
||||
Record *PostRecord `json:"record,omitempty"`
|
||||
External *External `json:"external,omitempty"`
|
||||
}
|
||||
type Values struct {
|
||||
Val string `json:"val,omitempty"`
|
||||
}
|
||||
type Labels struct {
|
||||
Type string `json:"$type,omitempty"`
|
||||
Values *[]Values `json:"values,omitempty"`
|
||||
}
|
||||
type Root struct {
|
||||
Cid string `json:"cid,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
}
|
||||
type Parent struct {
|
||||
Cid string `json:"cid,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
}
|
||||
type Reply struct {
|
||||
Root *Root `json:"root,omitempty"`
|
||||
Parent *Parent `json:"parent,omitempty"`
|
||||
}
|
||||
type Index struct {
|
||||
ByteEnd int `json:"byteEnd,omitempty"`
|
||||
ByteStart int `json:"byteStart,omitempty"`
|
||||
}
|
||||
type Features struct {
|
||||
Did string `json:"did,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
Tag string `json:"tag,omitempty"`
|
||||
Type string `json:"$type,omitempty"`
|
||||
}
|
||||
type Facets struct {
|
||||
Type string `json:"$type"`
|
||||
Index *Index `json:"index,omitempty"`
|
||||
Features *[]Features `json:"features,omitempty"`
|
||||
}
|
||||
|
||||
type ParsedEmbeds struct {
|
||||
Type string
|
||||
MimeType string
|
||||
Ref string
|
||||
URI string
|
||||
Width int64
|
||||
Height int64
|
||||
}
|
||||
|
||||
func (b *BSky) ParsePost(post []byte) (*Post, error) {
|
||||
var p = &Post{}
|
||||
err := json.Unmarshal(post, &p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return p, nil
|
||||
}
|
||||
|
||||
func (post *Post) ProcessFacets() string {
|
||||
if post == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
if post.Facets == nil {
|
||||
return post.Text
|
||||
}
|
||||
|
||||
sort.Slice((*post.Facets), func(i, j int) bool {
|
||||
return (*post.Facets)[i].Index.ByteStart < (*post.Facets)[j].Index.ByteStart
|
||||
})
|
||||
|
||||
var result strings.Builder
|
||||
lastIndex := 0
|
||||
// post.Text = html.EscapeString(post.Text)
|
||||
|
||||
for _, facet := range *post.Facets {
|
||||
start := facet.Index.ByteStart
|
||||
end := facet.Index.ByteEnd
|
||||
|
||||
result.WriteString(post.Text[lastIndex:start])
|
||||
|
||||
for _, feature := range *facet.Features {
|
||||
switch feature.Type {
|
||||
case "app.bsky.richtext.facet#mention":
|
||||
link := fmt.Sprintf(`<a href="https://bsky.app/profile/%s">%s</a>`, feature.Did, post.Text[start:end])
|
||||
result.WriteString(link)
|
||||
case "app.bsky.richtext.facet#link":
|
||||
link := fmt.Sprintf(`<a href="%s">%s</a>`, feature.URI, post.Text[start:end])
|
||||
result.WriteString(link)
|
||||
case "app.bsky.richtext.facet#tag":
|
||||
link := fmt.Sprintf(`<a href="https://bsky.app/search?q=%%23%s">%s</a>`, feature.Tag, post.Text[start:end])
|
||||
result.WriteString(link)
|
||||
default:
|
||||
result.WriteString(post.Text[start:end])
|
||||
}
|
||||
}
|
||||
lastIndex = end
|
||||
}
|
||||
result.WriteString(post.Text[lastIndex:])
|
||||
return result.String()
|
||||
}
|
||||
|
||||
func (p *Post) GetEmbeds() *[]ParsedEmbeds {
|
||||
var parsedEmbeds = &[]ParsedEmbeds{}
|
||||
if p.Embed != nil {
|
||||
if p.Embed.Video != nil {
|
||||
parsedEmbed := ParsedEmbeds{
|
||||
URI: p.Embed.Video.Ref.Link,
|
||||
Type: "video",
|
||||
}
|
||||
*parsedEmbeds = append(*parsedEmbeds, parsedEmbed)
|
||||
}
|
||||
if p.Embed.External != nil {
|
||||
if strings.Contains(p.Embed.External.URI, "media.tenor.com") {
|
||||
parsedEmbed := ParsedEmbeds{
|
||||
URI: p.Embed.External.URI,
|
||||
Type: "external",
|
||||
}
|
||||
*parsedEmbeds = append(*parsedEmbeds, parsedEmbed)
|
||||
}
|
||||
}
|
||||
if p.Embed.Media != nil {
|
||||
if p.Embed.Media.Images != nil {
|
||||
for _, image := range *p.Embed.Media.Images {
|
||||
parsedEmbed := ParsedEmbeds{
|
||||
URI: image.Image.Ref.Link,
|
||||
Type: "image",
|
||||
}
|
||||
*parsedEmbeds = append(*parsedEmbeds, parsedEmbed)
|
||||
}
|
||||
}
|
||||
if p.Embed.Media.Video != nil {
|
||||
parsedEmbed := ParsedEmbeds{
|
||||
URI: p.Embed.Media.Video.Ref.Link,
|
||||
Type: "video",
|
||||
}
|
||||
*parsedEmbeds = append(*parsedEmbeds, parsedEmbed)
|
||||
}
|
||||
if p.Embed.Media.External != nil {
|
||||
parsedEmbed := ParsedEmbeds{
|
||||
URI: p.Embed.Media.External.URI,
|
||||
Type: "external",
|
||||
}
|
||||
*parsedEmbeds = append(*parsedEmbeds, parsedEmbed)
|
||||
}
|
||||
}
|
||||
if p.Embed.Images != nil {
|
||||
for _, image := range *p.Embed.Images {
|
||||
parsedEmbed := ParsedEmbeds{
|
||||
URI: image.Image.Ref.Link,
|
||||
Type: "image",
|
||||
}
|
||||
*parsedEmbeds = append(*parsedEmbeds, parsedEmbed)
|
||||
}
|
||||
}
|
||||
}
|
||||
return parsedEmbeds
|
||||
}
|
||||
|
||||
func (p *Post) GetMedia() *Media {
|
||||
if p.GetEmbeds() != nil {
|
||||
if p.Embed.Media != nil {
|
||||
return p.Embed.Media
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Post) GetMediaImages() *[]Images {
|
||||
if p.GetMedia() != nil {
|
||||
return p.GetMedia().Images
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Post) GetExternal() *External {
|
||||
if p.GetMedia() != nil {
|
||||
if p.GetMedia().External != nil {
|
||||
return p.GetMedia().External
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Post) IsReply() bool {
|
||||
return p.Reply != nil
|
||||
}
|
||||
|
||||
func (p *Post) IsQuotePost() bool {
|
||||
if p.Embed != nil {
|
||||
if p.Embed.Record != nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
86
go.mod
Normal file
86
go.mod
Normal file
|
@ -0,0 +1,86 @@
|
|||
module git.zio.sh/astra/bsky2tg
|
||||
|
||||
go 1.24.3
|
||||
|
||||
require (
|
||||
git.zio.sh/astra/Vidio v0.0.0-20250530122612-531d5203622d
|
||||
github.com/OvyFlash/telegram-bot-api v0.0.0-20250511194450-d315c30d9c40
|
||||
github.com/bluesky-social/jetstream v0.0.0-20250414024304-d17bd81a945e
|
||||
github.com/charmbracelet/log v0.4.2
|
||||
github.com/dghubble/sling v1.4.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bluesky-social/indigo v0.0.0-20240905024844-a4f38639767f // indirect
|
||||
github.com/carlmjohnson/versioninfo v0.22.5 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
|
||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.8.0 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||
github.com/go-logfmt/logfmt v0.6.0 // indirect
|
||||
github.com/go-logr/logr v1.4.1 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/google/uuid v1.6.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.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.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.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/compress v1.17.9 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||
github.com/minio/sha256-simd v1.0.1 // indirect
|
||||
github.com/mr-tron/base58 v1.2.0 // indirect
|
||||
github.com/muesli/termenv v0.16.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.3 // indirect
|
||||
github.com/multiformats/go-varint v0.0.7 // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect
|
||||
github.com/prometheus/client_golang v1.19.1 // indirect
|
||||
github.com/prometheus/client_model v0.6.1 // indirect
|
||||
github.com/prometheus/common v0.54.0 // indirect
|
||||
github.com/prometheus/procfs v0.15.1 // indirect
|
||||
github.com/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/whyrusleeping/cbor-gen v0.1.3-0.20240904181319-8dc02b38228c // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // 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.26.0 // indirect
|
||||
golang.org/x/crypto v0.22.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
|
||||
golang.org/x/net v0.24.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
|
||||
google.golang.org/protobuf v1.34.2 // indirect
|
||||
lukechampine.com/blake3 v1.2.1 // indirect
|
||||
)
|
279
go.sum
Normal file
279
go.sum
Normal file
|
@ -0,0 +1,279 @@
|
|||
git.zio.sh/astra/Vidio v0.0.0-20250530122612-531d5203622d h1:XjfSKiPs876VY5aoePNGq8C2LlDxyNfJPwktYBQfh8U=
|
||||
git.zio.sh/astra/Vidio v0.0.0-20250530122612-531d5203622d/go.mod h1:E+ClJWJwklFdrD/6TZLubqMWF7+mPbIuCsgZgd1bJ48=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/OvyFlash/telegram-bot-api v0.0.0-20250511194450-d315c30d9c40 h1:5oc/17zzAT943MFhTDyjuT+pAdaNn0KT6YzGUNk5H/A=
|
||||
github.com/OvyFlash/telegram-bot-api v0.0.0-20250511194450-d315c30d9c40/go.mod h1:2nRUdsKyWhvezqW/rBGWEQdcTQeTtnbSNd2dgx76WYA=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
|
||||
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
|
||||
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bluesky-social/indigo v0.0.0-20240905024844-a4f38639767f h1:Q9cfCAlYWIWPsSDhg5w6qcutQ7YaJtfTjiRLP/mw+pc=
|
||||
github.com/bluesky-social/indigo v0.0.0-20240905024844-a4f38639767f/go.mod h1:Zx9nSWgd/FxMenkJW07VKnzspxpHBdPrPmS+Fspl2I0=
|
||||
github.com/bluesky-social/jetstream v0.0.0-20250414024304-d17bd81a945e h1:P/O6TDHs53gwgV845uDHI+Nri889ixksRrh4bCkCdxo=
|
||||
github.com/bluesky-social/jetstream v0.0.0-20250414024304-d17bd81a945e/go.mod h1:WiYEeyJSdUwqoaZ71KJSpTblemUCpwJfh5oVXplK6T4=
|
||||
github.com/carlmjohnson/versioninfo v0.22.5 h1:O00sjOLUAFxYQjlN/bzYTuZiS0y6fWDQjMRvwtKgwwc=
|
||||
github.com/carlmjohnson/versioninfo v0.22.5/go.mod h1:QT9mph3wcVfISUKd0i9sZfVrPviHuSF+cUtLjm2WSf8=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||
github.com/charmbracelet/log v0.4.2 h1:hYt8Qj6a8yLnvR+h7MwsJv/XvmBJXiueUcI3cIxsyig=
|
||||
github.com/charmbracelet/log v0.4.2/go.mod h1:qifHGX/tc7eluv2R6pWIpyHDDrrb/AG71Pf2ysQu5nw=
|
||||
github.com/charmbracelet/x/ansi v0.8.0 h1:9GTq3xq9caJW8ZrBTe0LIe2fvfLR/bYXKTx2llXn7xE=
|
||||
github.com/charmbracelet/x/ansi v0.8.0/go.mod h1:wdYl/ONOLHLIVmQaxbIYEC/cRKOQyjTkowiI4blgS9Q=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd h1:vy0GVL4jeHEwG5YOXDmi86oYw2yuYUGqz6a8sLwg0X8=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dghubble/sling v1.4.2 h1:vs1HIGBbSl2SEALyU+irpYFLZMfc49Fp+jYryFebQjM=
|
||||
github.com/dghubble/sling v1.4.2/go.mod h1:o0arCOz0HwfqYQJLrRtqunaWOn4X6jxE/6ORKRpVTD4=
|
||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
|
||||
github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
|
||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-yaml/yaml v2.1.0+incompatible/go.mod h1:w2MrLa16VYP0jy6N7M5kHaCkaLENm+P+Tv+MfurjSw0=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
||||
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.5 h1:bJj+Pj19UZMIweq/iie+1u5YCdGrnxCT9yvm0e+Nd5M=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.5/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
|
||||
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
|
||||
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
|
||||
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
|
||||
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
|
||||
github.com/ipfs/go-datastore v0.6.0 h1:JKyz+Gvz1QEZw0LsX1IBn+JFCJQH4SJVFtM4uWU0Myk=
|
||||
github.com/ipfs/go-datastore v0.6.0/go.mod h1:rt5M3nNbSO/8q1t4LNkLyUwRs8HupMeN/8O4Vn9YAT8=
|
||||
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
|
||||
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
|
||||
github.com/ipfs/go-ipfs-blockstore v1.3.1 h1:cEI9ci7V0sRNivqaOr0elDsamxXFxJMMMy7PTTDQNsQ=
|
||||
github.com/ipfs/go-ipfs-blockstore v1.3.1/go.mod h1:KgtZyc9fq+P2xJUiCAzbRdhhqJHvsw8u2Dlqy2MyRTE=
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.1 h1:B5UJOH52IbcfS56+Ul+sv8jnIV10lbjLF5eOO0C66Nw=
|
||||
github.com/ipfs/go-ipfs-ds-help v1.1.1/go.mod h1:75vrVCkSdSFidJscs8n4W+77AtTpCIAdDGAwjitJMIo=
|
||||
github.com/ipfs/go-ipfs-util v0.0.3 h1:2RFdGez6bu2ZlZdI+rWfIdbQb1KudQp3VGwPtdNCmE0=
|
||||
github.com/ipfs/go-ipfs-util v0.0.3/go.mod h1:LHzG1a0Ig4G+iZ26UUOMjHd+lfM84LZCrn17xAKWBvs=
|
||||
github.com/ipfs/go-ipld-cbor v0.1.0 h1:dx0nS0kILVivGhfWuB6dUpMa/LAwElHPw1yOGYopoYs=
|
||||
github.com/ipfs/go-ipld-cbor v0.1.0/go.mod h1:U2aYlmVrJr2wsUBU67K4KgepApSZddGRDWBYR0H4sCk=
|
||||
github.com/ipfs/go-ipld-format v0.6.0 h1:VEJlA2kQ3LqFSIm5Vu6eIlSxD/Ze90xtc4Meten1F5U=
|
||||
github.com/ipfs/go-ipld-format v0.6.0/go.mod h1:g4QVMTn3marU3qXchwjpKPKgJv+zF+OlaKMyhJ4LHPg=
|
||||
github.com/ipfs/go-log v1.0.5 h1:2dOuUCB1Z7uoczMWgAyDck5JLb72zHzrMnGnCNNbvY8=
|
||||
github.com/ipfs/go-log v1.0.5/go.mod h1:j0b8ZoR+7+R99LD9jZ6+AJsrzkPbSXbZfGakb5JPtIo=
|
||||
github.com/ipfs/go-log/v2 v2.1.3/go.mod h1:/8d0SH3Su5Ooc31QlL1WysJhvyOTDCjcCZ9Axpmri6g=
|
||||
github.com/ipfs/go-log/v2 v2.5.1 h1:1XdUzF7048prq4aBjDQQ4SL5RxftpRGdXhNRwKSAlcY=
|
||||
github.com/ipfs/go-log/v2 v2.5.1/go.mod h1:prSpmC1Gpllc9UYWxDiZDreBYw7zp4Iqp1kOLU9U5UI=
|
||||
github.com/ipfs/go-metrics-interface v0.0.1 h1:j+cpbjYvu4R8zbleSs36gvB7jR+wsL2fGD6n0jO4kdg=
|
||||
github.com/ipfs/go-metrics-interface v0.0.1/go.mod h1:6s6euYU4zowdslK0GKHmqaIZ3j/b/tL7HTWtJ4VPgWY=
|
||||
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
|
||||
github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0o=
|
||||
github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
||||
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
||||
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
||||
github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
|
||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||
github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aGkbLYxPE=
|
||||
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
|
||||
github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0=
|
||||
github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
|
||||
github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g=
|
||||
github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk=
|
||||
github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U=
|
||||
github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM=
|
||||
github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8=
|
||||
github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU=
|
||||
github.com/opentracing/opentracing-go v1.2.0 h1:uEJPy/1a5RIPAJ0Ov+OIO8OxWu77jEv+1B0VhjKrZUs=
|
||||
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f h1:VXTQfuJj9vKR4TCkEuWIckKvdHFeJH/huIFJ9/cXOB0=
|
||||
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f/go.mod h1:/zvteZs/GwLtCgZ4BL6CBsk9IKIlexP43ObX9AxTqTw=
|
||||
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
|
||||
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
|
||||
github.com/prometheus/common v0.54.0 h1:ZlZy0BgJhTwVZUn7dLOkwCZHUkrAqd3WYtcFCWnM1D8=
|
||||
github.com/prometheus/common v0.54.0/go.mod h1:/TQgMJP5CuVYveyT7n/0Ix8yLNNXy9yRSkhnLTHPDIQ=
|
||||
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
|
||||
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
|
||||
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
|
||||
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
|
||||
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
|
||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/urfave/cli v1.22.10/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0 h1:GDDkbFiaK8jsSDJfjId/PEGEShv6ugrt4kYsC5UIDaQ=
|
||||
github.com/warpfork/go-wish v0.0.0-20220906213052-39a1cc7a02d0/go.mod h1:x6AKhvSSexNrVSrViXSHUEbICjmGXhtgABaHIySUSGw=
|
||||
github.com/whyrusleeping/cbor-gen v0.1.3-0.20240904181319-8dc02b38228c h1:UsxJNcLPfyLyVaA4iusIrsLAqJn/xh36Qgb8emqtXzk=
|
||||
github.com/whyrusleeping/cbor-gen v0.1.3-0.20240904181319-8dc02b38228c/go.mod h1:pM99HXyEbSQHcosHc0iW7YFmwnscr+t9Te4ibko05so=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24=
|
||||
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1/go.mod h1:sEGXWArGqc3tVa+ekntsN65DmVbVeW+7lTKTjZF3/Fo=
|
||||
go.opentelemetry.io/otel v1.21.0 h1:hzLeKBZEL7Okw2mGzZ0cc4k/A7Fta0uoPgaJCr8fsFc=
|
||||
go.opentelemetry.io/otel v1.21.0/go.mod h1:QZzNPQPm1zLX4gZK4cMi+71eaorMSGT3A4znnUvNNEo=
|
||||
go.opentelemetry.io/otel/metric v1.21.0 h1:tlYWfeo+Bocx5kLEloTjbcDwBuELRrIFxwdQ36PlJu4=
|
||||
go.opentelemetry.io/otel/metric v1.21.0/go.mod h1:o1p3CA8nNHW8j5yuQLdc1eeqEaPfzug24uvsyIEJRWM=
|
||||
go.opentelemetry.io/otel/trace v1.21.0 h1:WD9i5gzvoUPuXIXH24ZNBudiarZDKuekPqi/E8fpfLc=
|
||||
go.opentelemetry.io/otel/trace v1.21.0/go.mod h1:LGbsEB0f9LGjN+OZaQQ26sohbOmiMR+BaslueVtS/qQ=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=
|
||||
go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.16.0/go.mod h1:MA8QOfq0BHJwdXa996Y4dYkAqRKB8/1K1QMMZVaNZjQ=
|
||||
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
|
||||
go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo=
|
||||
go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30=
|
||||
golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
|
||||
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 h1:LoYXNGAShUG3m/ehNk4iFctuhGX/+R1ZpfJ4/ia80JM=
|
||||
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
|
||||
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
|
||||
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
|
||||
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
|
||||
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI=
|
||||
lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=
|
319
main.go
Normal file
319
main.go
Normal file
|
@ -0,0 +1,319 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"image/jpeg"
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.zio.sh/astra/bsky2tg/bsky"
|
||||
tgbotapi "github.com/OvyFlash/telegram-bot-api"
|
||||
|
||||
// apibsky "github.com/bluesky-social/indigo/api/bsky"
|
||||
"github.com/bluesky-social/jetstream/pkg/client"
|
||||
"github.com/bluesky-social/jetstream/pkg/client/schedulers/sequential"
|
||||
"github.com/bluesky-social/jetstream/pkg/models"
|
||||
|
||||
vidio "git.zio.sh/astra/Vidio"
|
||||
)
|
||||
|
||||
const (
|
||||
serverAddr = "wss://jetstream2.us-west.bsky.network/subscribe"
|
||||
// serverAddr = "wss://stream.zio.blue/subscribe"
|
||||
postFormat = "%s\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>"
|
||||
)
|
||||
|
||||
type handler struct {
|
||||
seenSeqs map[int64]struct{}
|
||||
tg *tgbotapi.BotAPI
|
||||
bsky *bsky.BSky
|
||||
}
|
||||
|
||||
func main() {
|
||||
var handle = os.Getenv("BSKY_HANDLE")
|
||||
var password = os.Getenv("BSKY_PASSWORD")
|
||||
bskyClient := bsky.NewBSky()
|
||||
err := bskyClient.Auth([]string{handle, password})
|
||||
if err != nil {
|
||||
log.Fatal(err, ". please set BSKY_HANDLE and BSKY_PASSWORD env variables")
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
|
||||
Level: slog.LevelDebug.Level(),
|
||||
})))
|
||||
|
||||
logger := slog.Default()
|
||||
config := client.DefaultClientConfig()
|
||||
config.WebsocketURL = serverAddr
|
||||
config.WantedCollections = []string{"app.bsky.feed.post"}
|
||||
config.WantedDids = []string{bskyClient.Bluesky.Cfg.DID}
|
||||
config.Compress = true
|
||||
|
||||
h := &handler{
|
||||
seenSeqs: make(map[int64]struct{}),
|
||||
bsky: bskyClient,
|
||||
}
|
||||
|
||||
scheduler := sequential.NewScheduler("jetstream_localdev", logger, h.HandleEvent)
|
||||
|
||||
c, err := client.NewClient(config, logger, scheduler)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create client: %v", err)
|
||||
}
|
||||
|
||||
bot, err := tgbotapi.NewBotAPIWithAPIEndpoint(os.Getenv("TG_TOKEN"), "https://bot.astra.blue/bot%s/%s")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
h.tg = bot
|
||||
|
||||
if os.Getenv("TG_CHANNEL_ID") == "" {
|
||||
log.Fatal("TG_CHANNEL_ID is not set")
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// file, err := os.Open("posts.json")
|
||||
// if err != nil {
|
||||
// fmt.Printf("Error opening file: %v\n", err)
|
||||
// return
|
||||
// }
|
||||
// defer file.Close()
|
||||
// byteValue, err := io.ReadAll(file)
|
||||
// if err != nil {
|
||||
// fmt.Printf("Error reading file: %v\n", err)
|
||||
// return
|
||||
// }
|
||||
|
||||
// var posts = struct {
|
||||
// Records []struct {
|
||||
// URI string `json:"uri"`
|
||||
// CID string `json:"cid"`
|
||||
// Value *bsky.Post `json:"value"`
|
||||
// } `json:"records"`
|
||||
// }{}
|
||||
|
||||
// // 4. Unmarshal (decode) the JSON data into the struct
|
||||
// err = json.Unmarshal(byteValue, &posts)
|
||||
// if err != nil {
|
||||
// fmt.Printf("Error unmarshaling JSON: %v\n", err)
|
||||
// return
|
||||
// }
|
||||
// for _, post := range posts.Records {
|
||||
// log.Printf("post: %s\n", post.Value.ProcessFacets())
|
||||
// s, _ := json.Marshal(post.Value)
|
||||
// h.ProcessPost(&models.Event{Did: bskyClient.Bluesky.Cfg.DID, Commit: &models.Commit{
|
||||
// Record: s,
|
||||
// RKey: strings.Split(post.URI, "/")[4],
|
||||
// CID: post.CID,
|
||||
// Collection: "app.bsky.feed.post",
|
||||
// }})
|
||||
// time.Sleep(time.Second * 2)
|
||||
// }
|
||||
// return
|
||||
// ------------------------------------------------------------------------------
|
||||
|
||||
cursor := time.Now().UnixMicro()
|
||||
restartCount := 0
|
||||
loop:
|
||||
if err := c.ConnectAndRead(ctx, &cursor); err != nil {
|
||||
log.Printf("failed to connect: %v. retrying", err)
|
||||
if restartCount >= 3 {
|
||||
log.Print("restart count limit hit, setting cursor to now\n")
|
||||
restartCount = 0
|
||||
cursor = time.Now().UnixMicro()
|
||||
} else {
|
||||
restartCount += 1
|
||||
cursor = int64(bskyClient.Bluesky.Cfg.Cursor)
|
||||
}
|
||||
goto loop
|
||||
}
|
||||
}
|
||||
|
||||
func (h *handler) HandleEvent(ctx context.Context, event *models.Event) error {
|
||||
if event.Commit == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if event.Commit.Operation == models.CommitOperationCreate ||
|
||||
event.Commit.Operation == models.CommitOperationUpdate {
|
||||
h.bsky.Bluesky.Cfg.Cursor = event.TimeUS + 1 // +1 to not show same post
|
||||
bsky.PersistAuthSession(h.bsky.Bluesky.Cfg)
|
||||
h.ProcessPost(event)
|
||||
} else if event.Commit.Operation == models.CommitOperationDelete {
|
||||
h.bsky.Bluesky.Cfg.Cursor = event.TimeUS + 1 // +1 to not show same post
|
||||
bsky.PersistAuthSession(h.bsky.Bluesky.Cfg)
|
||||
r, e := h.bsky.Bluesky.GetTelegramData(event.Commit.RKey)
|
||||
if e == "" {
|
||||
m := tgbotapi.NewDeleteMessage(r.ChannelID, r.MessageID)
|
||||
h.tg.Send(m)
|
||||
h.bsky.Bluesky.DeleteRecord([]string{event.Commit.RKey, event.Did, event.Commit.Collection})
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *handler) ProcessPost(event *models.Event) error {
|
||||
ps, _ := h.bsky.ParsePost(event.Commit.Record)
|
||||
po := ps.GetEmbeds()
|
||||
cid, _ := strconv.ParseInt(os.Getenv("TG_CHANNEL_ID"), 10, 64)
|
||||
|
||||
if ps.IsReply() { //|| ps.IsQuotePost() {
|
||||
// don't want to post replies to channel
|
||||
return nil
|
||||
}
|
||||
|
||||
var captionText string
|
||||
if ps.IsQuotePost() {
|
||||
if ps.Embed.Record.Type == "app.bsky.embed.record" {
|
||||
handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.Record.URI, "/")[2])
|
||||
captionText = fmt.Sprintf(
|
||||
"<blockquote>%s</blockquote>\n<a href=\"https://bsky.app/profile/%s/post/%s\">➡️ @%s</a>\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>",
|
||||
ps.ProcessFacets(),
|
||||
strings.Split(ps.Embed.Record.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.Record.URI, "/")[4],
|
||||
handle,
|
||||
event.Did,
|
||||
event.Commit.RKey,
|
||||
h.bsky.Bluesky.Cfg.Handle)
|
||||
} else {
|
||||
handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.URI, "/")[2])
|
||||
captionText = fmt.Sprintf(
|
||||
"<blockquote>%s</blockquote>\n<a href=\"https://bsky.app/profile/%s/post/%s\">➡️ @%s</a>\n—\n<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>",
|
||||
ps.ProcessFacets(),
|
||||
strings.Split(ps.Embed.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.URI, "/")[4],
|
||||
handle,
|
||||
event.Did,
|
||||
event.Commit.RKey,
|
||||
h.bsky.Bluesky.Cfg.Handle)
|
||||
}
|
||||
}
|
||||
|
||||
if captionText == "" {
|
||||
if ps.ProcessFacets() != "" {
|
||||
captionText = fmt.Sprintf(postFormat, ps.ProcessFacets(), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle)
|
||||
} else {
|
||||
captionText = fmt.Sprintf("<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>", h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle)
|
||||
}
|
||||
}
|
||||
|
||||
// post has media
|
||||
if len((*po)) != 0 {
|
||||
mediaGroup := []tgbotapi.InputMedia{}
|
||||
if (*po)[0].Type == "external" {
|
||||
tenorGif := tgbotapi.NewInputMediaVideo(tgbotapi.FileURL((*po)[0].URI)) // is most likely gif from Tenor
|
||||
tenorGif.Caption = captionText
|
||||
tenorGif.ParseMode = tgbotapi.ModeHTML
|
||||
mediaGroup = append(mediaGroup, &tenorGif)
|
||||
} else {
|
||||
for _, media := range *po {
|
||||
switch media.Type {
|
||||
case "image":
|
||||
mediaAdd := tgbotapi.NewInputMediaPhoto(tgbotapi.FileURL(buildBlobURL(h.bsky.Bluesky.Cfg.PDSURL, h.bsky.Bluesky.Cfg.DID, media.URI)))
|
||||
if len(mediaGroup) == 0 {
|
||||
mediaAdd.Caption = captionText
|
||||
mediaAdd.ParseMode = tgbotapi.ModeHTML
|
||||
}
|
||||
mediaGroup = append(mediaGroup, &mediaAdd)
|
||||
case "video":
|
||||
log.Printf("Fetching video: %s\n", buildBlobURL(h.bsky.Bluesky.Cfg.PDSURL, h.bsky.Bluesky.Cfg.DID, media.URI))
|
||||
resp, _ := http.Get(buildBlobURL(h.bsky.Bluesky.Cfg.PDSURL, h.bsky.Bluesky.Cfg.DID, media.URI))
|
||||
defer resp.Body.Close()
|
||||
f, _ := os.Create(media.URI + ".mp4")
|
||||
io.Copy(f, resp.Body)
|
||||
f.Seek(0, 0)
|
||||
mediaAdd := tgbotapi.NewInputMediaVideo(tgbotapi.FileReader{Name: "video.mp4", Reader: f})
|
||||
metadata, err := getVideoMetadata(f.Name())
|
||||
if err != nil {
|
||||
log.Printf("Unable to read video metadata: %s\n", buildBlobURL(h.bsky.Bluesky.Cfg.PDSURL, h.bsky.Bluesky.Cfg.DID, media.URI))
|
||||
break
|
||||
}
|
||||
mediaAdd.SupportsStreaming = true
|
||||
mediaAdd.Height = metadata.Height()
|
||||
mediaAdd.Width = metadata.Width()
|
||||
mediaAdd.Duration = int(metadata.Duration())
|
||||
|
||||
frames, _ := metadata.ReadFrames(0)
|
||||
var buf bytes.Buffer
|
||||
jpeg.Encode(&buf, frames[0], &jpeg.Options{Quality: 90})
|
||||
mediaAdd.Thumb = tgbotapi.FileBytes{Name: "thumb.jpg", Bytes: buf.Bytes()}
|
||||
if len(mediaGroup) == 0 {
|
||||
mediaAdd.Caption = captionText
|
||||
mediaAdd.ParseMode = tgbotapi.ModeHTML
|
||||
}
|
||||
os.Remove(media.URI + ".mp4")
|
||||
mediaGroup = append(mediaGroup, &mediaAdd)
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(mediaGroup) == 0 {
|
||||
log.Print("No mediaGroup to send, see previous error")
|
||||
} else {
|
||||
resp, _ := h.tg.SendMediaGroup(tgbotapi.NewMediaGroup(cid, mediaGroup))
|
||||
uri, cid := getLink(event)
|
||||
h.bsky.Bluesky.CommitTelegramResponse(&bsky.TelegramRecord{
|
||||
ChannelID: resp[0].Chat.ID,
|
||||
MessageID: resp[0].MessageID,
|
||||
Link: &bsky.Link{
|
||||
Cid: cid,
|
||||
URI: uri,
|
||||
},
|
||||
}, event.Commit.RKey)
|
||||
}
|
||||
} else {
|
||||
m := tgbotapi.MessageConfig{}
|
||||
if captionText == "" {
|
||||
m = tgbotapi.NewMessage(cid, fmt.Sprintf(postFormat, ps.ProcessFacets(), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle))
|
||||
} else {
|
||||
m = tgbotapi.NewMessage(cid, captionText)
|
||||
}
|
||||
m.ParseMode = tgbotapi.ModeHTML
|
||||
if ps.IsQuotePost() {
|
||||
m.LinkPreviewOptions = tgbotapi.LinkPreviewOptions{
|
||||
IsDisabled: false,
|
||||
URL: fmt.Sprintf("https://bsky.app/profile/%s/post/%s",
|
||||
strings.Split(ps.Embed.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.URI, "/")[4]),
|
||||
PreferSmallMedia: true,
|
||||
ShowAboveText: true,
|
||||
}
|
||||
} else {
|
||||
m.LinkPreviewOptions = tgbotapi.LinkPreviewOptions{IsDisabled: true}
|
||||
}
|
||||
resp, _ := h.tg.Send(m)
|
||||
uri, cid := getLink(event)
|
||||
h.bsky.Bluesky.CommitTelegramResponse(&bsky.TelegramRecord{
|
||||
ChannelID: resp.Chat.ID,
|
||||
MessageID: resp.MessageID,
|
||||
Link: &bsky.Link{
|
||||
Cid: cid,
|
||||
URI: uri,
|
||||
},
|
||||
}, event.Commit.RKey)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func buildBlobURL(server string, did string, cid string) string {
|
||||
return server + "/xrpc/com.atproto.sync.getBlob?did=" + url.QueryEscape(did) + "&cid=" + url.QueryEscape(cid)
|
||||
}
|
||||
|
||||
func getLink(event *models.Event) (string, string) {
|
||||
return fmt.Sprintf("at://%s/%s/%s", event.Did, event.Commit.Collection, event.Commit.RKey), event.Commit.CID
|
||||
}
|
||||
|
||||
func getVideoMetadata(fname string) (video *vidio.Video, err error) {
|
||||
video, err = vidio.NewVideo(fname)
|
||||
return
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue