mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-04 22:51:13 +00:00
Added or updated actionSummary, actionTags, payloadExample, and returnExample properties for all OneBot action classes in the napcat-onebot package. This improves API documentation and discoverability by providing concise summaries, categorization tags, and usage examples for each action.
55 lines
2.4 KiB
TypeScript
55 lines
2.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';
|
|
|
|
const PayloadSchema = Type.Object({
|
|
message_id: Type.Union([Type.Number(), Type.String()], { description: '消息ID' }),
|
|
emojiId: Type.Union([Type.Number(), Type.String()], { description: '表情ID' }),
|
|
emojiType: Type.Union([Type.Number(), Type.String()], { description: '表情类型' }),
|
|
count: Type.Union([Type.Number(), Type.String()], { default: 20, description: '获取数量' }),
|
|
cookie: Type.String({ default: '', description: '分页Cookie' })
|
|
});
|
|
|
|
type PayloadType = Static<typeof PayloadSchema>;
|
|
|
|
const ReturnSchema = Type.Object({
|
|
emojiLikesList: Type.Array(Type.Object({
|
|
tinyId: Type.String({ description: 'TinyID' }),
|
|
nickName: Type.String({ description: '昵称' }),
|
|
headUrl: Type.String({ description: '头像URL' }),
|
|
}), { description: '表情回应列表' }),
|
|
cookie: Type.String({ description: '分页Cookie' }),
|
|
isLastPage: Type.Boolean({ description: '是否最后一页' }),
|
|
isFirstPage: Type.Boolean({ description: '是否第一页' }),
|
|
result: Type.Number({ description: '结果状态码' }),
|
|
errMsg: Type.String({ description: '错 误信息' }),
|
|
}, { description: '表情回应详情' });
|
|
|
|
type ReturnType = Static<typeof ReturnSchema>;
|
|
|
|
export class FetchEmojiLike extends OneBotAction<PayloadType, ReturnType> {
|
|
override actionName = ActionName.FetchEmojiLike;
|
|
override actionSummary = '获取表情点赞详情';
|
|
override actionTags = ['消息扩展'];
|
|
override payloadExample = {
|
|
message_id: 12345
|
|
};
|
|
override returnExample = {
|
|
likes: [{ emoji_id: '123', count: 10 }]
|
|
};
|
|
override payloadSchema = PayloadSchema;
|
|
override returnSchema = ReturnSchema;
|
|
|
|
async _handle (payload: PayloadType): Promise<ReturnType> {
|
|
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('消息不存在');
|
|
const res = await this.core.apis.MsgApi.getMsgEmojiLikesList(
|
|
msgIdPeer.Peer, msg.msgSeq, payload.emojiId.toString(), payload.emojiType.toString(), payload.cookie, +payload.count
|
|
);
|
|
return res;
|
|
}
|
|
}
|