mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Important improvements for retweets of long quoted tweets
This commit is contained in:
parent
efc5b481f8
commit
02538322c6
@ -26,17 +26,20 @@ def is_long(tweet):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def clear_url(tweet):
|
def clear_url(tweet):
|
||||||
if tweet.has_key("full_text"):
|
if tweet.has_key("retweeted_status"):
|
||||||
value = "full_text"
|
if tweet["retweeted_status"].has_key("full_text"):
|
||||||
|
value = "full_text"
|
||||||
|
else:
|
||||||
|
value = "text"
|
||||||
|
urls = utils.find_urls_in_text(tweet["retweeted_status"][value])
|
||||||
|
try: tweet["message"] = tweet["message"].replace(urls[-1], "")
|
||||||
|
except IndexError: pass
|
||||||
else:
|
else:
|
||||||
value = "text"
|
if tweet.has_key("full_text"):
|
||||||
urls = utils.find_urls_in_text(tweet[value])
|
value = "full_text"
|
||||||
try: tweet["message"] = tweet["message"].replace(urls[-1], "")
|
else:
|
||||||
except IndexError: pass
|
value = "text"
|
||||||
try:
|
urls = utils.find_urls_in_text(tweet[value])
|
||||||
tweet["entities"]["urls"].remove(tweet["entities"]["urls"][-1])
|
try: tweet["message"] = tweet["message"].replace(urls[-1], "")
|
||||||
except IndexError:
|
except IndexError: pass
|
||||||
tweet["retweeted_status"]["entities"]["urls"].remove(tweet["retweeted_status"]["entities"]["urls"][-1])
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
return tweet
|
return tweet
|
@ -101,18 +101,26 @@ def compose_dm(tweet, db, relative_times, show_screen_names=False):
|
|||||||
|
|
||||||
def compose_quoted_tweet(quoted_tweet, original_tweet, show_screen_names=False):
|
def compose_quoted_tweet(quoted_tweet, original_tweet, show_screen_names=False):
|
||||||
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
||||||
if quoted_tweet.has_key("full_text"):
|
if quoted_tweet.has_key("retweeted_status"):
|
||||||
value = "full_text"
|
if quoted_tweet["retweeted_status"].has_key("full_text"):
|
||||||
|
value = "full_text"
|
||||||
|
log.error(quoted_tweet["retweeted_status"]["full_text"])
|
||||||
|
else:
|
||||||
|
value = "text"
|
||||||
|
text = StripChars(quoted_tweet["retweeted_status"][value])
|
||||||
else:
|
else:
|
||||||
value = "text"
|
if quoted_tweet.has_key("full_text"):
|
||||||
text = StripChars(quoted_tweet[value])
|
value = "full_text"
|
||||||
|
else:
|
||||||
|
value = "text"
|
||||||
|
text = StripChars(quoted_tweet[value])
|
||||||
if show_screen_names:
|
if show_screen_names:
|
||||||
quoting_user = quoted_tweet["user"]["screen_name"]
|
quoting_user = quoted_tweet["user"]["screen_name"]
|
||||||
else:
|
else:
|
||||||
quoting_user = quoted_tweet["user"]["name"]
|
quoting_user = quoted_tweet["user"]["name"]
|
||||||
source = re.sub(r"(?s)<.*?>", "", quoted_tweet["source"])
|
source = re.sub(r"(?s)<.*?>", "", quoted_tweet["source"])
|
||||||
try: text = "rt @%s: %s" % (quoted_tweet["retweeted_status"]["user"]["screen_name"], StripChars(quoted_tweet["retweeted_status"][value]))
|
if quoted_tweet.has_key("retweeted_status"):
|
||||||
except KeyError: text = "%s" % (StripChars(quoted_tweet[value]))
|
text = "rt @%s: %s" % (quoted_tweet["retweeted_status"]["user"]["screen_name"], text)
|
||||||
if text[-1] in chars: text=text+"."
|
if text[-1] in chars: text=text+"."
|
||||||
original_user = original_tweet["user"]["screen_name"]
|
original_user = original_tweet["user"]["screen_name"]
|
||||||
if original_tweet.has_key("message"):
|
if original_tweet.has_key("message"):
|
||||||
@ -121,7 +129,7 @@ def compose_quoted_tweet(quoted_tweet, original_tweet, show_screen_names=False):
|
|||||||
original_text = StripChars(original_tweet["full_text"])
|
original_text = StripChars(original_tweet["full_text"])
|
||||||
else:
|
else:
|
||||||
original_text = StripChars(original_tweet["text"])
|
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["message"] = _(u"{0}. Quoted tweet from @{1}: {2}").format( text, original_user, original_text)
|
||||||
quoted_tweet = tweets.clear_url(quoted_tweet)
|
quoted_tweet = tweets.clear_url(quoted_tweet)
|
||||||
quoted_tweet["entities"]["urls"].extend(original_tweet["entities"]["urls"])
|
quoted_tweet["entities"]["urls"].extend(original_tweet["entities"]["urls"])
|
||||||
return quoted_tweet
|
return quoted_tweet
|
||||||
|
Loading…
Reference in New Issue
Block a user