fix(app): Add hashtags to bluesky post
This commit is contained in:
@ -161,15 +161,19 @@ def fetch_og_data(url):
|
||||
return None, None
|
||||
|
||||
|
||||
def post_to_bluesky(message, link):
|
||||
def post_to_bluesky(title, link, tags):
|
||||
client = Client()
|
||||
client.login(BSKY_HANDLE, BSKY_PASSWORD)
|
||||
|
||||
title, image_url = fetch_og_data(link)
|
||||
text = title or message
|
||||
hashtags = " ".join(f"#{tag}" for tag in tags) if tags else ""
|
||||
message = f"{title}\n\n{link}"
|
||||
if hashtags:
|
||||
message += f"\n\n{hashtags}"
|
||||
|
||||
if title and image_url:
|
||||
# Try rich embed
|
||||
try:
|
||||
og_title, image_url = fetch_og_data(link)
|
||||
if og_title and image_url:
|
||||
embed = {
|
||||
"$type": "app.bsky.embed.external",
|
||||
"external": {
|
||||
@ -190,13 +194,14 @@ def post_to_bluesky(message, link):
|
||||
blob = client.upload_blob(BytesIO(img_resp.content))
|
||||
embed["external"]["thumb"] = blob.blob
|
||||
|
||||
client.send_post(text=text, embed=embed)
|
||||
client.send_post(text=message, embed=embed)
|
||||
logger.info(f"✅ Posted to Bluesky with preview.")
|
||||
return
|
||||
except Exception as e:
|
||||
logger.error(f"❌ Error uploading preview to Bluesky: {e}")
|
||||
|
||||
client.send_post(f"{text}\n{link}")
|
||||
# Fallback to text-only post
|
||||
client.send_post(text=message)
|
||||
logger.info(f"💡 Posted to Bluesky without preview.")
|
||||
|
||||
|
||||
@ -265,7 +270,7 @@ def main():
|
||||
time.sleep(2)
|
||||
|
||||
if POST_TARGETS in ("bluesky", "both"):
|
||||
post_to_bluesky(f"{title}\n{link}", link)
|
||||
post_to_bluesky(title, link, tags)
|
||||
|
||||
save_seen_id(post_id)
|
||||
logger.info(f"✅ Post successfully published.")
|
||||
|
Reference in New Issue
Block a user