mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Mastodon: Fixed getting more mentions. Closes #508
This commit is contained in:
parent
f87ced817f
commit
a8c5fc8589
@ -2,7 +2,7 @@ TWBlue Changelog
|
|||||||
|
|
||||||
## changes in this version
|
## changes in this version
|
||||||
|
|
||||||
As we're sure users of TWBlue and other third-party clients already know, Twitter has added new rules to its developer policies that make it impossible to attempt to replicate the social network experience in other applications. This means that officially, TWBlue, as well as other clients, is breaking the platform's rules and could be blocked from using the Twitter API at any time. At this time, according to our reports, TWBlue still works with Twitter and has been working even after the platform's announcement. We do not know how long it will continue to work. From the TWBlue team, we want to assure our users that we will maintain the code that makes it possible for TWBlue to work with Twitter as long as possible, but there will be no feature updates for our Twitter session, as it could be blocked at any time. We will use our limited resources instead to improve Mastodon support and add more sites in the near future.
|
In this version, TWBlue will no longer support Twitter sessions starting on February 9, due to Twitter's policies prohibiting third-party clients, in addition to the shutdown of the free access to the Twitter API. All Twitter sessions that are active on TWBlue will stop working as of February 9, when the free API access will finally be shut down. From the TWBlue team, we will continue working to improve our support for Mastodon instances and add other social networks in the near future. If you want to keep in touch with the project, you can follow us in our mastodon account, at [@twblue@maaw.social.](https://maaw.social/@twblue)
|
||||||
|
|
||||||
* In the graphical interface, TWBlue will update menu items, in the menu bar, depending on whether you are focusing a Twitter or Mastodon session. This makes it possible for TWBlue to display the correct terms in each social network. Take into account that there might be unavailable items for the currently active session.
|
* In the graphical interface, TWBlue will update menu items, in the menu bar, depending on whether you are focusing a Twitter or Mastodon session. This makes it possible for TWBlue to display the correct terms in each social network. Take into account that there might be unavailable items for the currently active session.
|
||||||
* in the keystroke editor for the invisible interface, TWBlue displays the available shortcuts for the currently active session. Descriptions of those keystrokes are also different for Twitter and mastodon sessions to use correct terms for both networks.
|
* in the keystroke editor for the invisible interface, TWBlue displays the available shortcuts for the currently active session. Descriptions of those keystrokes are also different for Twitter and mastodon sessions to use correct terms for both networks.
|
||||||
@ -11,6 +11,7 @@ As we're sure users of TWBlue and other third-party clients already know, Twitte
|
|||||||
* Mastodon:
|
* Mastodon:
|
||||||
* Added basic support to notifications buffer. This buffer shows mastodon notifications in real time. Every notification is attached to a kind of object (posts, users, relationships or polls). At the moment, the only supported action for notification is dismissing, which allows you to remove the notification from the buffer (take into account, though, that mention notifications will remove also the mention in its corresponding buffer, due to the way TWBlue reads mentions from mastodon instances).
|
* Added basic support to notifications buffer. This buffer shows mastodon notifications in real time. Every notification is attached to a kind of object (posts, users, relationships or polls). At the moment, the only supported action for notification is dismissing, which allows you to remove the notification from the buffer (take into account, though, that mention notifications will remove also the mention in its corresponding buffer, due to the way TWBlue reads mentions from mastodon instances).
|
||||||
* Fixed an issue that was preventing TWBlue to create more than one user timeline during startup.
|
* Fixed an issue that was preventing TWBlue to create more than one user timeline during startup.
|
||||||
|
* Fixed getting more items in mentions buffer. ([#508](https://github.com/mcv-software/twblue/issues/508))
|
||||||
* TWBlue will display properly new paragraphs in mastodon posts.
|
* TWBlue will display properly new paragraphs in mastodon posts.
|
||||||
* In the session manager, Mastodon sessions are now displayed including the instance to avoid confusion.
|
* In the session manager, Mastodon sessions are now displayed including the instance to avoid confusion.
|
||||||
* TWBlue will now read default visibility preferences when posting new statuses, and display sensitive content. These preferences can be set on the mastodon instance, in the account's preferences section. If you wish to change TWBlue's behavior and have it not read those preferences from your instance, but instead set the default public visibility and hide sensitive content, you can uncheck the Read preferences from instance checkbox in the account options.
|
* TWBlue will now read default visibility preferences when posting new statuses, and display sensitive content. These preferences can be set on the mastodon instance, in the account's preferences section. If you wish to change TWBlue's behavior and have it not read those preferences from your instance, but instead set the default public visibility and hide sensitive content, you can uncheck the Read preferences from instance checkbox in the account options.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
import output
|
||||||
from controller.buffers.mastodon.base import BaseBuffer
|
from controller.buffers.mastodon.base import BaseBuffer
|
||||||
from sessions.mastodon import utils
|
from sessions.mastodon import utils
|
||||||
|
|
||||||
@ -8,6 +9,11 @@ log = logging.getLogger("controller.buffers.mastodon.mentions")
|
|||||||
|
|
||||||
class MentionsBuffer(BaseBuffer):
|
class MentionsBuffer(BaseBuffer):
|
||||||
|
|
||||||
|
def get_item(self):
|
||||||
|
index = self.buffer.list.get_selected()
|
||||||
|
if index > -1 and self.session.db.get(self.name) != None and len(self.session.db[self.name]) > index:
|
||||||
|
return self.session.db[self.name][index]["status"]
|
||||||
|
|
||||||
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
|
def start_stream(self, mandatory=False, play_sound=True, avoid_autoreading=False):
|
||||||
current_time = time.time()
|
current_time = time.time()
|
||||||
if self.execution_time == 0 or current_time-self.execution_time >= 180 or mandatory==True:
|
if self.execution_time == 0 or current_time-self.execution_time >= 180 or mandatory==True:
|
||||||
@ -17,13 +23,12 @@ class MentionsBuffer(BaseBuffer):
|
|||||||
count = self.session.settings["general"]["max_posts_per_call"]
|
count = self.session.settings["general"]["max_posts_per_call"]
|
||||||
min_id = None
|
min_id = None
|
||||||
try:
|
try:
|
||||||
items = getattr(self.session.api, self.function)(min_id=min_id, limit=count, exclude_types=["follow", "favourite", "reblog", "poll", "follow_request"], *self.args, **self.kwargs)
|
items = getattr(self.session.api, self.function)(min_id=min_id, limit=count, types=["mention"], *self.args, **self.kwargs)
|
||||||
items.reverse()
|
items.reverse()
|
||||||
results = [item.status for item in items if item.get("status") and item.type == "mention"]
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception("Error %s" % (str(e)))
|
log.exception("Error %s" % (str(e)))
|
||||||
return
|
return
|
||||||
number_of_items = self.session.order_buffer(self.name, results)
|
number_of_items = self.session.order_buffer(self.name, items)
|
||||||
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
log.debug("Number of items retrieved: %d" % (number_of_items,))
|
||||||
self.put_items_on_list(number_of_items)
|
self.put_items_on_list(number_of_items)
|
||||||
if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
|
if number_of_items > 0 and self.name != "sent_posts" and self.name != "sent_direct_messages" and self.sound != None and self.session.settings["sound"]["session_mute"] == False and self.name not in self.session.settings["other_buffers"]["muted_buffers"] and play_sound == True:
|
||||||
@ -40,11 +45,11 @@ class MentionsBuffer(BaseBuffer):
|
|||||||
else:
|
else:
|
||||||
max_id = self.session.db[self.name][-1].id
|
max_id = self.session.db[self.name][-1].id
|
||||||
try:
|
try:
|
||||||
items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_posts_per_call"], exclude_types=["follow", "favourite", "reblog", "poll", "follow_request"], *self.args, **self.kwargs)
|
items = getattr(self.session.api, self.function)(max_id=max_id, limit=self.session.settings["general"]["max_posts_per_call"], types=["mention"], *self.args, **self.kwargs)
|
||||||
items = [item.status for item in items if item.get("status") and item.type == "mention"]
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception("Error %s" % (str(e)))
|
log.exception("Error %s" % (str(e)))
|
||||||
return
|
return
|
||||||
|
print(items)
|
||||||
items_db = self.session.db[self.name]
|
items_db = self.session.db[self.name]
|
||||||
for i in items:
|
for i in items:
|
||||||
if utils.find_item(i, self.session.db[self.name]) == None:
|
if utils.find_item(i, self.session.db[self.name]) == None:
|
||||||
@ -61,11 +66,50 @@ 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, 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["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.status, self.session.db, 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)
|
||||||
|
|
||||||
|
def put_items_on_list(self, number_of_items):
|
||||||
|
list_to_use = self.session.db[self.name]
|
||||||
|
if number_of_items == 0 and self.session.settings["general"]["persist_size"] == 0: return
|
||||||
|
log.debug("The list contains %d items " % (self.buffer.list.get_count(),))
|
||||||
|
log.debug("Putting %d items on the list" % (number_of_items,))
|
||||||
|
safe = True
|
||||||
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
|
safe = self.session.expand_spoilers == False
|
||||||
|
if self.buffer.list.get_count() == 0:
|
||||||
|
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)
|
||||||
|
self.buffer.list.insert_item(False, *post)
|
||||||
|
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 = list_to_use[len(list_to_use)-number_of_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)
|
||||||
|
self.buffer.list.insert_item(False, *post)
|
||||||
|
else:
|
||||||
|
items = list_to_use[0:number_of_items]
|
||||||
|
items.reverse()
|
||||||
|
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)
|
||||||
|
self.buffer.list.insert_item(True, *post)
|
||||||
|
log.debug("Now the list contains %d items " % (self.buffer.list.get_count(),))
|
||||||
|
|
||||||
|
def add_new_item(self, item):
|
||||||
|
safe = True
|
||||||
|
if self.session.settings["general"]["read_preferences_from_instance"]:
|
||||||
|
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)
|
||||||
|
if self.session.settings["general"]["reverse_timelines"] == False:
|
||||||
|
self.buffer.list.insert_item(False, *post)
|
||||||
|
else:
|
||||||
|
self.buffer.list.insert_item(True, *post)
|
||||||
|
if 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(" ".join(post[:2]), speech=self.session.settings["reporting"]["speech_reporting"], braille=self.session.settings["reporting"]["braille_reporting"])
|
||||||
|
Loading…
Reference in New Issue
Block a user