mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-18 20:30:08 +08:00
Revert formatting-only changes, keep only bug fixes
Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com>
This commit is contained in:
parent
e6c694c2b7
commit
e431471c4c
4
package-lock.json
generated
4
package-lock.json
generated
@ -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",
|
||||
|
||||
@ -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
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -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) => {
|
||||
@ -159,7 +159,7 @@ export class PerformanceMonitor {
|
||||
'性能表现良好'}\n\n`;
|
||||
});
|
||||
|
||||
logContent += '=== 报告结束 ===\n';
|
||||
logContent += `=== 报告结束 ===\n`;
|
||||
|
||||
// 写入文件
|
||||
fs.writeFileSync(logPath, logContent, 'utf8');
|
||||
|
||||
@ -9,7 +9,7 @@ export async function runTask<T, R>(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);
|
||||
});
|
||||
|
||||
@ -110,7 +110,7 @@ export class NTQQFriendApi {
|
||||
time: item.reqTime, // 信息字段
|
||||
type: 'doubt' //保留字段
|
||||
};
|
||||
}));
|
||||
}))
|
||||
return requests;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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,7 +466,7 @@ 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: [],
|
||||
@ -511,6 +511,6 @@ export class NTQQWebApi {
|
||||
status: 1
|
||||
},
|
||||
createAlbumFeedPublish(qunId, uin, albumId, lloc)
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -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: {
|
||||
|
||||
@ -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,
|
||||
};
|
||||
}
|
||||
};
|
||||
@ -1 +1 @@
|
||||
export * from './group';
|
||||
export * from "./group";
|
||||
|
||||
@ -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
|
||||
|
||||
@ -40,7 +40,7 @@ export class NativePacketClient extends IPacketClient {
|
||||
|
||||
async init(_pid: number, recv: string, send: string): Promise<void> {
|
||||
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);
|
||||
|
||||
|
||||
@ -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<typeof PushMsgBody>[] | 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<NapProtoDecodeStructType<typeof PushMsgBody>[]> {
|
||||
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) {
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { AlbumCommentReplyContent, AlbumFeedLikePublish, AlbumListRequest, AlbumMediaFeed } from '../data/album';
|
||||
import { AlbumCommentReplyContent, AlbumFeedLikePublish, AlbumListRequest, AlbumMediaFeed } from "../data/album";
|
||||
|
||||
export interface NodeIKernelAlbumService {
|
||||
|
||||
|
||||
@ -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 };
|
||||
@ -25,6 +25,6 @@ export class ClickInlineKeyboardButton extends OneBotAction<Payload, unknown> {
|
||||
callback_data: payload.callback_data,
|
||||
dmFlag: 0,
|
||||
chatType: 2
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -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<typeof SchemaData>;
|
||||
|
||||
@ -36,7 +36,7 @@ export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
||||
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');
|
||||
|
||||
@ -55,7 +55,7 @@ export async function createContext(core: NapCatCore, payload: OB11PostContext |
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: payload.group_id.toString(),
|
||||
guildId: ''
|
||||
};
|
||||
}
|
||||
}
|
||||
throw new Error('无法获取用户信息');
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ export class GetRkeyEx extends GetPacketStatusDepends<void, unknown> {
|
||||
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,
|
||||
|
||||
@ -30,7 +30,7 @@ export class GetRkeyServer extends GetPacketStatusDepends<void, { private_rkey?:
|
||||
private_rkey: privateRkeyItem ? privateRkeyItem.rkey : undefined,
|
||||
group_rkey: groupRkeyItem ? groupRkeyItem.rkey : undefined,
|
||||
expired_time: this.expiryTime,
|
||||
name: 'NapCat 4'
|
||||
name: "NapCat 4"
|
||||
};
|
||||
|
||||
return this.rkeyCache;
|
||||
|
||||
@ -14,8 +14,8 @@ export class SendPokeBase extends GetPacketStatusDepends<Payload, void> {
|
||||
|
||||
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) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { OneBotAction, OneBotRequestToolkit } from '../OneBotAction';
|
||||
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
||||
import { OneBotAction, OneBotRequestToolkit } from "../OneBotAction";
|
||||
import { NetworkAdapterConfig } from "@/onebot/config/config";
|
||||
export type StreamPacketBasic = {
|
||||
type: StreamStatus;
|
||||
data_type?: string;
|
||||
|
||||
@ -154,7 +154,7 @@ export class UploadFileStream extends OneBotAction<Payload, StreamPacket<StreamR
|
||||
try {
|
||||
fs.rmSync(stream.tempDir, { recursive: true, force: true });
|
||||
} catch (cleanupError) {
|
||||
console.error('Failed to cleanup temp dir during creation error:', cleanupError);
|
||||
console.error(`Failed to cleanup temp dir during creation error:`, cleanupError);
|
||||
}
|
||||
}
|
||||
throw error;
|
||||
|
||||
@ -180,7 +180,7 @@ export class OneBotMsgApi {
|
||||
file_size: element.fileSize,
|
||||
url: url,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
@ -489,7 +489,7 @@ export class OneBotMsgApi {
|
||||
url: pttUrl,
|
||||
file_size: element.fileSize,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
type: OB11MessageDataType.voice,
|
||||
|
||||
@ -129,7 +129,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
|
||||
await this.onEvent({ ...OB11Response.ok(data, real_echo, true) } as unknown as OB11EmitEventContent);
|
||||
} : async (data: object) => {
|
||||
let newPromise = new Promise<void>((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<HttpServerConfig>
|
||||
}
|
||||
}, 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);
|
||||
|
||||
@ -74,7 +74,7 @@ export class OB11PluginMangerAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ export class OB11PluginAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user