diff --git a/wantzel.py b/wantzel.py index b68611329ac4745e835c62f01dbab6728e5a2347..47abda0efcf31041c147593d227b291b3cdce7f5 100644 --- a/wantzel.py +++ b/wantzel.py @@ -561,9 +561,17 @@ class Wantzel(object): # lesser than future if today < entry.published_parsed < now: if self.last_entry_published < entry.published_parsed: + # Let's see if we can truncate the lenght of the tweet + # We have 5 chars for the language, so max-length is 135 + title = entry.title.encode("utf-8") + link = entry.link.encode("utf-8") + if len(title) + len(link) > 135: + # What is the number of chars we need to remove + excess = len(title) + len(link) - 135 + title = ''.join([title[:-(excess + 4)], u' ...']) tweet(messages["tweet_rp_%s" % language] % ( - entry.title.encode("utf-8"), - entry.link.encode("utf-8") + title, + link )) Utils.debug(entry.published_parsed) Utils.debug(entry.title)