Compare commits

...

5 Commits

Author SHA1 Message Date
手瓜一十雪
eac58a2a50 fix: 9.9.17-30366 2024-12-04 21:04:24 +08:00
手瓜一十雪
e939ec0e52 fix: #597 2024-12-04 20:37:08 +08:00
Mlikiowa
5b17a14a2a release: v4.2.21 2024-12-04 11:49:26 +00:00
手瓜一十雪
8fb8c888f5 refactor: 移除未使用的uidCache和uinCache逻辑 2024-12-04 19:48:59 +08:00
Mlikiowa
4a2884509e release: v4.2.20 2024-12-04 11:46:12 +00:00
8 changed files with 24 additions and 26 deletions

View File

@@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.2.19",
"version": "4.2.21",
"icon": "./logo.png",
"authors": [
{

View File

@@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.2.19",
"version": "4.2.21",
"scripts": {
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",

View File

@@ -1 +1 @@
export const napCatVersion = '4.2.19';
export const napCatVersion = '4.2.21';

View File

@@ -8,14 +8,10 @@ import { LRUCache } from '@/common/lru-cache';
export class NTQQUserApi {
context: InstanceContext;
core: NapCatCore;
private uidCache: LRUCache<string, string>;
private uinCache: LRUCache<string, string>;
constructor(context: InstanceContext, core: NapCatCore) {
this.context = context;
this.core = core;
this.uidCache = new LRUCache(1000);
this.uinCache = new LRUCache(1000);
}
async getCoreAndBaseInfo(uids: string[]) {
@@ -174,9 +170,6 @@ export class NTQQUserApi {
}
async getUidByUinV2(Uin: string) {
if (this.uidCache.get(Uin)) {
return this.uidCache.get(Uin);
}
const services = [
() => this.context.session.getUixConvertService().getUid([Uin]).then((data) => data.uidInfo.get(Uin)).catch(() => undefined),
() => promisify<string, string[], Map<string, string>>
@@ -188,17 +181,13 @@ export class NTQQUserApi {
for (const service of services) {
uid = await service();
if (uid && uid.indexOf('*') == -1 && uid !== '') {
this.uidCache.put(Uin, uid);
break;
}
}
return uid;
return uid ?? '';
}
async getUinByUidV2(Uid: string) {
if (this.uinCache.get(Uid)) {
return this.uinCache.get(Uid);
}
const services = [
() => this.context.session.getUixConvertService().getUin([Uid]).then((data) => data.uinInfo.get(Uid)).catch(() => undefined),
() => this.context.session.getGroupService().getUinByUids([Uid]).then((data) => data.uins.get(Uid)).catch(() => undefined),
@@ -211,11 +200,10 @@ export class NTQQUserApi {
for (const service of services) {
uin = await service();
if (uin && uin !== '0' && uin !== '') {
this.uinCache.put(Uid, uin);
break;
}
}
return uin;
return uin ?? '0';
}
async getRecentContactListSnapShot(count: number) {

View File

@@ -98,5 +98,9 @@
"6.9.61-29927": {
"appid": 537255836,
"qua": "V1_MAC_NQ_6.9.61_29927_GW_B"
},
"9.9.17-30366": {
"appid": 537258389,
"qua": "V1_WIN_NQ_9.9.17_30366_GW_B"
}
}
}

View File

@@ -102,5 +102,9 @@
"6.9.61-29927-arm64": {
"send": "4038740",
"recv": "403AF58"
},
"9.9.17-30366-x64": {
"send": "39AB0B0",
"recv": "39AF4E4"
}
}
}

View File

@@ -187,11 +187,11 @@ export interface NodeIKernelGroupService {
destroyGroup(groupCode: string): void;
getSingleScreenNotifies(doubted: boolean, start_seq: string, num: number): Promise<GeneralCallResult>;
getSingleScreenNotifies(doubt: boolean, startSeq: string, count: number): Promise<GeneralCallResult>;
clearGroupNotifies(groupCode: string): void;
getGroupNotifiesUnreadCount(unknown: boolean): Promise<GeneralCallResult>;
getGroupNotifiesUnreadCount(doubt: boolean): Promise<GeneralCallResult>;
clearGroupNotifiesUnreadCount(doubt: boolean): void;

View File

@@ -405,8 +405,8 @@ export class NapCatOneBot11Adapter {
this.context.logger.logDebug(`收到邀请我加群通知:${notify}`);
const groupInviteEvent = new OB11GroupRequestEvent(
this.core,
parseInt(notify.group.groupCode),
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid)),
+notify.group.groupCode,
+await this.core.apis.UserApi.getUinByUidV2(notify.user2.uid),
'invite',
notify.postscript,
flag
@@ -423,8 +423,8 @@ export class NapCatOneBot11Adapter {
this.context.logger.logDebug(`收到群员邀请加群通知:${notify}`);
const groupInviteEvent = new OB11GroupRequestEvent(
this.core,
parseInt(notify.group.groupCode),
parseInt(await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid)),
+notify.group.groupCode,
+await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid),
'add',
notify.postscript,
flag
@@ -571,6 +571,8 @@ export class NapCatOneBot11Adapter {
}
private async emitFriendRecallMsg(message: RawMessage, oriMessageId: number, element: MessageElement) {
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
if (!operatorUid) return undefined;
return new OB11FriendRecallNoticeEvent(
this.core,
+message.senderUin,
@@ -581,7 +583,7 @@ export class NapCatOneBot11Adapter {
private async emitGroupRecallMsg(message: RawMessage, oriMessageId: number, element: MessageElement) {
const operatorUid = element.grayTipElement?.revokeElement.operatorUid;
if (!operatorUid) return undefined;
const operatorId = message.senderUin ?? await this.core.apis.UserApi.getUinByUidV2(operatorUid);
const operatorId = await this.core.apis.UserApi.getUinByUidV2(operatorUid);
return new OB11GroupRecallNoticeEvent(
this.core,
+message.peerUin,