mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-08-04 21:16:07 -04:00
Added user buffers (buffers for followers, following, blocked and muted users for now)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import arrow
|
||||
import languageHandler
|
||||
from . import utils, templates
|
||||
|
||||
def compose_toot(toot, db, relative_times, show_screen_names):
|
||||
@@ -11,9 +12,9 @@ def compose_toot(toot, db, relative_times, show_screen_names):
|
||||
user = toot.account.get("acct")
|
||||
original_date = arrow.get(toot.created_at)
|
||||
if relative_times:
|
||||
ts = original_date.humanize(locale="es")
|
||||
ts = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
else:
|
||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale="es")
|
||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m"), locale=languageHandler.curLang[:2])
|
||||
if toot.reblog != None:
|
||||
text = _("Boosted from @{}: {}").format(toot.reblog.account.acct, templates.process_text(toot.reblog))
|
||||
else:
|
||||
@@ -26,12 +27,12 @@ def compose_toot(toot, db, relative_times, show_screen_names):
|
||||
source = ""
|
||||
return [user+", ", text, ts+", ", source]
|
||||
|
||||
def compose_user(user, db, relative_times=True):
|
||||
def compose_user(user, db, relative_times=True, show_screen_names=False):
|
||||
original_date = arrow.get(user.created_at)
|
||||
if relative_times:
|
||||
ts = original_date.humanize(locale="es")
|
||||
ts = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
else:
|
||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale="es")
|
||||
ts = original_date.shift(hours=db["utc_offset"]).format(_("dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.curLang[:2])
|
||||
name = user.display_name
|
||||
if name == "":
|
||||
name = user.get("username")
|
||||
@@ -47,4 +48,4 @@ def compose_conversation(conversation, db, relative_times, show_screen_names):
|
||||
users = ", ".join(users)
|
||||
last_toot = compose_toot(conversation.last_status, db, relative_times, show_screen_names)
|
||||
text = _("Last message from {}: {}").format(last_toot[0], last_toot[1])
|
||||
return [users, text, last_toot[-1], ""]
|
||||
return [users, text, last_toot[-1], ""]
|
||||
|
@@ -25,6 +25,7 @@ class Session(base.baseSession):
|
||||
self.config_spec = "mastodon.defaults"
|
||||
self.supported_languages = []
|
||||
self.type = "mastodon"
|
||||
self.db["pagination_info"] = dict()
|
||||
|
||||
def login(self, verify_credentials=True):
|
||||
if self.settings["mastodon"]["access_token"] != None and self.settings["mastodon"]["instance"] != None:
|
||||
|
@@ -95,24 +95,22 @@ def render_toot(toot, template, relative_times=False, offset_hours=0):
|
||||
result = remove_unneeded_variables(result, toot_variables)
|
||||
return result
|
||||
|
||||
def render_person(user, template, relative_times=True, offset_hours=0):
|
||||
def render_user(user, template, relative_times=True, offset_hours=0):
|
||||
""" Renders persons by using the provided template.
|
||||
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.
|
||||
$screen_name: The screen name, handle, or alias that this user identifies themselves with.
|
||||
$location: The user-defined location for this account’s profile. Not necessarily a location, nor machine-parseable.
|
||||
$description: The user-defined UTF-8 string describing their account.
|
||||
$followers: The number of followers this account currently has. This value might be inaccurate.
|
||||
$following: The number of users this account is following (AKA their “followings”). This value might be inaccurate.
|
||||
$favorites: The number of Tweets this user has liked in the account’s lifetime. This value might be inaccurate.
|
||||
$tweets: The number of Tweets (including retweets) issued by the user. This value might be inaccurate.
|
||||
$toots: The number of Tweets (including retweets) issued by the user. This value might be inaccurate.
|
||||
$created_at: The date and time that the user account was created on Twitter.
|
||||
"""
|
||||
global person_variables
|
||||
display_name = user.display_name
|
||||
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, favorites=user.favourites_count, toots=user.statuses_count)
|
||||
available_data = dict(display_name=display_name, screen_name=user.acct, followers=user.followers_count, following=user.following_count, toots=user.statuses_count)
|
||||
# Nullable values.
|
||||
nullables = ["description"]
|
||||
for nullable in nullables:
|
||||
|
Reference in New Issue
Block a user