refactor: make sendMsg(WithOb11UniqueId) an instance method

This commit is contained in:
Wesley F. Young
2024-08-26 09:33:23 +08:00
parent 04fb771f42
commit 3237ceeb48
5 changed files with 60 additions and 64 deletions

View File

@@ -2,7 +2,6 @@ import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { ChatType, Peer, SendFileElement } from '@/core/entities';
import fs from 'fs';
import { sendMsg } from '@/onebot/action/msg/SendMsg';
import { uri2local } from '@/common/utils/file';
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
@@ -37,7 +36,6 @@ export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null>
}
async _handle(payload: Payload): Promise<null> {
const peer = await this.getPeer(payload);
let file = payload.file;
if (fs.existsSync(file)) {
file = `file://${file}`;
@@ -47,7 +45,7 @@ export default class GoCQHTTPUploadPrivateFile extends BaseAction<Payload, null>
throw new Error(downloadResult.errMsg);
}
const sendFileEle: SendFileElement = await this.core.apis.FileApi.createValidSendFileElement(downloadResult.path, payload.name);
await sendMsg(this.core, peer, [sendFileEle], [], true);
await this.obContext.apiContext.MsgApi.sendMsgWithOb11UniqueId(await this.getPeer(payload), [sendFileEle], [], true);
return null;
}
}