mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-11 23:40:24 +00:00
refactor: 通过@实现定位
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
import { checkFileExist, uri2local } from '@/common/file';
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { unlink } from 'node:fs';
|
||||
@@ -39,7 +39,7 @@ export class SendGroupNotice extends OneBotAction<Payload, null> {
|
||||
if (!path) {
|
||||
throw new Error(`群公告${payload.image}设置失败,获取资源失败`);
|
||||
}
|
||||
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||
await checkFileExist(path, 5000);
|
||||
const ImageUploadResult = await this.core.apis.GroupApi.uploadGroupBulletinPic(payload.group_id.toString(), path);
|
||||
if (ImageUploadResult.errCode != 0) {
|
||||
throw new Error(`群公告${payload.image}设置失败,图片上传失败`);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { ActionName, BaseCheckResult } from '../router';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/router';
|
||||
import * as fs from 'node:fs';
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
import { checkFileExistV2, uri2local } from '@/common/file';
|
||||
|
||||
interface Payload {
|
||||
file: string,
|
||||
@@ -30,7 +30,7 @@ export default class SetGroupPortrait extends OneBotAction<Payload, any> {
|
||||
throw new Error(`头像${payload.file}设置失败,file字段可能格式不正确`);
|
||||
}
|
||||
if (path) {
|
||||
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||
await checkFileExistV2(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||
const ret = await this.core.apis.GroupApi.setGroupAvatar(payload.group_id.toString(), path);
|
||||
fs.unlink(path, () => { });
|
||||
if (!ret) {
|
||||
|
||||
Reference in New Issue
Block a user