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",
|
"name": "napcat",
|
||||||
"version": "4.8.116",
|
"version": "4.8.98",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"version": "4.8.116",
|
"version": "4.8.98",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^5.0.0",
|
"express": "^5.0.0",
|
||||||
"silk-wasm": "^3.6.1",
|
"silk-wasm": "^3.6.1",
|
||||||
|
|||||||
@ -8,16 +8,16 @@ import { pipeline } from 'stream/promises';
|
|||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { LogWrapper } from './log';
|
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 = [
|
const urls = [
|
||||||
'https://j.1win.ggff.net/' + downloadOri,
|
"https://j.1win.ggff.net/" + downloadOri,
|
||||||
'https://git.yylx.win/' + downloadOri,
|
"https://git.yylx.win/" + downloadOri,
|
||||||
'https://ghfile.geekertao.top/' + downloadOri,
|
"https://ghfile.geekertao.top/" + downloadOri,
|
||||||
'https://gh-proxy.net/' + downloadOri,
|
"https://gh-proxy.net/" + downloadOri,
|
||||||
'https://ghm.078465.xyz/' + downloadOri,
|
"https://ghm.078465.xyz/" + downloadOri,
|
||||||
'https://gitproxy.127731.xyz/' + downloadOri,
|
"https://gitproxy.127731.xyz/" + downloadOri,
|
||||||
'https://jiashu.1win.eu.org/' + downloadOri,
|
"https://jiashu.1win.eu.org/" + downloadOri,
|
||||||
'https://github.tbedu.top/' + downloadOri,
|
"https://github.tbedu.top/" + downloadOri,
|
||||||
downloadOri
|
downloadOri
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -354,11 +354,11 @@ export async function downloadFFmpegIfNotExists(log: LogWrapper) {
|
|||||||
return {
|
return {
|
||||||
path: path.join(currentPath, 'ffmpeg'),
|
path: path.join(currentPath, 'ffmpeg'),
|
||||||
reset: true
|
reset: true
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
path: path.join(currentPath, 'ffmpeg'),
|
path: path.join(currentPath, 'ffmpeg'),
|
||||||
reset: true
|
reset: true
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
@ -182,28 +182,28 @@ export async function uriToLocalFile(dir: string, uri: string, filename: string
|
|||||||
const filePath = path.join(dir, filename);
|
const filePath = path.join(dir, filename);
|
||||||
|
|
||||||
switch (UriType) {
|
switch (UriType) {
|
||||||
case FileUriType.Local: {
|
case FileUriType.Local: {
|
||||||
const fileExt = path.extname(HandledUri);
|
const fileExt = path.extname(HandledUri);
|
||||||
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
|
const localFileName = path.basename(HandledUri, fileExt) + fileExt;
|
||||||
const tempFilePath = path.join(dir, filename + fileExt);
|
const tempFilePath = path.join(dir, filename + fileExt);
|
||||||
fs.copyFileSync(HandledUri, tempFilePath);
|
fs.copyFileSync(HandledUri, tempFilePath);
|
||||||
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
|
return { success: true, errMsg: '', fileName: localFileName, path: tempFilePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
case FileUriType.Remote: {
|
case FileUriType.Remote: {
|
||||||
const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} });
|
const buffer = await httpDownload({ url: HandledUri, headers: headers ?? {} });
|
||||||
fs.writeFileSync(filePath, buffer);
|
fs.writeFileSync(filePath, buffer);
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
case FileUriType.Base64: {
|
case FileUriType.Base64: {
|
||||||
const base64 = HandledUri.replace(/^base64:\/\//, '');
|
const base64 = HandledUri.replace(/^base64:\/\//, '');
|
||||||
const base64Buffer = Buffer.from(base64, 'base64');
|
const base64Buffer = Buffer.from(base64, 'base64');
|
||||||
fs.writeFileSync(filePath, base64Buffer);
|
fs.writeFileSync(filePath, base64Buffer);
|
||||||
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
return { success: true, errMsg: '', fileName: filename, path: filePath };
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };
|
return { success: false, errMsg: `识别URL失败, uri= ${uri}`, fileName: '', path: '' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -108,13 +108,13 @@ export class PerformanceMonitor {
|
|||||||
const totalTime = Array.from(this.stats.values()).reduce((sum, stat) => sum + stat.totalTime, 0);
|
const totalTime = Array.from(this.stats.values()).reduce((sum, stat) => sum + stat.totalTime, 0);
|
||||||
|
|
||||||
let logContent = '';
|
let logContent = '';
|
||||||
logContent += '=== 性能监控详细报告 ===\n';
|
logContent += `=== 性能监控详细报告 ===\n`;
|
||||||
logContent += `生成时间: ${now.toLocaleString()}\n`;
|
logContent += `生成时间: ${now.toLocaleString()}\n`;
|
||||||
logContent += '统计周期: 60秒\n';
|
logContent += `统计周期: 60秒\n`;
|
||||||
logContent += `总览: ${totalFunctions} 个函数, ${totalCalls} 次调用, 总耗时: ${totalTime.toFixed(2)}ms\n\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);
|
const allStats = this.getStats().sort((a, b) => b.totalTime - a.totalTime);
|
||||||
|
|
||||||
allStats.forEach((stat, index) => {
|
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.minTime === Infinity ? 'N/A' : stat.minTime.toFixed(4)}ms\n`;
|
||||||
logContent += ` 最大耗时: ${stat.maxTime.toFixed(4)}ms\n`;
|
logContent += ` 最大耗时: ${stat.maxTime.toFixed(4)}ms\n`;
|
||||||
logContent += ` 性能占比: ${((stat.totalTime / totalTime) * 100).toFixed(2)}%\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) => {
|
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 += `${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) => {
|
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 += `${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) => {
|
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 += `${index + 1}. ${stat.name} - 平均: ${stat.averageTime.toFixed(2)}ms, 调用: ${stat.callCount}次, 总耗时: ${stat.totalTime.toFixed(2)}ms\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
logContent += '\n=== 性能热点分析 ===\n';
|
logContent += `\n=== 性能热点分析 ===\n`;
|
||||||
// 找出最耗时的前10个函数
|
// 找出最耗时的前10个函数
|
||||||
const hotSpots = this.getTopByTotalTime(10);
|
const hotSpots = this.getTopByTotalTime(10);
|
||||||
hotSpots.forEach((stat, index) => {
|
hotSpots.forEach((stat, index) => {
|
||||||
@ -155,11 +155,11 @@ export class PerformanceMonitor {
|
|||||||
logContent += ` 性能影响: ${((stat.totalTime / totalTime) * 100).toFixed(2)}%\n`;
|
logContent += ` 性能影响: ${((stat.totalTime / totalTime) * 100).toFixed(2)}%\n`;
|
||||||
logContent += ` 调用效率: ${efficiency.toFixed(4)} 调用/ms\n`;
|
logContent += ` 调用效率: ${efficiency.toFixed(4)} 调用/ms\n`;
|
||||||
logContent += ` 优化建议: ${stat.averageTime > 10 ? '考虑优化此函数的执行效率' :
|
logContent += ` 优化建议: ${stat.averageTime > 10 ? '考虑优化此函数的执行效率' :
|
||||||
stat.callCount > 1000 ? '考虑减少此函数的调用频率' :
|
stat.callCount > 1000 ? '考虑减少此函数的调用频率' :
|
||||||
'性能表现良好'}\n\n`;
|
'性能表现良好'}\n\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
logContent += '=== 报告结束 ===\n';
|
logContent += `=== 报告结束 ===\n`;
|
||||||
|
|
||||||
// 写入文件
|
// 写入文件
|
||||||
fs.writeFileSync(logPath, logContent, 'utf8');
|
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);
|
console.error('Worker Log--->:', (result as { log: string }).log);
|
||||||
}
|
}
|
||||||
if ((result as any)?.error) {
|
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);
|
resolve(result);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -45,7 +45,7 @@ export class NTQQFileApi {
|
|||||||
'http://ss.xingzhige.com/music_card/rkey',
|
'http://ss.xingzhige.com/music_card/rkey',
|
||||||
'https://secret-service.bietiaop.com/rkeys',
|
'https://secret-service.bietiaop.com/rkeys',
|
||||||
],
|
],
|
||||||
this.context.logger
|
this.context.logger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,18 +378,18 @@ export class NTQQFileApi {
|
|||||||
element.elementType === ElementType.FILE
|
element.elementType === ElementType.FILE
|
||||||
) {
|
) {
|
||||||
switch (element.elementType) {
|
switch (element.elementType) {
|
||||||
case ElementType.PIC:
|
case ElementType.PIC:
|
||||||
element.picElement!.sourcePath = elementResults?.[elementIndex] ?? '';
|
element.picElement!.sourcePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
case ElementType.VIDEO:
|
case ElementType.VIDEO:
|
||||||
element.videoElement!.filePath = elementResults?.[elementIndex] ?? '';
|
element.videoElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
case ElementType.PTT:
|
case ElementType.PTT:
|
||||||
element.pttElement!.filePath = elementResults?.[elementIndex] ?? '';
|
element.pttElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
case ElementType.FILE:
|
case ElementType.FILE:
|
||||||
element.fileElement!.filePath = elementResults?.[elementIndex] ?? '';
|
element.fileElement!.filePath = elementResults?.[elementIndex] ?? '';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
elementIndex++;
|
elementIndex++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -110,7 +110,7 @@ export class NTQQFriendApi {
|
|||||||
time: item.reqTime, // 信息字段
|
time: item.reqTime, // 信息字段
|
||||||
type: 'doubt' //保留字段
|
type: 'doubt' //保留字段
|
||||||
};
|
};
|
||||||
}));
|
}))
|
||||||
return requests;
|
return requests;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,13 +58,13 @@ export class NTQQGroupApi {
|
|||||||
} as Peer,
|
} as Peer,
|
||||||
{
|
{
|
||||||
busiId: 2201,
|
busiId: 2201,
|
||||||
jsonStr: JSON.stringify({ 'align': 'center', 'items': [{ 'txt': tip, 'type': 'nor' }] }),
|
jsonStr: JSON.stringify({ "align": "center", "items": [{ "txt": tip, "type": "nor" }] }),
|
||||||
recentAbstract: tip,
|
recentAbstract: tip,
|
||||||
isServer: false
|
isServer: false
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
async initCache() {
|
async initCache() {
|
||||||
for (const group of await this.getGroups(true)) {
|
for (const group of await this.getGroups(true)) {
|
||||||
|
|||||||
@ -330,9 +330,9 @@ export class NTQQWebApi {
|
|||||||
attach_info: '',
|
attach_info: '',
|
||||||
seq: 3331,
|
seq: 3331,
|
||||||
request_time_line: {
|
request_time_line: {
|
||||||
request_invoke_time: '0'
|
request_invoke_time: "0"
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
async getAlbumList(gc: string) {
|
async getAlbumList(gc: string) {
|
||||||
const skey = await this.core.apis.UserApi.getSKey() || '';
|
const skey = await this.core.apis.UserApi.getSKey() || '';
|
||||||
@ -340,7 +340,7 @@ export class NTQQWebApi {
|
|||||||
const bkn = this.getBknFromSKey(skey);
|
const bkn = this.getBknFromSKey(skey);
|
||||||
const uin = this.core.selfInfo.uin || '10001';
|
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 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({
|
const params = new URLSearchParams({
|
||||||
random: '7570',
|
random: '7570',
|
||||||
g_tk: bkn,
|
g_tk: bkn,
|
||||||
@ -450,7 +450,7 @@ export class NTQQWebApi {
|
|||||||
attach_info: attach_info,
|
attach_info: attach_info,
|
||||||
seq: 0,
|
seq: 0,
|
||||||
request_time_line: {
|
request_time_line: {
|
||||||
request_invoke_time: '0'
|
request_invoke_time: "0"
|
||||||
},
|
},
|
||||||
album_id: albumId,
|
album_id: albumId,
|
||||||
lloc: '',
|
lloc: '',
|
||||||
@ -466,13 +466,13 @@ export class NTQQWebApi {
|
|||||||
const random_seq = Math.floor(Math.random() * 9000) + 1000;
|
const random_seq = Math.floor(Math.random() * 9000) + 1000;
|
||||||
const uin = this.core.selfInfo.uin || '10001';
|
const uin = this.core.selfInfo.uin || '10001';
|
||||||
//16位number数字
|
//16位number数字
|
||||||
const client_key = Date.now() * 1000;
|
const client_key = Date.now() * 1000
|
||||||
return await this.context.session.getAlbumService().doQunComment(
|
return await this.context.session.getAlbumService().doQunComment(
|
||||||
random_seq, {
|
random_seq, {
|
||||||
map_info: [],
|
map_info: [],
|
||||||
map_bytes_info: [],
|
map_bytes_info: [],
|
||||||
map_user_account: []
|
map_user_account: []
|
||||||
},
|
},
|
||||||
qunId,
|
qunId,
|
||||||
2,
|
2,
|
||||||
createAlbumMediaFeed(uin, albumId, lloc),
|
createAlbumMediaFeed(uin, albumId, lloc),
|
||||||
@ -503,14 +503,14 @@ export class NTQQWebApi {
|
|||||||
const uin = this.core.selfInfo.uin || '10001';
|
const uin = this.core.selfInfo.uin || '10001';
|
||||||
return await this.context.session.getAlbumService().doQunLike(
|
return await this.context.session.getAlbumService().doQunLike(
|
||||||
random_seq, {
|
random_seq, {
|
||||||
map_info: [],
|
map_info: [],
|
||||||
map_bytes_info: [],
|
map_bytes_info: [],
|
||||||
map_user_account: []
|
map_user_account: []
|
||||||
}, {
|
}, {
|
||||||
id: id,
|
id: id,
|
||||||
status: 1
|
status: 1
|
||||||
},
|
},
|
||||||
createAlbumFeedPublish(qunId, uin, albumId, lloc)
|
createAlbumFeedPublish(qunId, uin, albumId, lloc)
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,14 +27,14 @@ export function createAlbumListRequest(
|
|||||||
): AlbumListRequest {
|
): AlbumListRequest {
|
||||||
return {
|
return {
|
||||||
qun_id: qunId,
|
qun_id: qunId,
|
||||||
attach_info: '',
|
attach_info: "",
|
||||||
seq: seq,
|
seq: seq,
|
||||||
request_time_line: {
|
request_time_line: {
|
||||||
request_invoke_time: '0'
|
request_invoke_time: "0"
|
||||||
},
|
},
|
||||||
album_id: albumId,
|
album_id: albumId,
|
||||||
lloc: '',
|
lloc: "",
|
||||||
batch_id: ''
|
batch_id: ""
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ export function createAlbumMediaFeed(
|
|||||||
): AlbumMediaFeed {
|
): AlbumMediaFeed {
|
||||||
return {
|
return {
|
||||||
cell_common: {
|
cell_common: {
|
||||||
time: ''
|
time: ""
|
||||||
},
|
},
|
||||||
cell_user_info: {
|
cell_user_info: {
|
||||||
user: {
|
user: {
|
||||||
@ -84,7 +84,7 @@ export function createAlbumMediaFeed(
|
|||||||
},
|
},
|
||||||
cell_media: {
|
cell_media: {
|
||||||
album_id: albumId,
|
album_id: albumId,
|
||||||
batch_id: '',
|
batch_id: "",
|
||||||
media_items: [{
|
media_items: [{
|
||||||
image: {
|
image: {
|
||||||
lloc: lloc
|
lloc: lloc
|
||||||
@ -141,9 +141,9 @@ export function createAlbumCommentRequest(
|
|||||||
type: RichMsgType.KRICHMSGTYPEPLAINTEXT,
|
type: RichMsgType.KRICHMSGTYPEPLAINTEXT,
|
||||||
content: content,
|
content: content,
|
||||||
who: 0,
|
who: 0,
|
||||||
uid: '',
|
uid: "",
|
||||||
name: '',
|
name: "",
|
||||||
url: ''
|
url: ""
|
||||||
}],
|
}],
|
||||||
user: {
|
user: {
|
||||||
uin: uin
|
uin: uin
|
||||||
@ -196,7 +196,7 @@ export function createAlbumFeedPublish(
|
|||||||
return {
|
return {
|
||||||
cell_common: {
|
cell_common: {
|
||||||
time: Date.now(),
|
time: Date.now(),
|
||||||
feed_id: ''
|
feed_id: ""
|
||||||
},
|
},
|
||||||
cell_user_info: {
|
cell_user_info: {
|
||||||
user: {
|
user: {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { GroupDetailInfoV2Param, GroupExtInfo, GroupExtFilter } from '../types';
|
import { GroupDetailInfoV2Param, GroupExtInfo, GroupExtFilter } from "../types";
|
||||||
|
|
||||||
export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInfoV2Param {
|
export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInfoV2Param {
|
||||||
return {
|
return {
|
||||||
@ -51,7 +51,7 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf
|
|||||||
}, groupSecLevel: 0,
|
}, groupSecLevel: 0,
|
||||||
groupSecLevelInfo: 0,
|
groupSecLevelInfo: 0,
|
||||||
subscriptionUin: 0,
|
subscriptionUin: 0,
|
||||||
subscriptionUid: '',
|
subscriptionUid: "",
|
||||||
allowMemberInvite: 0,
|
allowMemberInvite: 0,
|
||||||
groupQuestion: 0,
|
groupQuestion: 0,
|
||||||
groupAnswer: 0,
|
groupAnswer: 0,
|
||||||
@ -81,34 +81,34 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf
|
|||||||
modifyInfo: {
|
modifyInfo: {
|
||||||
noCodeFingerOpenFlag: 0,
|
noCodeFingerOpenFlag: 0,
|
||||||
noFingerOpenFlag: 0,
|
noFingerOpenFlag: 0,
|
||||||
groupName: '',
|
groupName: "",
|
||||||
classExt: 0,
|
classExt: 0,
|
||||||
classText: '',
|
classText: "",
|
||||||
fingerMemo: '',
|
fingerMemo: "",
|
||||||
richFingerMemo: '',
|
richFingerMemo: "",
|
||||||
tagRecord: [],
|
tagRecord: [],
|
||||||
groupGeoInfo: {
|
groupGeoInfo: {
|
||||||
ownerUid: '',
|
ownerUid: "",
|
||||||
SetTime: 0,
|
SetTime: 0,
|
||||||
CityId: 0,
|
CityId: 0,
|
||||||
Longitude: '',
|
Longitude: "",
|
||||||
Latitude: '',
|
Latitude: "",
|
||||||
GeoContent: '',
|
GeoContent: "",
|
||||||
poiId: ''
|
poiId: ""
|
||||||
},
|
},
|
||||||
groupExtAdminNum: 0,
|
groupExtAdminNum: 0,
|
||||||
flag: 0,
|
flag: 0,
|
||||||
groupMemo: '',
|
groupMemo: "",
|
||||||
groupAioSkinUrl: '',
|
groupAioSkinUrl: "",
|
||||||
groupBoardSkinUrl: '',
|
groupBoardSkinUrl: "",
|
||||||
groupCoverSkinUrl: '',
|
groupCoverSkinUrl: "",
|
||||||
groupGrade: 0,
|
groupGrade: 0,
|
||||||
activeMemberNum: 0,
|
activeMemberNum: 0,
|
||||||
certificationType: 0,
|
certificationType: 0,
|
||||||
certificationText: '',
|
certificationText: "",
|
||||||
groupNewGuideLines: {
|
groupNewGuideLines: {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
content: ''
|
content: ""
|
||||||
}, groupFace: 0,
|
}, groupFace: 0,
|
||||||
addOption: 0,
|
addOption: 0,
|
||||||
shutUpTime: 0,
|
shutUpTime: 0,
|
||||||
@ -121,15 +121,15 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf
|
|||||||
},
|
},
|
||||||
groupSecLevel: 0,
|
groupSecLevel: 0,
|
||||||
groupSecLevelInfo: 0,
|
groupSecLevelInfo: 0,
|
||||||
subscriptionUin: '',
|
subscriptionUin: "",
|
||||||
subscriptionUid: '',
|
subscriptionUid: "",
|
||||||
allowMemberInvite: 0,
|
allowMemberInvite: 0,
|
||||||
groupQuestion: '',
|
groupQuestion: "",
|
||||||
groupAnswer: '',
|
groupAnswer: "",
|
||||||
groupFlagExt3: 0,
|
groupFlagExt3: 0,
|
||||||
groupFlagExt3Mask: 0,
|
groupFlagExt3Mask: 0,
|
||||||
groupOpenAppid: 0,
|
groupOpenAppid: 0,
|
||||||
rootId: '',
|
rootId: "",
|
||||||
msgLimitFrequency: 0,
|
msgLimitFrequency: 0,
|
||||||
hlGuildAppid: 0,
|
hlGuildAppid: 0,
|
||||||
hlGuildSubType: 0,
|
hlGuildSubType: 0,
|
||||||
@ -137,20 +137,20 @@ export function createGroupDetailInfoV2Param(group_code: string): GroupDetailInf
|
|||||||
groupFlagExt4: 0,
|
groupFlagExt4: 0,
|
||||||
groupFlagExt4Mask: 0,
|
groupFlagExt4Mask: 0,
|
||||||
groupSchoolInfo: {
|
groupSchoolInfo: {
|
||||||
location: '',
|
location: "",
|
||||||
grade: 0,
|
grade: 0,
|
||||||
school: ''
|
school: ""
|
||||||
},
|
},
|
||||||
groupCardPrefix:
|
groupCardPrefix:
|
||||||
{
|
{
|
||||||
introduction: '',
|
introduction: "",
|
||||||
rptPrefix: []
|
rptPrefix: []
|
||||||
},
|
},
|
||||||
allianceId: '',
|
allianceId: "",
|
||||||
groupFlagPro1: 0,
|
groupFlagPro1: 0,
|
||||||
groupFlagPro1Mask: 0
|
groupFlagPro1Mask: 0
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
export function createGroupExtInfo(group_code: string): GroupExtInfo {
|
export function createGroupExtInfo(group_code: string): GroupExtInfo {
|
||||||
return {
|
return {
|
||||||
@ -205,7 +205,7 @@ export function createGroupExtInfo(group_code: string): GroupExtInfo {
|
|||||||
inviteRobotMemberExamine: 0,
|
inviteRobotMemberExamine: 0,
|
||||||
groupSquareSwitch: 0,
|
groupSquareSwitch: 0,
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
export function createGroupExtFilter(): GroupExtFilter {
|
export function createGroupExtFilter(): GroupExtFilter {
|
||||||
return {
|
return {
|
||||||
@ -241,5 +241,5 @@ export function createGroupExtFilter(): GroupExtFilter {
|
|||||||
inviteRobotMemberSwitch: 0,
|
inviteRobotMemberSwitch: 0,
|
||||||
inviteRobotMemberExamine: 0,
|
inviteRobotMemberExamine: 0,
|
||||||
groupSquareSwitch: 0,
|
groupSquareSwitch: 0,
|
||||||
};
|
}
|
||||||
};
|
};
|
||||||
@ -1 +1 @@
|
|||||||
export * from './group';
|
export * from "./group";
|
||||||
|
|||||||
@ -70,9 +70,9 @@ export function qunAlbumControl({
|
|||||||
img_name,
|
img_name,
|
||||||
sAlbumName,
|
sAlbumName,
|
||||||
sAlbumID,
|
sAlbumID,
|
||||||
photo_num = '1',
|
photo_num = "1",
|
||||||
video_num = '0',
|
video_num = "0",
|
||||||
batch_num = '1'
|
batch_num = "1"
|
||||||
}: {
|
}: {
|
||||||
uin: string,
|
uin: string,
|
||||||
group_id: string,
|
group_id: string,
|
||||||
@ -100,18 +100,18 @@ export function qunAlbumControl({
|
|||||||
data: pskey,
|
data: pskey,
|
||||||
appid: 5
|
appid: 5
|
||||||
},
|
},
|
||||||
appid: 'qun',
|
appid: "qun",
|
||||||
checksum: pic_md5,
|
checksum: pic_md5,
|
||||||
check_type: 0,
|
check_type: 0,
|
||||||
file_len: img_size,
|
file_len: img_size,
|
||||||
env: {
|
env: {
|
||||||
refer: 'qzone',
|
refer: "qzone",
|
||||||
deviceInfo: 'h5'
|
deviceInfo: "h5"
|
||||||
},
|
},
|
||||||
model: 0,
|
model: 0,
|
||||||
biz_req: {
|
biz_req: {
|
||||||
sPicTitle: img_name,
|
sPicTitle: img_name,
|
||||||
sPicDesc: '',
|
sPicDesc: "",
|
||||||
sAlbumName: sAlbumName,
|
sAlbumName: sAlbumName,
|
||||||
sAlbumID: sAlbumID,
|
sAlbumID: sAlbumID,
|
||||||
iAlbumTypeID: 0,
|
iAlbumTypeID: 0,
|
||||||
@ -119,7 +119,7 @@ export function qunAlbumControl({
|
|||||||
iUploadType: 0,
|
iUploadType: 0,
|
||||||
iUpPicType: 0,
|
iUpPicType: 0,
|
||||||
iBatchID: timestamp,
|
iBatchID: timestamp,
|
||||||
sPicPath: '',
|
sPicPath: "",
|
||||||
iPicWidth: 0,
|
iPicWidth: 0,
|
||||||
iPicHight: 0,
|
iPicHight: 0,
|
||||||
iWaterType: 0,
|
iWaterType: 0,
|
||||||
@ -127,7 +127,7 @@ export function qunAlbumControl({
|
|||||||
iNeedFeeds: 1,
|
iNeedFeeds: 1,
|
||||||
iUploadTime: timestamp,
|
iUploadTime: timestamp,
|
||||||
mapExt: {
|
mapExt: {
|
||||||
appid: 'qun',
|
appid: "qun",
|
||||||
userid: group_id
|
userid: group_id
|
||||||
},
|
},
|
||||||
stExtendInfo: {
|
stExtendInfo: {
|
||||||
@ -138,11 +138,11 @@ export function qunAlbumControl({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
session: '',
|
session: "",
|
||||||
asy_upload: 0,
|
asy_upload: 0,
|
||||||
cmd: 'FileUpload'
|
cmd: "FileUpload"
|
||||||
}]
|
}]
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createStreamUpload(
|
export function createStreamUpload(
|
||||||
@ -159,16 +159,16 @@ export function createStreamUpload(
|
|||||||
) {
|
) {
|
||||||
return {
|
return {
|
||||||
uin: uin,
|
uin: uin,
|
||||||
appid: 'qun',
|
appid: "qun",
|
||||||
session: session,
|
session: session,
|
||||||
offset: offset,//分片起始位置
|
offset: offset,//分片起始位置
|
||||||
data: data,//base64编码数据
|
data: data,//base64编码数据
|
||||||
checksum: '',
|
checksum: "",
|
||||||
check_type: 0,
|
check_type: 0,
|
||||||
retry: 0,//重试次数
|
retry: 0,//重试次数
|
||||||
seq: seq,//分片序号
|
seq: seq,//分片序号
|
||||||
end: end,//分片结束位置 文件总大小
|
end: end,//分片结束位置 文件总大小
|
||||||
cmd: 'FileUpload',
|
cmd: "FileUpload",
|
||||||
slice_size: slice_size,//分片大小16KB 16384
|
slice_size: slice_size,//分片大小16KB 16384
|
||||||
biz_req: {
|
biz_req: {
|
||||||
iUploadType: 3
|
iUploadType: 3
|
||||||
|
|||||||
@ -40,7 +40,7 @@ export class NativePacketClient extends IPacketClient {
|
|||||||
|
|
||||||
async init(_pid: number, recv: string, send: string): Promise<void> {
|
async init(_pid: number, recv: string, send: string): Promise<void> {
|
||||||
const platform = process.platform + '.' + process.arch;
|
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');
|
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);
|
process.dlopen(this.MoeHooExport, moehoo_path, constants.dlopen.RTLD_LAZY);
|
||||||
|
|
||||||
|
|||||||
@ -183,9 +183,9 @@ export class PacketOperationContext {
|
|||||||
const ps = msg.map((m) => {
|
const ps = msg.map((m) => {
|
||||||
return m.msg.map(async (e) => {
|
return m.msg.map(async (e) => {
|
||||||
if (e instanceof PacketMsgReplyElement && !e.targetElems) {
|
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) {
|
if (!e.targetPeer?.peerUid) {
|
||||||
this.context.logger.error('targetPeer is undefined!');
|
this.context.logger.error(`targetPeer is undefined!`);
|
||||||
}
|
}
|
||||||
let targetMsg: NapProtoEncodeStructType<typeof PushMsgBody>[] | undefined;
|
let targetMsg: NapProtoEncodeStructType<typeof PushMsgBody>[] | undefined;
|
||||||
if (e.isGroupReply) {
|
if (e.isGroupReply) {
|
||||||
@ -198,7 +198,7 @@ export class PacketOperationContext {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).flat();
|
}).flat();
|
||||||
await Promise.all(ps);
|
await Promise.all(ps)
|
||||||
await this.UploadResources(msg, groupUin);
|
await this.UploadResources(msg, groupUin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,14 +206,14 @@ export class PacketOperationContext {
|
|||||||
const req = trans.FetchGroupMessage.build(groupUin, startSeq, endSeq);
|
const req = trans.FetchGroupMessage.build(groupUin, startSeq, endSeq);
|
||||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||||
const res = trans.FetchGroupMessage.parse(resp);
|
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>[]> {
|
async FetchC2CMessage(targetUid: string, startSeq: number, endSeq: number): Promise<NapProtoDecodeStructType<typeof PushMsgBody>[]> {
|
||||||
const req = trans.FetchC2CMessage.build(targetUid, startSeq, endSeq);
|
const req = trans.FetchC2CMessage.build(targetUid, startSeq, endSeq);
|
||||||
const resp = await this.context.client.sendOidbPacket(req, true);
|
const resp = await this.context.client.sendOidbPacket(req, true);
|
||||||
const res = trans.FetchC2CMessage.parse(resp);
|
const res = trans.FetchC2CMessage.parse(resp);
|
||||||
return res.messages;
|
return res.messages
|
||||||
}
|
}
|
||||||
|
|
||||||
async UploadForwardMsg(msg: PacketMsg[], groupUin: number = 0) {
|
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 = {
|
export const OidbSvcTrpcTcp0XF90_1 = {
|
||||||
groupUin: ProtoField(1, ScalarType.UINT32),
|
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 {
|
export interface NodeIKernelAlbumService {
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
import { EventType } from '@/onebot/event/OneBotEvent';
|
import { EventType } from "@/onebot/event/OneBotEvent";
|
||||||
import type { PluginModule } from '@/onebot/network/plugin-manger';
|
import type { PluginModule } from "@/onebot/network/plugin-manger";
|
||||||
|
|
||||||
const plugin_init: PluginModule['plugin_init'] = async (_core, _obContext, _actions, _instance) => {
|
const plugin_init: PluginModule["plugin_init"] = async (_core, _obContext, _actions, _instance) => {
|
||||||
console.log('[Plugin: example] 插件已初始化');
|
console.log(`[Plugin: example] 插件已初始化`);
|
||||||
};
|
}
|
||||||
const plugin_onmessage: PluginModule['plugin_onmessage'] = async (adapter, _core, _obCtx, event, actions, instance) => {
|
const plugin_onmessage: PluginModule["plugin_onmessage"] = async (adapter, _core, _obCtx, event, actions, instance) => {
|
||||||
if (event.post_type === EventType.MESSAGE && event.raw_message.includes('ping')) {
|
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);
|
await actions.get('send_group_msg')?.handle({ group_id: String(event.group_id), message: 'pong' }, adapter, instance.config);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
export { plugin_init, plugin_onmessage };
|
export { plugin_init, plugin_onmessage };
|
||||||
@ -25,6 +25,6 @@ export class ClickInlineKeyboardButton extends OneBotAction<Payload, unknown> {
|
|||||||
callback_data: payload.callback_data,
|
callback_data: payload.callback_data,
|
||||||
dmFlag: 0,
|
dmFlag: 0,
|
||||||
chatType: 2
|
chatType: 2
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { Static, Type } from '@sinclair/typebox';
|
|||||||
const SchemaData = Type.Object({
|
const SchemaData = Type.Object({
|
||||||
group_id: Type.String(),
|
group_id: Type.String(),
|
||||||
album_id: Type.String(),
|
album_id: Type.String(),
|
||||||
attach_info: Type.String({ default: '' }),
|
attach_info: Type.String({ default: "" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
type Payload = Static<typeof SchemaData>;
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|||||||
@ -36,7 +36,7 @@ export class GetUnidirectionalFriendList extends OneBotAction<void, Friend[]> {
|
|||||||
uint64_uin: self_id,
|
uint64_uin: self_id,
|
||||||
uint64_top: 0,
|
uint64_top: 0,
|
||||||
uint32_req_num: 99,
|
uint32_req_num: 99,
|
||||||
bytes_cookies: ''
|
bytes_cookies: ""
|
||||||
};
|
};
|
||||||
const packed_data = await this.pack_data(JSON.stringify(req_json));
|
const packed_data = await this.pack_data(JSON.stringify(req_json));
|
||||||
const data = Buffer.from(packed_data).toString('hex');
|
const data = Buffer.from(packed_data).toString('hex');
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class GetMsg extends OneBotAction<Payload, OB11Message> {
|
|||||||
// if (orimsg) {
|
// if (orimsg) {
|
||||||
// msg = orimsg;
|
// msg = orimsg;
|
||||||
// } else {
|
// } 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('消息不存在');
|
if (!msg) throw Error('消息不存在');
|
||||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg, config.messagePostFormat);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ export async function createContext(core: NapCatCore, payload: OB11PostContext |
|
|||||||
chatType: ChatType.KCHATTYPEGROUP,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: payload.group_id.toString(),
|
peerUid: payload.group_id.toString(),
|
||||||
guildId: ''
|
guildId: ''
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
throw new Error('无法获取用户信息');
|
throw new Error('无法获取用户信息');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ export class GetRkeyEx extends GetPacketStatusDepends<void, unknown> {
|
|||||||
let rkeys = await this.core.apis.PacketApi.pkt.operation.FetchRkey();
|
let rkeys = await this.core.apis.PacketApi.pkt.operation.FetchRkey();
|
||||||
return rkeys.map(rkey => {
|
return rkeys.map(rkey => {
|
||||||
return {
|
return {
|
||||||
type: rkey.type === 10 ? 'private' : 'group',
|
type: rkey.type === 10 ? "private" : "group",
|
||||||
rkey: rkey.rkey,
|
rkey: rkey.rkey,
|
||||||
created_at: rkey.time,
|
created_at: rkey.time,
|
||||||
ttl: rkey.ttl,
|
ttl: rkey.ttl,
|
||||||
|
|||||||
@ -30,7 +30,7 @@ export class GetRkeyServer extends GetPacketStatusDepends<void, { private_rkey?:
|
|||||||
private_rkey: privateRkeyItem ? privateRkeyItem.rkey : undefined,
|
private_rkey: privateRkeyItem ? privateRkeyItem.rkey : undefined,
|
||||||
group_rkey: groupRkeyItem ? groupRkeyItem.rkey : undefined,
|
group_rkey: groupRkeyItem ? groupRkeyItem.rkey : undefined,
|
||||||
expired_time: this.expiryTime,
|
expired_time: this.expiryTime,
|
||||||
name: 'NapCat 4'
|
name: "NapCat 4"
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.rkeyCache;
|
return this.rkeyCache;
|
||||||
|
|||||||
@ -14,8 +14,8 @@ export class SendPokeBase extends GetPacketStatusDepends<Payload, void> {
|
|||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
// 这里的 !! 可以传入空字符串 忽略这些数据有利用接口统一接口
|
// 这里的 !! 可以传入空字符串 忽略这些数据有利用接口统一接口
|
||||||
const target_id = payload.target_id ? payload.target_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 peer_id = !!payload.group_id ? payload.group_id : payload.user_id;
|
||||||
|
|
||||||
const is_group = !!payload.group_id;
|
const is_group = !!payload.group_id;
|
||||||
if (!target_id || !peer_id) {
|
if (!target_id || !peer_id) {
|
||||||
|
|||||||
@ -14,7 +14,7 @@ export const ActionName = {
|
|||||||
CleanStreamTempFile: 'clean_stream_temp_file',
|
CleanStreamTempFile: 'clean_stream_temp_file',
|
||||||
|
|
||||||
// 所有 Upload/Download Stream Api 应当 _stream 结尾
|
// 所有 Upload/Download Stream Api 应当 _stream 结尾
|
||||||
TestDownloadStream: 'test_download_stream',
|
TestDownloadStream: 'test_download_stream',
|
||||||
UploadFileStream: 'upload_file_stream',
|
UploadFileStream: 'upload_file_stream',
|
||||||
DownloadFileStream: 'download_file_stream',
|
DownloadFileStream: 'download_file_stream',
|
||||||
|
|
||||||
|
|||||||
@ -104,7 +104,7 @@ export class DownloadFileStream extends OneBotAction<Payload, StreamPacket<Downl
|
|||||||
const base64Chunk = chunk.toString('base64');
|
const base64Chunk = chunk.toString('base64');
|
||||||
bytesRead += chunk.length;
|
bytesRead += chunk.length;
|
||||||
|
|
||||||
await req.send({
|
await req.send({
|
||||||
type: StreamStatus.Stream,
|
type: StreamStatus.Stream,
|
||||||
data_type: 'file_chunk',
|
data_type: 'file_chunk',
|
||||||
index: chunkIndex,
|
index: chunkIndex,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { OneBotAction, OneBotRequestToolkit } from '../OneBotAction';
|
import { OneBotAction, OneBotRequestToolkit } from "../OneBotAction";
|
||||||
import { NetworkAdapterConfig } from '@/onebot/config/config';
|
import { NetworkAdapterConfig } from "@/onebot/config/config";
|
||||||
export type StreamPacketBasic = {
|
export type StreamPacketBasic = {
|
||||||
type: StreamStatus;
|
type: StreamStatus;
|
||||||
data_type?: string;
|
data_type?: string;
|
||||||
|
|||||||
@ -154,7 +154,7 @@ export class UploadFileStream extends OneBotAction<Payload, StreamPacket<StreamR
|
|||||||
try {
|
try {
|
||||||
fs.rmSync(stream.tempDir, { recursive: true, force: true });
|
fs.rmSync(stream.tempDir, { recursive: true, force: true });
|
||||||
} catch (cleanupError) {
|
} 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;
|
throw error;
|
||||||
|
|||||||
@ -180,7 +180,7 @@ export class OneBotMsgApi {
|
|||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
url: url,
|
url: url,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
@ -489,7 +489,7 @@ export class OneBotMsgApi {
|
|||||||
url: pttUrl,
|
url: pttUrl,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.voice,
|
type: OB11MessageDataType.voice,
|
||||||
@ -1150,16 +1150,16 @@ export class OneBotMsgApi {
|
|||||||
const calculateTotalSize = async (elements: SendMessageElement[]): Promise<number> => {
|
const calculateTotalSize = async (elements: SendMessageElement[]): Promise<number> => {
|
||||||
const sizePromises = elements.map(async element => {
|
const sizePromises = elements.map(async element => {
|
||||||
switch (element.elementType) {
|
switch (element.elementType) {
|
||||||
case ElementType.PTT:
|
case ElementType.PTT:
|
||||||
return (await fsPromise.stat(element.pttElement.filePath)).size;
|
return (await fsPromise.stat(element.pttElement.filePath)).size;
|
||||||
case ElementType.FILE:
|
case ElementType.FILE:
|
||||||
return (await fsPromise.stat(element.fileElement.filePath)).size;
|
return (await fsPromise.stat(element.fileElement.filePath)).size;
|
||||||
case ElementType.VIDEO:
|
case ElementType.VIDEO:
|
||||||
return (await fsPromise.stat(element.videoElement.filePath)).size;
|
return (await fsPromise.stat(element.videoElement.filePath)).size;
|
||||||
case ElementType.PIC:
|
case ElementType.PIC:
|
||||||
return (await fsPromise.stat(element.picElement.sourcePath)).size;
|
return (await fsPromise.stat(element.picElement.sourcePath)).size;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const sizes = await Promise.all(sizePromises);
|
const sizes = await Promise.all(sizePromises);
|
||||||
@ -1249,16 +1249,16 @@ export class OneBotMsgApi {
|
|||||||
|
|
||||||
groupChangDecreseType2String(type: number): GroupDecreaseSubType {
|
groupChangDecreseType2String(type: number): GroupDecreaseSubType {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 130:
|
case 130:
|
||||||
return 'leave';
|
return 'leave';
|
||||||
case 131:
|
case 131:
|
||||||
return 'kick';
|
return 'kick';
|
||||||
case 3:
|
case 3:
|
||||||
return 'kick_me';
|
return 'kick_me';
|
||||||
case 129:
|
case 129:
|
||||||
return 'disband';
|
return 'disband';
|
||||||
default:
|
default:
|
||||||
return 'kick';
|
return 'kick';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
|
|||||||
await this.onEvent({ ...OB11Response.ok(data, real_echo, true) } as unknown as OB11EmitEventContent);
|
await this.onEvent({ ...OB11Response.ok(data, real_echo, true) } as unknown as OB11EmitEventContent);
|
||||||
} : async (data: object) => {
|
} : async (data: object) => {
|
||||||
let newPromise = new Promise<void>((resolve, _reject) => {
|
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();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -137,7 +137,7 @@ export class OB11HttpServerAdapter extends IOB11NetworkAdapter<HttpServerConfig>
|
|||||||
}
|
}
|
||||||
}, real_echo);
|
}, real_echo);
|
||||||
if (useStream) {
|
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.end();
|
||||||
};
|
};
|
||||||
return res.json(result);
|
return res.json(result);
|
||||||
|
|||||||
@ -74,7 +74,7 @@ export class OB11PluginMangerAdapter extends IOB11NetworkAdapter<PluginConfig> {
|
|||||||
|
|
||||||
this.logger.log(`[Plugin Adapter] Loaded ${this.loadedPlugins.size} plugins`);
|
this.logger.log(`[Plugin Adapter] Loaded ${this.loadedPlugins.size} plugins`);
|
||||||
} catch (error) {
|
} 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`);
|
this.logger.log(`[Plugin Adapter] Loaded ${this.loadedPlugins.size} plugins`);
|
||||||
} catch (error) {
|
} 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));
|
handleLoginInner(context, logger, loginService, quickLoginUin, historyLoginList).then().catch(e => logger.logError(e));
|
||||||
loginListener.onLoginConnected = () => { };
|
loginListener.onLoginConnected = () => { };
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
loginListener.onQRCodeGetPicture = ({ pngBase64QrcodeData, qrcodeUrl }) => {
|
loginListener.onQRCodeGetPicture = ({ pngBase64QrcodeData, qrcodeUrl }) => {
|
||||||
WebUiDataRuntime.setQQLoginQrcodeURL(qrcodeUrl);
|
WebUiDataRuntime.setQQLoginQrcodeURL(qrcodeUrl);
|
||||||
|
|
||||||
@ -222,7 +222,7 @@ async function handleLoginInner(context: { isLogined: boolean }, logger: LogWrap
|
|||||||
logger.log(`可用于快速登录的 QQ:\n${historyLoginList
|
logger.log(`可用于快速登录的 QQ:\n${historyLoginList
|
||||||
.map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`)
|
.map((u, index) => `${index + 1}. ${u.uin} ${u.nickName}`)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
}`);
|
}`);
|
||||||
}
|
}
|
||||||
loginService.getQRCodePicture();
|
loginService.getQRCodePicture();
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user