Commit 0932f29
Changed files (6)
src
messages
src/messages/sender.py
@@ -139,6 +139,8 @@ async def send_texts(
if not msg:
continue
if idx == 0:
+ if msg.startswith("> "): # this is the remaining part of comments
+ msg = f"**{msg}" # noqa: PLW2901 use block quote
sent_messages.append(await client.send_message(target_chat, msg, reply_parameters=reply_parameters))
else: # disbale reply
sent_messages.append(await client.send_message(target_chat, msg, reply_parameters=ReplyParameters()))
src/preview/douyin.py
@@ -102,12 +102,9 @@ async def preview_douyin(
comments = []
if comments_list := await get_comments(aweme_id, platform, douyin_comments_provider):
comments.append("\n**> 💬**点此展开评论区**:")
- for idx, cmt in enumerate(comments_list):
+ for cmt in comments_list:
cmt_text = cmt["text"].replace("\n", "\n> ")
- if idx == len(comments_list) - 1: # last cmt
- comments.append(f"\n> 💬**{cmt['name']}**{cmt['region']}: {cmt_text}||")
- else:
- comments.append(f"\n> 💬**{cmt['name']}**{cmt['region']}: {cmt_text}")
+ comments.append(f"\n> 💬**{cmt['name']}**{cmt['region']}: {cmt_text}")
sent_messages = await send2tg(client, message, texts=emojify(texts), media=media, comments=comments, **kwargs)
await modify_progress(del_status=True, **kwargs)
src/preview/instagram.py
@@ -98,10 +98,7 @@ async def preview_instagram(
cmt_text = cmt["text"].replace("\n", "\n> ")
if idx == 0:
comments.append("\n**> 💬**点此展开评论区**:")
- if idx == len(comment_list) - 1: # last cmt
- comments.append(f"\n> 💬**{cmt['author']}**: {cmt_text}||")
- else:
- comments.append(f"\n> 💬**{cmt['author']}**: {cmt_text}")
+ comments.append(f"\n> 💬**{cmt['author']}**: {cmt_text}")
await modify_progress(text=f"⏬正在下载:\n{summay_media(media)}", force_update=True, **kwargs)
media = await download_media(media, **kwargs)
src/preview/twitter.py
@@ -149,14 +149,11 @@ async def preview_twitter(
msg += f"\n{texts}"
if true(twitter_comments_provider) and (comments := master_info.get("comments")):
msg += "\n**> 💬**点此展开评论区**:"
- for idx, cmt in enumerate(comments):
+ for cmt in comments:
if str(cmt["post_id"]) == str(this_info["post_id"]):
continue
cmt_texts = cmt["text"].replace("\n", "\n> ")
- if idx == len(comments) - 1: # last cmt
- msg += f"\n> 💬**{cmt['author']}**: {cmt_texts}||"
- else:
- msg += f"\n> 💬**{cmt['author']}**: {cmt_texts}"
+ msg += f"\n> 💬**{cmt['author']}**: {cmt_texts}"
media.extend(master_media)
@@ -182,12 +179,9 @@ async def preview_twitter(
if true(twitter_comments_provider) and (comments := this_info.get("comments")):
msg += "\n**> 💬**点此展开评论区**:"
- for idx, cmt in enumerate(comments):
+ for cmt in comments:
cmt_texts = cmt["text"].strip().removeprefix(f"@{master_handle}").strip().replace("\n", "\n> ") # 有时回推的comment前会附带被回推的handle, 这里去掉
- if idx == len(comments) - 1: # last cmt
- msg += f"\n> 💬**{cmt['author']}**: {cmt_texts}||"
- else:
- msg += f"\n> 💬**{cmt['author']}**: {cmt_texts}"
+ msg += f"\n> 💬**{cmt['author']}**: {cmt_texts}"
# 引用推文
if quote_info:
src/preview/weibo.py
@@ -297,8 +297,6 @@ async def parse_weibo_comments(post_id: str) -> list[str]:
comments.append(f"\n> {cmt}")
if len(comments) == 1:
return []
- if len(comments) > 2:
- comments[-1] += "||"
return comments
src/preview/ytdlp.py
@@ -494,8 +494,6 @@ async def get_bilibili_comments(bvid: str | None, provider: str = PROVIDER.BILIB
if cmt := r.get("content", {}).get("message"):
cmt = cmt.replace("\n", "\n> ")
comments.append(f"\n> ↪️**{name}**: {emojify(cmt)}")
- if len(comments) > 2:
- comments[-1] += "||"
except Exception as e:
logger.error(f"Failed to get Bilibili comments: {e}")
return []
@@ -522,10 +520,7 @@ async def get_youtube_comments(vid: str | None, provider: str = PROVIDER.YOUTUBE
cmt = cmt.replace("\n", "\n> ")
if idx == 0:
comments.append("\n**> 💬**点此展开评论区**:")
- if idx == len(data) - 1: # last cmt
- comments.append(f"\n> 💬**{name}**: {cmt}||")
- else:
- comments.append(f"\n> 💬**{name}**: {cmt}")
+ comments.append(f"\n> 💬**{name}**: {cmt}")
except Exception as e:
logger.error(f"Failed to get YouTube comments: {e}")
return []