🐛 修复深渊统计因透明头像而报错的问题

This commit is contained in:
CMHopeSunshine 2022-10-01 13:46:03 +08:00
parent 5290b0fc72
commit f2a8c38e2a

View File

@ -13,17 +13,23 @@ from LittlePaimon.utils.message import MessageBuild
async def get_user_avatar(user_id: str, size: Tuple[int, int] = (60, 60)): async def get_user_avatar(user_id: str, size: Tuple[int, int] = (60, 60)):
img = await get_qq_avatar(user_id) try:
await img.resize(size) img = await get_qq_avatar(user_id)
await img.to_circle('circle') await img.resize(size)
return img await img.to_circle('circle')
return img
except Exception:
return PMImage(size=size, color=(255, 255, 255, 255))
async def get_group_avatar(group_id: str): async def get_group_avatar(group_id: str):
img = await aiorequests.get_img(f'https://p.qlogo.cn/gh/{group_id}/{group_id}/100', size=(110, 110)) try:
img = PMImage(img) img = await aiorequests.get_img(f'https://p.qlogo.cn/gh/{group_id}/{group_id}/100', size=(110, 110))
await img.to_circle('circle') img = PMImage(img)
return img await img.to_circle('circle')
return img
except Exception:
return PMImage(size=(110, 110), color=(255, 255, 255, 255))