From 15eb0f62ea5ca2950cc8f353fcef58ecefdfc93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Tue, 24 Mar 2015 17:28:01 -0600 Subject: [PATCH] TWBlue does not open timelines for protected users when is not possible --- src/controller/mainController.py | 9 ++++++++- src/twitter/utils.py | 2 +- src/wxUI/commonMessageDialogs.py | 6 ++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 999a2367..35f9ded1 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -631,7 +631,14 @@ class Controller(object): dlg = dialogs.userSelection.selectUserDialog(users=users, default=default) if dlg.get_response() == widgetUtils.OK: buffer = self.get_best_buffer() - if utils.if_user_exists(buffer.session.twitter.twitter, dlg.get_user()) != None: + usr = utils.if_user_exists(buffer.session.twitter.twitter, dlg.get_user()) + if usr != None: + if usr["protected"] == True: + if usr["following"] == False: + commonMessageDialogs.no_following() + return + answer = commonMessageDialogs.protected_user() + if answer == widgetUtils.NO: return if dlg.get_action() == "tweets": if dlg.get_user() in buffer.session.settings["other_buffers"]["timelines"]: commonMessageDialogs.timeline_exist() diff --git a/src/twitter/utils.py b/src/twitter/utils.py index 8f2a4ecc..6e4f3ae8 100644 --- a/src/twitter/utils.py +++ b/src/twitter/utils.py @@ -82,7 +82,7 @@ def get_all_users(tweet, conf): def if_user_exists(twitter, user): try: data = twitter.show_user(screen_name=user) - return data["screen_name"] + return data except TwythonError as err: if err.error_code == 404: return None diff --git a/src/wxUI/commonMessageDialogs.py b/src/wxUI/commonMessageDialogs.py index 26d467e6..b4427b95 100644 --- a/src/wxUI/commonMessageDialogs.py +++ b/src/wxUI/commonMessageDialogs.py @@ -38,3 +38,9 @@ def timeline_exist(): def no_tweets(): return wx.MessageDialog(None, _(u"This user has no tweets. You can't open a timeline for this user"), _(u"Error!"), wx.ICON_ERROR).ShowModal() + +def protected_user(): + return wx.MessageDialog(None, _(u"This is a protected Twitter user. It means you can not open a timeline using the Streaming API. The user's tweets will not update due to a twitter policy. Do you want to continue?"), _(u"Warning"), wx.ICON_WARNING|wx.YES_NO).ShowModal() + +def no_following(): + return wx.MessageDialog(None, _(u"This is a protected user account, you need follow to this user for viewing your tweets or favourites."), _(u"Error"), wx.ICON_ERROR).ShowModal() \ No newline at end of file