From ab979e26237e0cb520915a091a9936a9387b50cd Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 13 May 2022 13:04:12 -0500 Subject: [PATCH] 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)