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