feat: support essence

This commit is contained in:
手瓜一十雪 2024-07-20 16:09:44 +08:00
parent 3f7a85d80b
commit 557864395b
4 changed files with 65 additions and 3 deletions

View File

@ -10,12 +10,11 @@ QQ Version: Windows 9.9.12-26000 / Linux 3.2.9-26000
## 修复与优化
1. 尝试修复卡顿问题
2. 修复精华消息设置时的报错
2. 修复 精华消息设置/一起听 接受时的报错
## 新增与调整
1. 戳一戳上报raw
2. 精华消息设置通知事件
3. 新增设置/删除群精华API
4. 表情回应事件
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)

View 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
);
}
}

View 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
);
}
}

View File

@ -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"
}