diff --git a/defs/bsky.py b/defs/bsky.py index 7c5d797..a8404ee 100644 --- a/defs/bsky.py +++ b/defs/bsky.py @@ -75,18 +75,15 @@ class Timeline: @staticmethod def get_post_text(post: HumanPost) -> str: text = "Bsky Post Info\n\n" - key = "发表" - if post.is_reply: - key = "回复" - elif post.is_quote: - key = "引用" if post.parent_post: text += f"> {post.parent_post.content}\n\n=====================\n\n" text += post.content text += "\n\n" - text += f"{post.author.format} {key}于 {post.time_str}\n" + if (post.is_reply or post.is_quote) and post.parent_post: + text += f"{post.parent_post.author.format} {post.parent_post.status}于 {post.parent_post.time_str}\n" + text += f"{post.author.format} {post.status}于 {post.time_str}\n" if post.is_repost: - text += f"{post.repost_info.by.format} 转发于 {post.repost_info.time_str}\n" + text += f"{post.repost_info.by.format} {post.status}于 {post.repost_info.time_str}\n" text += f"点赞: {post.like_count} | 引用: {post.quote_count} | 回复: {post.reply_count} | 转发: {post.repost_count}" return text diff --git a/models/models/bsky.py b/models/models/bsky.py index 2a5be37..2abf9a1 100644 --- a/models/models/bsky.py +++ b/models/models/bsky.py @@ -125,6 +125,16 @@ class HumanPost(BaseModel, frozen=False): # utc+8 return self.created_at.astimezone(TZ).strftime("%Y-%m-%d %H:%M:%S") + @property + def status(self) -> str: + if self.is_quote: + return "引用" + elif self.is_reply: + return "回复" + elif self.is_repost: + return "转发" + return "发表" + @staticmethod def parse_view(post: Union["PostView", "BskyViewRecordRecord"]) -> "HumanPost": record = post.value if isinstance(post, BskyViewRecordRecord) else post.record @@ -181,7 +191,9 @@ class HumanPost(BaseModel, frozen=False): parent_post = HumanPost.parse_view(data.reply.parent) elif data.reason: is_repost = True - repost_info = HumanRepostInfo(by=HumanAuthor.parse(data.reason.by), at=data.reason.at) + repost_info = HumanRepostInfo( + by=HumanAuthor.parse(data.reason.by), at=data.reason.at + ) elif data.post.embed and isinstance(data.post.embed, BskyViewRecord): is_quote = True if isinstance(data.post.embed.record, BskyViewRecordRecord):