diff --git a/src/common/audio.ts b/src/common/audio.ts index b45e7240..4dd82afd 100644 --- a/src/common/audio.ts +++ b/src/common/audio.ts @@ -1,4 +1,3 @@ -import fs from 'fs'; import fsPromise from 'fs/promises'; import path from 'node:path'; import { randomUUID } from 'crypto'; @@ -12,7 +11,7 @@ const FFMPEG_PATH = process.env.FFMPEG_PATH || 'ffmpeg'; async function guessDuration(pttPath: string, logger: LogWrapper) { const pttFileInfo = await fsPromise.stat(pttPath); - let duration = Math.max(1, Math.floor(pttFileInfo.size / 1024 / 3)); // 3kb/s + const duration = Math.max(1, Math.floor(pttFileInfo.size / 1024 / 3)); // 3kb/s logger.log('通过文件大小估算语音的时长:', duration); return duration; } @@ -20,7 +19,7 @@ async function guessDuration(pttPath: string, logger: LogWrapper) { async function convert(filePath: string, pcmPath: string, logger: LogWrapper): Promise { return new Promise((resolve, reject) => { const cp = spawn(FFMPEG_PATH, ['-y', '-i', filePath, '-ar', '24000', '-ac', '1', '-f', 's16le', pcmPath]); - cp.on('error', err => { + cp.on('error', (err: Error) => { logger.log('FFmpeg处理转换出错: ', err.message); reject(err); }); diff --git a/src/common/file.ts b/src/common/file.ts index e93b1932..502648aa 100644 --- a/src/common/file.ts +++ b/src/common/file.ts @@ -242,7 +242,6 @@ export async function uri2local(dir: string, uri: string, filename: string | und const filenameTemp = tempName + fileExt; const filePath = path.join(dir, filenameTemp); fs.copyFileSync(HandledUri, filePath); - //console.log('复制文件到临时文件', HandledUri, filePath); return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath }; } //接下来都要有文件名 @@ -250,7 +249,7 @@ export async function uri2local(dir: string, uri: string, filename: string | und if (UriType == FileUriType.Remote) { const pathInfo = path.parse(decodeURIComponent(new URL(HandledUri).pathname)); if (pathInfo.name) { - let pathlen = 200 - dir.length - pathInfo.name.length; + const pathlen = 200 - dir.length - pathInfo.name.length; filename = pathlen > 0 ? pathInfo.name.substring(0, pathlen) : pathInfo.name.substring(pathInfo.name.length, pathInfo.name.length - 10);//过长截断 if (pathInfo.ext) { filename += pathInfo.ext; @@ -260,7 +259,6 @@ export async function uri2local(dir: string, uri: string, filename: string | und const fileExt = path.extname(HandledUri).replace(/[/\\:*?"<>|]/g, '_').substring(0, 10); const filePath = path.join(dir, tempName + fileExt); const buffer = await httpDownload(HandledUri); - //fs.writeFileSync(filePath, buffer); //没有文件就创建 fs.writeFileSync(filePath, buffer, { flag: 'wx' }); return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath }; diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 8384eb9c..1d1d2e9d 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -32,10 +32,6 @@ export class NTQQGroupApi { for (const group of this.groups) { this.groupCache.set(group.groupCode, group); } - // let text = await this.context.session.getMsgService().sendSsoCmdReqByContend( - // 'LightAppSvc.mini_app_share.AdaptShareInfo', - // JSON.stringify({ data: 'test' })); - // console.log(text); this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`); } diff --git a/src/core/index.ts b/src/core/index.ts index c5be4abd..cf6667b2 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -145,7 +145,6 @@ export class NapCatCore { if (Info.status == 20) { this.selfInfo.online = false; this.context.logger.log("账号状态变更为离线"); - return; } else { this.selfInfo.online = true; } diff --git a/src/onebot/action/go-cqhttp/SendGroupNotice.ts b/src/onebot/action/go-cqhttp/SendGroupNotice.ts index a4b5f7ee..55fa973c 100644 --- a/src/onebot/action/go-cqhttp/SendGroupNotice.ts +++ b/src/onebot/action/go-cqhttp/SendGroupNotice.ts @@ -57,7 +57,6 @@ export class SendGroupNotice extends BaseAction { const noticeShowEditCard = +(payload.is_show_edit_card ?? 0); const noticeTipWindowType = +(payload.tip_window_type ?? 0); const noticeConfirmRequired = +(payload.confirm_required ?? 1); - //const publishGroupBulletinResult = await this.core.apis.GroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, noticePinned, noticeConfirmRequired); const publishGroupBulletinResult = await this.core.apis.WebApi.setGroupNotice( payload.group_id.toString(), payload.content, @@ -71,7 +70,7 @@ export class SendGroupNotice extends BaseAction { UploadImage?.height ); if (!publishGroupBulletinResult || publishGroupBulletinResult.ec != 0) { - throw `设置群公告失败,错误信息:${publishGroupBulletinResult?.em}`; + throw new Error(`设置群公告失败,错误信息:${publishGroupBulletinResult?.em}`); } return null; }