mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
feat: support essence
This commit is contained in:
31
src/onebot11/action/group/DelEssenceMsg.ts
Normal file
31
src/onebot11/action/group/DelEssenceMsg.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { NTQQGroupApi } from '@/core';
|
||||
|
||||
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 DelEssenceMsg extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.DelEssenceMsg;
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
const msg = await dbUtil.getMsgByShortId(parseInt(payload.message_id.toString()));
|
||||
if (!msg) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
return await NTQQGroupApi.removeGroupEssence(
|
||||
msg.peerUin,
|
||||
msg.msgId
|
||||
);
|
||||
}
|
||||
}
|
||||
30
src/onebot11/action/group/SetEssenceMsg.ts
Normal file
30
src/onebot11/action/group/SetEssenceMsg.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { dbUtil } from '@/common/utils/db';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { NTQQGroupApi, NTQQMsgApi } from '@/core';
|
||||
|
||||
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 BaseAction<Payload, any> {
|
||||
actionName = ActionName.SetEssenceMsg;
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload): Promise<any> {
|
||||
const msg = await dbUtil.getMsgByShortId(parseInt(payload.message_id.toString()));
|
||||
if (!msg) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
return await NTQQGroupApi.addGroupEssence(
|
||||
msg.peerUin,
|
||||
msg.msgId
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -93,5 +93,7 @@ export enum ActionName {
|
||||
SetSelfProfile = 'set_self_profile',
|
||||
CreateCollection = 'create_collection',
|
||||
GetCollectionList = 'get_collection_list',
|
||||
SetLongNick = 'set_self_longnick'
|
||||
SetLongNick = 'set_self_longnick',
|
||||
SetEssenceMsg = "set_essence_msg",
|
||||
DelEssenceMsg = "delete_essence_msg"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user