qqgroup平台提供头像获取 (#116)

*  为`qqgroup`平台提供头像获取

* 🚨 `pre-commit-ci`修复格式错误

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Edelweiss 2025-04-11 10:09:29 +08:00 committed by GitHub
parent 80507ebb5a
commit 5ff2b39871
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,