chiark / gitweb /
Proof of concept fetching my notifications timeline.
authorSimon Tatham <anakin@pobox.com>
Sat, 2 Dec 2023 18:12:39 +0000 (18:12 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 2 Dec 2023 18:12:39 +0000 (18:12 +0000)
mastodonochrome

index b857039b1eac6ba3a744aaab03e655ced484feec..7a2326058c46c9aa994787e0f15cd29b075aebdf 100755 (executable)
@@ -21,6 +21,17 @@ class TimelineUI(client.Client):
                 for line in thing.render(80):
                     print(line.ecma48())
 
+class MentionsUI(client.Client):
+    def run(self):
+        login.setup_client(self)
+        for item in reversed(self.get("notifications", limit=40)):
+            if item['type'] != 'mention':
+                continue
+            p = client.Status(item['status'])
+            for thing in p.text():
+                for line in thing.render(80):
+                    print(line.ecma48())
+
 class MyTestLoader(unittest.TestLoader):
     def loadTestsFromModule(self, module):
         suite = super().loadTestsFromModule(module)
@@ -39,6 +50,9 @@ def main():
     parser.add_argument("--timeline", action="store_const", dest="action",
                         const=TimelineUI, help="Temporary mode to fetch "
                         "the user's timeline and print it on the terminal.")
+    parser.add_argument("--mentions", action="store_const", dest="action",
+                        const=MentionsUI, help="Temporary mode to fetch "
+                        "the user's mentions and print them on the terminal.")
     parser.add_argument("--login", action="store_const", dest="action",
                         const=login.LoginUI, help="Log in to a user account.")
     parser.set_defaults(action=cursesclient.CursesUI)