mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-29 04:41:22 +08:00
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { z } from 'zod';
|
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|
import { ActionName } from '@/onebot/action/router';
|
|
import { MessageUnique } from '@/common/message-unique';
|
|
import { type NTQQMsgApi } from '@/core/apis';
|
|
|
|
const SchemaData = z.object({
|
|
message_id: z.string(),
|
|
emojiId: z.string(),
|
|
emojiType: z.string(),
|
|
count: z.number().default(20),
|
|
});
|
|
|
|
type Payload = z.infer<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, payload.emojiType, +payload.count
|
|
);
|
|
}
|
|
}
|