mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
chore: run a full eslint
This commit is contained in:
@@ -10,11 +10,11 @@ const SchemaData = {
|
||||
message_id: {
|
||||
oneOf: [
|
||||
{ type: 'number' },
|
||||
{ type: 'string' }
|
||||
]
|
||||
}
|
||||
{ type: 'string' },
|
||||
],
|
||||
},
|
||||
},
|
||||
required: ['message_id']
|
||||
required: ['message_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
@@ -22,6 +22,7 @@ type Payload = FromSchema<typeof SchemaData>;
|
||||
class DeleteMsg extends BaseAction<Payload, void> {
|
||||
actionName = ActionName.DeleteMsg;
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
||||
@@ -36,8 +37,10 @@ class DeleteMsg extends BaseAction<Payload, void> {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
).catch(e => new Promise<undefined>((resolve, reject) => { resolve(undefined); }));
|
||||
},
|
||||
).catch(e => new Promise<undefined>((resolve, reject) => {
|
||||
resolve(undefined);
|
||||
}));
|
||||
await NTQQMsgApi.recallMsg(msg.Peer, [msg.MsgId]);
|
||||
const data = await ret;
|
||||
if (!data) {
|
||||
|
||||
@@ -9,9 +9,9 @@ const SchemaData = {
|
||||
properties: {
|
||||
message_id: { type: 'number' },
|
||||
group_id: { type: ['number', 'string'] },
|
||||
user_id: { type: ['number', 'string'] }
|
||||
user_id: { type: ['number', 'string'] },
|
||||
},
|
||||
required: ['message_id']
|
||||
required: ['message_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
@@ -13,7 +13,7 @@ const SchemaData = {
|
||||
properties: {
|
||||
message_id: { type: ['number', 'string'] },
|
||||
},
|
||||
required: ['message_id']
|
||||
required: ['message_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
@@ -21,6 +21,7 @@ type Payload = FromSchema<typeof SchemaData>;
|
||||
class GetMsg extends BaseAction<Payload, OB11Message> {
|
||||
actionName = ActionName.GetMsg;
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
// log("history msg ids", Object.keys(msgHistory));
|
||||
@@ -36,7 +37,7 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
||||
const msg = await NTQQMsgApi.getMsgsByMsgId(
|
||||
peer,
|
||||
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
||||
const retMsg = await OB11Constructor.message(this.CoreContext, msg.msgList[0], "array");
|
||||
const retMsg = await OB11Constructor.message(this.CoreContext, msg.msgList[0], 'array');
|
||||
try {
|
||||
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!;
|
||||
retMsg.message_seq = retMsg.message_id;
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQFriendApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
user_id: { type: ['number', 'string'] },
|
||||
group_id: { type: ['number', 'string'] }
|
||||
}
|
||||
group_id: { type: ['number', 'string'] },
|
||||
},
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type PlayloadType = FromSchema<typeof SchemaData>;
|
||||
@@ -31,6 +30,7 @@ class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
|
||||
}
|
||||
return { chatType: ChatType.group, peerUid: payload.group_id.toString() };
|
||||
}
|
||||
|
||||
protected async _handle(payload: PlayloadType): Promise<null> {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
// 调用API
|
||||
@@ -41,11 +41,13 @@ class MarkMsgAsRead extends BaseAction<PlayloadType, null> {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 以下为非标准实现
|
||||
export class MarkPrivateMsgAsRead extends MarkMsgAsRead {
|
||||
PayloadSchema = SchemaData;
|
||||
actionName = ActionName.MarkPrivateMsgAsRead;
|
||||
}
|
||||
|
||||
export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
||||
PayloadSchema = SchemaData;
|
||||
actionName = ActionName.MarkGroupMsgAsRead;
|
||||
@@ -53,7 +55,7 @@ export class MarkGroupMsgAsRead extends MarkMsgAsRead {
|
||||
|
||||
|
||||
interface Payload {
|
||||
message_id: number
|
||||
message_id: number;
|
||||
}
|
||||
|
||||
export class GoCQHTTPMarkMsgAsRead extends BaseAction<Payload, null> {
|
||||
|
||||
@@ -6,16 +6,23 @@ import { AtType, CustomMusicSignPostData, IdMusicSignPostData, NapCatCore, Peer,
|
||||
import { SendMsgElementConstructor } from '@/onebot/helper/msg';
|
||||
|
||||
export type MessageContext = {
|
||||
deleteAfterSentFiles: string[],
|
||||
peer: Peer
|
||||
deleteAfterSentFiles: string[],
|
||||
peer: Peer
|
||||
}
|
||||
|
||||
async function handleOb11FileLikeMessage(
|
||||
coreContext: NapCatCore,
|
||||
{ data: inputdata }: OB11MessageFileBase,
|
||||
{ deleteAfterSentFiles }: MessageContext
|
||||
{ deleteAfterSentFiles }: MessageContext,
|
||||
) {
|
||||
//有的奇怪的框架将url作为参数 而不是file 此时优先url 同时注意可能传入的是非file://开头的目录 By Mlikiowa
|
||||
const { path, isLocal, fileName, errMsg, success } = (await uri2local(coreContext.NapCatTempPath, inputdata?.url || inputdata.file));
|
||||
const {
|
||||
path,
|
||||
isLocal,
|
||||
fileName,
|
||||
errMsg,
|
||||
success,
|
||||
} = (await uri2local(coreContext.NapCatTempPath, inputdata?.url || inputdata.file));
|
||||
|
||||
if (!success) {
|
||||
coreContext.context.logger.logError('文件下载失败', errMsg);
|
||||
@@ -30,13 +37,13 @@ async function handleOb11FileLikeMessage(
|
||||
}
|
||||
|
||||
const _handlers: {
|
||||
[Key in OB11MessageDataType]: (
|
||||
CoreContext: NapCatCore,
|
||||
sendMsg: Extract<OB11MessageData, { type: Key }>,
|
||||
// This picks the correct message type out
|
||||
// How great the type system of TypeScript is!
|
||||
context: MessageContext
|
||||
) => Promise<SendMessageElement | undefined>
|
||||
[Key in OB11MessageDataType]: (
|
||||
CoreContext: NapCatCore,
|
||||
sendMsg: Extract<OB11MessageData, { type: Key }>,
|
||||
// This picks the correct message type out
|
||||
// How great the type system of TypeScript is!
|
||||
context: MessageContext,
|
||||
) => Promise<SendMessageElement | undefined>
|
||||
} = {
|
||||
[OB11MessageDataType.text]: async (coreContext, { data: { text } }) => SendMsgElementConstructor.text(coreContext, text),
|
||||
|
||||
@@ -49,7 +56,7 @@ const _handlers: {
|
||||
// Mlikiowa V2.0.0 Refactor Todo
|
||||
const uid = await coreContext.getApiContext().UserApi.getUidByUin(atQQ);
|
||||
if (!uid) throw new Error('Get Uid Error');
|
||||
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, "");
|
||||
return SendMsgElementConstructor.at(coreContext, atQQ, uid, AtType.atUser, '');
|
||||
},
|
||||
[OB11MessageDataType.reply]: async (coreContext, { data: { id } }) => {
|
||||
const replyMsgM = MessageUnique.getMsgIdAndPeerByShortId(parseInt(id));
|
||||
@@ -69,8 +76,8 @@ const _handlers: {
|
||||
|
||||
[OB11MessageDataType.mface]: async (coreContext, {
|
||||
data: {
|
||||
emoji_package_id, emoji_id, key, summary
|
||||
}
|
||||
emoji_package_id, emoji_id, key, summary,
|
||||
},
|
||||
}) => SendMsgElementConstructor.mface(coreContext, emoji_package_id, emoji_id, key, summary),
|
||||
|
||||
// File service
|
||||
@@ -79,7 +86,7 @@ const _handlers: {
|
||||
coreContext,
|
||||
(await handleOb11FileLikeMessage(coreContext, sendMsg, context)).path,
|
||||
sendMsg.data.summary || '',
|
||||
sendMsg.data.subType || 0
|
||||
sendMsg.data.subType || 0,
|
||||
);
|
||||
context.deleteAfterSentFiles.push(PicEle.picElement.sourcePath);
|
||||
return PicEle;
|
||||
@@ -119,7 +126,7 @@ const _handlers: {
|
||||
[OB11MessageDataType.markdown]: async (coreContext, { data: { content } }) => SendMsgElementConstructor.markdown(coreContext, content),
|
||||
|
||||
[OB11MessageDataType.music]: async (coreContext, { data }) => {
|
||||
// 保留, 直到...找到更好的解决方案
|
||||
// 保留, 直到...找到更好的解决方案
|
||||
if (data.type === 'custom') {
|
||||
if (!data.url) {
|
||||
coreContext.context.logger.logError('自定义音卡缺少参数url');
|
||||
@@ -152,7 +159,7 @@ const _handlers: {
|
||||
postData = data;
|
||||
}
|
||||
// Mlikiowa V2.0.0 Refactor Todo
|
||||
const signUrl = "";
|
||||
const signUrl = '';
|
||||
if (!signUrl) {
|
||||
if (data.type === 'qq') {
|
||||
//const musicJson = (await SignMusicWrapper(data.id.toString())).data.arkResult.slice(0, -1);
|
||||
@@ -179,24 +186,24 @@ const _handlers: {
|
||||
[OB11MessageDataType.Location]: async (coreContext) => {
|
||||
return SendMsgElementConstructor.location(coreContext);
|
||||
},
|
||||
[OB11MessageDataType.miniapp]: function (CoreContext: NapCatCore, sendMsg: never, context: MessageContext): Promise<SendMessageElement | undefined> {
|
||||
[OB11MessageDataType.miniapp]: function(CoreContext: NapCatCore, sendMsg: never, context: MessageContext): Promise<SendMessageElement | undefined> {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const handlers = <{
|
||||
[Key in OB11MessageDataType]: (
|
||||
coreContext: NapCatCore,
|
||||
sendMsg: OB11MessageData,
|
||||
context: MessageContext
|
||||
) => Promise<SendMessageElement | undefined>
|
||||
[Key in OB11MessageDataType]: (
|
||||
coreContext: NapCatCore,
|
||||
sendMsg: OB11MessageData,
|
||||
context: MessageContext,
|
||||
) => Promise<SendMessageElement | undefined>
|
||||
}>_handlers;
|
||||
|
||||
export default async function createSendElements(
|
||||
CoreContext: NapCatCore,
|
||||
messageData: OB11MessageData[],
|
||||
peer: Peer,
|
||||
ignoreTypes: OB11MessageDataType[] = []
|
||||
ignoreTypes: OB11MessageDataType[] = [],
|
||||
) {
|
||||
const deleteAfterSentFiles: string[] = [];
|
||||
const callResultList: Array<Promise<SendMessageElement | undefined>> = [];
|
||||
@@ -207,7 +214,7 @@ export default async function createSendElements(
|
||||
const callResult = handlers[sendMsg.type](
|
||||
CoreContext,
|
||||
sendMsg,
|
||||
{ peer, deleteAfterSentFiles }
|
||||
{ peer, deleteAfterSentFiles },
|
||||
)?.catch(undefined);
|
||||
callResultList.push(callResult);
|
||||
}
|
||||
@@ -220,19 +227,19 @@ export async function createSendElementsParallel(
|
||||
CoreContext: NapCatCore,
|
||||
messageData: OB11MessageData[],
|
||||
peer: Peer,
|
||||
ignoreTypes: OB11MessageDataType[] = []
|
||||
ignoreTypes: OB11MessageDataType[] = [],
|
||||
) {
|
||||
const deleteAfterSentFiles: string[] = [];
|
||||
const sendElements = <SendMessageElement[]>(
|
||||
await Promise.all(
|
||||
messageData.map(async sendMsg => ignoreTypes.includes(sendMsg.type) ?
|
||||
undefined :
|
||||
handlers[sendMsg.type](CoreContext, sendMsg, { peer, deleteAfterSentFiles }))
|
||||
).then(
|
||||
results => results.filter(
|
||||
element => element !== undefined
|
||||
await Promise.all(
|
||||
messageData.map(async sendMsg => ignoreTypes.includes(sendMsg.type) ?
|
||||
undefined :
|
||||
handlers[sendMsg.type](CoreContext, sendMsg, { peer, deleteAfterSentFiles })),
|
||||
).then(
|
||||
results => results.filter(
|
||||
element => element !== undefined,
|
||||
),
|
||||
)
|
||||
)
|
||||
);
|
||||
);
|
||||
return { sendElements, deleteAfterSentFiles };
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendMessageElement
|
||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||
import { OB11MessageDataType, OB11MessageNode } from '@/onebot/types';
|
||||
import createSendElements from './create-send-elements';
|
||||
import { normalize, sendMsg } from "../SendMsg/index";
|
||||
import { normalize, sendMsg } from '../SendMsg/index';
|
||||
|
||||
async function cloneMsg(coreContext: NapCatCore, msg: RawMessage): Promise<RawMessage | undefined> {
|
||||
const selfPeer = {
|
||||
chatType: ChatType.friend,
|
||||
peerUid: coreContext.selfInfo.uid
|
||||
peerUid: coreContext.selfInfo.uid,
|
||||
};
|
||||
const logger = coreContext.context.logger;
|
||||
const NTQQMsgApi = coreContext.getApiContext().MsgApi;
|
||||
@@ -33,7 +34,7 @@ export async function handleForwardNode(coreContext: NapCatCore, destPeer: Peer,
|
||||
const NTQQMsgApi = coreContext.getApiContext().MsgApi;
|
||||
const selfPeer = {
|
||||
chatType: ChatType.friend,
|
||||
peerUid: coreContext.selfInfo.uid
|
||||
peerUid: coreContext.selfInfo.uid,
|
||||
};
|
||||
let nodeMsgIds: string[] = [];
|
||||
const logger = coreContext.context.logger;
|
||||
@@ -54,20 +55,28 @@ export async function handleForwardNode(coreContext: NapCatCore, destPeer: Peer,
|
||||
//筛选node消息
|
||||
const isNodeMsg = OB11Data.filter(e => e.type === OB11MessageDataType.node).length;//找到子转发消息
|
||||
if (isNodeMsg !== 0) {
|
||||
if (isNodeMsg !== OB11Data.length) { logger.logError('子消息中包含非node消息 跳过不合法部分'); continue; }
|
||||
if (isNodeMsg !== OB11Data.length) {
|
||||
logger.logError('子消息中包含非node消息 跳过不合法部分');
|
||||
continue;
|
||||
}
|
||||
const nodeMsg = await handleForwardNode(coreContext, selfPeer, OB11Data.filter(e => e.type === OB11MessageDataType.node));
|
||||
if (nodeMsg) { nodeMsgIds.push(nodeMsg.msgId); MessageUnique.createMsg(selfPeer, nodeMsg.msgId); }
|
||||
if (nodeMsg) {
|
||||
nodeMsgIds.push(nodeMsg.msgId);
|
||||
MessageUnique.createMsg(selfPeer, nodeMsg.msgId);
|
||||
}
|
||||
//完成子卡片生成跳过后续
|
||||
continue;
|
||||
}
|
||||
const { sendElements } = await createSendElements(coreContext,OB11Data, destPeer);
|
||||
const { sendElements } = await createSendElements(coreContext, OB11Data, destPeer);
|
||||
//拆分消息
|
||||
const MixElement = sendElements.filter(element => element.elementType !== ElementType.FILE && element.elementType !== ElementType.VIDEO);
|
||||
const SingleElement = sendElements.filter(element => element.elementType === ElementType.FILE || element.elementType === ElementType.VIDEO).map(e => [e]);
|
||||
const AllElement: SendMessageElement[][] = [MixElement, ...SingleElement].filter(e => e !== undefined && e.length !== 0);
|
||||
const MsgNodeList: Promise<RawMessage | undefined>[] = [];
|
||||
for (const sendElementsSplitElement of AllElement) {
|
||||
MsgNodeList.push(sendMsg(coreContext,selfPeer, sendElementsSplitElement, [], true).catch(e => new Promise((resolve, reject) => { resolve(undefined); })));
|
||||
MsgNodeList.push(sendMsg(coreContext, selfPeer, sendElementsSplitElement, [], true).catch(e => new Promise((resolve, reject) => {
|
||||
resolve(undefined);
|
||||
})));
|
||||
}
|
||||
(await Promise.allSettled(MsgNodeList)).map((result) => {
|
||||
if (result.status === 'fulfilled' && result.value) {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
|
||||
import {
|
||||
OB11MessageData,
|
||||
OB11MessageDataType,
|
||||
OB11MessageMixType,
|
||||
OB11MessageNode,
|
||||
OB11PostSendMsg
|
||||
OB11PostSendMsg,
|
||||
} from '@/onebot/types';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/types';
|
||||
import fs from 'node:fs';
|
||||
@@ -17,13 +16,15 @@ import BaseAction from '../../BaseAction';
|
||||
import { handleForwardNode } from './handle-forward-node';
|
||||
|
||||
export interface ReturnDataType {
|
||||
message_id: number;
|
||||
message_id: number;
|
||||
}
|
||||
|
||||
export enum ContextMode {
|
||||
Normal = 0,
|
||||
Private = 1,
|
||||
Group = 2
|
||||
Normal = 0,
|
||||
Private = 1,
|
||||
Group = 2
|
||||
}
|
||||
|
||||
// Normalizes a mixed type (CQCode/a single segment/segment array) into a segment array.
|
||||
export function normalize(message: OB11MessageMixType, autoEscape = false): OB11MessageData[] {
|
||||
return typeof message === 'string' ? (
|
||||
@@ -68,12 +69,18 @@ export async function sendMsg(coreContext: NapCatCore, peer: Peer, sendElements:
|
||||
}
|
||||
const returnMsg = await NTQQMsgApi.sendMsg(peer, sendElements, waitComplete, timeout);
|
||||
try {
|
||||
returnMsg!.id = MessageUnique.createMsg({ chatType: peer.chatType, guildId: '', peerUid: peer.peerUid }, returnMsg!.msgId);
|
||||
returnMsg!.id = MessageUnique.createMsg({
|
||||
chatType: peer.chatType,
|
||||
guildId: '',
|
||||
peerUid: peer.peerUid,
|
||||
}, returnMsg!.msgId);
|
||||
} catch (e: any) {
|
||||
logger.logDebug('发送消息id获取失败', e);
|
||||
returnMsg!.id = 0;
|
||||
returnMsg!.id = 0;
|
||||
}
|
||||
deleteAfterSentFiles.map((f) => { fsPromise.unlink(f).then().catch(e => logger.logError('发送消息删除文件失败', e)); });
|
||||
deleteAfterSentFiles.map((f) => {
|
||||
fsPromise.unlink(f).then().catch(e => logger.logError('发送消息删除文件失败', e));
|
||||
});
|
||||
return returnMsg;
|
||||
}
|
||||
|
||||
@@ -88,7 +95,7 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
|
||||
const group = (await NTQQGroupApi.getGroups()).find(e => e.groupCode == payload.group_id?.toString());
|
||||
return {
|
||||
chatType: ChatType.group,
|
||||
peerUid: payload.group_id.toString()
|
||||
peerUid: payload.group_id.toString(),
|
||||
};
|
||||
}
|
||||
if ((contextMode === ContextMode.Private || contextMode === ContextMode.Normal) && payload.user_id) {
|
||||
@@ -97,7 +104,7 @@ async function createContext(coreContext: NapCatCore, payload: OB11PostSendMsg,
|
||||
//console.log("[调试代码] UIN:", payload.user_id, " UID:", Uid, " IsBuddy:", isBuddy);
|
||||
return {
|
||||
chatType: isBuddy ? ChatType.friend : ChatType.temp,
|
||||
peerUid: Uid!
|
||||
peerUid: Uid!,
|
||||
};
|
||||
}
|
||||
throw '请指定 group_id 或 user_id';
|
||||
@@ -121,7 +128,10 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
const messages = normalize(payload.message);
|
||||
const nodeElementLength = getSpecialMsgNum(payload, OB11MessageDataType.node);
|
||||
if (nodeElementLength > 0 && nodeElementLength != messages.length) {
|
||||
return { valid: false, message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素' };
|
||||
return {
|
||||
valid: false,
|
||||
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
||||
};
|
||||
}
|
||||
// if (payload.message_type !== 'private' && payload.group_id && !(await getGroup(payload.group_id))) {
|
||||
// return { valid: false, message: `群${payload.group_id}不存在` };
|
||||
@@ -142,13 +152,17 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
|
||||
const messages = normalize(
|
||||
payload.message,
|
||||
payload.auto_escape === true || payload.auto_escape === 'true'
|
||||
payload.auto_escape === true || payload.auto_escape === 'true',
|
||||
);
|
||||
|
||||
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
const returnMsg = await handleForwardNode(this.CoreContext,peer, messages as OB11MessageNode[]);
|
||||
const returnMsg = await handleForwardNode(this.CoreContext, peer, messages as OB11MessageNode[]);
|
||||
if (returnMsg) {
|
||||
const msgShortId = MessageUnique.createMsg({ guildId: '', peerUid: peer.peerUid, chatType: peer.chatType }, returnMsg!.msgId);
|
||||
const msgShortId = MessageUnique.createMsg({
|
||||
guildId: '',
|
||||
peerUid: peer.peerUid,
|
||||
chatType: peer.chatType,
|
||||
}, returnMsg!.msgId);
|
||||
return { message_id: msgShortId! };
|
||||
} else {
|
||||
throw Error('发送转发消息失败');
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import SendMsg, { ContextMode } from './SendMsg';
|
||||
import { ActionName, BaseCheckResult } from '../types';
|
||||
import { OB11PostSendMsg } from '../../types';
|
||||
|
||||
// 未检测参数
|
||||
class SendPrivateMsg extends SendMsg {
|
||||
actionName = ActionName.SendPrivateMsg;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ActionName } from '../types';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { NTQQMsgApi } from '@/core/apis';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||
|
||||
@@ -8,9 +7,9 @@ const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
message_id: { type: ['string', 'number'] },
|
||||
emoji_id: { type: ['string', 'number'] }
|
||||
emoji_id: { type: ['string', 'number'] },
|
||||
},
|
||||
required: ['message_id', 'emoji_id']
|
||||
required: ['message_id', 'emoji_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
@@ -18,6 +17,7 @@ type Payload = FromSchema<typeof SchemaData>;
|
||||
export class SetMsgEmojiLike extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.SetMsgEmojiLike;
|
||||
PayloadSchema = SchemaData;
|
||||
|
||||
protected async _handle(payload: Payload) {
|
||||
const NTQQMsgApi = this.CoreContext.getApiContext().MsgApi;
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
||||
|
||||
Reference in New Issue
Block a user