From 8928a64a125e60b99d687fe34d9af35ee591b11a Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 15 Nov 2017 09:50:59 -0600 Subject: [PATCH] Links in quoted tweets should be opened properly. Fixes #167 and #184 --- src/long_tweets/tweets.py | 4 ++++ src/twitter/compose.py | 1 + 2 files changed, 5 insertions(+) diff --git a/src/long_tweets/tweets.py b/src/long_tweets/tweets.py index 4292b15e..e84095a5 100644 --- a/src/long_tweets/tweets.py +++ b/src/long_tweets/tweets.py @@ -31,4 +31,8 @@ def clear_url(tweet): urls = utils.find_urls_in_text(tweet[value]) try: tweet["message"] = tweet["message"].replace(urls[-1], "") except IndexError: pass + try: + tweet["entities"]["urls"].remove(tweet["entities"]["urls"][-1]) + except ValueError: + pass return tweet \ No newline at end of file diff --git a/src/twitter/compose.py b/src/twitter/compose.py index 0c5f03dc..9d0ede0f 100644 --- a/src/twitter/compose.py +++ b/src/twitter/compose.py @@ -123,6 +123,7 @@ def compose_quoted_tweet(quoted_tweet, original_tweet, show_screen_names=False): original_text = StripChars(original_tweet["text"]) quoted_tweet["message"] = _(u"{0}. Quoted tweet from @{1}: {2}").format( quoted_tweet[value], original_user, original_text) quoted_tweet = tweets.clear_url(quoted_tweet) + quoted_tweet["entities"]["urls"].extend(original_tweet["entities"]["urls"]) return quoted_tweet def compose_followers_list(tweet, db, relative_times=True, show_screen_names=False):