From c4d4e915484c027bfe6a556eb27c03d3a833c486 Mon Sep 17 00:00:00 2001 From: astravexton Date: Tue, 23 Sep 2025 17:51:12 +0100 Subject: [PATCH] check if post is already in channel --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index eef0dc9..2f4ac7e 100644 --- a/main.go +++ b/main.go @@ -88,11 +88,11 @@ func main() { log.Fatal("Unable to send posts from other accounts") } + tgpost, tgposterr := h.bsky.Bluesky.GetTelegramData(s[2]) if *delete { - r, e := h.bsky.Bluesky.GetTelegramData(s[2]) - if e == "" { - log.Printf("Found post %s in channel %d, deleting", s[2], r.ChannelID) - m := tgbotapi.NewDeleteMessages(r.ChannelID, r.MessageID) + if tgposterr == "" { + 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"}) } else { @@ -101,6 +101,11 @@ func main() { return } + if tgpost.ChannelID != 0 { + log.Printf("Post %s already sent to channel %d, exiting", s[2], tgpost.ChannelID) + return + } + postJSON := bskyClient.Bluesky.FetchPost(handle, s[2]) p, _ := json.Marshal(postJSON.Record) h.ProcessPost(&models.Event{