Example refactor forcompose_tweet method. #2

Fusionado
spla merged 1 commit from mr-origin-1 into master 2021-10-19 15:42:14 +02:00
Showing only changes of commit 1d8fb19731 - Show all commits

Veure arxiu

@ -51,9 +51,6 @@ def get_toot(title):
return tuit_text return tuit_text
def compose_tweet(tuit_text, with_images, is_reply): def compose_tweet(tuit_text, with_images, is_reply):
tuit_max_length = 250 if len(tuit_text) > 280 else 275
tuit_text2 = ''
images_ids = [] images_ids = []
if with_images: if with_images:
@ -92,10 +89,11 @@ def compose_tweet(tuit_text, with_images, is_reply):
sys.exit(err) sys.exit(err)
# Compose tuit # Compose tuit
tuit_text2 = ''
if len(tuit_text) > 280:
tuit_max_length = 250 if with_images else 275
# This means that the OG tweet is bigger than 280
# Thus we need to break it down in two
if tuit_max_length == 250:
tuit_text = '{0} (1/2)'.format( tuit_text = '{0} (1/2)'.format(
tuit_text[:tuit_max_length].rsplit(' ', 1)[0] tuit_text[:tuit_max_length].rsplit(' ', 1)[0]
) )