From 036d6a3358fab6cd840bc61b88bc04f584df6f96 Mon Sep 17 00:00:00 2001 From: Homer S Date: Thu, 12 Sep 2019 23:42:40 +0200 Subject: [PATCH] Added conditional to prevent exceeding of 500 characters limit of API --- mastobot.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mastobot.py b/mastobot.py index c2ae3d4..e16d58c 100644 --- a/mastobot.py +++ b/mastobot.py @@ -104,6 +104,11 @@ for account in transitions: mastodon_text += "\n\nPosted " + parse(str(status.created_at)).strftime("%d. %B %Y - %H:%M on Twitter") mastodon_text += "\nOrigin: https://twitter.com/" + account['twitter_handle'] + "/status/" + tweet_origin + # Make sure that 500 char limit of Mastodon-API doesn't break the script + if len(mastodon_text) > 500: + mastodon_text = mastodon_text[:489] + + # Output text to stdout respect. post it to Mastodon. print(mastodon_text)