From e431471c4cf3da54828ff6c2fdafec59d2e40648 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 2 Oct 2025 01:48:08 +0000 Subject: [PATCH] Revert formatting-only changes, keep only bug fixes Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com> --- package-lock.json | 4 +- src/common/download-ffmpeg.ts | 22 +++---- src/common/file.ts | 40 ++++++------- src/common/performance-monitor.ts | 22 +++---- src/common/worker.ts | 2 +- src/core/apis/file.ts | 18 +++--- src/core/apis/friend.ts | 2 +- src/core/apis/group.ts | 4 +- src/core/apis/webapi.ts | 34 +++++------ src/core/data/album.ts | 20 +++---- src/core/data/group.ts | 58 +++++++++---------- src/core/data/index.ts | 2 +- src/core/data/webapi.ts | 30 +++++----- src/core/packet/client/nativeClient.ts | 2 +- src/core/packet/context/operationContext.ts | 10 ++-- .../transformer/proto/oidb/Oidb.0xf90_1.ts | 2 +- src/core/services/NodeIKernelAlbumService.ts | 2 +- src/example-plugin/index.ts | 14 ++--- .../extends/ClickInlineKeyboardButton.ts | 2 +- .../action/extends/GetGroupAlbumMediaList.ts | 2 +- .../extends/GetUnidirectionalFriendList.ts | 2 +- src/onebot/action/msg/GetMsg.ts | 2 +- src/onebot/action/msg/SendMsg.ts | 2 +- src/onebot/action/packet/GetRkeyEx.ts | 2 +- src/onebot/action/packet/GetRkeyServer.ts | 2 +- src/onebot/action/packet/SendPoke.ts | 4 +- src/onebot/action/router.ts | 2 +- .../action/stream/DownloadFileStream.ts | 2 +- src/onebot/action/stream/StreamBasic.ts | 4 +- src/onebot/action/stream/UploadFileStream.ts | 2 +- src/onebot/api/msg.ts | 44 +++++++------- src/onebot/network/http-server.ts | 4 +- src/onebot/network/plugin-manger.ts | 2 +- src/onebot/network/plugin.ts | 2 +- src/shell/base.ts | 4 +- 35 files changed, 186 insertions(+), 186 deletions(-) diff --git a/package-lock.json b/package-lock.json index 48182ffb..39c76197 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "napcat", - "version": "4.8.116", + "version": "4.8.98", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "napcat", - "version": "4.8.116", + "version": "4.8.98", "dependencies": { "express": "^5.0.0", "silk-wasm": "^3.6.1", diff --git a/src/common/download-ffmpeg.ts b/src/common/download-ffmpeg.ts index 4c4dff63..734c5e85 100644 --- a/src/common/download-ffmpeg.ts +++ b/src/common/download-ffmpeg.ts @@ -8,16 +8,16 @@ import { pipeline } from 'stream/promises'; import { fileURLToPath } from 'url'; import { LogWrapper } from './log'; -const downloadOri = 'https://github.com/NapNeko/ffmpeg-build/releases/download/v1.0.0/ffmpeg-7.1.1-win64.zip'; +const downloadOri = "https://github.com/NapNeko/ffmpeg-build/releases/download/v1.0.0/ffmpeg-7.1.1-win64.zip" const urls = [ - 'https://j.1win.ggff.net/' + downloadOri, - 'https://git.yylx.win/' + downloadOri, - 'https://ghfile.geekertao.top/' + downloadOri, - 'https://gh-proxy.net/' + downloadOri, - 'https://ghm.078465.xyz/' + downloadOri, - 'https://gitproxy.127731.xyz/' + downloadOri, - 'https://jiashu.1win.eu.org/' + downloadOri, - 'https://github.tbedu.top/' + downloadOri, + "https://j.1win.ggff.net/" + downloadOri, + "https://git.yylx.win/" + downloadOri, + "https://ghfile.geekertao.top/" + downloadOri, + "https://gh-proxy.net/" + downloadOri, + "https://ghm.078465.xyz/" + downloadOri, + "https://gitproxy.127731.xyz/" + downloadOri, + "https://jiashu.1win.eu.org/" + downloadOri, + "https://github.tbedu.top/" + downloadOri, downloadOri ]; @@ -354,11 +354,11 @@ export async function downloadFFmpegIfNotExists(log: LogWrapper) { return { path: path.join(currentPath, 'ffmpeg'), reset: true - }; + } } return { path: path.join(currentPath, 'ffmpeg'), reset: true - }; + } } \ No newline at end of file diff --git a/src/common/file.ts b/src/common/file.ts index f2ef8795..b62ad7b0 100644 --- a/src/common/file.ts +++ b/src/common/file.ts @@ -182,28 +182,28 @@ export async function uriToLocalFile(dir: string, uri: string, filename: string const filePath = path.join(dir, filename); switch (UriType) { - case FileUriType.Local: { - const fileExt = path.extname(HandledUri); - const localFileName = path.basename(HandledUri, fileExt) + fileExt; - const tempFilePath = path.join(dir, filename + fileExt); - fs.copyFileSync(HandledUri, tempFilePath); - return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath }; - } + case FileUriType.Local: { + const fileExt = path.extname(HandledUri); + const localFileName = path.basename(HandledUri, fileExt) + fileExt; + const tempFilePath = path.join(dir, filename + fileExt); + fs.copyFileSync(HandledUri, tempFilePath); + return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath }; + } - case FileUriType.Remote: { - const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} }); - fs.writeFileSync(filePath, buffer); - return { success: true, errMsg: '', fileName: filename, path: filePath }; - } + case FileUriType.Remote: { + const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} }); + fs.writeFileSync(filePath, buffer); + return { success: true, errMsg: '', fileName: filename, path: filePath }; + } - case FileUriType.Base64: { - const base64 = HandledUri.replace(/^base64:\/\//, ''); - const base64Buffer = Buffer.from(base64, 'base64'); - fs.writeFileSync(filePath, base64Buffer); - return { success: true, errMsg: '', fileName: filename, path: filePath }; - } + case FileUriType.Base64: { + const base64 = HandledUri.replace(/^base64:\/\//, ''); + const base64Buffer = Buffer.from(base64, 'base64'); + fs.writeFileSync(filePath, base64Buffer); + return { success: true, errMsg: '', fileName: filename, path: filePath }; + } - default: - return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' }; + default: + return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' }; } } diff --git a/src/common/performance-monitor.ts b/src/common/performance-monitor.ts index 5fbb23c6..7d818033 100644 --- a/src/common/performance-monitor.ts +++ b/src/common/performance-monitor.ts @@ -108,13 +108,13 @@ export class PerformanceMonitor { const totalTime = Array.from(this.stats.values()).reduce((sum, stat) => sum + stat.totalTime, 0); let logContent = ''; - logContent += '=== 性能监控详细报告 ===\n'; + logContent += `=== 性能监控详细报告 ===\n`; logContent += `生成时间: ${now.toLocaleString()}\n`; - logContent += '统计周期: 60秒\n'; + logContent += `统计周期: 60秒\n`; logContent += `总览: ${totalFunctions} 个函数, ${totalCalls} 次调用, 总耗时: ${totalTime.toFixed(2)}ms\n\n`; // 详细函数统计 - logContent += '=== 所有函数详细统计 ===\n'; + logContent += `=== 所有函数详细统计 ===\n`; const allStats = this.getStats().sort((a, b) => b.totalTime - a.totalTime); allStats.forEach((stat, index) => { @@ -127,26 +127,26 @@ export class PerformanceMonitor { logContent += ` 最小耗时: ${stat.minTime === Infinity ? 'N/A' : stat.minTime.toFixed(4)}ms\n`; logContent += ` 最大耗时: ${stat.maxTime.toFixed(4)}ms\n`; logContent += ` 性能占比: ${((stat.totalTime / totalTime) * 100).toFixed(2)}%\n`; - logContent += '\n'; + logContent += `\n`; }); // 排行榜统计 - logContent += '=== 总耗时排行榜 (Top 20) ===\n'; + logContent += `=== 总耗时排行榜 (Top 20) ===\n`; this.getTopByTotalTime(20).forEach((stat, index) => { logContent += `${index + 1}. ${stat.name} - 总耗时: ${stat.totalTime.toFixed(2)}ms, 调用: ${stat.callCount}次, 平均: ${stat.averageTime.toFixed(2)}ms\n`; }); - logContent += '\n=== 调用次数排行榜 (Top 20) ===\n'; + logContent += `\n=== 调用次数排行榜 (Top 20) ===\n`; this.getTopByCallCount(20).forEach((stat, index) => { logContent += `${index + 1}. ${stat.name} - 调用: ${stat.callCount}次, 总耗时: ${stat.totalTime.toFixed(2)}ms, 平均: ${stat.averageTime.toFixed(2)}ms\n`; }); - logContent += '\n=== 平均耗时排行榜 (Top 20) ===\n'; + logContent += `\n=== 平均耗时排行榜 (Top 20) ===\n`; this.getTopByAverageTime(20).forEach((stat, index) => { logContent += `${index + 1}. ${stat.name} - 平均: ${stat.averageTime.toFixed(2)}ms, 调用: ${stat.callCount}次, 总耗时: ${stat.totalTime.toFixed(2)}ms\n`; }); - logContent += '\n=== 性能热点分析 ===\n'; + logContent += `\n=== 性能热点分析 ===\n`; // 找出最耗时的前10个函数 const hotSpots = this.getTopByTotalTime(10); hotSpots.forEach((stat, index) => { @@ -155,11 +155,11 @@ export class PerformanceMonitor { logContent += ` 性能影响: ${((stat.totalTime / totalTime) * 100).toFixed(2)}%\n`; logContent += ` 调用效率: ${efficiency.toFixed(4)} 调用/ms\n`; logContent += ` 优化建议: ${stat.averageTime > 10 ? '考虑优化此函数的执行效率' : - stat.callCount > 1000 ? '考虑减少此函数的调用频率' : - '性能表现良好'}\n\n`; + stat.callCount > 1000 ? '考虑减少此函数的调用频率' : + '性能表现良好'}\n\n`; }); - logContent += '=== 报告结束 ===\n'; + logContent += `=== 报告结束 ===\n`; // 写入文件 fs.writeFileSync(logPath, logContent, 'utf8'); diff --git a/src/common/worker.ts b/src/common/worker.ts index 1e2bc0b7..da5c1321 100644 --- a/src/common/worker.ts +++ b/src/common/worker.ts @@ -9,7 +9,7 @@ export async function runTask(workerScript: string, taskData: T): Promise< console.error('Worker Log--->:', (result as { log: string }).log); } if ((result as any)?.error) { - reject(new Error('Worker error: ' + (result as { error: string }).error)); + reject(new Error("Worker error: " + (result as { error: string }).error)); } resolve(result); }); diff --git a/src/core/apis/file.ts b/src/core/apis/file.ts index 1f44bd73..14bf8b87 100644 --- a/src/core/apis/file.ts +++ b/src/core/apis/file.ts @@ -45,7 +45,7 @@ export class NTQQFileApi { 'http://ss.xingzhige.com/music_card/rkey', 'https://secret-service.bietiaop.com/rkeys', ], - this.context.logger + this.context.logger ); } @@ -378,18 +378,18 @@ export class NTQQFileApi { element.elementType === ElementType.FILE ) { switch (element.elementType) { - case ElementType.PIC: + case ElementType.PIC: element.picElement!.sourcePath = elementResults?.[elementIndex] ?? ''; - break; - case ElementType.VIDEO: + break; + case ElementType.VIDEO: element.videoElement!.filePath = elementResults?.[elementIndex] ?? ''; - break; - case ElementType.PTT: + break; + case ElementType.PTT: element.pttElement!.filePath = elementResults?.[elementIndex] ?? ''; - break; - case ElementType.FILE: + break; + case ElementType.FILE: element.fileElement!.filePath = elementResults?.[elementIndex] ?? ''; - break; + break; } elementIndex++; } diff --git a/src/core/apis/friend.ts b/src/core/apis/friend.ts index fd1e6ee6..a8254ec1 100644 --- a/src/core/apis/friend.ts +++ b/src/core/apis/friend.ts @@ -110,7 +110,7 @@ export class NTQQFriendApi { time: item.reqTime, // 信息字段 type: 'doubt' //保留字段 }; - })); + })) return requests; } } diff --git a/src/core/apis/group.ts b/src/core/apis/group.ts index 6d80132e..2952c30b 100644 --- a/src/core/apis/group.ts +++ b/src/core/apis/group.ts @@ -58,13 +58,13 @@ export class NTQQGroupApi { } as Peer, { busiId: 2201, - jsonStr: JSON.stringify({ 'align': 'center', 'items': [{ 'txt': tip, 'type': 'nor' }] }), + jsonStr: JSON.stringify({ "align": "center", "items": [{ "txt": tip, "type": "nor" }] }), recentAbstract: tip, isServer: false }, true, true - ); + ) } async initCache() { for (const group of await this.getGroups(true)) { diff --git a/src/core/apis/webapi.ts b/src/core/apis/webapi.ts index 4fc22c97..cede8d2e 100644 --- a/src/core/apis/webapi.ts +++ b/src/core/apis/webapi.ts @@ -330,9 +330,9 @@ export class NTQQWebApi { attach_info: '', seq: 3331, request_time_line: { - request_invoke_time: '0' + request_invoke_time: "0" } - }); + }) } async getAlbumList(gc: string) { const skey = await this.core.apis.UserApi.getSKey() || ''; @@ -340,7 +340,7 @@ export class NTQQWebApi { const bkn = this.getBknFromSKey(skey); const uin = this.core.selfInfo.uin || '10001'; const cookies = `p_uin=o${this.core.selfInfo.uin}; p_skey=${pskey}; skey=${skey}; uin=o${uin} `; - const api = 'https://h5.qzone.qq.com/proxy/domain/u.photo.qzone.qq.com/cgi-bin/upp/qun_list_album_v2?'; + const api = `https://h5.qzone.qq.com/proxy/domain/u.photo.qzone.qq.com/cgi-bin/upp/qun_list_album_v2?`; const params = new URLSearchParams({ random: '7570', g_tk: bkn, @@ -450,7 +450,7 @@ export class NTQQWebApi { attach_info: attach_info, seq: 0, request_time_line: { - request_invoke_time: '0' + request_invoke_time: "0" }, album_id: albumId, lloc: '', @@ -466,13 +466,13 @@ export class NTQQWebApi { const random_seq = Math.floor(Math.random() * 9000) + 1000; const uin = this.core.selfInfo.uin || '10001'; //16位number数字 - const client_key = Date.now() * 1000; + const client_key = Date.now() * 1000 return await this.context.session.getAlbumService().doQunComment( random_seq, { - map_info: [], - map_bytes_info: [], - map_user_account: [] - }, + map_info: [], + map_bytes_info: [], + map_user_account: [] + }, qunId, 2, createAlbumMediaFeed(uin, albumId, lloc), @@ -503,14 +503,14 @@ export class NTQQWebApi { const uin = this.core.selfInfo.uin || '10001'; return await this.context.session.getAlbumService().doQunLike( random_seq, { - map_info: [], - map_bytes_info: [], - map_user_account: [] - }, { - id: id, - status: 1 - }, + map_info: [], + map_bytes_info: [], + map_user_account: [] + }, { + id: id, + status: 1 + }, createAlbumFeedPublish(qunId, uin, albumId, lloc) - ); + ) } } \ No newline at end of file diff --git a/src/core/data/album.ts b/src/core/data/album.ts index f2a70ab7..3568a193 100644 --- a/src/core/data/album.ts +++ b/src/core/data/album.ts @@ -27,14 +27,14 @@ export function createAlbumListRequest( ): AlbumListRequest { return { qun_id: qunId, - attach_info: '', + attach_info: "", seq: seq, request_time_line: { - request_invoke_time: '0' + request_invoke_time: "0" }, album_id: albumId, - lloc: '', - batch_id: '' + lloc: "", + batch_id: "" }; } @@ -75,7 +75,7 @@ export function createAlbumMediaFeed( ): AlbumMediaFeed { return { cell_common: { - time: '' + time: "" }, cell_user_info: { user: { @@ -84,7 +84,7 @@ export function createAlbumMediaFeed( }, cell_media: { album_id: albumId, - batch_id: '', + batch_id: "", media_items: [{ image: { lloc: lloc @@ -141,9 +141,9 @@ export function createAlbumCommentRequest( type: RichMsgType.KRICHMSGTYPEPLAINTEXT, content: content, who: 0, - uid: '', - name: '', - url: '' + uid: "", + name: "", + url: "" }], user: { uin: uin @@ -196,7 +196,7 @@ export function createAlbumFeedPublish( return { cell_common: { time: Date.now(), - feed_id: '' + feed_id: "" }, cell_user_info: { user: { diff --git a/src/core/data/group.ts b/src/core/data/group.ts index 3adf5a1c..2b9636e7 100644 --- a/src/core/data/group.ts +++ b/src/core/data/group.ts @@ -1,4 +1,4 @@ -import { GroupDetailInfoV2Param, GroupExtInfo, GroupExtFilter } from '../types'; +import { GroupDetailInfoV2Param, GroupExtInfo, GroupExtFilter } from "../types"; export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInfoV2Param { return { @@ -51,7 +51,7 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf }, groupSecLevel: 0, groupSecLevelInfo: 0, subscriptionUin: 0, - subscriptionUid: '', + subscriptionUid: "", allowMemberInvite: 0, groupQuestion: 0, groupAnswer: 0, @@ -81,34 +81,34 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf modifyInfo: { noCodeFingerOpenFlag: 0, noFingerOpenFlag: 0, - groupName: '', + groupName: "", classExt: 0, - classText: '', - fingerMemo: '', - richFingerMemo: '', + classText: "", + fingerMemo: "", + richFingerMemo: "", tagRecord: [], groupGeoInfo: { - ownerUid: '', + ownerUid: "", SetTime: 0, CityId: 0, - Longitude: '', - Latitude: '', - GeoContent: '', - poiId: '' + Longitude: "", + Latitude: "", + GeoContent: "", + poiId: "" }, groupExtAdminNum: 0, flag: 0, - groupMemo: '', - groupAioSkinUrl: '', - groupBoardSkinUrl: '', - groupCoverSkinUrl: '', + groupMemo: "", + groupAioSkinUrl: "", + groupBoardSkinUrl: "", + groupCoverSkinUrl: "", groupGrade: 0, activeMemberNum: 0, certificationType: 0, - certificationText: '', + certificationText: "", groupNewGuideLines: { enabled: false, - content: '' + content: "" }, groupFace: 0, addOption: 0, shutUpTime: 0, @@ -121,15 +121,15 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf }, groupSecLevel: 0, groupSecLevelInfo: 0, - subscriptionUin: '', - subscriptionUid: '', + subscriptionUin: "", + subscriptionUid: "", allowMemberInvite: 0, - groupQuestion: '', - groupAnswer: '', + groupQuestion: "", + groupAnswer: "", groupFlagExt3: 0, groupFlagExt3Mask: 0, groupOpenAppid: 0, - rootId: '', + rootId: "", msgLimitFrequency: 0, hlGuildAppid: 0, hlGuildSubType: 0, @@ -137,20 +137,20 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf groupFlagExt4: 0, groupFlagExt4Mask: 0, groupSchoolInfo: { - location: '', + location: "", grade: 0, - school: '' + school: "" }, groupCardPrefix: { - introduction: '', + introduction: "", rptPrefix: [] }, - allianceId: '', + allianceId: "", groupFlagPro1: 0, groupFlagPro1Mask: 0 } - }; + } } export function createGroupExtInfo(group_code: string): GroupExtInfo { return { @@ -205,7 +205,7 @@ export function createGroupExtInfo(group_code: string): GroupExtInfo { inviteRobotMemberExamine: 0, groupSquareSwitch: 0, } - }; + } } export function createGroupExtFilter(): GroupExtFilter { return { @@ -241,5 +241,5 @@ export function createGroupExtFilter(): GroupExtFilter { inviteRobotMemberSwitch: 0, inviteRobotMemberExamine: 0, groupSquareSwitch: 0, - }; + } }; \ No newline at end of file diff --git a/src/core/data/index.ts b/src/core/data/index.ts index 8a78f593..7cd52db8 100644 --- a/src/core/data/index.ts +++ b/src/core/data/index.ts @@ -1 +1 @@ -export * from './group'; +export * from "./group"; diff --git a/src/core/data/webapi.ts b/src/core/data/webapi.ts index a4652deb..69fff601 100644 --- a/src/core/data/webapi.ts +++ b/src/core/data/webapi.ts @@ -70,9 +70,9 @@ export function qunAlbumControl({ img_name, sAlbumName, sAlbumID, - photo_num = '1', - video_num = '0', - batch_num = '1' + photo_num = "1", + video_num = "0", + batch_num = "1" }: { uin: string, group_id: string, @@ -100,18 +100,18 @@ export function qunAlbumControl({ data: pskey, appid: 5 }, - appid: 'qun', + appid: "qun", checksum: pic_md5, check_type: 0, file_len: img_size, env: { - refer: 'qzone', - deviceInfo: 'h5' + refer: "qzone", + deviceInfo: "h5" }, model: 0, biz_req: { sPicTitle: img_name, - sPicDesc: '', + sPicDesc: "", sAlbumName: sAlbumName, sAlbumID: sAlbumID, iAlbumTypeID: 0, @@ -119,7 +119,7 @@ export function qunAlbumControl({ iUploadType: 0, iUpPicType: 0, iBatchID: timestamp, - sPicPath: '', + sPicPath: "", iPicWidth: 0, iPicHight: 0, iWaterType: 0, @@ -127,7 +127,7 @@ export function qunAlbumControl({ iNeedFeeds: 1, iUploadTime: timestamp, mapExt: { - appid: 'qun', + appid: "qun", userid: group_id }, stExtendInfo: { @@ -138,11 +138,11 @@ export function qunAlbumControl({ } } }, - session: '', + session: "", asy_upload: 0, - cmd: 'FileUpload' + cmd: "FileUpload" }] - }; + } } export function createStreamUpload( @@ -159,16 +159,16 @@ export function createStreamUpload( ) { return { uin: uin, - appid: 'qun', + appid: "qun", session: session, offset: offset,//分片起始位置 data: data,//base64编码数据 - checksum: '', + checksum: "", check_type: 0, retry: 0,//重试次数 seq: seq,//分片序号 end: end,//分片结束位置 文件总大小 - cmd: 'FileUpload', + cmd: "FileUpload", slice_size: slice_size,//分片大小16KB 16384 biz_req: { iUploadType: 3 diff --git a/src/core/packet/client/nativeClient.ts b/src/core/packet/client/nativeClient.ts index 728013aa..1d08ded2 100644 --- a/src/core/packet/client/nativeClient.ts +++ b/src/core/packet/client/nativeClient.ts @@ -40,7 +40,7 @@ export class NativePacketClient extends IPacketClient { async init(_pid: number, recv: string, send: string): Promise { const platform = process.platform + '.' + process.arch; - const isNewQQ = this.napcore.basicInfo.requireMinNTQQBuild('36580'); + const isNewQQ = this.napcore.basicInfo.requireMinNTQQBuild("36580"); const moehoo_path = path.join(dirname(fileURLToPath(import.meta.url)), './moehoo/MoeHoo.' + platform + (isNewQQ ? '.new' : '') + '.node'); process.dlopen(this.MoeHooExport, moehoo_path, constants.dlopen.RTLD_LAZY); diff --git a/src/core/packet/context/operationContext.ts b/src/core/packet/context/operationContext.ts index 1bf2639e..e3ab7de6 100644 --- a/src/core/packet/context/operationContext.ts +++ b/src/core/packet/context/operationContext.ts @@ -183,9 +183,9 @@ export class PacketOperationContext { const ps = msg.map((m) => { return m.msg.map(async (e) => { if (e instanceof PacketMsgReplyElement && !e.targetElems) { - this.context.logger.debug('Cannot find reply element\'s targetElems, prepare to fetch it...'); + this.context.logger.debug(`Cannot find reply element's targetElems, prepare to fetch it...`); if (!e.targetPeer?.peerUid) { - this.context.logger.error('targetPeer is undefined!'); + this.context.logger.error(`targetPeer is undefined!`); } let targetMsg: NapProtoEncodeStructType[] | undefined; if (e.isGroupReply) { @@ -198,7 +198,7 @@ export class PacketOperationContext { } }); }).flat(); - await Promise.all(ps); + await Promise.all(ps) await this.UploadResources(msg, groupUin); } @@ -206,14 +206,14 @@ export class PacketOperationContext { const req = trans.FetchGroupMessage.build(groupUin, startSeq, endSeq); const resp = await this.context.client.sendOidbPacket(req, true); const res = trans.FetchGroupMessage.parse(resp); - return res.body.messages; + return res.body.messages } async FetchC2CMessage(targetUid: string, startSeq: number, endSeq: number): Promise[]> { const req = trans.FetchC2CMessage.build(targetUid, startSeq, endSeq); const resp = await this.context.client.sendOidbPacket(req, true); const res = trans.FetchC2CMessage.parse(resp); - return res.messages; + return res.messages } async UploadForwardMsg(msg: PacketMsg[], groupUin: number = 0) { diff --git a/src/core/packet/transformer/proto/oidb/Oidb.0xf90_1.ts b/src/core/packet/transformer/proto/oidb/Oidb.0xf90_1.ts index bbe21bf2..98af201e 100644 --- a/src/core/packet/transformer/proto/oidb/Oidb.0xf90_1.ts +++ b/src/core/packet/transformer/proto/oidb/Oidb.0xf90_1.ts @@ -1,4 +1,4 @@ -import { ProtoField, ScalarType } from '@napneko/nap-proto-core'; +import { ProtoField, ScalarType } from "@napneko/nap-proto-core"; export const OidbSvcTrpcTcp0XF90_1 = { groupUin: ProtoField(1, ScalarType.UINT32), diff --git a/src/core/services/NodeIKernelAlbumService.ts b/src/core/services/NodeIKernelAlbumService.ts index 5590b896..9cc086b2 100644 --- a/src/core/services/NodeIKernelAlbumService.ts +++ b/src/core/services/NodeIKernelAlbumService.ts @@ -1,4 +1,4 @@ -import { AlbumCommentReplyContent, AlbumFeedLikePublish, AlbumListRequest, AlbumMediaFeed } from '../data/album'; +import { AlbumCommentReplyContent, AlbumFeedLikePublish, AlbumListRequest, AlbumMediaFeed } from "../data/album"; export interface NodeIKernelAlbumService { diff --git a/src/example-plugin/index.ts b/src/example-plugin/index.ts index 25dd01ca..1bd308ec 100644 --- a/src/example-plugin/index.ts +++ b/src/example-plugin/index.ts @@ -1,12 +1,12 @@ -import { EventType } from '@/onebot/event/OneBotEvent'; -import type { PluginModule } from '@/onebot/network/plugin-manger'; +import { EventType } from "@/onebot/event/OneBotEvent"; +import type { PluginModule } from "@/onebot/network/plugin-manger"; -const plugin_init: PluginModule['plugin_init'] = async (_core, _obContext, _actions, _instance) => { - console.log('[Plugin: example] 插件已初始化'); -}; -const plugin_onmessage: PluginModule['plugin_onmessage'] = async (adapter, _core, _obCtx, event, actions, instance) => { +const plugin_init: PluginModule["plugin_init"] = async (_core, _obContext, _actions, _instance) => { + console.log(`[Plugin: example] 插件已初始化`); +} +const plugin_onmessage: PluginModule["plugin_onmessage"] = async (adapter, _core, _obCtx, event, actions, instance) => { if (event.post_type === EventType.MESSAGE && event.raw_message.includes('ping')) { await actions.get('send_group_msg')?.handle({ group_id: String(event.group_id), message: 'pong' }, adapter, instance.config); } -}; +} export { plugin_init, plugin_onmessage }; \ No newline at end of file diff --git a/src/onebot/action/extends/ClickInlineKeyboardButton.ts b/src/onebot/action/extends/ClickInlineKeyboardButton.ts index 273c726f..f27acfb2 100644 --- a/src/onebot/action/extends/ClickInlineKeyboardButton.ts +++ b/src/onebot/action/extends/ClickInlineKeyboardButton.ts @@ -25,6 +25,6 @@ export class ClickInlineKeyboardButton extends OneBotAction { callback_data: payload.callback_data, dmFlag: 0, chatType: 2 - }); + }) } } diff --git a/src/onebot/action/extends/GetGroupAlbumMediaList.ts b/src/onebot/action/extends/GetGroupAlbumMediaList.ts index c71765a1..be14af05 100644 --- a/src/onebot/action/extends/GetGroupAlbumMediaList.ts +++ b/src/onebot/action/extends/GetGroupAlbumMediaList.ts @@ -5,7 +5,7 @@ import { Static, Type } from '@sinclair/typebox'; const SchemaData = Type.Object({ group_id: Type.String(), album_id: Type.String(), - attach_info: Type.String({ default: '' }), + attach_info: Type.String({ default: "" }), }); type Payload = Static; diff --git a/src/onebot/action/extends/GetUnidirectionalFriendList.ts b/src/onebot/action/extends/GetUnidirectionalFriendList.ts index 5bf57f7c..96de0f7d 100644 --- a/src/onebot/action/extends/GetUnidirectionalFriendList.ts +++ b/src/onebot/action/extends/GetUnidirectionalFriendList.ts @@ -36,7 +36,7 @@ export class GetUnidirectionalFriendList extends OneBotAction { uint64_uin: self_id, uint64_top: 0, uint32_req_num: 99, - bytes_cookies: '' + bytes_cookies: "" }; const packed_data = await this.pack_data(JSON.stringify(req_json)); const data = Buffer.from(packed_data).toString('hex'); diff --git a/src/onebot/action/msg/GetMsg.ts b/src/onebot/action/msg/GetMsg.ts index 680fada1..91526377 100644 --- a/src/onebot/action/msg/GetMsg.ts +++ b/src/onebot/action/msg/GetMsg.ts @@ -33,7 +33,7 @@ class GetMsg extends OneBotAction { // if (orimsg) { // msg = orimsg; // } else { - msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0]; + msg = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgIdWithPeer?.MsgId || payload.message_id.toString()])).msgList[0]; //} if (!msg) throw Error('消息不存在'); const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat); diff --git a/src/onebot/action/msg/SendMsg.ts b/src/onebot/action/msg/SendMsg.ts index eff637a7..60ef8322 100644 --- a/src/onebot/action/msg/SendMsg.ts +++ b/src/onebot/action/msg/SendMsg.ts @@ -55,7 +55,7 @@ export async function createContext(core: NapCatCore, payload: OB11PostContext | chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString(), guildId: '' - }; + } } throw new Error('无法获取用户信息'); } diff --git a/src/onebot/action/packet/GetRkeyEx.ts b/src/onebot/action/packet/GetRkeyEx.ts index ca95dfbd..d330b8ee 100644 --- a/src/onebot/action/packet/GetRkeyEx.ts +++ b/src/onebot/action/packet/GetRkeyEx.ts @@ -8,7 +8,7 @@ export class GetRkeyEx extends GetPacketStatusDepends { let rkeys = await this.core.apis.PacketApi.pkt.operation.FetchRkey(); return rkeys.map(rkey => { return { - type: rkey.type === 10 ? 'private' : 'group', + type: rkey.type === 10 ? "private" : "group", rkey: rkey.rkey, created_at: rkey.time, ttl: rkey.ttl, diff --git a/src/onebot/action/packet/GetRkeyServer.ts b/src/onebot/action/packet/GetRkeyServer.ts index 17e04c35..ebfa7049 100644 --- a/src/onebot/action/packet/GetRkeyServer.ts +++ b/src/onebot/action/packet/GetRkeyServer.ts @@ -30,7 +30,7 @@ export class GetRkeyServer extends GetPacketStatusDepends { async _handle(payload: Payload) { // 这里的 !! 可以传入空字符串 忽略这些数据有利用接口统一接口 - const target_id = payload.target_id ? payload.target_id : payload.user_id; - const peer_id = payload.group_id ? payload.group_id : payload.user_id; + const target_id = !!payload.target_id ? payload.target_id : payload.user_id; + const peer_id = !!payload.group_id ? payload.group_id : payload.user_id; const is_group = !!payload.group_id; if (!target_id || !peer_id) { diff --git a/src/onebot/action/router.ts b/src/onebot/action/router.ts index 4e20dec0..bb6de99f 100644 --- a/src/onebot/action/router.ts +++ b/src/onebot/action/router.ts @@ -14,7 +14,7 @@ export const ActionName = { CleanStreamTempFile: 'clean_stream_temp_file', // 所有 Upload/Download Stream Api 应当 _stream 结尾 - TestDownloadStream: 'test_download_stream', + TestDownloadStream: 'test_download_stream', UploadFileStream: 'upload_file_stream', DownloadFileStream: 'download_file_stream', diff --git a/src/onebot/action/stream/DownloadFileStream.ts b/src/onebot/action/stream/DownloadFileStream.ts index 4418de63..2c0095ef 100644 --- a/src/onebot/action/stream/DownloadFileStream.ts +++ b/src/onebot/action/stream/DownloadFileStream.ts @@ -104,7 +104,7 @@ export class DownloadFileStream extends OneBotAction => { const sizePromises = elements.map(async element => { switch (element.elementType) { - case ElementType.PTT: - return (await fsPromise.stat(element.pttElement.filePath)).size; - case ElementType.FILE: - return (await fsPromise.stat(element.fileElement.filePath)).size; - case ElementType.VIDEO: - return (await fsPromise.stat(element.videoElement.filePath)).size; - case ElementType.PIC: - return (await fsPromise.stat(element.picElement.sourcePath)).size; - default: - return 0; + case ElementType.PTT: + return (await fsPromise.stat(element.pttElement.filePath)).size; + case ElementType.FILE: + return (await fsPromise.stat(element.fileElement.filePath)).size; + case ElementType.VIDEO: + return (await fsPromise.stat(element.videoElement.filePath)).size; + case ElementType.PIC: + return (await fsPromise.stat(element.picElement.sourcePath)).size; + default: + return 0; } }); const sizes = await Promise.all(sizePromises); @@ -1249,16 +1249,16 @@ export class OneBotMsgApi { groupChangDecreseType2String(type: number): GroupDecreaseSubType { switch (type) { - case 130: - return 'leave'; - case 131: - return 'kick'; - case 3: - return 'kick_me'; - case 129: - return 'disband'; - default: - return 'kick'; + case 130: + return 'leave'; + case 131: + return 'kick'; + case 3: + return 'kick_me'; + case 129: + return 'disband'; + default: + return 'kick'; } } diff --git a/src/onebot/network/http-server.ts b/src/onebot/network/http-server.ts index eb89749c..75f9c96a 100644 --- a/src/onebot/network/http-server.ts +++ b/src/onebot/network/http-server.ts @@ -129,7 +129,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter await this.onEvent({ ...OB11Response.ok(data, real_echo, true) } as unknown as OB11EmitEventContent); } : async (data: object) => { let newPromise = new Promise((resolve, _reject) => { - res.write(JSON.stringify({ ...OB11Response.ok(data, real_echo, true) }) + '\r\n\r\n', () => { + res.write(JSON.stringify({ ...OB11Response.ok(data, real_echo, true) }) + "\r\n\r\n", () => { resolve(); }); }); @@ -137,7 +137,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter } }, real_echo); if (useStream) { - res.write(JSON.stringify({ ...result }) + '\r\n\r\n'); + res.write(JSON.stringify({ ...result }) + "\r\n\r\n"); return res.end(); }; return res.json(result); diff --git a/src/onebot/network/plugin-manger.ts b/src/onebot/network/plugin-manger.ts index 2289b3cc..fcd29723 100644 --- a/src/onebot/network/plugin-manger.ts +++ b/src/onebot/network/plugin-manger.ts @@ -74,7 +74,7 @@ export class OB11PluginMangerAdapter extends IOB11NetworkAdapter { this.logger.log(`[Plugin Adapter] Loaded ${this.loadedPlugins.size} plugins`); } catch (error) { - this.logger.logError('[Plugin Adapter] Error loading plugins:', error); + this.logger.logError(`[Plugin Adapter] Error loading plugins:`, error); } } diff --git a/src/onebot/network/plugin.ts b/src/onebot/network/plugin.ts index fab0fb8f..c805edb8 100644 --- a/src/onebot/network/plugin.ts +++ b/src/onebot/network/plugin.ts @@ -74,7 +74,7 @@ export class OB11PluginAdapter extends IOB11NetworkAdapter { this.logger.log(`[Plugin Adapter] Loaded ${this.loadedPlugins.size} plugins`); } catch (error) { - this.logger.logError('[Plugin Adapter] Error loading plugins:', error); + this.logger.logError(`[Plugin Adapter] Error loading plugins:`, error); } } diff --git a/src/shell/base.ts b/src/shell/base.ts index 68dda864..708ac2a7 100644 --- a/src/shell/base.ts +++ b/src/shell/base.ts @@ -143,7 +143,7 @@ async function handleLogin( handleLoginInner(context, logger, loginService, quickLoginUin, historyLoginList).then().catch(e => logger.logError(e)); loginListener.onLoginConnected = () => { }; }); - }; + } loginListener.onQRCodeGetPicture = ({ pngBase64QrcodeData, qrcodeUrl }) => { WebUiDataRuntime.setQQLoginQrcodeURL(qrcodeUrl); @@ -222,7 +222,7 @@ async function handleLoginInner(context: { isLogined: boolean }, logger: LogWrap logger.log(`可用于快速登录的 QQ:\n${historyLoginList .map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`) .join('\n') - }`); + }`); } loginService.getQRCodePicture(); try {