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);
}
}
getKeyList(): K[] {
return Array.from(this.keyToValue.keys());
}
}
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 { NTEventDispatch } from '@/common/utils/EventTask';
import { log } from '@/common/utils/log';
@ -84,14 +84,9 @@ export class NTQQGroupApi {
static async getLastestMsg(GroupCode: string, uins: string[]) {
let uids: Array<string> = [];
for (let uin of uins) {
try {
let uid = await NTQQUserApi.getUidByUin(uin)
if (uid) {
uids.push(uid);
}
} catch (error) {
log("getLastestMsg--->", error);
return undefined;
let uid = await NTQQUserApi.getUidByUin(uin)
if (uid) {
uids.push(uid);
}
}
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {

View File

@ -63,7 +63,19 @@ export class NTQQMsgApi {
} | undefined> {
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[]) {
return await napCatCore.session.getMsgService().getMsgsByMsgId(peer, msgIds);
}

View File

@ -141,7 +141,7 @@ export interface NodeIKernelMsgService {
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>;

View File

@ -18,7 +18,7 @@ const SchemaData = {
message_seq: { type: 'number' },
count: { type: 'number' }
},
required: ['group_id', 'count']
required: ['group_id']
} as const satisfies JSONSchema;
type Payload = FromSchema<typeof SchemaData>;
@ -31,13 +31,17 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
if (!group) {
throw `${payload.group_id}不存在`;
}
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq || 0))?.MsgId || '0';
// log("startMsgId", startMsgId)
const historyResult = (await NTQQMsgApi.getMsgHistory({
let targetMsgShortId, count = parseInt(payload.count?.toString() ?? '20');
const peer = {
chatType: ChatType.group,
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;
await Promise.all(msgList.map(async msg => {
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;
for (const member of members.values()) {
//console.log(member?.isDelete, role, isPrivilege);
if (member?.isDelete && !isPrivilege && selfInfo.uin !== member.uin) {
log('[群聊] 群组 ', groupCode, ' 成员' + member.uin + '退出');
const groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(groupCode), parseInt(member.uin), 0, 'leave');// 不知道怎么出去的
postOB11Event(groupDecreaseEvent, true);
}
// Develop Mlikiowa Taged: 暂时屏蔽这个方案 考虑onMemberListChange
// if (member?.isDelete && !isPrivilege && selfInfo.uin !== member.uin) {
// log('[群聊] 群组 ', groupCode, ' 成员' + member.uin + '退出');
// const groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(groupCode), parseInt(member.uin), 0, 'leave');// 不知道怎么出去的
// postOB11Event(groupDecreaseEvent, true);
// }
}
};
groupListener.onJoinGroupNotify = (...notify) => {