From 5ff2b39871eb4b3e775f5312276dbb024f7871b8 Mon Sep 17 00:00:00 2001 From: Edelweiss <2633668472@qq.com> Date: Fri, 11 Apr 2025 10:09:29 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E4=B8=BA`qqgroup`=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=8F=90=E4=BE=9B=E5=A4=B4=E5=83=8F=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=20(#116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ 为`qqgroup`平台提供头像获取 * 🚨 `pre-commit-ci`修复格式错误 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- gsuid_core/utils/image/image_tools.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gsuid_core/utils/image/image_tools.py b/gsuid_core/utils/image/image_tools.py index e1423f8..609b565 100644 --- a/gsuid_core/utils/image/image_tools.py +++ b/gsuid_core/utils/image/image_tools.py @@ -114,6 +114,8 @@ async def get_event_avatar( if img is None and ev.bot_id == 'onebot' and not ev.sender: img = await get_qq_avatar(ev.user_id) + elif img is None and ev.bot_id == 'qqgroup': + img = await get_qqgroup_avatar(ev.bot_self_id, ev.user_id) if img is None and avatar_path: pic_path_list = list(avatar_path.iterdir()) @@ -331,6 +333,20 @@ async def get_qq_avatar( return char_pic +async def get_qqgroup_avatar( + bot_id: Optional[Union[int, str]] = None, + qid: Optional[Union[int, str]] = None, + avatar_url: Optional[str] = None, +) -> Image.Image: + if not qid or not bot_id: + return None + avatar_url = f'https://q.qlogo.cn/qqapp/{bot_id}/{qid}/100' + char_pic = Image.open(BytesIO((await sget(avatar_url)).content)).convert( + 'RGBA' + ) + return char_pic + + async def draw_pic_with_ring( pic: Image.Image, size: int,