diff --git a/bluemastofeed.py b/bluemastofeed.py index 395378e..f6b3d46 100644 --- a/bluemastofeed.py +++ b/bluemastofeed.py @@ -137,8 +137,12 @@ def save_seen_id(post_id): f.write(post_id + "\n") -def post_to_mastodon(message): +def post_to_mastodon(title, link, tags): mastodon = Mastodon(access_token=MASTODON_TOKEN, api_base_url=MASTODON_BASE_URL) + hashtags = " ".join(f"#{tag}" for tag in tags) if tags else "" + message = f"{title}\n\n{link}" + if hashtags: + message += f"\n\n{hashtags}" mastodon.toot(message) @@ -257,7 +261,7 @@ def main(): try: if POST_TARGETS in ("mastodon", "both"): - post_to_mastodon(message) + post_to_mastodon(title, link, tags) time.sleep(2) if POST_TARGETS in ("bluesky", "both"):