mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-05 07:01:16 +00:00
Introduces an optional 'cookie' parameter to the getMsgEmojiLikesList method in NTQQMsgApi and updates FetchEmojiLike to support passing this parameter. This allows for more flexible pagination or state management when fetching emoji likes.
31 lines
1.4 KiB
TypeScript
31 lines
1.4 KiB
TypeScript
import { Type, Static } from '@sinclair/typebox';
|
|
import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
|
|
import { ActionName } from '@/napcat-onebot/action/router';
|
|
import { MessageUnique } from 'napcat-common/src/message-unique';
|
|
import { type NTQQMsgApi } from 'napcat-core/apis';
|
|
|
|
const SchemaData = Type.Object({
|
|
message_id: Type.Union([Type.Number(), Type.String()]),
|
|
emojiId: Type.Union([Type.Number(), Type.String()]),
|
|
emojiType: Type.Union([Type.Number(), Type.String()]),
|
|
count: Type.Union([Type.Number(), Type.String()], { default: 20 }),
|
|
cookie: Type.String({ default: '' })
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
|
|
export class FetchEmojiLike extends OneBotAction<Payload, Awaited<ReturnType<NTQQMsgApi['getMsgEmojiLikesList']>>> {
|
|
override actionName = ActionName.FetchEmojiLike;
|
|
override payloadSchema = SchemaData;
|
|
|
|
async _handle (payload: Payload) {
|
|
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
|
if (!msgIdPeer) throw new Error('消息不存在');
|
|
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
|
if (!msg) throw new Error('消息不存在');
|
|
return await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
|
msgIdPeer.Peer, msg.msgSeq, payload.emojiId.toString(), payload.emojiType.toString(), payload.cookie, +payload.count
|
|
);
|
|
}
|
|
}
|