Added conditional to prevent exceeding of 500 characters limit of API

This commit is contained in:
Homer S. 2019-09-12 23:42:40 +02:00
parent 068b03c578
commit 036d6a3358
1 changed files with 5 additions and 0 deletions

View File

@ -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)