mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Mastodon: Implemented hide emojis for usernames.
This commit is contained in:
parent
0764679164
commit
972b851b93
@ -7,7 +7,8 @@ During the development of the current TWBlue version, Twitter has cut out access
|
|||||||
* TWBlue should be able to display variables within templates (for example, now it is possible to send a template inside a post's text). Before, it was removing $variables so it was difficult to show how to edit templates from the client. ([#515](https://github.com/MCV-Software/TWBlue/issues/515))
|
* TWBlue should be able to display variables within templates (for example, now it is possible to send a template inside a post's text). Before, it was removing $variables so it was difficult to show how to edit templates from the client. ([#515](https://github.com/MCV-Software/TWBlue/issues/515))
|
||||||
* Mastodon:
|
* Mastodon:
|
||||||
* it is possible to add descriptions for all media available on Mastodon (audio, photos, video and Givs). ([#516](https://github.com/MCV-Software/TWBlue/issues/516))
|
* it is possible to add descriptions for all media available on Mastodon (audio, photos, video and Givs). ([#516](https://github.com/MCV-Software/TWBlue/issues/516))
|
||||||
* Added an experimetal feature to recover from connection errors. When making a post, if the post cannot be published due to any kind of error, TWBlue will bring up the dialog where the post was composed, so you can give the post a second chance or save the post's text. This feature should work for threads, posts with attachments, polls and replies. ([#527,](https://github.com/MCV-Software/TWBlue/issues/527) [#526,](https://github.com/MCV-Software/TWBlue/issues/526) [#377,](https://github.com/MCV-Software/TWBlue/issues/377) [#137,](https://github.com/MCV-Software/TWBlue/issues/137) [#108](https://github.com/MCV-Software/TWBlue/issues/108))
|
* Implemented "Hide emojis on usernames" in both GUI and invisible interface.
|
||||||
|
* Added an experimental feature to recover from connection errors. When making a post, if the post cannot be published due to any kind of error, TWBlue will bring up the dialog where the post was composed, so you can give the post a second chance or save the post's text. This feature should work for threads, posts with attachments, polls and replies. ([#527,](https://github.com/MCV-Software/TWBlue/issues/527) [#526,](https://github.com/MCV-Software/TWBlue/issues/526) [#377,](https://github.com/MCV-Software/TWBlue/issues/377) [#137,](https://github.com/MCV-Software/TWBlue/issues/137) [#108](https://github.com/MCV-Software/TWBlue/issues/108))
|
||||||
* Fixed an error on mentions buffer that was making TWBlue unable to load posts if there were mentions from a blocked or deleted account.
|
* Fixed an error on mentions buffer that was making TWBlue unable to load posts if there were mentions from a blocked or deleted account.
|
||||||
|
|
||||||
## Changes on version 2023.2.6
|
## Changes on version 2023.2.6
|
||||||
|
@ -78,7 +78,7 @@ class BaseBuffer(base.Buffer):
|
|||||||
safe = True
|
safe = True
|
||||||
if self.session.settings["general"]["read_preferences_from_instance"]:
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
return self.compose_function(self.get_item(), self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)[1]
|
return self.compose_function(self.get_item(), self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)[1]
|
||||||
|
|
||||||
def get_message(self):
|
def get_message(self):
|
||||||
post = self.get_item()
|
post = self.get_item()
|
||||||
@ -91,7 +91,7 @@ class BaseBuffer(base.Buffer):
|
|||||||
template = template.replace("$safe_text", "$text")
|
template = template.replace("$safe_text", "$text")
|
||||||
elif self.session.expand_spoilers == False and "$text" in template:
|
elif self.session.expand_spoilers == False and "$text" in template:
|
||||||
template = template.replace("$text", "$safe_text")
|
template = template.replace("$text", "$safe_text")
|
||||||
t = templates.render_post(post, template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
t = templates.render_post(post, template, self.session.settings, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
|
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
|
||||||
@ -138,7 +138,7 @@ class BaseBuffer(base.Buffer):
|
|||||||
safe = True
|
safe = True
|
||||||
if self.session.settings["general"]["read_preferences_from_instance"]:
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
output.speak(" ".join(self.compose_function(post, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)))
|
output.speak(" ".join(self.compose_function(post, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)))
|
||||||
elif number_of_items > 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
|
elif number_of_items > 1 and self.name in self.session.settings["other_buffers"]["autoread_buffers"] and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and self.session.settings["sound"]["session_mute"] == False:
|
||||||
output.speak(_("{0} new posts in {1}.").format(number_of_items, self.get_buffer_name()))
|
output.speak(_("{0} new posts in {1}.").format(number_of_items, self.get_buffer_name()))
|
||||||
|
|
||||||
@ -169,11 +169,11 @@ class BaseBuffer(base.Buffer):
|
|||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(True, *post)
|
self.buffer.list.insert_item(True, *post)
|
||||||
else:
|
else:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
self.buffer.list.select_item(selection)
|
self.buffer.list.select_item(selection)
|
||||||
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
||||||
@ -207,20 +207,20 @@ class BaseBuffer(base.Buffer):
|
|||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
if self.buffer.list.get_count() == 0:
|
if self.buffer.list.get_count() == 0:
|
||||||
for i in list_to_use:
|
for i in list_to_use:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
self.buffer.set_position(self.session.settings["general"]["reverse_timelines"])
|
self.buffer.set_position(self.session.settings["general"]["reverse_timelines"])
|
||||||
elif self.buffer.list.get_count() > 0 and number_of_items > 0:
|
elif self.buffer.list.get_count() > 0 and number_of_items > 0:
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
items = list_to_use[len(list_to_use)-number_of_items:]
|
items = list_to_use[len(list_to_use)-number_of_items:]
|
||||||
for i in items:
|
for i in items:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
else:
|
else:
|
||||||
items = list_to_use[0:number_of_items]
|
items = list_to_use[0:number_of_items]
|
||||||
items.reverse()
|
items.reverse()
|
||||||
for i in items:
|
for i in items:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(True, *post)
|
self.buffer.list.insert_item(True, *post)
|
||||||
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
|
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ class BaseBuffer(base.Buffer):
|
|||||||
safe = True
|
safe = True
|
||||||
if self.session.settings["general"]["read_preferences_from_instance"]:
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
post = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(item, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
else:
|
else:
|
||||||
@ -240,7 +240,7 @@ class BaseBuffer(base.Buffer):
|
|||||||
safe = True
|
safe = True
|
||||||
if self.session.settings["general"]["read_preferences_from_instance"]:
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
post = self.compose_function(item, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(item, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.list.SetItem(position, 1, post[1])
|
self.buffer.list.list.SetItem(position, 1, post[1])
|
||||||
|
|
||||||
def bind_events(self):
|
def bind_events(self):
|
||||||
@ -412,6 +412,7 @@ class BaseBuffer(base.Buffer):
|
|||||||
item = self.get_item()
|
item = self.get_item()
|
||||||
if item == None:
|
if item == None:
|
||||||
return
|
return
|
||||||
|
print(item)
|
||||||
urls = utils.get_media_urls(item)
|
urls = utils.get_media_urls(item)
|
||||||
if len(urls) == 1:
|
if len(urls) == 1:
|
||||||
url=urls[0]
|
url=urls[0]
|
||||||
|
@ -28,7 +28,7 @@ class ConversationListBuffer(BaseBuffer):
|
|||||||
return self.session.db[self.name][index]
|
return self.session.db[self.name][index]
|
||||||
|
|
||||||
def get_formatted_message(self):
|
def get_formatted_message(self):
|
||||||
return self.compose_function(self.get_conversation(), self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])[1]
|
return self.compose_function(self.get_conversation(), self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])[1]
|
||||||
|
|
||||||
def get_message(self):
|
def get_message(self):
|
||||||
conversation = self.get_conversation()
|
conversation = self.get_conversation()
|
||||||
@ -36,7 +36,7 @@ class ConversationListBuffer(BaseBuffer):
|
|||||||
return
|
return
|
||||||
template = self.session.settings["templates"]["conversation"]
|
template = self.session.settings["templates"]["conversation"]
|
||||||
post_template = self.session.settings["templates"]["post"]
|
post_template = self.session.settings["templates"]["post"]
|
||||||
t = templates.render_conversation(conversation=conversation, template=template, post_template=post_template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
t = templates.render_conversation(conversation=conversation, template=template, post_template=post_template, settings=self.session.settings, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
|
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
|
||||||
@ -89,11 +89,11 @@ class ConversationListBuffer(BaseBuffer):
|
|||||||
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
|
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
conversation = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
conversation = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||||
self.buffer.list.insert_item(True, *conversation)
|
self.buffer.list.insert_item(True, *conversation)
|
||||||
else:
|
else:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
conversation = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
conversation = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||||
self.buffer.list.insert_item(False, *conversation)
|
self.buffer.list.insert_item(False, *conversation)
|
||||||
self.buffer.list.select_item(selection)
|
self.buffer.list.select_item(selection)
|
||||||
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
||||||
|
@ -69,11 +69,11 @@ class MentionsBuffer(BaseBuffer):
|
|||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
post = self.compose_function(i.status, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i.status, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(True, *post)
|
self.buffer.list.insert_item(True, *post)
|
||||||
else:
|
else:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
post = self.compose_function(i.status, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i.status, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
self.buffer.list.select_item(selection)
|
self.buffer.list.select_item(selection)
|
||||||
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
||||||
@ -88,20 +88,20 @@ class MentionsBuffer(BaseBuffer):
|
|||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
if self.buffer.list.get_count() == 0:
|
if self.buffer.list.get_count() == 0:
|
||||||
for i in list_to_use:
|
for i in list_to_use:
|
||||||
post = self.compose_function(i.status, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i.status, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
self.buffer.set_position(self.session.settings["general"]["reverse_timelines"])
|
self.buffer.set_position(self.session.settings["general"]["reverse_timelines"])
|
||||||
elif self.buffer.list.get_count() > 0 and number_of_items > 0:
|
elif self.buffer.list.get_count() > 0 and number_of_items > 0:
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
items = list_to_use[len(list_to_use)-number_of_items:]
|
items = list_to_use[len(list_to_use)-number_of_items:]
|
||||||
for i in items:
|
for i in items:
|
||||||
post = self.compose_function(i.status, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i.status, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
else:
|
else:
|
||||||
items = list_to_use[0:number_of_items]
|
items = list_to_use[0:number_of_items]
|
||||||
items.reverse()
|
items.reverse()
|
||||||
for i in items:
|
for i in items:
|
||||||
post = self.compose_function(i.status, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(i.status, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
self.buffer.list.insert_item(True, *post)
|
self.buffer.list.insert_item(True, *post)
|
||||||
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
|
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ class MentionsBuffer(BaseBuffer):
|
|||||||
safe = True
|
safe = True
|
||||||
if self.session.settings["general"]["read_preferences_from_instance"]:
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
safe = self.session.expand_spoilers == False
|
safe = self.session.expand_spoilers == False
|
||||||
post = self.compose_function(item.status, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
post = self.compose_function(item.status, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"], safe=safe)
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
else:
|
else:
|
||||||
|
@ -18,7 +18,7 @@ class NotificationsBuffer(BaseBuffer):
|
|||||||
return
|
return
|
||||||
template = self.session.settings["templates"]["notification"]
|
template = self.session.settings["templates"]["notification"]
|
||||||
post_template = self.session.settings["templates"]["post"]
|
post_template = self.session.settings["templates"]["post"]
|
||||||
t = templates.render_notification(notification, template, post_template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
t = templates.render_notification(notification, template, post_template, self.session.settings, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def create_buffer(self, parent, name):
|
def create_buffer(self, parent, name):
|
||||||
|
@ -22,7 +22,7 @@ class UserBuffer(BaseBuffer):
|
|||||||
if user == None:
|
if user == None:
|
||||||
return
|
return
|
||||||
template = self.session.settings["templates"]["person"]
|
template = self.session.settings["templates"]["person"]
|
||||||
t = templates.render_user(user=user, template=template, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
t = templates.render_user(user=user, template=template, settings=self.session.settings, relative_times=self.session.settings["general"]["relative_times"], offset_hours=self.session.db["utc_offset"])
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def bind_events(self):
|
def bind_events(self):
|
||||||
@ -123,11 +123,11 @@ class UserBuffer(BaseBuffer):
|
|||||||
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
|
log.debug("Retrieved %d items from cursored search in function %s." % (len(elements), self.function))
|
||||||
if self.session.settings["general"]["reverse_timelines"] == False:
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||||
self.buffer.list.insert_item(True, *post)
|
self.buffer.list.insert_item(True, *post)
|
||||||
else:
|
else:
|
||||||
for i in elements:
|
for i in elements:
|
||||||
post = self.compose_function(i, self.session.db, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
post = self.compose_function(i, self.session.db, self.session.settings, self.session.settings["general"]["relative_times"], self.session.settings["general"]["show_screen_names"])
|
||||||
self.buffer.list.insert_item(False, *post)
|
self.buffer.list.insert_item(False, *post)
|
||||||
self.buffer.list.select_item(selection)
|
self.buffer.list.select_item(selection)
|
||||||
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
output.speak(_(u"%s items retrieved") % (str(len(elements))), True)
|
||||||
|
@ -3,11 +3,9 @@ import arrow
|
|||||||
import languageHandler
|
import languageHandler
|
||||||
from . import utils, templates
|
from . import utils, templates
|
||||||
|
|
||||||
def compose_post(post, db, relative_times, show_screen_names, safe=True):
|
def compose_post(post, db, settings, relative_times, show_screen_names, safe=True):
|
||||||
if show_screen_names == False:
|
if show_screen_names == False:
|
||||||
user = post.account.get("display_name")
|
user = utils.get_user_alias(post.account, settings)
|
||||||
if user == "":
|
|
||||||
user = post.account.get("username")
|
|
||||||
else:
|
else:
|
||||||
user = post.account.get("acct")
|
user = post.account.get("acct")
|
||||||
original_date = arrow.get(post.created_at)
|
original_date = arrow.get(post.created_at)
|
||||||
@ -27,34 +25,30 @@ def compose_post(post, db, relative_times, show_screen_names, safe=True):
|
|||||||
source = ""
|
source = ""
|
||||||
return [user+", ", text, ts+", ", source]
|
return [user+", ", text, ts+", ", source]
|
||||||
|
|
||||||
def compose_user(user, db, relative_times=True, show_screen_names=False, safe=False):
|
def compose_user(user, db, settings, relative_times=True, show_screen_names=False, safe=False):
|
||||||
original_date = arrow.get(user.created_at)
|
original_date = arrow.get(user.created_at)
|
||||||
if relative_times:
|
if relative_times:
|
||||||
ts = original_date.humanize(locale=languageHandler.curLang[:2])
|
ts = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||||
else:
|
else:
|
||||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.curLang[:2])
|
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.curLang[:2])
|
||||||
name = user.display_name
|
name = utils.get_user_alias(user, settings)
|
||||||
if name == "":
|
|
||||||
name = user.get("username")
|
|
||||||
return [_("%s (@%s). %s followers, %s following, %s posts. Joined %s") % (name, user.acct, user.followers_count, user.following_count, user.statuses_count, ts)]
|
return [_("%s (@%s). %s followers, %s following, %s posts. Joined %s") % (name, user.acct, user.followers_count, user.following_count, user.statuses_count, ts)]
|
||||||
|
|
||||||
def compose_conversation(conversation, db, relative_times, show_screen_names, safe=False):
|
def compose_conversation(conversation, db, settings, relative_times, show_screen_names, safe=False):
|
||||||
users = []
|
users = []
|
||||||
for account in conversation.accounts:
|
for account in conversation.accounts:
|
||||||
if account.display_name != "":
|
if account.display_name != "":
|
||||||
users.append(account.display_name)
|
users.append(utils.get_user_alias(account, settings))
|
||||||
else:
|
else:
|
||||||
users.append(account.username)
|
users.append(account.username)
|
||||||
users = ", ".join(users)
|
users = ", ".join(users)
|
||||||
last_post = compose_post(conversation.last_status, db, relative_times, show_screen_names)
|
last_post = compose_post(conversation.last_status, db, settings, relative_times, show_screen_names)
|
||||||
text = _("Last message from {}: {}").format(last_post[0], last_post[1])
|
text = _("Last message from {}: {}").format(last_post[0], last_post[1])
|
||||||
return [users, text, last_post[-2], last_post[-1]]
|
return [users, text, last_post[-2], last_post[-1]]
|
||||||
|
|
||||||
def compose_notification(notification, db, relative_times, show_screen_names, safe=False):
|
def compose_notification(notification, db, settings, relative_times, show_screen_names, safe=False):
|
||||||
if show_screen_names == False:
|
if show_screen_names == False:
|
||||||
user = notification.account.get("display_name")
|
user = utils.get_user_alias(notification.account, settings)
|
||||||
if user == "":
|
|
||||||
user = notification.account.get("username")
|
|
||||||
else:
|
else:
|
||||||
user = notification.account.get("acct")
|
user = notification.account.get("acct")
|
||||||
original_date = arrow.get(notification.created_at)
|
original_date = arrow.get(notification.created_at)
|
||||||
@ -64,19 +58,19 @@ def compose_notification(notification, db, relative_times, show_screen_names, sa
|
|||||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m"), locale=languageHandler.curLang[:2])
|
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m"), locale=languageHandler.curLang[:2])
|
||||||
text = "Unknown: %r" % (notification)
|
text = "Unknown: %r" % (notification)
|
||||||
if notification.type == "status":
|
if notification.type == "status":
|
||||||
text = _("{username} has posted: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names, safe=safe)))
|
text = _("{username} has posted: {status}").format(username=user, status=",".join(compose_post(notification.status, db, settings, relative_times, show_screen_names, safe=safe)))
|
||||||
elif notification.type == "mention":
|
elif notification.type == "mention":
|
||||||
text = _("{username} has mentioned you: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names, safe=safe)))
|
text = _("{username} has mentioned you: {status}").format(username=user, status=",".join(compose_post(notification.status, db, settings, relative_times, show_screen_names, safe=safe)))
|
||||||
elif notification.type == "reblog":
|
elif notification.type == "reblog":
|
||||||
text = _("{username} has boosted: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names, safe=safe)))
|
text = _("{username} has boosted: {status}").format(username=user, status=",".join(compose_post(notification.status, db, settings, relative_times, show_screen_names, safe=safe)))
|
||||||
elif notification.type == "favourite":
|
elif notification.type == "favourite":
|
||||||
text = _("{username} has added to favorites: {status}").format(username=user, status=",".join(compose_post(notification.status, db, relative_times, show_screen_names, safe=safe)))
|
text = _("{username} has added to favorites: {status}").format(username=user, status=",".join(compose_post(notification.status, db, settings, relative_times, show_screen_names, safe=safe)))
|
||||||
elif notification.type == "follow":
|
elif notification.type == "follow":
|
||||||
text = _("{username} has followed you.").format(username=user)
|
text = _("{username} has followed you.").format(username=user)
|
||||||
elif notification.type == "admin.sign_up":
|
elif notification.type == "admin.sign_up":
|
||||||
text = _("{username} has joined the instance.").format(username=user)
|
text = _("{username} has joined the instance.").format(username=user)
|
||||||
elif notification.type == "poll":
|
elif notification.type == "poll":
|
||||||
text = _("A poll in which you have voted has expired: {status}").format(status=",".join(compose_post(notification.status, db, relative_times, show_screen_names, safe=safe)))
|
text = _("A poll in which you have voted has expired: {status}").format(status=",".join(compose_post(notification.status, db, settings, relative_times, show_screen_names, safe=safe)))
|
||||||
elif notification.type == "follow_request":
|
elif notification.type == "follow_request":
|
||||||
text = _("{username} wants to follow you.").format(username=user)
|
text = _("{username} wants to follow you.").format(username=user)
|
||||||
return [user, text, ts]
|
return [user, text, ts]
|
@ -123,25 +123,6 @@ class Session(base.baseSession):
|
|||||||
### ToDo: Use a function to retrieve all muted users.
|
### ToDo: Use a function to retrieve all muted users.
|
||||||
self.db["muted_users"] = self.api.mutes()
|
self.db["muted_users"] = self.api.mutes()
|
||||||
|
|
||||||
def get_user_alias(self, user):
|
|
||||||
if user.display_name == None or user.display_name == "":
|
|
||||||
display_name = user.username
|
|
||||||
else:
|
|
||||||
display_name = user.display_name
|
|
||||||
aliases = self.settings.get("user-aliases")
|
|
||||||
if aliases == None:
|
|
||||||
log.error("Aliases are not defined for this config spec.")
|
|
||||||
return self.demoji_user(display_name)
|
|
||||||
user_alias = aliases.get(user.id)
|
|
||||||
if user_alias != None:
|
|
||||||
return user_alias
|
|
||||||
return self.demoji_user(display_name)
|
|
||||||
|
|
||||||
def demoji_user(self, name):
|
|
||||||
if self.settings["general"]["hide_emojis"] == True:
|
|
||||||
return demoji.replace(name, "")
|
|
||||||
return name
|
|
||||||
|
|
||||||
def order_buffer(self, name, data, ignore_older=False):
|
def order_buffer(self, name, data, ignore_older=False):
|
||||||
num = 0
|
num = 0
|
||||||
last_id = None
|
last_id = None
|
||||||
|
@ -45,7 +45,7 @@ def process_image_descriptions(media_attachments):
|
|||||||
idescriptions = idescriptions + _("Media description: {}").format(image) + "\n"
|
idescriptions = idescriptions + _("Media description: {}").format(image) + "\n"
|
||||||
return idescriptions
|
return idescriptions
|
||||||
|
|
||||||
def render_post(post, template, relative_times=False, offset_hours=0):
|
def render_post(post, template, settings, relative_times=False, offset_hours=0):
|
||||||
""" Renders any given post according to the passed template.
|
""" Renders any given post according to the passed template.
|
||||||
Available data for posts will be stored in the following variables:
|
Available data for posts will be stored in the following variables:
|
||||||
$date: Creation date.
|
$date: Creation date.
|
||||||
@ -63,9 +63,7 @@ def render_post(post, template, relative_times=False, offset_hours=0):
|
|||||||
created_at = process_date(post.created_at, relative_times, offset_hours)
|
created_at = process_date(post.created_at, relative_times, offset_hours)
|
||||||
available_data.update(date=created_at)
|
available_data.update(date=created_at)
|
||||||
# user.
|
# user.
|
||||||
display_name = post.account.display_name
|
display_name = utils.get_user_alias(post.account, settings)
|
||||||
if display_name == "":
|
|
||||||
display_name = post.account.username
|
|
||||||
available_data.update(display_name=display_name, screen_name=post.account.acct)
|
available_data.update(display_name=display_name, screen_name=post.account.acct)
|
||||||
# Source client from where tweet was originated.
|
# Source client from where tweet was originated.
|
||||||
source = ""
|
source = ""
|
||||||
@ -90,7 +88,7 @@ def render_post(post, template, relative_times=False, offset_hours=0):
|
|||||||
result = Template(_(template)).safe_substitute(**available_data)
|
result = Template(_(template)).safe_substitute(**available_data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def render_user(user, template, relative_times=True, offset_hours=0):
|
def render_user(user, template, settings, relative_times=True, offset_hours=0):
|
||||||
""" Renders persons by using the provided template.
|
""" Renders persons by using the provided template.
|
||||||
Available data will be stored in the following variables:
|
Available data will be stored in the following variables:
|
||||||
$display_name: The name of the user, as they’ve defined it. Not necessarily a person’s name. Typically capped at 50 characters, but subject to change.
|
$display_name: The name of the user, as they’ve defined it. Not necessarily a person’s name. Typically capped at 50 characters, but subject to change.
|
||||||
@ -102,9 +100,7 @@ def render_user(user, template, relative_times=True, offset_hours=0):
|
|||||||
$created_at: The date and time that the user account was created on Twitter.
|
$created_at: The date and time that the user account was created on Twitter.
|
||||||
"""
|
"""
|
||||||
global person_variables
|
global person_variables
|
||||||
display_name = user.display_name
|
display_name = utils.get_user_alias(user, settings)
|
||||||
if display_name == "":
|
|
||||||
display_name = user.username
|
|
||||||
available_data = dict(display_name=display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, posts=user.statuses_count)
|
available_data = dict(display_name=display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, posts=user.statuses_count)
|
||||||
# Nullable values.
|
# Nullable values.
|
||||||
nullables = ["description"]
|
nullables = ["description"]
|
||||||
@ -116,20 +112,20 @@ def render_user(user, template, relative_times=True, offset_hours=0):
|
|||||||
result = Template(_(template)).safe_substitute(**available_data)
|
result = Template(_(template)).safe_substitute(**available_data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def render_conversation(conversation, template, post_template, relative_times=False, offset_hours=0):
|
def render_conversation(conversation, template, settings, post_template, relative_times=False, offset_hours=0):
|
||||||
users = []
|
users = []
|
||||||
for account in conversation.accounts:
|
for account in conversation.accounts:
|
||||||
if account.display_name != "":
|
if account.display_name != "":
|
||||||
users.append(account.display_name)
|
users.append(utils.get_user_alias(account, settings))
|
||||||
else:
|
else:
|
||||||
users.append(account.username)
|
users.append(account.username)
|
||||||
users = ", ".join(users)
|
users = ", ".join(users)
|
||||||
last_post = render_post(conversation.last_status, post_template, relative_times=relative_times, offset_hours=offset_hours)
|
last_post = render_post(conversation.last_status, post_template, settings, relative_times=relative_times, offset_hours=offset_hours)
|
||||||
available_data = dict(users=users, last_post=last_post)
|
available_data = dict(users=users, last_post=last_post)
|
||||||
result = Template(_(template)).safe_substitute(**available_data)
|
result = Template(_(template)).safe_substitute(**available_data)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def render_notification(notification, template, post_template, relative_times=False, offset_hours=0):
|
def render_notification(notification, template, post_template, settings, relative_times=False, offset_hours=0):
|
||||||
""" Renders any given notification according to the passed template.
|
""" Renders any given notification according to the passed template.
|
||||||
Available data for notifications will be stored in the following variables:
|
Available data for notifications will be stored in the following variables:
|
||||||
$date: Creation date.
|
$date: Creation date.
|
||||||
@ -142,29 +138,27 @@ def render_notification(notification, template, post_template, relative_times=Fa
|
|||||||
created_at = process_date(notification.created_at, relative_times, offset_hours)
|
created_at = process_date(notification.created_at, relative_times, offset_hours)
|
||||||
available_data.update(date=created_at)
|
available_data.update(date=created_at)
|
||||||
# user.
|
# user.
|
||||||
display_name = notification.account.display_name
|
display_name = utils.get_user_alias(notification.account, settings)
|
||||||
if display_name == "":
|
|
||||||
display_name = notification.account.username
|
|
||||||
available_data.update(display_name=display_name, screen_name=notification.account.acct)
|
available_data.update(display_name=display_name, screen_name=notification.account.acct)
|
||||||
text = "Unknown: %r" % (notification)
|
text = "Unknown: %r" % (notification)
|
||||||
# Remove date from status, so it won't be rendered twice.
|
# Remove date from status, so it won't be rendered twice.
|
||||||
post_template = post_template.replace("$date", "")
|
post_template = post_template.replace("$date", "")
|
||||||
if notification.type == "status":
|
if notification.type == "status":
|
||||||
text = _("has posted: {status}").format(status=render_post(notification.status, post_template, relative_times, offset_hours))
|
text = _("has posted: {status}").format(status=render_post(notification.status, post_template, settings, relative_times, offset_hours))
|
||||||
elif notification.type == "mention":
|
elif notification.type == "mention":
|
||||||
text = _("has mentioned you: {status}").format(status=render_post(notification.status, post_template, relative_times, offset_hours))
|
text = _("has mentioned you: {status}").format(status=render_post(notification.status, post_template, settings, relative_times, offset_hours))
|
||||||
elif notification.type == "reblog":
|
elif notification.type == "reblog":
|
||||||
text = _("has boosted: {status}").format(status=render_post(notification.status, post_template, relative_times, offset_hours))
|
text = _("has boosted: {status}").format(status=render_post(notification.status, post_template, settings, relative_times, offset_hours))
|
||||||
elif notification.type == "favourite":
|
elif notification.type == "favourite":
|
||||||
text = _("has added to favorites: {status}").format(status=render_post(notification.status, post_template, relative_times, offset_hours))
|
text = _("has added to favorites: {status}").format(status=render_post(notification.status, post_template, settings, relative_times, offset_hours))
|
||||||
elif notification.type == "update":
|
elif notification.type == "update":
|
||||||
text = _("has updated a status: {status}").format(status=render_post(notification.status, post_template, relative_times, offset_hours))
|
text = _("has updated a status: {status}").format(status=render_post(notification.status, post_template, settings, relative_times, offset_hours))
|
||||||
elif notification.type == "follow":
|
elif notification.type == "follow":
|
||||||
text = _("has followed you.")
|
text = _("has followed you.")
|
||||||
elif notification.type == "admin.sign_up":
|
elif notification.type == "admin.sign_up":
|
||||||
text = _("has joined the instance.")
|
text = _("has joined the instance.")
|
||||||
elif notification.type == "poll":
|
elif notification.type == "poll":
|
||||||
text = _("A poll in which you have voted has expired: {status}").format(status=render_post(notification.status, post_template, relative_times, offset_hours))
|
text = _("A poll in which you have voted has expired: {status}").format(status=render_post(notification.status, post_template, settings, relative_times, offset_hours))
|
||||||
elif notification.type == "follow_request":
|
elif notification.type == "follow_request":
|
||||||
text = _("wants to follow you.")
|
text = _("wants to follow you.")
|
||||||
available_data.update(text=text)
|
available_data.update(text=text)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import re
|
import re
|
||||||
|
import demoji
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
|
|
||||||
url_re = re.compile('<a\s*href=[\'|"](.*?)[\'"].*?>')
|
url_re = re.compile('<a\s*href=[\'|"](.*?)[\'"].*?>')
|
||||||
@ -69,3 +70,24 @@ def find_urls(post, include_tags=False):
|
|||||||
if url.lower().endswith("/tags/"+tag["name"]):
|
if url.lower().endswith("/tags/"+tag["name"]):
|
||||||
urls.remove(url)
|
urls.remove(url)
|
||||||
return urls
|
return urls
|
||||||
|
|
||||||
|
def get_user_alias(user, settings):
|
||||||
|
if user.display_name == None or user.display_name == "":
|
||||||
|
display_name = user.username
|
||||||
|
else:
|
||||||
|
display_name = user.display_name
|
||||||
|
aliases = settings.get("user-aliases")
|
||||||
|
if aliases == None:
|
||||||
|
return demoji_user(display_name, settings)
|
||||||
|
user_alias = aliases.get(user.id)
|
||||||
|
if user_alias != None:
|
||||||
|
return user_alias
|
||||||
|
return demoji_user(display_name, settings)
|
||||||
|
|
||||||
|
def demoji_user(name, settings):
|
||||||
|
if settings["general"]["hide_emojis"] == True:
|
||||||
|
user = demoji.replace(name, "")
|
||||||
|
# Take care of Mastodon instance emojis.
|
||||||
|
user = re.sub(r":(.*?):", "", user)
|
||||||
|
return user
|
||||||
|
return name
|
||||||
|
Loading…
Reference in New Issue
Block a user