mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
commit
92579d5949
@ -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 {
|
||||||
|
@ -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', {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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>;
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user