From 7e42a096a5e5b8e019e83ba898a73d3bdcccee5f Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 13 Nov 2018 16:33:17 -0600 Subject: [PATCH] Finished implementing autoreading features. Closes #221 --- doc/changelog.md | 1 + src/controller/buffers/twitterBuffers.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index 4f3e6ede..97ab0ee7 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -2,6 +2,7 @@ ## changes in this version +* autoreading has been redesigned to work in a similar way for almost all buffers. Needs testing. ([#221](https://github.com/manuelcortez/TWBlue/issues/221)) * When displaying tweets or direct messages, a new field has been added to show the date when the item has been posted to Twitter. * Added support for deleting direct messages by using the new Twitter API methods. * When quoting a retweet, the quote will be made to the original tweet instead of the retweet. diff --git a/src/controller/buffers/twitterBuffers.py b/src/controller/buffers/twitterBuffers.py index 5de86072..e03e9398 100644 --- a/src/controller/buffers/twitterBuffers.py +++ b/src/controller/buffers/twitterBuffers.py @@ -69,7 +69,18 @@ class baseBufferController(baseBuffers.buffer): basic_buffers = dict(home_timeline=_(u"Home"), mentions=_(u"Mentions"), direct_messages=_(u"Direct messages"), sent_direct_messages=_(u"Sent direct messages"), sent_tweets=_(u"Sent tweets"), favourites=_(u"Likes"), followers=_(u"Followers"), friends=_(u"Friends"), blocked=_(u"Blocked users"), muted=_(u"Muted users")) if self.name in basic_buffers.keys(): return basic_buffers[self.name] - return "unknown buffer" + # Check user timelines + elif hasattr(self, "username"): + if "-timeline" in self.name: + return _(u"{username}'s timeline").format(username=self.username,) + elif "-favorite" in self.name: + return _(u"{username}'s likes").format(username=self.username,) + elif "-followers" in self.name: + return _(u"{username}'s followers").format(username=self.username,) + elif "-friends" in self.name: + return _(u"{username}'s friends").format(username=self.username,) + log.error("Error getting name for buffer %s" % (self.name,)) + return _(u"Unknown buffer") def post_status(self, *args, **kwargs): title = _(u"Tweet") @@ -180,6 +191,7 @@ class baseBufferController(baseBuffers.buffer): tweet = self.session.db[self.name][-1] else: tweet = self.session.db[self.name][0] + output.speak(_(u"New tweet in {0}").format(self.get_buffer_name())) output.speak(" ".join(self.compose_function(tweet, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], self.session))) elif number_of_items > 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False: output.speak(_(u"{0} new tweets in {1}.").format(number_of_items, self.get_buffer_name())) @@ -702,6 +714,7 @@ class directMessagesController(baseBufferController): tweet = self.session.db[self.name]["items"][-1] else: tweet = self.session.db[self.name]["items"][0] + output.speak(_(u"New direct message")) output.speak(" ".join(self.compose_function(tweet, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], self.session))) elif number_of_items > 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False: output.speak(_(u"{0} new direct messages.").format(number_of_items,))