fix: type check & type output

This commit is contained in:
手瓜一十雪 2024-05-31 18:55:18 +08:00
parent a716fdf6d4
commit 4f4af5985a
3 changed files with 15 additions and 5 deletions

View File

@ -9,11 +9,12 @@ import { logDebug } from '@/common/utils/log';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { ob11Config } from '@/onebot11/config';
import { dbUtil } from '@/common/utils/db';
import { TypeConvert } from '@/common/utils/type';
const SchemaData = {
type: 'object',
properties: {
group_id: { type: [ 'number' , 'string' ] },
group_id: { type: ['number', 'string'] },
no_cache: { type: ['boolean', 'string'] },
},
required: ['group_id']
@ -58,12 +59,12 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
MemberData.join_time = webGroupMembers[i]?.join_time;
MemberData.last_sent_time = webGroupMembers[i]?.last_speak_time;
MemberData.qage = webGroupMembers[i]?.qage;
MemberData.level = webGroupMembers[i]?.lv.level;
MemberData.level = webGroupMembers[i]?.lv.level.toString();
MemberMap.set(webGroupMembers[i]?.uin, MemberData);
}
}
} else if (ob11Config.GroupLocalTime.Record && ob11Config.GroupLocalTime.RecordList[0] === '-1' || ob11Config.GroupLocalTime.RecordList.includes(payload.group_id.toString())) {
const _sendAndJoinRember = await dbUtil.getLastSentTimeAndJoinTime(payload.group_id);
const _sendAndJoinRember = await dbUtil.getLastSentTimeAndJoinTime(TypeConvert.toNumber(payload.group_id));
_sendAndJoinRember.forEach((element) => {
let MemberData = MemberMap.get(element.user_id);
if (MemberData) {
@ -73,6 +74,15 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
});
}
// 还原索引到Array 一同返回
// let retData: any[] = [];
// for (let retMem of MemberMap.values()) {
// retMem.level = TypeConvert.toString(retMem.level) as any;
// retData.push(retMem)
// }
// _groupMembers = Array.from(retData);
_groupMembers = Array.from(MemberMap.values());
return _groupMembers;
}

View File

@ -506,7 +506,7 @@ export class OB11Constructor {
sex: OB11Constructor.sex(member.sex!),
age: 0,
area: '',
level: 0,
level: '0',
qq_level: member.qqLevel && calcQQLevel(member.qqLevel) || 0,
join_time: 0, // 暂时没法获取
last_sent_time: 0, // 暂时没法获取

View File

@ -30,7 +30,7 @@ export interface OB11GroupMember {
age?: number
join_time?: number
last_sent_time?: number
level?: number
level?: string
qq_level?: number
role?: OB11GroupMemberRole
title?: string