diff --git a/defs/bsky.py b/defs/bsky.py index d9df6b5..7c5d797 100644 --- a/defs/bsky.py +++ b/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 = "Bsky Post Info\n\n" - text += post.content - text += "\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,