hotfix!!!!!!

This commit is contained in:
2026-01-06 23:51:09 +08:00
parent e50679eac2
commit afd2c36f88
2 changed files with 39 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ import json
from core.redis_manager import redis_manager
from .base import BaseAPI
from models.objects import GroupInfo, GroupMemberInfo, GroupHonorInfo
from core.logger import logger
class GroupAPI(BaseAPI):
@@ -194,6 +195,22 @@ class GroupAPI(BaseAPI):
List[GroupInfo]: 包含所有群组信息的 `GroupInfo` 对象列表。
"""
res = await self.call_api("get_group_list")
# 增加日志记录 API 原始返回
logger.debug(f"OneBot API 'get_group_list' raw response: {res}")
# 健壮性处理:如果返回的是字符串,尝试解析为 JSON
if isinstance(res, str):
try:
res = json.loads(res)
except json.JSONDecodeError:
logger.error(f"Failed to decode JSON from 'get_group_list' response: {res}")
return []
if not isinstance(res, list):
logger.error(f"Expected a list from 'get_group_list', but got {type(res)}: {res}")
return []
return [GroupInfo(**item) for item in res]
async def get_group_member_info(self, group_id: int, user_id: int, no_cache: bool = False) -> GroupMemberInfo: