chiark / gitweb /
Change my mind about account name policy.
authorSimon Tatham <anakin@pobox.com>
Sun, 3 Dec 2023 07:18:06 +0000 (07:18 +0000)
committerSimon Tatham <anakin@pobox.com>
Sun, 3 Dec 2023 07:18:06 +0000 (07:18 +0000)
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
mastodonochrome

index ac35589f49b19949c80db2f4653ec95315cf4d6d..20e6d666bd45afabcbb2b2461474350c04db89aa 100644 (file)
--- 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
index 4e50a518f2de02b34b94c4e6e57b7cd18cd3a5c9..b097e932906773300f1ab736814b182909194251 100755 (executable)
@@ -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())