From ef2d672b35dce9aecd15fc2654f32ca593542ad8 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 7 Nov 2017 16:49:49 -0600 Subject: [PATCH 1/5] Increased limit to 280 characters in tweets. Closes #172 --- doc/changelog.md | 1 + src/controller/messages.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 4e5d974c..add945f0 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -5,6 +5,7 @@ * When authorising an account, you will see a dialogue with a cancel button, in case you want to abort the process. Also, NVDA will not be blocked when the process starts. ([#101](https://github.com/manuelcortez/TWBlue/issues/101)) * 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)) ## changes in version 0.91 and 0.92 diff --git a/src/controller/messages.py b/src/controller/messages.py index 52df839b..0ec13312 100644 --- a/src/controller/messages.py +++ b/src/controller/messages.py @@ -18,7 +18,7 @@ from twitter import utils class basicTweet(object): """ This class handles the tweet main features. Other classes should derive from this class.""" - def __init__(self, session, title, caption, text, messageType="tweet", max=140, *args, **kwargs): + def __init__(self, session, title, caption, text, messageType="tweet", max=280, *args, **kwargs): super(basicTweet, self).__init__() self.max = max self.title = title @@ -124,7 +124,7 @@ class basicTweet(object): self.message.text_focus() class tweet(basicTweet): - def __init__(self, session, title, caption, text, twishort_enabled, messageType="tweet", max=140, *args, **kwargs): + def __init__(self, session, title, caption, text, twishort_enabled, max=280, messageType="tweet", *args, **kwargs): super(tweet, self).__init__(session, title, caption, text, messageType, max, *args, **kwargs) self.image = None widgetUtils.connect_event(self.message.upload_image, widgetUtils.BUTTON_PRESSED, self.upload_image) From 3a465f231412a853265de56752955d24a3b1e7f6 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 7 Nov 2017 16:57:46 -0600 Subject: [PATCH 2/5] display extended retweets properly. Fixes #173 --- doc/changelog.md | 2 +- src/twitter/compose.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index add945f0..ce20befe 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)) +* 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)) ## changes in version 0.91 and 0.92 diff --git a/src/twitter/compose.py b/src/twitter/compose.py index 7506c027..e326006c 100644 --- a/src/twitter/compose.py +++ b/src/twitter/compose.py @@ -44,8 +44,10 @@ def compose_tweet(tweet, db, relative_times, show_screen_names=False): value = "full_text" else: value = "text" -# log.exception(tweet.keys()) - text = StripChars(tweet[value]) + if tweet.has_key("retweeted_status") and value == "full_text": + text = StripChars(tweet["retweeted_status"][value]) + else: + text = StripChars(tweet[value]) if show_screen_names: user = tweet["user"]["screen_name"] else: From 68ea029fe329e1b8c8ea126606a27c8c8ed15aa1 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Tue, 7 Nov 2017 17:49:43 -0600 Subject: [PATCH 3/5] Remove unneeded code --- src/twitter/compose.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/twitter/compose.py b/src/twitter/compose.py index e326006c..0c5f03dc 100644 --- a/src/twitter/compose.py +++ b/src/twitter/compose.py @@ -44,7 +44,7 @@ def compose_tweet(tweet, db, relative_times, show_screen_names=False): value = "full_text" else: value = "text" - if tweet.has_key("retweeted_status") and value == "full_text": + if tweet.has_key("retweeted_status") and value != "message": text = StripChars(tweet["retweeted_status"][value]) else: text = StripChars(tweet[value]) @@ -55,12 +55,11 @@ def compose_tweet(tweet, db, relative_times, show_screen_names=False): source = re.sub(r"(?s)<.*?>", "", tweet["source"]) if tweet.has_key("retweeted_status"): if tweet.has_key("message") == False and tweet["retweeted_status"]["is_quote_status"] == False: - text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet["retweeted_status"][value])) + text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], text) elif tweet["retweeted_status"]["is_quote_status"]: - text = "%s" % (StripChars(tweet[value])) + text = "%s" % (text) else: - text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], StripChars(tweet[value])) -# if text[-1] in chars: text=text+"." + text = "RT @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], text) if tweet.has_key("message") == False: urls = utils.find_urls_in_text(text) for url in range(0, len(urls)): From ed7c9802d150c9b45cb5185bb0d923ac109b696e Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 8 Nov 2017 09:43:12 -0600 Subject: [PATCH 4/5] 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) From 0d0aed0490eb96f2ee7ee327749b9f7a3006997c Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 8 Nov 2017 12:09:53 -0600 Subject: [PATCH 5/5] Long tweet and mention to all options won't be saved in config. Closes #170 --- doc/changelog.md | 1 + src/Conf.defaults | 2 -- src/controller/buffersController.py | 19 +++++++------------ src/controller/messages.py | 13 +++---------- src/wxUI/dialogs/message.py | 1 - 5 files changed, 11 insertions(+), 25 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 8683430e..66af84dd 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -6,6 +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)) +* Per popular request, Status for mention to all and long tweet checkboxes will not be saved in settings. ([#170](https://github.com/manuelcortez/TWBlue/issues/170)) * 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/Conf.defaults b/src/Conf.defaults index 9c415648..85c88ae6 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -42,6 +42,4 @@ autoread_buffers = list(default=list(mentions, direct_messages, events)) spelling_language = string(default="") save_followers_in_autocompletion_db = boolean(default=False) save_friends_in_autocompletion_db = boolean(default=False) -twishort_enabled = boolean(default=False) -mention_all = boolean(default=True) ocr_language = string(default="") \ No newline at end of file diff --git a/src/controller/buffersController.py b/src/controller/buffersController.py index 8262eda1..099e69dd 100644 --- a/src/controller/buffersController.py +++ b/src/controller/buffersController.py @@ -136,11 +136,10 @@ class bufferController(object): def post_tweet(self, *args, **kwargs): title = _(u"Tweet") caption = _(u"Write the tweet here") - tweet = messages.tweet(self.session, title, caption, "", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"]) + tweet = messages.tweet(self.session, title, caption, "") if tweet.message.get_response() == widgetUtils.OK: - self.session.settings["mysc"]["twishort_enabled"] = tweet.message.long_tweet.GetValue() text = tweet.message.get_text() - if len(text) > 140 and tweet.message.get("long_tweet") == True: + if len(text) > 280 and tweet.message.get("long_tweet") == True: if not hasattr(tweet, "attachments"): text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text) else: @@ -517,12 +516,9 @@ class baseBufferController(bufferController): title=_("Reply to {arg0}").format(arg0=screen_name) else: title=_("Reply") - message = messages.reply(self.session, title, _(u"Reply to %s") % (screen_name,), "", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"], users=users, ids=ids) + message = messages.reply(self.session, title, _(u"Reply to %s") % (screen_name,), "", users=users, ids=ids) if message.message.get_response() == widgetUtils.OK: params = {"_sound": "reply_send.ogg", "in_reply_to_status_id": id,} - self.session.settings["mysc"]["twishort_enabled"] = message.message.long_tweet.GetValue() - if len(message.users) > 0: - self.session.settings["mysc"]["mention_all"] = message.message.mentionAll.GetValue() text = message.message.get_text() if twishort_enabled == False: excluded_ids = message.get_ids() @@ -531,7 +527,7 @@ class baseBufferController(bufferController): else: mentioned_people = message.get_people() text = "@"+screen_name+" "+mentioned_people+u" "+text - if len(text) > 140 and message.message.get("long_tweet") == True: + if len(text) > 280 and message.message.get("long_tweet") == True: if message.image == None: text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text) else: @@ -589,7 +585,7 @@ class baseBufferController(bufferController): comments = tweet["full_text"] else: comments = tweet["text"] - retweet = messages.tweet(self.session, _(u"Quote"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (tweet["user"]["screen_name"], comments), max=116, messageType="retweet", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"]) + retweet = messages.tweet(self.session, _(u"Quote"), _(u"Add your comment to the tweet"), u"“@%s: %s ”" % (tweet["user"]["screen_name"], comments), max=256, messageType="retweet") if comment != '': retweet.message.set_text(comment) if retweet.message.get_response() == widgetUtils.OK: @@ -1217,12 +1213,11 @@ class trendsBufferController(bufferController): if self.buffer.list.get_count() == 0: return title = _(u"Tweet") caption = _(u"Write the tweet here") - tweet = messages.tweet(self.session, title, caption, self.get_message()+ " ", twishort_enabled=self.session.settings["mysc"]["twishort_enabled"]) + tweet = messages.tweet(self.session, title, caption, self.get_message()+ " ") tweet.message.set_cursor_at_end() if tweet.message.get_response() == widgetUtils.OK: - self.session.settings["mysc"]["twishort_enabled"] = tweet.message.long_tweet.GetValue() text = tweet.message.get_text() - if len(text) > 140 and tweet.message.get("long_tweet") == True: + if len(text) > 280 and tweet.message.get("long_tweet") == True: if tweet.image == None: text = twishort.create_tweet(self.session.settings["twitter"]["user_key"], self.session.settings["twitter"]["user_secret"], text) else: diff --git a/src/controller/messages.py b/src/controller/messages.py index 0ec13312..ff0fb7de 100644 --- a/src/controller/messages.py +++ b/src/controller/messages.py @@ -124,14 +124,11 @@ class basicTweet(object): self.message.text_focus() class tweet(basicTweet): - def __init__(self, session, title, caption, text, twishort_enabled, max=280, messageType="tweet", *args, **kwargs): + def __init__(self, session, title, caption, text, max=280, messageType="tweet", *args, **kwargs): super(tweet, self).__init__(session, title, caption, text, messageType, max, *args, **kwargs) self.image = None widgetUtils.connect_event(self.message.upload_image, widgetUtils.BUTTON_PRESSED, self.upload_image) widgetUtils.connect_event(self.message.autocompletionButton, widgetUtils.BUTTON_PRESSED, self.autocomplete_users) - if twishort_enabled == False: - try: self.message.long_tweet.SetValue(False) - except AttributeError: pass self.text_processor() def upload_image(self, *args, **kwargs): @@ -144,16 +141,13 @@ class tweet(basicTweet): c.show_menu() class reply(tweet): - def __init__(self, session, title, caption, text, twishort_enabled, users=[], ids=[]): - super(reply, self).__init__(session, title, caption, text, twishort_enabled, messageType="reply", users=users) + def __init__(self, session, title, caption, text, users=[], ids=[]): + super(reply, self).__init__(session, title, caption, text, messageType="reply", users=users) self.ids = ids self.users = users if len(users) > 0: widgetUtils.connect_event(self.message.mentionAll, widgetUtils.CHECKBOX, self.mention_all) self.message.enable_button("mentionAll") - self.message.mentionAll.SetValue(self.session.settings["mysc"]["mention_all"]) - if self.message.mentionAll.GetValue() == True: - self.mention_all() self.message.set_cursor_at_end() self.text_processor() @@ -167,7 +161,6 @@ class reply(tweet): i.SetValue(False) i.Show() - def get_ids(self): excluded_ids = "" for i in xrange(0, len(self.message.checkboxes)): diff --git a/src/wxUI/dialogs/message.py b/src/wxUI/dialogs/message.py index 95c45809..998add9d 100644 --- a/src/wxUI/dialogs/message.py +++ b/src/wxUI/dialogs/message.py @@ -71,7 +71,6 @@ class tweet(textLimited): self.createTextArea(message, text) self.mainBox.Add(self.textBox, 0, wx.ALL, 5) self.long_tweet = wx.CheckBox(self.panel, -1, _(u"&Long tweet")) - self.long_tweet.SetValue(True) self.upload_image = wx.Button(self.panel, -1, _(u"&Upload image..."), size=wx.DefaultSize) self.spellcheck = wx.Button(self.panel, -1, _("Check &spelling..."), size=wx.DefaultSize) self.attach = wx.Button(self.panel, -1, _(u"&Attach audio..."), size=wx.DefaultSize)