From ab979e26237e0cb520915a091a9936a9387b50cd Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 13 May 2022 13:04:12 -0500 Subject: [PATCH 1/4] Added setting to hide emojis in usernames --- doc/changelog.md | 5 +++++ requirements.txt | 1 + src/Conf.defaults | 1 + src/controller/settings.py | 2 ++ src/sessions/twitter/session.py | 10 ++++++++-- src/wxUI/dialogs/configuration.py | 2 ++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 83d7022f..a89e3001 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -1,6 +1,11 @@ TWBlue Changelog ## changes in this version +* Fixed an issue that was making TWBlue to display incorrectly some retweets of quoted tweets. +* Implemented a new setting, available in the account settings dialog, that allows to hide emojis in twitter usernames. + +## changes in version 22.2.23 + * We have added Experimental support for templates in the invisible interface. The GUI will remain unchanged for now: * Each object (tweet, received direct message, sent direct message and people) has its own template in the settings. You can edit those templates from the account settings dialog, in the new "templates" tab. * Every template is composed of the group of variables you want to display for each object. Each variable will start with a dollar sign ($) and cannot contain spaces or special characters. Templates can include arbitrary text that will not be processed. When editing the example templates, you can get an idea of the variables that are available for each object by using the template editing dialog. When you press enter on a variable from the list of available variables, it will be added to the template automatically. When you try to save a template, TWBlue will warn you if the template is incorrectly formatted or if it includes variables that do not exist in the information provided by objects. It is also possible to return to default values from the same dialog when editing a template. diff --git a/requirements.txt b/requirements.txt index 576a6522..d03a714d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -48,6 +48,7 @@ importlib-metadata numpy pillow charset-normalizer +demoji git+https://github.com/accessibleapps/libloader git+https://github.com/accessibleapps/platform_utils git+https://github.com/accessibleapps/accessible_output2 diff --git a/src/Conf.defaults b/src/Conf.defaults index da579d6b..c937d90a 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -14,6 +14,7 @@ retweet_mode = string(default="ask") persist_size = integer(default=0) load_cache_in_memory=boolean(default=True) show_screen_names = boolean(default=False) +hide_emojis = boolean(default=False) buffer_order = list(default=list('home','mentions', 'dm', 'sent_dm', 'sent_tweets','favorites','followers','friends','blocks','muted')) [sound] diff --git a/src/controller/settings.py b/src/controller/settings.py index 81b077c7..c4ab8d2f 100644 --- a/src/controller/settings.py +++ b/src/controller/settings.py @@ -145,6 +145,7 @@ class accountSettingsController(globalSettingsController): widgetUtils.connect_event(self.dialog.general.au, widgetUtils.BUTTON_PRESSED, self.manage_autocomplete) self.dialog.set_value("general", "relative_time", self.config["general"]["relative_times"]) self.dialog.set_value("general", "show_screen_names", self.config["general"]["show_screen_names"]) + self.dialog.set_value("general", "hide_emojis", self.config["general"]["hide_emojis"]) self.dialog.set_value("general", "itemsPerApiCall", self.config["general"]["max_tweets_per_call"]) self.dialog.set_value("general", "reverse_timelines", self.config["general"]["reverse_timelines"]) rt = self.config["general"]["retweet_mode"] @@ -242,6 +243,7 @@ class accountSettingsController(globalSettingsController): log.debug("Triggered app restart due to change in relative times.") self.config["general"]["relative_times"] = self.dialog.get_value("general", "relative_time") self.config["general"]["show_screen_names"] = self.dialog.get_value("general", "show_screen_names") + self.config["general"]["hide_emojis"] = self.dialog.get_value("general", "hide_emojis") self.config["general"]["max_tweets_per_call"] = self.dialog.get_value("general", "itemsPerApiCall") if self.config["general"]["load_cache_in_memory"] != self.dialog.get_value("general", "load_cache_in_memory"): self.config["general"]["load_cache_in_memory"] = self.dialog.get_value("general", "load_cache_in_memory") diff --git a/src/sessions/twitter/session.py b/src/sessions/twitter/session.py index 735b1b7e..94bf3ae3 100644 --- a/src/sessions/twitter/session.py +++ b/src/sessions/twitter/session.py @@ -5,6 +5,7 @@ import time import logging import webbrowser import wx +import demoji import config import output import application @@ -472,11 +473,16 @@ class Session(base.baseSession): aliases = self.settings.get("user-aliases") if aliases == None: log.error("Aliases are not defined for this config spec.") - return user.name + return self.demoji_user(user.name) user_alias = aliases.get(user.id_str) if user_alias != None: return user_alias - return user.name + return self.demoji_user(user.name) + + def demoji_user(self, name): + if self.settings["general"]["hide_emojis"] == True: + return demoji.replace(name, "") + return name def get_user_by_screen_name(self, screen_name): """ Returns an user identifier associated with a screen_name. diff --git a/src/wxUI/dialogs/configuration.py b/src/wxUI/dialogs/configuration.py index e8220ae9..ba5345c2 100644 --- a/src/wxUI/dialogs/configuration.py +++ b/src/wxUI/dialogs/configuration.py @@ -120,6 +120,8 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog): sizer.Add(rMode, 0, wx.ALL, 5) self.show_screen_names = wx.CheckBox(self, wx.ID_ANY, _(U"Show screen names instead of full names")) sizer.Add(self.show_screen_names, 0, wx.ALL, 5) + self.hide_emojis = wx.CheckBox(self, wx.ID_ANY, _("hide emojis in usernames")) + sizer.Add(self.hide_emojis, 0, wx.ALL, 5) PersistSizeLabel = wx.StaticText(self, -1, _(u"Number of items per buffer to cache in database (0 to disable caching, blank for unlimited)")) self.persist_size = wx.TextCtrl(self, -1) sizer.Add(PersistSizeLabel, 0, wx.ALL, 5) From fa9ebea83669ad1c492a19bc3b4cb1a0f6844b19 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 13 May 2022 13:22:52 -0500 Subject: [PATCH 2/4] Remove issue reporting dialogs as we no longer use mantis --- src/application.py | 2 +- src/controller/mainController.py | 5 -- src/issueReporter/__init__.py | 0 src/issueReporter/constants.py | 22 ------- src/issueReporter/issueReporter.py | 66 --------------------- src/issueReporter/wx_ui.py | 95 ------------------------------ 6 files changed, 1 insertion(+), 189 deletions(-) delete mode 100644 src/issueReporter/__init__.py delete mode 100644 src/issueReporter/constants.py delete mode 100644 src/issueReporter/issueReporter.py delete mode 100644 src/issueReporter/wx_ui.py diff --git a/src/application.py b/src/application.py index f173a916..f9227f4b 100644 --- a/src/application.py +++ b/src/application.py @@ -9,6 +9,6 @@ copyright = "Copyright (C) 2013-2022, MCV Software." description = name+" is an app designed to use Twitter simply and efficiently while using minimal system resources. This app provides access to most Twitter features." translators = ["Manuel Cortéz (English)", "Mohammed Al Shara, Hatoun Felemban (Arabic)", "Francisco Torres (Catalan)", "Manuel cortéz (Spanish)", "Sukil Etxenike Arizaleta (Basque)", "Jani Kinnunen (finnish)", "Corentin Bacqué-Cazenave (Français)", "Juan Buño (Galician)", "Steffen Schultz (German)", "Zvonimir Stanečić (Croatian)", "Robert Osztolykan (Hungarian)", "Christian Leo Mameli (Italian)", "Riku (Japanese)", "Paweł Masarczyk (Polish)", "Odenilton Júnior Santos (Portuguese)", "Florian Ionașcu, Nicușor Untilă (Romanian)", "Natalia Hedlund, Valeria Kuznetsova (Russian)", "Aleksandar Đurić (Serbian)", "Burak Yüksek (Turkish)"] url = "https://twblue.es" -report_bugs_url = "https://github.com/manuelcortez/twblue/issues" +report_bugs_url = "https://github.com/mcvsoftware/twblue/issues" supported_languages = [] version = "11" diff --git a/src/controller/mainController.py b/src/controller/mainController.py index cc24c47a..d97e8bd3 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -18,7 +18,6 @@ if system == "Windows": from . import user from . import listsController from . import filterController -# from issueReporter import issueReporter elif system == "Linux": from gtkUI import (view, commonMessageDialogs) from sessions.twitter import utils, compose @@ -185,7 +184,6 @@ class Controller(object): widgetUtils.connect_event(self.view, widgetUtils.MENU, self.seekRight, menuitem=self.view.seekRight) if widgetUtils.toolkit == "wx": widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed) - widgetUtils.connect_event(self.view, widgetUtils.MENU, self.report_error, self.view.reportError) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.view_documentation, self.view.doc) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.view_changelog, self.view.changelog) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_alias, self.view.addAlias) @@ -611,9 +609,6 @@ class Controller(object): buff.session.save_persistent_data() restart.restart_program() - def report_error(self, *args, **kwargs): - r = issueReporter.reportBug(self.get_best_buffer().session.db["user_name"]) - def check_for_updates(self, *args, **kwargs): update = updater.do_update() if update == False: diff --git a/src/issueReporter/__init__.py b/src/issueReporter/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/src/issueReporter/constants.py b/src/issueReporter/constants.py deleted file mode 100644 index 3c254c53..00000000 --- a/src/issueReporter/constants.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################ -# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################ -from __future__ import unicode_literals -categories = ["General"] -reproducibilities = ["always", "sometimes", "random", "have not tried", "unable to duplicate"] -severities = ["block", "crash", "major", "minor", "tweak", "text", "trivial", "feature"] diff --git a/src/issueReporter/issueReporter.py b/src/issueReporter/issueReporter.py deleted file mode 100644 index db261b5e..00000000 --- a/src/issueReporter/issueReporter.py +++ /dev/null @@ -1,66 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################ -# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################ -from __future__ import unicode_literals -from builtins import object -import keys -import wx -import wx_ui -import widgetUtils -import application -from suds.client import Client -import constants - -class reportBug(object): - def __init__(self, user_name): - self.user_name = user_name - self.categories = [_(u"General")] - self.reproducibilities = [_(u"always"), _(u"sometimes"), _(u"random"), _(u"have not tried"), _(u"unable to duplicate")] - self.severities = [_(u"block"), _(u"crash"), _(u"major"), _(u"minor"), _(u"tweak"), _(u"text"), _(u"trivial"), _(u"feature")] - self.dialog = wx_ui.reportBugDialog(self.categories, self.reproducibilities, self.severities) - widgetUtils.connect_event(self.dialog.ok, widgetUtils.BUTTON_PRESSED, self.send) - self.dialog.get_response() - - def send(self, *args, **kwargs): - if self.dialog.get("summary") == "" or self.dialog.get("description") == "": - self.dialog.no_filled() - return - if self.dialog.get("agree") == False: - self.dialog.no_checkbox() - return - try: - client = Client(application.report_bugs_url) - issue = client.factory.create('IssueData') - issue.project.name = application.name - issue.project.id = 0 - issue.summary = self.dialog.get("summary"), - issue.description = "Reported by @%s on version %s (snapshot = %s)\n\n" % (self.user_name, application.version, application.snapshot) + self.dialog.get("description") - # to do: Create getters for category, severity and reproducibility in wx_UI. - issue.category = constants.categories[self.dialog.category.GetSelection()] - issue.reproducibility.name = constants.reproducibilities[self.dialog.reproducibility.GetSelection()] - issue.severity.name = constants.severities[self.dialog.severity.GetSelection()] - issue.priority.name = "normal" - issue.view_state.name = "public" - issue.resolution.name = "open" - issue.projection.name = "none" - issue.eta.name = "eta" - issue.status.name = "new" - id = client.service.mc_issue_add(keys.keyring.get("bts_user"), keys.keyring.get("bts_password"), issue) - self.dialog.success(id) - except: - self.dialog.error() diff --git a/src/issueReporter/wx_ui.py b/src/issueReporter/wx_ui.py deleted file mode 100644 index 82d0c51c..00000000 --- a/src/issueReporter/wx_ui.py +++ /dev/null @@ -1,95 +0,0 @@ -# -*- coding: utf-8 -*- -############################################################ -# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -############################################################ -from __future__ import unicode_literals -import wx -import widgetUtils -import application -class reportBugDialog(widgetUtils.BaseDialog): - def __init__(self, categories, reproducibilities, severities): - super(reportBugDialog, self).__init__(parent=None, id=wx.NewId()) - self.SetTitle(_(u"Report an error")) - panel = wx.Panel(self) - sizer = wx.BoxSizer(wx.VERTICAL) - categoryLabel = wx.StaticText(panel, -1, _(u"Select a category"), size=wx.DefaultSize) - self.category = wx.ComboBox(panel, -1, choices=categories, style=wx.CB_READONLY) - self.category.SetSelection(0) - categoryB = wx.BoxSizer(wx.HORIZONTAL) - categoryB.Add(categoryLabel, 0, wx.ALL, 5) - categoryB.Add(self.category, 0, wx.ALL, 5) - self.category.SetFocus() - sizer.Add(categoryB, 0, wx.ALL, 5) - summaryLabel = wx.StaticText(panel, -1, _(u"Briefly describe what happened. You will be able to thoroughly explain it later"), size=wx.DefaultSize) - self.summary = wx.TextCtrl(panel, -1) - dc = wx.WindowDC(self.summary) - dc.SetFont(self.summary.GetFont()) - self.summary.SetSize(dc.GetTextExtent("a"*80)) - summaryB = wx.BoxSizer(wx.HORIZONTAL) - summaryB.Add(summaryLabel, 0, wx.ALL, 5) - summaryB.Add(self.summary, 0, wx.ALL, 5) - sizer.Add(summaryB, 0, wx.ALL, 5) - descriptionLabel = wx.StaticText(panel, -1, _(u"Here, you can describe the bug in detail"), size=wx.DefaultSize) - self.description = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE) - dc = wx.WindowDC(self.description) - dc.SetFont(self.description.GetFont()) - (x, y, z) = dc.GetMultiLineTextExtent("0"*2000) - self.description.SetSize((x, y)) - descBox = wx.BoxSizer(wx.HORIZONTAL) - descBox.Add(descriptionLabel, 0, wx.ALL, 5) - descBox.Add(self.description, 0, wx.ALL, 5) - sizer.Add(descBox, 0, wx.ALL, 5) - reproducibilityLabel = wx.StaticText(panel, -1, _(u"how often does this bug happen?"), size=wx.DefaultSize) - self.reproducibility = wx.ComboBox(panel, -1, choices=reproducibilities, style=wx.CB_READONLY) - self.reproducibility.SetSelection(3) - reprB = wx.BoxSizer(wx.HORIZONTAL) - reprB.Add(reproducibilityLabel, 0, wx.ALL, 5) - reprB.Add(self.reproducibility, 0, wx.ALL, 5) - sizer.Add(reprB, 0, wx.ALL, 5) - severityLabel = wx.StaticText(panel, -1, _(u"Select the importance that you think this bug has")) - self.severity = wx.ComboBox(panel, -1, choices=severities, style=wx.CB_READONLY) - self.severity.SetSelection(3) - severityB = wx.BoxSizer(wx.HORIZONTAL) - severityB.Add(severityLabel, 0, wx.ALL, 5) - severityB.Add(self.severity, 0, wx.ALL, 5) - sizer.Add(severityB, 0, wx.ALL, 5) - self.agree = wx.CheckBox(panel, -1, _(u"I know that the {0} bug system will get my Twitter username to contact me and fix the bug quickly").format(application.name,)) - self.agree.SetValue(False) - sizer.Add(self.agree, 0, wx.ALL, 5) - self.ok = wx.Button(panel, wx.ID_OK, _(u"Send report")) - self.ok.SetDefault() - cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel")) - btnBox = wx.BoxSizer(wx.HORIZONTAL) - btnBox.Add(self.ok, 0, wx.ALL, 5) - btnBox.Add(cancel, 0, wx.ALL, 5) - sizer.Add(btnBox, 0, wx.ALL, 5) - panel.SetSizer(sizer) - self.SetClientSize(sizer.CalcMin()) - - def no_filled(self): - wx.MessageDialog(self, _(u"You must fill out both fields"), _(u"Error"), wx.OK|wx.ICON_ERROR).ShowModal() - - def no_checkbox(self): - wx.MessageDialog(self, _(u"You need to mark the checkbox to provide us your twitter username to contact you if it is necessary."), _(u"Error"), wx.ICON_ERROR).ShowModal() - - def success(self, id): - wx.MessageDialog(self, _(u"Thanks for reporting this bug! In future versions, you may be able to find it in the changes list. You've reported the bug number %i") % (id), _(u"reported"), wx.OK).ShowModal() - self.EndModal(wx.ID_OK) - - def error(self): - wx.MessageDialog(self, _(u"Something unexpected occurred while trying to report the bug. Please, try again later"), _(u"Error while reporting"), wx.ICON_ERROR|wx.OK).ShowModal() - self.EndModal(wx.ID_CANCEL) From bed8e26204310566996cb7bbf8781d85f3d58029 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 13 May 2022 13:33:10 -0500 Subject: [PATCH 3/4] Fixed loading of other users lists. Fixes #465 --- doc/changelog.md | 1 + src/controller/listsController.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/changelog.md b/doc/changelog.md index a89e3001..efa9827a 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -3,6 +3,7 @@ TWBlue Changelog * Fixed an issue that was making TWBlue to display incorrectly some retweets of quoted tweets. * Implemented a new setting, available in the account settings dialog, that allows to hide emojis in twitter usernames. +* Fixed error when loading other user lists. ([#465](https://github.com/MCV-Software/TWBlue/issues/465)) ## changes in version 22.2.23 diff --git a/src/controller/listsController.py b/src/controller/listsController.py index ca861c31..b5736bc4 100644 --- a/src/controller/listsController.py +++ b/src/controller/listsController.py @@ -32,7 +32,7 @@ class listsController(object): return [compose.compose_list(item) for item in self.session.db["lists"]] def get_user_lists(self, user): - self.lists = self.session.twitter.lists_all(reverse=True, screen_name=user) + self.lists = self.session.twitter.get_lists(reverse=True, screen_name=user) return [compose.compose_list(item) for item in self.lists] def create_list(self, *args, **kwargs): From 8bf9c6519e46e6b4273b29d9655e3ecb40b73962 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 20 May 2022 12:22:25 -0500 Subject: [PATCH 4/4] Improve text for direct messages when displayed via the templates system --- src/sessions/twitter/templates.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sessions/twitter/templates.py b/src/sessions/twitter/templates.py index ec54a13d..f8d6e9bb 100644 --- a/src/sessions/twitter/templates.py +++ b/src/sessions/twitter/templates.py @@ -114,7 +114,7 @@ def render_dm(dm, template, session, relative_times=False, offset_seconds=0): """ global dm_variables available_data = dict() - available_data.update(text=utils.expand_urls(dm.message_create["message_data"]["text"], dm.message_create["message_data"]["entities"])) + available_data.update(text=utils.expand_urls(utils.StripChars(dm.message_create["message_data"]["text"]), dm.message_create["message_data"]["entities"])) # Let's remove the last 3 digits in the timestamp string. # Twitter sends their "epoch" timestamp with 3 digits for milliseconds and arrow doesn't like it. original_date = arrow.get(int(dm.created_timestamp))