mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-21 14:48:23 +00:00
feat: bsky show parent post status
This commit is contained in:
parent
b1db99beff
commit
e8e6b08372
11
defs/bsky.py
11
defs/bsky.py
@ -75,18 +75,15 @@ class Timeline:
|
||||
@staticmethod
|
||||
def get_post_text(post: HumanPost) -> str:
|
||||
text = "<b>Bsky Post Info</b>\n\n<code>"
|
||||
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
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user