Commit d927a2a1 authored by okhin's avatar okhin 🚴

Fix #23 let's truncate the tweet

parent 07f3d342
...@@ -561,9 +561,17 @@ class Wantzel(object): ...@@ -561,9 +561,17 @@ class Wantzel(object):
# lesser than future # lesser than future
if today < entry.published_parsed < now: if today < entry.published_parsed < now:
if self.last_entry_published < entry.published_parsed: 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] % ( tweet(messages["tweet_rp_%s" % language] % (
entry.title.encode("utf-8"), title,
entry.link.encode("utf-8") link
)) ))
Utils.debug(entry.published_parsed) Utils.debug(entry.published_parsed)
Utils.debug(entry.title) Utils.debug(entry.title)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment