add logger for merge image

This commit is contained in:
felinae98 2021-02-19 15:58:44 +08:00
parent 0d35e3390e
commit a2a91ee804
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 4 additions and 2 deletions

View File

@ -68,7 +68,7 @@ class Weibo(Platform):
def _get_text(self, raw_text: str) -> str: def _get_text(self, raw_text: str) -> str:
text = raw_text.replace('<br />', '\n') text = raw_text.replace('<br />', '\n')
return bs(text).text return bs(text, 'html.parser').text
async def parse(self, raw_post: RawPost) -> Post: async def parse(self, raw_post: RawPost) -> Post:
info = raw_post['mblog'] info = raw_post['mblog']

View File

@ -2,6 +2,7 @@ import base64
from dataclasses import dataclass, field from dataclasses import dataclass, field
from io import BytesIO from io import BytesIO
from typing import NoReturn, Optional from typing import NoReturn, Optional
from nonebot import logger
import httpx import httpx
from PIL import Image from PIL import Image
from .plugin_config import plugin_config from .plugin_config import plugin_config
@ -47,11 +48,12 @@ class Post:
if len(images) == 6: if len(images) == 6:
matrix = (3, 2) matrix = (3, 2)
self.pics = self.pics[6:] self.pics = self.pics[6:]
elif len(images) == 9: elif len(images) >= 9:
matrix = (3, 3) matrix = (3, 3)
self.pics = self.pics[9:] self.pics = self.pics[9:]
else: else:
return return
logger.info('trigger merge image')
target = Image.new('RGB', (matrix[0] * pic_size, matrix[1] * pic_size)) target = Image.new('RGB', (matrix[0] * pic_size, matrix[1] * pic_size))
for y in range(matrix[1]): for y in range(matrix[1]):
for x in range(matrix[0]): for x in range(matrix[0]):