From ed7c9802d150c9b45cb5185bb0d923ac109b696e Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 8 Nov 2017 09:43:12 -0600 Subject: [PATCH] Fixed extended retweets in Streaming API. Closes #174 --- doc/changelog.md | 2 +- src/twitter/buffers/indibidual.py | 10 +++++----- src/twitter/buffers/stream.py | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index ce20befe..8683430e 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -6,7 +6,7 @@ * In the translator module, the list of available languages is fetched automatically from the provider. That means all of these languages will work and there will not be inconsistencies. Also we've removed the first combo box, because the language is detected automatically by Yandex'S API. ([#153](https://github.com/manuelcortez/TWBlue/issues/153)) * Trending topics, searches and conversation buffers will use mute settings set for the session in wich they were opened. ([#157](https://github.com/manuelcortez/TWBlue/issues/157)) * The Tweet limit is now 280 characters lenght instead 140. It means you can tweet longer tweets. ([#172](https://github.com/manuelcortez/TWBlue/issues/172)) -* And more. ([#156,](https://github.com/manuelcortez/TWBlue/issues/156) [#163,](https://github.com/manuelcortez/TWBlue/issues/163) [#159,](https://github.com/manuelcortez/TWBlue/issues/159) [#173,](https://github.com/manuelcortez/TWBlue/issues/173)) +* And more. ([#156,](https://github.com/manuelcortez/TWBlue/issues/156) [#163,](https://github.com/manuelcortez/TWBlue/issues/163) [#159,](https://github.com/manuelcortez/TWBlue/issues/159) [#173,](https://github.com/manuelcortez/TWBlue/issues/173) [#174,](https://github.com/manuelcortez/TWBlue/issues/174)) ## changes in version 0.91 and 0.92 diff --git a/src/twitter/buffers/indibidual.py b/src/twitter/buffers/indibidual.py index 66c7d74d..e23e5078 100644 --- a/src/twitter/buffers/indibidual.py +++ b/src/twitter/buffers/indibidual.py @@ -60,12 +60,12 @@ class timelinesStreamer(TwythonStreamer): self.friends = friends def on_success(self, data): -# try: if "text" in data and utils.is_allowed(data, self.session.settings["twitter"]["ignored_clients"]) == True: if data.has_key("extended_tweet"): data["full_text"] = data["extended_tweet"]["full_text"] -# data["entities"] = data["extended_tweet"]["entities"] -# log.error(data["extended_entities"]) + 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"] self.check_tls(data) -# except: -# pass diff --git a/src/twitter/buffers/stream.py b/src/twitter/buffers/stream.py index 77929082..f8a624f0 100644 --- a/src/twitter/buffers/stream.py +++ b/src/twitter/buffers/stream.py @@ -132,8 +132,11 @@ class streamer(TwythonStreamer): if data.has_key("extended_tweet"): data["full_text"] = data["extended_tweet"]["full_text"] data["entities"] = data["extended_tweet"]["entities"] -# log.error(data["extended_tweet"]) -# log.error("Extended tweet") + 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"] if data["user"]["id"] in self.muted_users: return self.check_mentions(data) self.check_send(data)