From 7ea714e61c9b19a56558969e3d092de85f653297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ng=C3=B4=20Ng=E1=BB=8Dc=20=C4=90=E1=BB=A9c=20Huy?= Date: Wed, 14 Feb 2024 17:26:06 +0700 Subject: [PATCH] Add support for viewing emoji reacts --- witchie/entities.py | 10 ++++++++++ witchie/output.py | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/witchie/entities.py b/witchie/entities.py index 3fdead5..a341226 100644 --- a/witchie/entities.py +++ b/witchie/entities.py @@ -224,6 +224,15 @@ class FilterResult: status_matches: Optional[str] +@dataclass +class EmojiReaction: + account_ids: List[str] + count: int + me: bool + name: str + url: Optional[str] + + @dataclass class Status: """ @@ -260,6 +269,7 @@ class Status: bookmarked: Optional[bool] pinned: Optional[bool] filtered: Optional[List[FilterResult]] + emoji_reactions: Optional[List[EmojiReaction]] @property def original(self) -> "Status": diff --git a/witchie/output.py b/witchie/output.py index 316d4d6..9307fe3 100644 --- a/witchie/output.py +++ b/witchie/output.py @@ -292,6 +292,9 @@ def print_status(status: Status, width: int = 80): if display_name: spacing -= wcswidth(display_name) + 1 + reacts = '\n'.join([f'{react.count} × {react.name}' + for react in status.emoji_reactions]) + print_out( f"{display_name}" if display_name else "", f"{username}", @@ -315,6 +318,7 @@ def print_status(status: Status, width: int = 80): print_out() print_out( + f"Reacts:\n{reacts}\n" if reacts else "", f"ID {status_id} ", f"↲ In reply to {in_reply_to_id} " if in_reply_to_id else "", f"↻ @{reblogged_by.acct} boosted " if reblogged_by else "",