This commit is contained in:
parent
85fc508aa3
commit
c9cc325ef7
3 changed files with 77 additions and 51 deletions
17
main.go
17
main.go
|
|
@ -97,7 +97,7 @@ func main() {
|
|||
log.Printf("Found post %s in channel %d, deleting", s[2], tgpost.ChannelID)
|
||||
m := tgbotapi.NewDeleteMessages(tgpost.ChannelID, tgpost.MessageID)
|
||||
h.tg.Send(m)
|
||||
h.bsky.Bluesky.DeleteRecord([]string{s[2], s[1], "blue.zio.bsky2tg.post"})
|
||||
h.bsky.Bluesky.DeleteRecord([]string{s[2], s[1], bsky.PostCollection})
|
||||
} else {
|
||||
log.Printf("Unable to find post %s on PDS", s[2])
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ func (h *handler) HandleEvent(ctx context.Context, event *models.Event) error {
|
|||
if e == "" {
|
||||
m := tgbotapi.NewDeleteMessages(r.ChannelID, r.MessageID)
|
||||
h.tg.Send(m)
|
||||
h.bsky.Bluesky.DeleteRecord([]string{event.Commit.RKey, event.Did, "blue.zio.bsky2tg.post"})
|
||||
h.bsky.Bluesky.DeleteRecord([]string{event.Commit.RKey, event.Did, bsky.PostCollection})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -206,6 +206,9 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
isEditedPost = true
|
||||
}
|
||||
|
||||
aliases := h.bsky.Bluesky.FetchAliases()
|
||||
facets := ps.ProcessFacets(aliases)
|
||||
|
||||
var captionText string
|
||||
if ps.IsQuotePost() {
|
||||
ownHandle, handleErr := h.bsky.GetHandleFromDID(h.bsky.Bluesky.Cfg.DID)
|
||||
|
|
@ -216,7 +219,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.Record.URI, "/")[2])
|
||||
captionText = fmt.Sprintf(
|
||||
quotePostFormat,
|
||||
ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()),
|
||||
facets,
|
||||
strings.Split(ps.Embed.Record.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.Record.URI, "/")[4],
|
||||
handle,
|
||||
|
|
@ -227,7 +230,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
handle, _ := h.bsky.GetHandleFromDID(strings.Split(ps.Embed.Record.URI, "/")[2])
|
||||
captionText = fmt.Sprintf(
|
||||
quotePostFormat,
|
||||
ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()),
|
||||
facets,
|
||||
strings.Split(ps.Embed.Record.URI, "/")[2],
|
||||
strings.Split(ps.Embed.Record.URI, "/")[4],
|
||||
handle,
|
||||
|
|
@ -242,8 +245,8 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
if handleErr != nil {
|
||||
ownHandle = h.bsky.Bluesky.Cfg.Handle
|
||||
}
|
||||
if ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()) != "" {
|
||||
captionText = fmt.Sprintf(postFormat, ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle)
|
||||
if facets != "" {
|
||||
captionText = fmt.Sprintf(postFormat, facets, h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle)
|
||||
} else {
|
||||
captionText = fmt.Sprintf("<a href=\"https://bsky.app/profile/%s/post/%s\">🦋 @%s</a>", h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, ownHandle)
|
||||
}
|
||||
|
|
@ -325,7 +328,7 @@ func (h *handler) ProcessPost(event *models.Event) error {
|
|||
} else {
|
||||
m := tgbotapi.MessageConfig{}
|
||||
if captionText == "" {
|
||||
m = tgbotapi.NewMessage(cid, fmt.Sprintf(postFormat, ps.ProcessFacets(h.bsky.Bluesky.FetchAliases()), h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle))
|
||||
m = tgbotapi.NewMessage(cid, fmt.Sprintf(postFormat, facets, h.bsky.Bluesky.Cfg.DID, event.Commit.RKey, h.bsky.Bluesky.Cfg.Handle))
|
||||
} else {
|
||||
m = tgbotapi.NewMessage(cid, captionText)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue