Merge pull request #163 from cnxysoft/main

修复提交疏漏
This commit is contained in:
手瓜一十雪 2024-07-28 13:00:12 +08:00 committed by GitHub
commit 92579d5949
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 38 additions and 22 deletions

View File

@ -61,6 +61,10 @@ class LimitedHashTable<K, V> {
this.valueToKey.delete(value); this.valueToKey.delete(value);
} }
} }
getKeyList(): K[] {
return Array.from(this.keyToValue.keys());
}
} }
class MessageUniqueWrapper { class MessageUniqueWrapper {

View File

@ -1,4 +1,4 @@
import { GroupMember, GroupRequestOperateTypes, GroupMemberRole, GroupNotify, Group, MemberExtSourceType, GroupNotifyTypes, ChatType } from '../entities'; import { GroupMember, GroupRequestOperateTypes, GroupMemberRole, GroupNotify, Group, MemberExtSourceType, GroupNotifyTypes, ChatType, Peer } from '../entities';
import { GeneralCallResult, NTQQUserApi, napCatCore } from '@/core'; import { GeneralCallResult, NTQQUserApi, napCatCore } from '@/core';
import { NTEventDispatch } from '@/common/utils/EventTask'; import { NTEventDispatch } from '@/common/utils/EventTask';
import { log } from '@/common/utils/log'; import { log } from '@/common/utils/log';
@ -84,14 +84,9 @@ export class NTQQGroupApi {
static async getLastestMsg(GroupCode: string, uins: string[]) { static async getLastestMsg(GroupCode: string, uins: string[]) {
let uids: Array<string> = []; let uids: Array<string> = [];
for (let uin of uins) { for (let uin of uins) {
try { let uid = await NTQQUserApi.getUidByUin(uin)
let uid = await NTQQUserApi.getUidByUin(uin) if (uid) {
if (uid) { uids.push(uid);
uids.push(uid);
}
} catch (error) {
log("getLastestMsg--->", error);
return undefined;
} }
} }
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', { let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {

View File

@ -63,7 +63,19 @@ export class NTQQMsgApi {
} | undefined> { } | undefined> {
return napCatCore.session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId); return napCatCore.session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId);
} }
static async getLastestMsgByUids(peer: Peer) {
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
chatInfo: peer,
filterMsgType: [],
filterSendersUid: [],
filterMsgToTime: '0',
filterMsgFromTime: '0',
isReverseOrder: false,
isIncludeCurrent: true,
pageLimit: 1,
});
return ret;
}
static async getMsgsByMsgId(peer: Peer, msgIds: string[]) { static async getMsgsByMsgId(peer: Peer, msgIds: string[]) {
return await napCatCore.session.getMsgService().getMsgsByMsgId(peer, msgIds); return await napCatCore.session.getMsgService().getMsgsByMsgId(peer, msgIds);
} }

View File

@ -141,7 +141,7 @@ export interface NodeIKernelMsgService {
getLastMessageList(peer: Peer[]): Promise<unknown>; getLastMessageList(peer: Peer[]): Promise<unknown>;
getAioFirstViewLatestMsgs(peer: Peer, unknown: number): unknown; getAioFirstViewLatestMsgs(peer: Peer, num: number): unknown;
getMsgs(peer: Peer, msgId: string, count: unknown, queryOrder: boolean): Promise<unknown>; getMsgs(peer: Peer, msgId: string, count: unknown, queryOrder: boolean): Promise<unknown>;

View File

@ -18,7 +18,7 @@ const SchemaData = {
message_seq: { type: 'number' }, message_seq: { type: 'number' },
count: { type: 'number' } count: { type: 'number' }
}, },
required: ['group_id', 'count'] required: ['group_id']
} as const satisfies JSONSchema; } as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>; type Payload = FromSchema<typeof SchemaData>;
@ -31,13 +31,17 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
if (!group) { if (!group) {
throw `${payload.group_id}不存在`; throw `${payload.group_id}不存在`;
} }
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq || 0))?.MsgId || '0'; let targetMsgShortId, count = parseInt(payload.count?.toString() ?? '20');
// log("startMsgId", startMsgId) const peer = {
const historyResult = (await NTQQMsgApi.getMsgHistory({
chatType: ChatType.group, chatType: ChatType.group,
peerUid: group.groupCode peerUid: group.groupCode
}, startMsgId, parseInt(payload.count?.toString()) || 20)); }
//logDebug(historyResult); if (!payload.message_seq) {
let latestMsgId = (await NTQQMsgApi.getLastestMsgByUids(peer)).msgList[0].msgId;
targetMsgShortId = await MessageUnique.createMsg(peer, latestMsgId || '0');
}
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(targetMsgShortId ?? (payload.message_seq ?? 0)))?.MsgId || '0';
const historyResult = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, count));
const msgList = historyResult.msgList; const msgList = historyResult.msgList;
await Promise.all(msgList.map(async msg => { await Promise.all(msgList.map(async msg => {
msg.id = await MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId); msg.id = await MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);

View File

@ -323,11 +323,12 @@ export class NapCatOnebot11 {
const isPrivilege = role === 3 || role === 4; const isPrivilege = role === 3 || role === 4;
for (const member of members.values()) { for (const member of members.values()) {
//console.log(member?.isDelete, role, isPrivilege); //console.log(member?.isDelete, role, isPrivilege);
if (member?.isDelete && !isPrivilege && selfInfo.uin !== member.uin) { // Develop Mlikiowa Taged: 暂时屏蔽这个方案 考虑onMemberListChange
log('[群聊] 群组 ', groupCode, ' 成员' + member.uin + '退出'); // if (member?.isDelete && !isPrivilege && selfInfo.uin !== member.uin) {
const groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(groupCode), parseInt(member.uin), 0, 'leave');// 不知道怎么出去的 // log('[群聊] 群组 ', groupCode, ' 成员' + member.uin + '退出');
postOB11Event(groupDecreaseEvent, true); // const groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(groupCode), parseInt(member.uin), 0, 'leave');// 不知道怎么出去的
} // postOB11Event(groupDecreaseEvent, true);
// }
} }
}; };
groupListener.onJoinGroupNotify = (...notify) => { groupListener.onJoinGroupNotify = (...notify) => {