mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-20 05:30:06 +08:00
feat: 取消群精华接口支持传递原始参数
- 1. onebot v11标准: 传递message_id - 2. 通过官方http接口获取到的group_id、msg_random、msg_seq 二者任选其一
This commit is contained in:
parent
32e886e53b
commit
98ef642cd1
@ -4,7 +4,10 @@ import { MessageUnique } from '@/common/message-unique';
|
|||||||
import { Static, Type } from '@sinclair/typebox';
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
message_id: Type.Union([Type.Number(), Type.String()]),
|
message_id: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
||||||
|
msg_seq: Type.Optional(Type.String()),
|
||||||
|
msg_random: Type.Optional(Type.String()),
|
||||||
|
group_id: Type.Optional(Type.String()),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
@ -13,6 +16,20 @@ export default class DelEssenceMsg extends OneBotAction<Payload, unknown> {
|
|||||||
override payloadSchema = SchemaData;
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<unknown> {
|
async _handle(payload: Payload): Promise<unknown> {
|
||||||
|
// 如果直接提供了 msg_seq, msg_random, group_id,优先使用
|
||||||
|
if (payload.msg_seq && payload.msg_random && payload.group_id) {
|
||||||
|
return await this.core.apis.GroupApi.removeGroupEssenceBySeq(
|
||||||
|
payload.group_id,
|
||||||
|
payload.msg_random,
|
||||||
|
payload.msg_seq,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有 message_id,则必须提供 msg_seq, msg_random, group_id
|
||||||
|
if (!payload.message_id) {
|
||||||
|
throw new Error('必须提供 message_id 或者同时提供 msg_seq, msg_random, group_id');
|
||||||
|
}
|
||||||
|
|
||||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
const data = this.core.apis.GroupApi.essenceLRU.getValue(+payload.message_id);
|
const data = this.core.apis.GroupApi.essenceLRU.getValue(+payload.message_id);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user