From 5eb64060dc032f75ef42d50949c2ae290d1b87dc Mon Sep 17 00:00:00 2001 From: HibiKier <45528451+HibiKier@users.noreply.github.com> Date: Mon, 6 Sep 2021 21:14:26 +0800 Subject: [PATCH] Update data_source.py --- plugins/check_zhenxun_update/data_source.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/check_zhenxun_update/data_source.py b/plugins/check_zhenxun_update/data_source.py index 7bf6efd4..87ac12d1 100644 --- a/plugins/check_zhenxun_update/data_source.py +++ b/plugins/check_zhenxun_update/data_source.py @@ -89,10 +89,12 @@ async def check_update(bot: Bot) -> 'int, str': update_info = data["body"] width = 0 height = len(update_info.split('\n')) * 24 - for m in update_info.split('\n'): - if len(m) * 20 > width: - width = len(m) * 18 A = CreateImg(width, height, font_size=20) + for m in update_info.split('\n'): + w, h = A.getsize(m) + if w > width: + width = w + A = CreateImg(width + 50, height, font_size=20) A.text((10, 10), update_info) A.save(f'{IMAGE_PATH}/update_info.png') await bot.send_private_msg(