Code cleanup and a few fixes in streaming API

This commit is contained in:
Manuel Cortez 2017-12-05 10:24:52 -06:00
parent 02538322c6
commit d9a9adef1f
3 changed files with 13 additions and 5 deletions

View File

@ -67,6 +67,11 @@ class timelinesStreamer(TwythonStreamer):
if data.has_key("retweeted_status"):
if data["retweeted_status"].has_key("extended_tweet"):
data["retweeted_status"]["full_text"] = data["retweeted_status"]["extended_tweet"]["full_text"]
data["full_text"] = data["text"]
data["retweeted_status"]["entities"] = data["retweeted_status"]["extended_tweet"]["entities"]
data["full_text"] = data["text"]
if data.has_key("quoted_status"):
if data["quoted_status"].has_key("extended_tweet"):
data["quoted_status"]["full_text"] = data["quoted_status"]["extended_tweet"]["full_text"]
data["quoted_status"]["entities"] = data["quoted_status"]["extended_tweet"]["entities"]
data["full_text"] = data["text"]
self.check_tls(data)

View File

@ -137,8 +137,13 @@ class streamer(TwythonStreamer):
if data.has_key("retweeted_status"):
if data["retweeted_status"].has_key("extended_tweet"):
data["retweeted_status"]["full_text"] = data["retweeted_status"]["extended_tweet"]["full_text"]
data["full_text"] = data["text"]
data["retweeted_status"]["entities"] = data["retweeted_status"]["extended_tweet"]["entities"]
data["full_text"] = data["text"]
if data.has_key("quoted_status"):
if data["quoted_status"].has_key("extended_tweet"):
data["quoted_status"]["full_text"] = data["quoted_status"]["extended_tweet"]["full_text"]
data["quoted_status"]["entities"] = data["quoted_status"]["extended_tweet"]["entities"]
data["full_text"] = data["text"]
if data["user"]["id"] in self.muted_users: return
self.check_mentions(data)
self.check_send(data)

View File

@ -123,9 +123,7 @@ def compose_quoted_tweet(quoted_tweet, original_tweet, show_screen_names=False):
text = "rt @%s: %s" % (quoted_tweet["retweeted_status"]["user"]["screen_name"], 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"])
elif original_tweet.has_key("full_text"):
if original_tweet.has_key("full_text"):
original_text = StripChars(original_tweet["full_text"])
else:
original_text = StripChars(original_tweet["text"])