mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-21 22:58:09 +00:00
feat: bsky show parent content
This commit is contained in:
parent
16e2a9bce5
commit
b1db99beff
34
defs/bsky.py
34
defs/bsky.py
@ -40,14 +40,13 @@ def flood_wait():
|
||||
class Timeline:
|
||||
@staticmethod
|
||||
def get_button(post: HumanPost) -> InlineKeyboardMarkup:
|
||||
return InlineKeyboardMarkup(
|
||||
[
|
||||
[
|
||||
InlineKeyboardButton("Source", url=post.url),
|
||||
InlineKeyboardButton("Author", url=post.author.url),
|
||||
]
|
||||
]
|
||||
)
|
||||
buttons = [
|
||||
InlineKeyboardButton("Source", url=post.url),
|
||||
InlineKeyboardButton("Author", url=post.author.url),
|
||||
]
|
||||
if post.parent_post:
|
||||
buttons.insert(1, InlineKeyboardButton("RSource", url=post.parent_post.url))
|
||||
return InlineKeyboardMarkup([buttons])
|
||||
|
||||
@staticmethod
|
||||
def get_author_button(author: HumanAuthor) -> InlineKeyboardMarkup:
|
||||
@ -76,16 +75,18 @@ class Timeline:
|
||||
@staticmethod
|
||||
def get_post_text(post: HumanPost) -> str:
|
||||
text = "<b>Bsky Post Info</b>\n\n<code>"
|
||||
text += post.content
|
||||
text += "</code>\n\n"
|
||||
key = "发表"
|
||||
if post.is_reply:
|
||||
key = "回复"
|
||||
elif post.is_quote:
|
||||
key = "引用"
|
||||
elif post.is_repost:
|
||||
text += f"{post.repost_info.by.format} 转发于 {post.repost_info.time_str}\n"
|
||||
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_repost:
|
||||
text += f"{post.repost_info.by.format} 转发于 {post.repost_info.time_str}\n"
|
||||
text += f"点赞: {post.like_count} | 引用: {post.quote_count} | 回复: {post.reply_count} | 转发: {post.repost_count}"
|
||||
return text
|
||||
|
||||
@ -102,6 +103,15 @@ class Timeline:
|
||||
parse_mode=ParseMode.HTML,
|
||||
reply_markup=Timeline.get_button(post),
|
||||
)
|
||||
elif post.external:
|
||||
return await bot.send_document(
|
||||
reply.cid,
|
||||
post.external,
|
||||
caption=text,
|
||||
reply_to_message_id=reply.mid,
|
||||
parse_mode=ParseMode.HTML,
|
||||
reply_markup=Timeline.get_button(post),
|
||||
)
|
||||
elif not post.images:
|
||||
return await bot.send_message(
|
||||
reply.cid,
|
||||
|
Loading…
Reference in New Issue
Block a user