🐛 Fix IndexError in PostPlugin

This commit is contained in:
xtaodada 2023-10-25 13:38:54 +08:00
parent 94c0b249cb
commit 95d488625a
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659

View File

@ -331,7 +331,7 @@ class Post(Plugin.Conversation):
try: try:
if len(post_images) > 1: if len(post_images) > 1:
media = [self.input_media(img_info) for img_info in post_images if not img_info.is_error] media = [self.input_media(img_info) for img_info in post_images if not img_info.is_error]
index = ((math.ceil(len(media) / 10) - 1) * 10 + 1) if len(media) > 10 else 0 index = (math.ceil(len(media) / 10) - 1) * 10
media[index].caption = post_text media[index].caption = post_text
media[index].parse_mode = ParseMode.MARKDOWN_V2 media[index].parse_mode = ParseMode.MARKDOWN_V2
for group in ArkoWrapper(media).group(10): # 每 10 张图片分一个组 for group in ArkoWrapper(media).group(10): # 每 10 张图片分一个组
@ -507,7 +507,7 @@ class Post(Plugin.Conversation):
try: try:
if len(post_images) > 1: if len(post_images) > 1:
media = [self.input_media(img_info) for img_info in post_images if not img_info.is_error] media = [self.input_media(img_info) for img_info in post_images if not img_info.is_error]
index = ((math.ceil(len(media) / 10) - 1) * 10 + 1) if len(media) > 10 else 0 index = (math.ceil(len(media) / 10) - 1) * 10
media[index].caption = post_text media[index].caption = post_text
media[index].parse_mode = ParseMode.MARKDOWN_V2 media[index].parse_mode = ParseMode.MARKDOWN_V2
for group in ArkoWrapper(media).group(10): # 每 10 张图片分一个组 for group in ArkoWrapper(media).group(10): # 每 10 张图片分一个组