From: Simon Tatham Date: Sat, 2 Dec 2023 18:12:39 +0000 (+0000) Subject: Proof of concept fetching my notifications timeline. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=6c05e4d1dcddf250f6e97b4ae7c4a4d4d3c3efb3;p=mastodonochrome.git Proof of concept fetching my notifications timeline. --- diff --git a/mastodonochrome b/mastodonochrome index b857039..7a23260 100755 --- a/mastodonochrome +++ b/mastodonochrome @@ -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)