mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 04:48:09 -06:00
Added an option for displaying usernames instead full names
This commit is contained in:
parent
88a706dd7d
commit
516acb501a
@ -9,6 +9,7 @@
|
||||
* Fixed a bug that caused duplicated user mentions in replies when the tweet was made with Twishort.
|
||||
* Retweets should be displayed normally again when the originating tweet is a Twishort's long tweet.
|
||||
* Changed the way TWBlue saves user timelines in configuration. Now it uses user IDS instead usernames. With user IDS, if an user changes the username, TWBlue still will create his/her timeline. This was not possible by using usernames.
|
||||
* Added a new setting in the account settings dialogue that makes TWBlue to show twitter usernames instead the full name.
|
||||
|
||||
## Changes in version 0.87
|
||||
|
||||
@ -94,4 +95,4 @@
|
||||
* New followers and friends buffer for user timelines.
|
||||
|
||||
---
|
||||
Copyright © 2014-2016, Manuel Cortez.
|
||||
Copyright © 2014-2017, Manuel Cortez.
|
@ -348,4 +348,4 @@ Many thanks also to the people who worked on the documentation. Initially, [Manu
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Copyright © 2013-2016. Manuel Cortéz
|
||||
Copyright © 2013-2017. Manuel Cortéz
|
@ -13,6 +13,7 @@ time_to_check_streams = integer(default=30)
|
||||
announce_stream_status = boolean(default=True)
|
||||
retweet_mode = string(default="ask")
|
||||
persist_size = integer(default=0)
|
||||
show_screen_names = boolean(default=False)
|
||||
buffer_order = list(default=list('home','mentions','dm','sent_dm','sent_tweets','favorites','followers','friends','blocks','muted','events'))
|
||||
|
||||
[sound]
|
||||
|
@ -253,12 +253,12 @@ class baseBufferController(bufferController):
|
||||
self.kwargs.pop("user_id")
|
||||
|
||||
def get_formatted_message(self):
|
||||
if self.type == "dm" or self.name == "sent_tweets" or self.name == "sent_direct_messages": return self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"])[1]
|
||||
if self.type == "dm" or self.name == "sent_tweets" or self.name == "sent_direct_messages": return self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])[1]
|
||||
return self.get_message()
|
||||
|
||||
def get_message(self):
|
||||
tweet = self.get_right_tweet()
|
||||
return " ".join(self.compose_function(tweet, self.session.db, self.session.settings["general"]["relative_times"]))
|
||||
return " ".join(self.compose_function(tweet, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]))
|
||||
|
||||
def get_full_tweet(self):
|
||||
tweet = self.get_right_tweet()
|
||||
@ -339,11 +339,11 @@ class baseBufferController(bufferController):
|
||||
selection = self.buffer.list.get_selected()
|
||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||
for i in elements:
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||
self.buffer.list.insert_item(True, *tweet)
|
||||
else:
|
||||
for i in items:
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||
self.buffer.list.insert_item(False, *tweet)
|
||||
# self.buffer.list.select_item(selection+elements)
|
||||
# else:
|
||||
@ -386,25 +386,25 @@ class baseBufferController(bufferController):
|
||||
log.debug("Putting %d items on the list" % (number_of_items,))
|
||||
if self.buffer.list.get_count() == 0:
|
||||
for i in self.session.db[self.name]:
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||
self.buffer.list.insert_item(False, *tweet)
|
||||
self.buffer.set_position(self.session.settings["general"]["reverse_timelines"])
|
||||
elif self.buffer.list.get_count() > 0 and number_of_items > 0:
|
||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||
items = self.session.db[self.name][len(self.session.db[self.name])-number_of_items:]
|
||||
for i in items:
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||
self.buffer.list.insert_item(False, *tweet)
|
||||
else:
|
||||
items = self.session.db[self.name][0:number_of_items]
|
||||
items.reverse()
|
||||
for i in items:
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"])
|
||||
tweet = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||
self.buffer.list.insert_item(True, *tweet)
|
||||
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
|
||||
|
||||
def add_new_item(self, item):
|
||||
tweet = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"])
|
||||
tweet = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||
self.buffer.list.insert_item(False, *tweet)
|
||||
else:
|
||||
@ -743,7 +743,7 @@ class eventsBufferController(bufferController):
|
||||
return "%s. %s" % (self.buffer.list.list.GetItemText(self.buffer.list.get_selected()), self.buffer.list.list.GetItemText(self.buffer.list.get_selected(), 1))
|
||||
|
||||
def add_new_item(self, item):
|
||||
tweet = self.compose_function(item, self.session.db["user_name"])
|
||||
tweet = self.compose_function(item, self.session.db["user_name"], self.session.settings["general"]["show_screen_names"])
|
||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||
self.buffer.list.insert_item(False, *tweet)
|
||||
else:
|
||||
@ -821,7 +821,7 @@ class peopleBufferController(baseBufferController):
|
||||
pass
|
||||
|
||||
def get_message(self):
|
||||
return " ".join(self.compose_function(self.get_tweet(), self.session.db, self.session.settings["general"]["relative_times"]))
|
||||
return " ".join(self.compose_function(self.get_tweet(), self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"]))
|
||||
|
||||
def delete_item(self): pass
|
||||
|
||||
|
@ -121,6 +121,7 @@ class accountSettingsController(globalSettingsController):
|
||||
self.dialog.create_general_account()
|
||||
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", "apiCalls", self.config["general"]["max_api_calls"])
|
||||
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"])
|
||||
@ -169,6 +170,7 @@ class accountSettingsController(globalSettingsController):
|
||||
if self.config["general"]["relative_times"] != self.dialog.get_value("general", "relative_time"):
|
||||
self.needs_restart = True
|
||||
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"]["max_api_calls"] = self.dialog.get_value("general", "apiCalls")
|
||||
self.config["general"]["max_tweets_per_call"] = self.dialog.get_value("general", "itemsPerApiCall")
|
||||
if self.config["general"]["persist_size"] != self.dialog.get_value("general", "persist_size"):
|
||||
|
@ -28,7 +28,7 @@ def StripChars(s):
|
||||
|
||||
chars = "abcdefghijklmnopqrstuvwxyz"
|
||||
|
||||
def compose_tweet(tweet, db, relative_times):
|
||||
def compose_tweet(tweet, db, relative_times, show_screen_names=False):
|
||||
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
||||
if system == "Windows":
|
||||
original_date = arrow.get(tweet["created_at"], "ddd MMM DD H:m:s Z YYYY", locale="en")
|
||||
@ -46,6 +46,9 @@ def compose_tweet(tweet, db, relative_times):
|
||||
value = "text"
|
||||
# log.exception(tweet.keys())
|
||||
text = StripChars(tweet[value])
|
||||
if show_screen_names:
|
||||
user = tweet["user"]["screen_name"]
|
||||
else:
|
||||
user = tweet["user"]["name"]
|
||||
source = re.sub(r"(?s)<.*?>", "", tweet["source"])
|
||||
if tweet.has_key("retweeted_status"):
|
||||
@ -66,7 +69,7 @@ def compose_tweet(tweet, db, relative_times):
|
||||
# return [user+", ", text, ts+", ", source]
|
||||
return [user+", ", text, ts+", ", source]
|
||||
|
||||
def compose_dm(tweet, db, relative_times):
|
||||
def compose_dm(tweet, db, relative_times, show_screen_names=False):
|
||||
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
||||
if system == "Windows":
|
||||
original_date = arrow.get(tweet["created_at"], "ddd MMM DD H:m:s Z YYYY", locale="en")
|
||||
@ -78,8 +81,16 @@ def compose_dm(tweet, db, relative_times):
|
||||
ts = tweet["created_at"]
|
||||
text = StripChars(tweet["text"])
|
||||
source = "DM"
|
||||
if db["user_name"] == tweet["sender"]["screen_name"]: user = _(u"Dm to %s ") % (tweet["recipient"]["name"],)
|
||||
else: user = tweet["sender"]["name"]
|
||||
if db["user_name"] == tweet["sender"]["screen_name"]:
|
||||
if show_screen_names:
|
||||
user = _(u"Dm to %s ") % (tweet["recipient"]["screen_name"],)
|
||||
else:
|
||||
user = _(u"Dm to %s ") % (tweet["recipient"]["name"],)
|
||||
else:
|
||||
if show_screen_names:
|
||||
user = tweet["sender"]["screen_name"]
|
||||
else:
|
||||
user = tweet["sender"]["name"]
|
||||
if text[-1] in chars: text=text+"."
|
||||
urls = utils.find_urls_in_text(text)
|
||||
for url in range(0, len(urls)):
|
||||
@ -87,13 +98,16 @@ def compose_dm(tweet, db, relative_times):
|
||||
except IndexError: pass
|
||||
return [user+", ", text, ts+", ", source]
|
||||
|
||||
def compose_quoted_tweet(quoted_tweet, original_tweet):
|
||||
def compose_quoted_tweet(quoted_tweet, original_tweet, show_screen_names=False):
|
||||
""" It receives a tweet and returns a list with the user, text for the tweet or message, date and the client where user is."""
|
||||
if quoted_tweet.has_key("full_text"):
|
||||
value = "full_text"
|
||||
else:
|
||||
value = "text"
|
||||
text = StripChars(quoted_tweet[value])
|
||||
if show_screen_names:
|
||||
quoting_user = quoted_tweet["user"]["screen_name"]
|
||||
else:
|
||||
quoting_user = quoted_tweet["user"]["name"]
|
||||
source = re.sub(r"(?s)<.*?>", "", quoted_tweet["source"])
|
||||
try: text = "rt @%s: %s" % (quoted_tweet["retweeted_status"]["user"]["screen_name"], StripChars(quoted_tweet["retweeted_status"][value]))
|
||||
@ -110,7 +124,7 @@ def compose_quoted_tweet(quoted_tweet, original_tweet):
|
||||
quoted_tweet = tweets.clear_url(quoted_tweet)
|
||||
return quoted_tweet
|
||||
|
||||
def compose_followers_list(tweet, db, relative_times=True):
|
||||
def compose_followers_list(tweet, db, relative_times=True, show_screen_names=False):
|
||||
if system == "Windows":
|
||||
original_date = arrow.get(tweet["created_at"], "ddd MMM D H:m:s Z YYYY", locale="en")
|
||||
if relative_times == True:
|
||||
@ -132,11 +146,15 @@ def compose_followers_list(tweet, db, relative_times=True):
|
||||
ts2 = _("Unavailable")
|
||||
return [_(u"%s (@%s). %s followers, %s friends, %s tweets. Last tweeted %s. Joined Twitter %s") % (tweet["name"], tweet["screen_name"], tweet["followers_count"], tweet["friends_count"], tweet["statuses_count"], ts2, ts)]
|
||||
|
||||
def compose_event(data, username):
|
||||
def compose_event(data, username, show_screen_names=False):
|
||||
if show_screen_names:
|
||||
value = "screen_name"
|
||||
else:
|
||||
value = "name"
|
||||
if data["event"] == "block":
|
||||
event = _("You've blocked %s") % (data["target"]["name"])
|
||||
event = _("You've blocked %s") % (data["target"][value])
|
||||
elif data["event"] == "unblock":
|
||||
event = _(u"You've unblocked %s") % (data["target"]["name"])
|
||||
event = _(u"You've unblocked %s") % (data["target"][value])
|
||||
elif data["event"] == "follow":
|
||||
if data["target"]["screen_name"] == username:
|
||||
event = _(u"%s(@%s) has followed you") % (data["source"]["name"], data["source"]["screen_name"])
|
||||
@ -146,11 +164,11 @@ def compose_event(data, username):
|
||||
event = _(u"You've unfollowed %s (@%s)") % (data["target"]["name"], data["target"]["screen_name"])
|
||||
elif data["event"] == "favorite":
|
||||
if data["source"]["screen_name"] == username:
|
||||
event = _(u"You've liked: %s, %s") % (data["target"]["name"], data["target_object"]["text"])
|
||||
event = _(u"You've liked: %s, %s") % (data["target"][value], data["target_object"]["text"])
|
||||
else:
|
||||
event = _(u"%s(@%s) has liked: %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["text"])
|
||||
elif data["event"] == "unfavorite":
|
||||
if data["source"]["screen_name"] == username: event = _(u"You've unliked: %s, %s") % (data["target"]["name"], data["target_object"]["text"])
|
||||
if data["source"]["screen_name"] == username: event = _(u"You've unliked: %s, %s") % (data["target"][value], data["target_object"]["text"])
|
||||
else: event = _(u"%s(@%s) has unliked: %s") % (data["source"]["name"], data["source"]["screen_name"], data["target_object"]["text"])
|
||||
elif data["event"] == "list_created":
|
||||
event = _(u"You've created the list %s") % (data["target_object"]["name"])
|
||||
|
@ -106,6 +106,8 @@ class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
|
||||
rMode.Add(lbl, 0, wx.ALL, 5)
|
||||
rMode.Add(self.retweet_mode, 0, wx.ALL, 5)
|
||||
sizer.Add(rMode, 0, wx.ALL, 5)
|
||||
self.show_screen_names = wx.CheckBox(self, wx.NewId(), _(U"Show screen names instead full names"))
|
||||
sizer.Add(self.show_screen_names, 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)
|
||||
|
Loading…
Reference in New Issue
Block a user