diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index c3b8e34b..3cae3467 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -267,9 +267,8 @@ class baseBufferController(bufferController): l = tweets.is_long(tweet) while l != False: tweetsList.append(tweet) - id = tweets.get_id(l) try: - tweet = self.session.twitter.twitter.show_status(id=id, include_ext_alt_text=True) + tweet = self.session.twitter.twitter.show_status(id=l, include_ext_alt_text=True) urls = utils.find_urls_in_text(tweet["text"]) for url in range(0, len(urls)): try: tweet["text"] = tweet["text"].replace(urls[url], tweet["entities"]["urls"][url]["expanded_url"]) diff --git a/src/controller/messages.py b/src/controller/messages.py index bb302e0e..6412028f 100644 --- a/src/controller/messages.py +++ b/src/controller/messages.py @@ -174,12 +174,15 @@ class viewTweet(basicTweet): text = "" for i in xrange(0, len(tweetList)): # tweets with message keys are longer tweets, the message value is the full messaje taken from twishort. - if tweetList[i].has_key("message"): + if tweetList[i].has_key("message") and tweetList[i]["is_quote_status"] == False: value = "message" else: value = "text" - if tweetList[i].has_key("retweeted_status"): - text = text + "rt @%s: %s\n" % (tweetList[i]["retweeted_status"]["user"]["screen_name"], tweetList[i][value]) + if tweetList[i].has_key("retweeted_status") and tweetList[i]["is_quote_status"] == False: + if tweetList[i].has_key("message") == False: + text = text + "rt @%s: %s\n" % (tweetList[i]["retweeted_status"]["user"]["screen_name"], tweetList[i]["retweeted_status"]["text"]) + else: + text = text + "rt @%s: %s\n" % (tweetList[i]["retweeted_status"]["user"]["screen_name"], tweetList[i][value]) else: text = text + "@%s: %s\n" % (tweetList[i]["user"]["screen_name"], tweetList[i][value]) # tweets with extended_entities could include image descriptions. @@ -198,7 +201,10 @@ class viewTweet(basicTweet): else: value = "text" if tweet.has_key("retweeted_status"): - text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], tweet[value]) + if tweet.has_key("message") == False: + text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], tweet["retweeted_status"]["text"]) + else: + text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], tweet[value]) else: text = tweet[value] text = self.clear_text(text) diff --git a/src/long_tweets/tweets.py b/src/long_tweets/tweets.py index a13d4859..cc5bbee4 100644 --- a/src/long_tweets/tweets.py +++ b/src/long_tweets/tweets.py @@ -18,15 +18,10 @@ ############################################################ from twitter import utils -def get_id(url): - return url.split("/")[-1] - def is_long(tweet): - long = False - for url in range(0, len(tweet["entities"]["urls"])): - if "twitter.com" in tweet["entities"]["urls"][url]["expanded_url"]: - long = get_id(tweet["entities"]["urls"][url]["expanded_url"]) - return long + if tweet.has_key("is_quote_status") and tweet["is_quote_status"] == True: + return tweet["quoted_status_id"] + return False def clear_url(tweet): urls = utils.find_urls_in_text(tweet["text"]) diff --git a/src/sessionmanager/session.py b/src/sessionmanager/session.py index c787141b..2c51278e 100644 --- a/src/sessionmanager/session.py +++ b/src/sessionmanager/session.py @@ -426,7 +426,6 @@ class Session(object): def check_quoted_status(self, tweet): status = tweets.is_long(tweet) if status != False: - tweet["quoted"] = 1 tweet = self.get_quoted_tweet(tweet) return tweet @@ -437,8 +436,7 @@ class Session(object): for url in range(0, len(urls)): try: quoted_tweet["text"] = quoted_tweet["text"].replace(urls[url], quoted_tweet["entities"]["urls"][url]["expanded_url"]) except IndexError: pass - l = tweets.is_long(quoted_tweet) - id = tweets.get_id(l) + id = tweets.is_long(quoted_tweet) try: original_tweet = self.twitter.twitter.show_status(id=id) except: return quoted_tweet urls = utils.find_urls_in_text(original_tweet["text"]) diff --git a/src/twitter/compose.py b/src/twitter/compose.py index 515623aa..63fdc525 100644 --- a/src/twitter/compose.py +++ b/src/twitter/compose.py @@ -50,9 +50,11 @@ def compose_tweet(tweet, db, relative_times): elif tweet.has_key("user"): user = tweet["user"]["name"] source = re.sub(r"(?s)<.*?>", "", tweet["source"]) - try: text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet[value])) - except KeyError: pass -#text = "%s" % (StripChars(tweet["text"])) + if tweet.has_key("retweeted_status"): + if tweet.has_key("message") == False: + text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet["retweeted_status"]["text"])) + else: + text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet[value])) if text[-1] in chars: text=text+"." urls = utils.find_urls_in_text(text) for url in range(0, len(urls)):