mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-01-09 13:03:37 +08:00
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
import { MessageUnique } from 'napcat-common/src/message-unique';
|
|
import { ChatType, Peer } from 'napcat-core';
|
|
import { GetPacketStatusDepends } from '@/napcat-onebot/action/packet/GetPacketStatus';
|
|
import { Static, Type } from '@sinclair/typebox';
|
|
import { ActionName } from '../router';
|
|
|
|
const SchemaData = Type.Object({
|
|
group_id: Type.String(),
|
|
message_id: Type.String(),
|
|
message_seq: Type.Optional(Type.String()),
|
|
});
|
|
|
|
type Payload = Static<typeof SchemaData>;
|
|
export class SetGroupTodo extends GetPacketStatusDepends<Payload, void> {
|
|
override payloadSchema = SchemaData;
|
|
override actionName = ActionName.SetGroupTodo;
|
|
async _handle (payload: Payload) {
|
|
if (payload.message_seq) {
|
|
return await this.core.apis.PacketApi.pkt.operation.SetGroupTodo(+payload.group_id, payload.message_seq);
|
|
}
|
|
const peer: Peer = {
|
|
chatType: ChatType.KCHATTYPEGROUP,
|
|
peerUid: payload.group_id,
|
|
};
|
|
const { MsgId, Peer } = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id) ?? { Peer: peer, MsgId: payload.message_id };
|
|
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(Peer, [MsgId])).msgList[0];
|
|
if (!msg) throw new Error('消息不存在');
|
|
await this.core.apis.PacketApi.pkt.operation.SetGroupTodo(+payload.group_id, msg.msgSeq);
|
|
}
|
|
}
|