1111
This commit is contained in:
@@ -199,20 +199,22 @@ class GroupAPI(BaseAPI):
|
|||||||
# 增加日志记录 API 原始返回
|
# 增加日志记录 API 原始返回
|
||||||
logger.debug(f"OneBot API 'get_group_list' raw response: {res}")
|
logger.debug(f"OneBot API 'get_group_list' raw response: {res}")
|
||||||
|
|
||||||
# 健壮性处理:如果返回的是字符串,尝试解析为 JSON
|
# 健壮性处理:处理标准的 OneBot v11 响应格式
|
||||||
if isinstance(res, str):
|
if isinstance(res, dict) and res.get("status") == "ok":
|
||||||
try:
|
group_data = res.get("data", [])
|
||||||
res = json.loads(res)
|
if isinstance(group_data, list):
|
||||||
except json.JSONDecodeError:
|
return [GroupInfo(**item) for item in group_data]
|
||||||
logger.error(f"Failed to decode JSON from 'get_group_list' response: {res}")
|
else:
|
||||||
return []
|
logger.error(f"The 'data' field in 'get_group_list' response is not a list: {group_data}")
|
||||||
|
|
||||||
if not isinstance(res, list):
|
|
||||||
logger.error(f"Expected a list from 'get_group_list', but got {type(res)}: {res}")
|
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
# 兼容处理:如果返回的是列表(非标准但可能存在)
|
||||||
|
if isinstance(res, list):
|
||||||
return [GroupInfo(**item) for item in res]
|
return [GroupInfo(**item) for item in res]
|
||||||
|
|
||||||
|
logger.error(f"Unexpected response format from 'get_group_list': {res}")
|
||||||
|
return []
|
||||||
|
|
||||||
async def get_group_member_info(self, group_id: int, user_id: int, no_cache: bool = False) -> GroupMemberInfo:
|
async def get_group_member_info(self, group_id: int, user_id: int, no_cache: bool = False) -> GroupMemberInfo:
|
||||||
"""
|
"""
|
||||||
获取指定群组成员的详细信息。
|
获取指定群组成员的详细信息。
|
||||||
|
|||||||
Reference in New Issue
Block a user