Fixed a bug with URLS in complex tweets

This commit is contained in:
Manuel Cortez 2016-07-25 13:58:05 -05:00
parent 990ddf64f5
commit d50e8e2798

View File

@ -58,6 +58,7 @@ def compose_tweet(tweet, db, relative_times):
else:
text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet[value]))
if text[-1] in chars: text=text+"."
if tweet.has_key("message") == False:
urls = utils.find_urls_in_text(text)
for url in range(0, len(urls)):
try: text = text.replace(urls[url], tweet["entities"]["urls"][url]["expanded_url"])
@ -75,6 +76,9 @@ def compose_quoted_tweet(quoted_tweet, original_tweet):
except KeyError: text = "%s" % (StripChars(quoted_tweet["text"]))
if text[-1] in chars: text=text+"."
original_user = original_tweet["user"]["screen_name"]
if original_tweet.has_key("message"):
original_text = StripChars(original_tweet["message"])
else:
original_text = StripChars(original_tweet["text"])
try: original_text = "rt @%s: %s" % (original_tweet["retweeted_status"]["user"]["screen_name"], StripChars(original_tweet["retweeted_status"]["text"]))
except KeyError: original_text = "%s" % (StripChars(original_tweet["text"]))