From cf191f34b5ae5af86b91b5e1635c92e6fc577f94 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Sun, 3 Dec 2023 07:18:06 +0000 Subject: [PATCH] Change my mind about account name policy. I think the leading @ is only for @mentioning people, and it's only out of the Mastodon context that people put it on by habit as a hint that they're talking about the fediverse. Also, I think I prefer my account names fully qualified, so now I have access to the correct instance domain, I'll put it in From lines where the server didn't send one at all. --- client.py | 12 +++++++++--- mastodonochrome | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/client.py b/client.py index ac35589..20e6d66 100644 --- a/client.py +++ b/client.py @@ -105,8 +105,12 @@ class Client: p = r.prepare() return p.url + def fq(self, account_name): + return (account_name if '@' in account_name + else account_name + '@' + self.instance_domain) + class Status: - def __init__(self, data): + def __init__(self, data, client): rb = data.get('reblog') if rb is not None: self.booster = data['account'] @@ -131,12 +135,14 @@ class Status: self.media = data.get('media_attachments', []) + self.client = client + def text(self): yield text.SeparatorLine(self.datestamp) - yield text.FromLine('@' + self.account['acct'], + yield text.FromLine(self.client.fq(self.account['acct']), self.account['display_name']) if self.booster is not None: - yield text.BoosterLine('@' + self.booster['acct'], + yield text.BoosterLine(self.client.fq(self.booster['acct']), self.booster['display_name']) yield text.BlankLine() yield from self.content diff --git a/mastodonochrome b/mastodonochrome index 4e50a51..b097e93 100755 --- a/mastodonochrome +++ b/mastodonochrome @@ -52,7 +52,7 @@ class CombinedUI(client.Client): def run(self): items = list(itertools.islice(self.combined_feed(), 0, 100)) for item in reversed(items): - p = client.Status(item) + p = client.Status(item, self) for thing in p.text(): for line in thing.render(80): print(line.ecma48()) -- 2.30.2