对 get_group_member_list 增强

非管理员的Bot可以通过本地数据库获取到最近的发言时间
This commit is contained in:
po-lan 2024-05-27 17:07:23 +08:00 committed by GitHub
parent 1f2e80cd39
commit 9fa0dcd7aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,6 +7,8 @@ import { napCatCore, NTQQGroupApi, NTQQUserApi, SignMiniApp } from '@/core';
import { WebApi } from '@/core/apis/webapi'; import { WebApi } from '@/core/apis/webapi';
import { logDebug } from '@/common/utils/log'; import { logDebug } from '@/common/utils/log';
import { FromSchema, JSONSchema } from 'json-schema-to-ts'; import { FromSchema, JSONSchema } from 'json-schema-to-ts';
import { getLastSentTimeAndJoinTime }from "./LastSendAndJoinRemberLRU"
const SchemaData = { const SchemaData = {
type: 'object', type: 'object',
properties: { properties: {
@ -56,6 +58,21 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
} }
// 还原Map到Array // 还原Map到Array
const RetGroupMember: OB11GroupMember[] = Array.from(MemberMap.values()); const RetGroupMember: OB11GroupMember[] = Array.from(MemberMap.values());
// 无管理员权限通过本地记录获取发言时间
const haveAdmin = RetGroupMember[0].last_sent_time !== 0;
if (!haveAdmin) {
logDebug('没有管理员权限,使用本地记录');
const _sendAndJoinRember = await getLastSentTimeAndJoinTime(parseInt(group.groupCode));
_sendAndJoinRember.forEach((rember) => {
const member = RetGroupMember.find(member=>member.user_id == rember.user_id);
if(member){
member.last_sent_time = rember.last_sent_time;
member.join_time = rember.join_time;
}
})
}
return RetGroupMember; return RetGroupMember;
} }
} }