mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-13 00:10:27 +00:00
refactor: enhanced type definition for other methods
This commit is contained in:
@@ -431,55 +431,14 @@ export class NTQQFileApi {
|
||||
}
|
||||
|
||||
async searchfile(keys: string[]) {
|
||||
type EventType = NodeIKernelSearchService['searchFileWithKeywords'];
|
||||
|
||||
interface OnListener {
|
||||
searchId: string,
|
||||
hasMore: boolean,
|
||||
resultItems: {
|
||||
chatType: ChatType,
|
||||
buddyChatInfo: any[],
|
||||
discussChatInfo: any[],
|
||||
groupChatInfo:
|
||||
{
|
||||
groupCode: string,
|
||||
isConf: boolean,
|
||||
hasModifyConfGroupFace: boolean,
|
||||
hasModifyConfGroupName: boolean,
|
||||
groupName: string,
|
||||
remark: string
|
||||
}[],
|
||||
dataLineChatInfo: any[],
|
||||
tmpChatInfo: any[],
|
||||
msgId: string,
|
||||
msgSeq: string,
|
||||
msgTime: string,
|
||||
senderUid: string,
|
||||
senderNick: string,
|
||||
senderRemark: string,
|
||||
senderCard: string,
|
||||
elemId: string,
|
||||
elemType: number,
|
||||
fileSize: string,
|
||||
filePath: string,
|
||||
fileName: string,
|
||||
hits:
|
||||
{
|
||||
start: number,
|
||||
end: number
|
||||
}[]
|
||||
}[]
|
||||
}
|
||||
|
||||
const Event = this.core.eventWrapper.createEventFunction<EventType>('NodeIKernelSearchService/searchFileWithKeywords');
|
||||
let id = '';
|
||||
const Listener = this.core.eventWrapper.RegisterListen<(params: OnListener) => void>(
|
||||
const Event = this.core.eventWrapper.createEventFunction('NodeIKernelSearchService/searchFileWithKeywords');
|
||||
const id = await Event!(keys, 12);
|
||||
const Listener = this.core.eventWrapper.registerListen(
|
||||
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
);
|
||||
id = await Event!(keys, 12);
|
||||
const [ret] = (await Listener);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class NTQQFriendApi {
|
||||
const buddyService = this.context.session.getBuddyService();
|
||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
||||
);
|
||||
return Array.from(data.values());
|
||||
@@ -33,7 +33,7 @@ export class NTQQFriendApi {
|
||||
const buddyService = this.context.session.getBuddyService();
|
||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
||||
);
|
||||
data.forEach((value) => {
|
||||
@@ -55,7 +55,7 @@ export class NTQQFriendApi {
|
||||
});
|
||||
return item.buddyUids;
|
||||
}));
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
||||
);
|
||||
return buddyListV2.map(category => ({
|
||||
|
||||
@@ -268,17 +268,16 @@ export class NTQQGroupApi {
|
||||
|
||||
async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
||||
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
||||
const Listener = this.core.eventWrapper.RegisterListen<(params: any) => void>
|
||||
(
|
||||
const Listener = this.core.eventWrapper.registerListen(
|
||||
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||
1,
|
||||
forced ? 5000 : 250,
|
||||
(params) => {
|
||||
return params === GroupCode;
|
||||
},
|
||||
);
|
||||
const EventFunc = this.core.eventWrapper.createEventFunction<EventType>('NodeIKernelGroupService/getMemberInfo');
|
||||
const retData = await EventFunc!(GroupCode, [uid], forced);
|
||||
(params) => params === GroupCode,
|
||||
);
|
||||
const retData = await (
|
||||
this.core.eventWrapper
|
||||
.createEventFunction('NodeIKernelGroupService/getMemberInfo')
|
||||
)!(GroupCode, [uid], forced);
|
||||
if (retData.result !== 0) {
|
||||
throw new Error(`${retData.errMsg}`);
|
||||
}
|
||||
@@ -324,12 +323,10 @@ export class NTQQGroupApi {
|
||||
}
|
||||
|
||||
async getArkJsonGroupShare(GroupCode: string) {
|
||||
const ret = await this.core.eventWrapper.callNoListenerEvent<(GroupId: string) => Promise<GeneralCallResult & {
|
||||
arkJson: string
|
||||
}>>(
|
||||
const ret = await this.core.eventWrapper.callNoListenerEvent(
|
||||
'NodeIKernelGroupService/getGroupRecommendContactArkJson',
|
||||
GroupCode,
|
||||
);
|
||||
) as GeneralCallResult & { arkJson: string };
|
||||
return ret.arkJson;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ export class NTQQSystemApi {
|
||||
|
||||
//1-2-162b9b42-65b9-4405-a8ed-2e256ec8aa50
|
||||
async getArkJsonCollection(cid: string) {
|
||||
return await this.core.eventWrapper.callNoListenerEvent<(cid: string) => Promise<GeneralCallResult & {
|
||||
arkJson: string
|
||||
}>>('NodeIKernelCollectionService/collectionArkShare', '1717662698058');
|
||||
return await this.core.eventWrapper.callNoListenerEvent('NodeIKernelCollectionService/collectionArkShare', '1717662698058');
|
||||
}
|
||||
|
||||
async BootMiniApp(appfile: string, params: string) {
|
||||
|
||||
@@ -231,8 +231,7 @@ export class NTQQUserApi {
|
||||
}
|
||||
|
||||
async getUserDetailInfoByUinV2(Uin: string) {
|
||||
return await this.core.eventWrapper.callNoListenerEvent<(Uin: string) => Promise<UserDetailInfoByUinV2>>
|
||||
('NodeIKernelProfileService/getUserDetailInfoByUin', Uin);
|
||||
return await this.core.eventWrapper.callNoListenerEvent('NodeIKernelProfileService/getUserDetailInfoByUin', Uin);
|
||||
}
|
||||
|
||||
async forceFetchClientKey() {
|
||||
|
||||
39
src/core/listeners/NodeIKernelSearchListener_Polyfill.ts
Normal file
39
src/core/listeners/NodeIKernelSearchListener_Polyfill.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { ChatType } from '@/core';
|
||||
|
||||
export interface NodeIKernelSearchListener_Polyfill {
|
||||
onSearchFileKeywordsResult(params: {
|
||||
searchId: string,
|
||||
hasMore: boolean,
|
||||
resultItems: {
|
||||
chatType: ChatType,
|
||||
buddyChatInfo: any[],
|
||||
discussChatInfo: any[],
|
||||
groupChatInfo: {
|
||||
groupCode: string,
|
||||
isConf: boolean,
|
||||
hasModifyConfGroupFace: boolean,
|
||||
hasModifyConfGroupName: boolean,
|
||||
groupName: string,
|
||||
remark: string
|
||||
}[],
|
||||
dataLineChatInfo: any[],
|
||||
tmpChatInfo: any[],
|
||||
msgId: string,
|
||||
msgSeq: string,
|
||||
msgTime: string,
|
||||
senderUid: string,
|
||||
senderNick: string,
|
||||
senderRemark: string,
|
||||
senderCard: string,
|
||||
elemId: string,
|
||||
elemType: number,
|
||||
fileSize: string,
|
||||
filePath: string,
|
||||
fileName: string,
|
||||
hits: {
|
||||
start: number,
|
||||
end: number
|
||||
}[]
|
||||
}[]
|
||||
}): void;
|
||||
}
|
||||
@@ -9,6 +9,7 @@ export * from './NodeIKernelProfileListener';
|
||||
export * from './NodeIKernelTicketListener';
|
||||
export * from './NodeIKernelStorageCleanListener';
|
||||
export * from './NodeIKernelFileAssistantListener';
|
||||
export * from './NodeIKernelSearchListener_Polyfill';
|
||||
|
||||
import type {
|
||||
NodeIKernelBuddyListener,
|
||||
@@ -21,6 +22,7 @@ import type {
|
||||
NodeIKernelSessionListener,
|
||||
NodeIKernelStorageCleanListener,
|
||||
NodeIKernelTicketListener,
|
||||
NodeIKernelSearchListener_Polyfill,
|
||||
} from '.';
|
||||
|
||||
export type ListenerNamingMapping = {
|
||||
@@ -34,4 +36,5 @@ export type ListenerNamingMapping = {
|
||||
NodeIKernelTicketListener: NodeIKernelTicketListener;
|
||||
NodeIKernelStorageCleanListener: NodeIKernelStorageCleanListener;
|
||||
NodeIKernelFileAssistantListener: NodeIKernelFileAssistantListener;
|
||||
NodeIKernelSearchListener: NodeIKernelSearchListener_Polyfill;
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AnyCnameRecord } from 'node:dns';
|
||||
import { BizKey, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin } from '@/core';
|
||||
import { BizKey, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '@/core';
|
||||
import { NodeIKernelProfileListener } from '@/core';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
@@ -86,7 +86,7 @@ export interface NodeIKernelProfileService {
|
||||
|
||||
getUserDetailInfoWithBizInfo(uid: string, Biz: BizKey[]): Promise<GeneralCallResult>;
|
||||
|
||||
getUserDetailInfoByUin(uin: string): Promise<UserDetailInfoByUin>;
|
||||
getUserDetailInfoByUin(uin: string): Promise<UserDetailInfoByUinV2>;
|
||||
|
||||
getZplanAvatarInfos(args: string[]): Promise<unknown>;
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ export * from './NodeIKernelRobotService';
|
||||
export * from './NodeIKernelRichMediaService';
|
||||
export * from './NodeIKernelDbToolsService';
|
||||
export * from './NodeIKernelTipOffService';
|
||||
export * from './NodeIKernelSearchService';
|
||||
export * from './NodeIKernelCollectionService';
|
||||
|
||||
import type {
|
||||
NodeIKernelAvatarService,
|
||||
@@ -31,6 +33,8 @@ import type {
|
||||
NodeIKernelStorageCleanService,
|
||||
NodeIKernelTicketService,
|
||||
NodeIKernelTipOffService,
|
||||
NodeIKernelSearchService,
|
||||
NodeIKernelCollectionService,
|
||||
} from '.';
|
||||
|
||||
export type ServiceNamingMapping = {
|
||||
@@ -49,4 +53,6 @@ export type ServiceNamingMapping = {
|
||||
NodeIKernelRichMediaService: NodeIKernelRichMediaService;
|
||||
NodeIKernelDbToolsService: NodeIKernelDbToolsService;
|
||||
NodeIKernelTipOffService: NodeIKernelTipOffService;
|
||||
NodeIKernelSearchService: NodeIKernelSearchService,
|
||||
NodeIKernelCollectionService: NodeIKernelCollectionService;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user