mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-27 11:21:21 +08:00
31 lines
972 B
TypeScript
31 lines
972 B
TypeScript
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
|
import { ActionName } from '@/onebot/action/router';
|
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
import { MessageUnique } from '@/common/message-unique';
|
|
|
|
const SchemaData = {
|
|
type: 'object',
|
|
properties: {
|
|
message_id: { type: ['number', 'string'] },
|
|
},
|
|
required: ['message_id'],
|
|
} as const satisfies JSONSchema;
|
|
|
|
type Payload = FromSchema<typeof SchemaData>;
|
|
|
|
export default class SetEssenceMsg extends OneBotAction<Payload, any> {
|
|
actionName = ActionName.SetEssenceMsg;
|
|
payloadSchema = SchemaData;
|
|
|
|
async _handle(payload: Payload): Promise<any> {
|
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
|
if (!msg) {
|
|
throw new Error('msg not found');
|
|
}
|
|
return await this.core.apis.GroupApi.addGroupEssence(
|
|
msg.Peer.peerUid,
|
|
msg.MsgId,
|
|
);
|
|
}
|
|
}
|