From 8ea7e171d0ff10cdef2c738ef8ee8b303e4bc348 Mon Sep 17 00:00:00 2001 From: linus Date: Sun, 27 Aug 2023 17:33:30 +0200 Subject: [PATCH] added handling of posts referencing feeds --- crosspost.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crosspost.py b/crosspost.py index b7f0cce..b0d6aae 100644 --- a/crosspost.py +++ b/crosspost.py @@ -61,10 +61,17 @@ def getPosts(): # both tweets that are not replies, and posts that are part of a thread. replyToUser = bsky_handle replyTo = "" - # Checking if post is a quote tweet + # Checking if post is a quote post. Posts with references to feeds look like quote posts but aren't, and so will fail on missing attribute. + # Since quote posts can give values in two different ways it's a bit of a hassle to double check if it is an actual quote post, + # so instead I just try to run the function and if it fails I'll set postType as an empty string to signify that this post should + # not be crossposted. If there is some reason you would want to crosspost a post referencing a bluesky-feed that I'm not + # seeing, I might update this in the future. if feed_view.post.embed and hasattr(feed_view.post.embed, "record"): - replyToUser, replyTo = getQuotePost(feed_view.post.embed.record) - postType = "quote" + try: + replyToUser, replyTo = getQuotePost(feed_view.post.embed.record) + postType = "quote" + except: + postType = "" # Checking if post is regular reply elif feed_view.post.record.reply: replyToUser = getReplyToUser(feed_view.post.record.reply) @@ -73,7 +80,7 @@ def getPosts(): if not replyToUser: continue # Checking if post is by user (i.e. not a repost), withing the last 12 hours and either not a reply or a reply in a thread. - if feed_view.post.author.handle == bsky_handle and timestamp > datetime.now() - timedelta(hours = 12) and replyToUser == bsky_handle: + if postType and feed_view.post.author.handle == bsky_handle and timestamp > datetime.now() - timedelta(hours = 12) and replyToUser == bsky_handle: # Fetching images if there are any in the post imageData = "" images = []