From e1691991077f42c69180c1880fc6d03b4df1dc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 29 Jul 2024 08:29:24 +0800 Subject: [PATCH] feat: #162 --- src/core/src/apis/msg.ts | 3 +++ .../src/services/NodeIKernelMsgService.ts | 11 +++++++--- .../action/extends/FetchCustomFace.ts | 20 +++++++++++++++++++ src/onebot11/action/index.ts | 4 +++- src/onebot11/action/types.ts | 3 ++- 5 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 src/onebot11/action/extends/FetchCustomFace.ts diff --git a/src/core/src/apis/msg.ts b/src/core/src/apis/msg.ts index 9fb304db..2c3cf580 100644 --- a/src/core/src/apis/msg.ts +++ b/src/core/src/apis/msg.ts @@ -99,6 +99,9 @@ export class NTQQMsgApi { static async getSingleMsg(peer: Peer, seq: string) { return await napCatCore.session.getMsgService().getSingleMsg(peer, seq); } + static async fetchFavEmojiList(num:number) { + return napCatCore.session.getMsgService().fetchFavEmojiList("",num , true, true) + } static async queryMsgsWithFilterExWithSeq(peer: Peer, msgSeq: string, msgTime: string, senderUid: string) { let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', msgTime, msgSeq, { chatInfo: peer, diff --git a/src/core/src/services/NodeIKernelMsgService.ts b/src/core/src/services/NodeIKernelMsgService.ts index d06a87d0..5984de50 100644 --- a/src/core/src/services/NodeIKernelMsgService.ts +++ b/src/core/src/services/NodeIKernelMsgService.ts @@ -393,8 +393,13 @@ export interface NodeIKernelMsgService { translatePtt2Text(MsgId: string, Peer: {}, MsgElement: {}): unknown; setPttPlayedState(...args: unknown[]): unknown; - - fetchFavEmojiList(...args: unknown[]): unknown; + // NodeIQQNTWrapperSession fetchFavEmojiList [ + // "", + // 48, + // true, + // true + // ] + fetchFavEmojiList(str: string, num: number, uk1: boolean, uk2: boolean): Promise; addFavEmoji(...args: unknown[]): unknown; @@ -663,7 +668,7 @@ export interface NodeIKernelMsgService { dataMigrationGetMsgList(...args: unknown[]): unknown; dataMigrationStopOperation(...args: unknown[]): unknown; - + //新的希望 dataMigrationImportMsgPbRecord(DataMigrationMsgInfo: Array<{ extensionData: string//"Hex" diff --git a/src/onebot11/action/extends/FetchCustomFace.ts b/src/onebot11/action/extends/FetchCustomFace.ts new file mode 100644 index 00000000..817b5758 --- /dev/null +++ b/src/onebot11/action/extends/FetchCustomFace.ts @@ -0,0 +1,20 @@ +import { FromSchema, JSONSchema } from 'json-schema-to-ts'; +import BaseAction from '../BaseAction'; +import { ActionName } from '../types'; +import { NTQQMsgApi } from '@/core/apis'; +const SchemaData = { + type: 'object', + properties: { + count: { type: 'number' }, + } +} as const satisfies JSONSchema; + +type Payload = FromSchema; + +export class FetchCustomFace extends BaseAction { + actionName = ActionName.FetchCustomFace; + PayloadSchema = SchemaData; + protected async _handle(payload: Payload) { + return await NTQQMsgApi.fetchFavEmojiList(payload.count || 48); + } +} diff --git a/src/onebot11/action/index.ts b/src/onebot11/action/index.ts index 9f5e5e80..f032a784 100644 --- a/src/onebot11/action/index.ts +++ b/src/onebot11/action/index.ts @@ -75,6 +75,7 @@ import SetEssenceMsg from './group/SetEssenceMsg'; import GetRecentContact from './user/GetRecentContact'; import { GetProfileLike } from './extends/GetProfileLike'; import SetGroupHeader from './extends/SetGroupHeader'; +import { FetchCustomFace } from './extends/FetchCustomFace'; export const actionHandlers = [ new RebootNormal(), @@ -156,7 +157,8 @@ export const actionHandlers = [ new GetRecentContact(), new MarkAllMsgAsRead(), new GetProfileLike(), - new SetGroupHeader() + new SetGroupHeader(), + new FetchCustomFace() ]; function initActionMap() { diff --git a/src/onebot11/action/types.ts b/src/onebot11/action/types.ts index c3a26c6d..2a689d8c 100644 --- a/src/onebot11/action/types.ts +++ b/src/onebot11/action/types.ts @@ -99,5 +99,6 @@ export enum ActionName { GetRecentContact = 'get_recent_contact', _MarkAllMsgAsRead = '_mark_all_as_read', GetProfileLike = 'get_profile_like', - SetGroupHeader = "set_group_head" + SetGroupHeader = "set_group_head", + FetchCustomFace = "fetch_custom_face" }