Compare commits

..

No commits in common. "5d2d8c7123b7591e200474523d7b819e8cb211d6" and "3a6748ae377f2e2766a5078c42d2e030e06758fa" have entirely different histories.

10 changed files with 49 additions and 69 deletions

View File

@ -34,7 +34,7 @@ NapCatQQ 是现代化的基于 NTQQ 的 Bot 协议端实现
## 回家旅途
[QQ Group](https://qm.qq.com/q/NWP25OeV0c)
[QQ Group](https://qm.qq.com/q/haLGHixZ74)
## 感谢他们
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持 参考部分代码 已获授权

View File

@ -4,7 +4,7 @@
"name": "NapCatQQ",
"slug": "NapCat.Framework",
"description": "高性能的 OneBot 11 协议实现",
"version": "4.1.12",
"version": "4.1.8",
"icon": "./logo.png",
"authors": [
{

View File

@ -12,7 +12,6 @@
"dependencies": {
"eslint-plugin-prettier": "^5.2.1",
"qrcode": "^1.5.4",
"tdesign-icons-vue-next": "^0.3.3",
"tdesign-vue-next": "^1.10.3",
"vue": "^3.5.12",
"vue-router": "^4.4.5"
@ -21,12 +20,10 @@
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.14.0",
"@types/qrcode": "^1.5.5",
"@vitejs/plugin-legacy": "^5.4.3",
"@vitejs/plugin-vue": "^5.1.4",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-vue": "^9.31.0",
"globals": "^15.12.0",
"terser": "^5.36.0",
"typescript": "~5.6.2",
"vite": "^5.4.10",
"vue-tsc": "^2.1.8"

View File

@ -1,17 +1,10 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import legacy from '@vitejs/plugin-legacy';
import path from 'path';
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
legacy({
targets: ['defaults', 'not IE 11'],
modernPolyfills: ['web.structured-clone'],
}),
],
plugins: [vue()],
base: './',
resolve: {
alias: {
@ -24,18 +17,14 @@ export default defineConfig({
},
},
build: {
chunkSizeWarningLimit: 4000,
rollupOptions: {
output: {
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
manualChunks(id: string) {
manualChunks(id) {
if (id.includes('node_modules')) {
return id.toString().split('node_modules/')[1].split('/')[0].toString();
}
},
},
},
},
});
}
}
}
}
});

View File

@ -2,7 +2,7 @@
"name": "napcat",
"private": true,
"type": "module",
"version": "4.1.12",
"version": "4.1.8",
"scripts": {
"build:framework": "npm run build:webui && vite build --mode framework",
"build:shell": "npm run build:webui && vite build --mode shell",

View File

@ -1 +1 @@
export const napCatVersion = '4.1.12';
export const napCatVersion = '4.1.8';

View File

@ -107,7 +107,7 @@ export class NTQQFileApi {
};
}
async createValidSendPicElement(context: MessageContext, picPath: string, summary: string = '', subType: 0 | 1 = 0): Promise<SendPicElement> {
async createValidSendPicElement(context: MessageContext, picPath: string, summary: string = '', subType: 0 | 1 = 0,): Promise<SendPicElement> {
const { md5, fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
if (fileSize === 0) {
throw new Error('文件异常大小为0');
@ -412,17 +412,15 @@ export class NTQQFileApi {
}
const url: string = element.originImageUrl ?? '';
const md5HexStr = element.md5HexStr;
const fileMd5 = element.md5HexStr;
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
const imageAppid = parsedUrl.searchParams.get('appid');
const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid);
const imageFileId = parsedUrl.searchParams.get('fileid');
if (url && isNTV2 && imageFileId) {
if (url) {
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
const rkeyData = await this.getRkeyData();
return this.getImageUrlFromParsedUrl(imageFileId, imageAppid, rkeyData);
return this.getImageUrlFromParsedUrl(parsedUrl, rkeyData);
}
return this.getImageUrlFromMd5(fileMd5, md5HexStr);
}
@ -464,12 +462,19 @@ export class NTQQFileApi {
return rkeyData;
}
private getImageUrlFromParsedUrl(imageFileId: string, appid: string, rkeyData: any): string {
const rkey = appid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
if (rkeyData.online_rkey) {
return IMAGE_HTTP_HOST_NT + `/download?appid=${appid}&fileid=${imageFileId}&rkey=${rkey}`;
private getImageUrlFromParsedUrl(parsedUrl: URL, rkeyData: any): string {
const imageAppid = parsedUrl.searchParams.get('appid');
const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid);
const imageFileId = parsedUrl.searchParams.get('fileid');
if (isNTV2 && rkeyData.online_rkey) {
const rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
return IMAGE_HTTP_HOST_NT + `/download?appid=${imageAppid}&fileid=${imageFileId}&rkey=${rkey}`;
} else if (isNTV2 && imageFileId) {
const rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
return IMAGE_HTTP_HOST + `/download?appid=${imageAppid}&fileid=${imageFileId}&rkey=${rkey}`;
}
return IMAGE_HTTP_HOST + `/download?appid=${appid}&fileid=${imageFileId}&rkey=${rkey}`;
return '';
}
private getImageUrlFromMd5(fileMd5: string | undefined, md5HexStr: string | undefined): string {

View File

@ -867,11 +867,9 @@ export class OneBotMsgApi {
guildId: '',
peerUid: peer.peerUid,
}, returnMsg.msgId);
setTimeout(() => {
deleteAfterSentFiles.forEach(file => {
fsPromise.unlink(file).then().catch(e => this.core.context.logger.logError.bind(this.core.context.logger)('发送消息删除文件失败', e));
});
}, 60000);
deleteAfterSentFiles.forEach(file => {
fsPromise.unlink(file).then().catch(e => this.core.context.logger.logError.bind(this.core.context.logger)('发送消息删除文件失败', e));
});
return returnMsg;
}

View File

@ -149,9 +149,6 @@ export function mergeOneBotConfigs(
if (userConfig.musicSignUrl !== undefined) {
mergedConfig.musicSignUrl = userConfig.musicSignUrl;
}
if(userConfig.enableLocalFile2Url !== undefined) {
mergedConfig.enableLocalFile2Url = userConfig.enableLocalFile2Url;
}
return mergedConfig;
}

View File

@ -4,7 +4,6 @@ import { LogWrapper } from '@/common/log';
import { NapCatPathWrapper } from '@/common/path';
import { WebUiConfigWrapper } from './src/helper/config';
import { RequestUtil } from '@/common/request';
import { isIP } from "node:net";
const app = express();
@ -47,29 +46,24 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
});
app.use(config.prefix + '/api', ALLRouter);
app.listen(config.port, config.host, async () => {
const normalizeHost = (host: string) => {
if (host === '0.0.0.0') return '127.0.0.1';
if (isIP(host) === 6) return `[${host}]`;
return host;
};
const createUrl = (host: string, path: string, token: string) => {
const url = new URL(`http://${normalizeHost(host)}`);
url.port = config.port.toString();
url.pathname = `${config.prefix}${path}`;
url.searchParams.set('token', token);
return url.toString();
};
log(`[NapCat] [WebUi] Current WebUi is running at http://${config.host}:${config.port}${config.prefix}`);
log(`[NapCat] [WebUi] Login Token is ${config.token}`);
log(`[NapCat] [WebUi] WebUi User Panel Url: ${createUrl(config.host, '/webui', config.token)}`);
log(`[NapCat] [WebUi] WebUi Local Panel Url: ${createUrl('127.0.0.1', '/webui', config.token)}`);
try {
const publishUrl = 'https://ip.011102.xyz/';
const data = await RequestUtil.HttpGetJson<{ IP: { IP: string } }>(publishUrl, 'GET', {}, {}, true, true);
log("IP data", data);
log(`[NapCat] [WebUi] WebUi Publish Panel Url: ${createUrl(data.IP.IP, '/webui', config.token)}`);
} catch (err) {
logger.logError(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
}
log(
`[NapCat] [WebUi] WebUi User Panel Url: http://${config.host}:${config.port}${config.prefix}/webui?token=${config.token}`
);
log(
`[NapCat] [WebUi] WebUi Local Panel Url: http://127.0.0.1:${config.port}${config.prefix}/webui?token=${config.token}`
);
//获取上网Ip
//https://www.ip.cn/api/index?ip&type=0
RequestUtil.HttpGetJson<{ IP: { IP: string } }>('https://ip.011102.xyz/', 'GET', {}, {}, true, true)
.then((data) => {
log(
`[NapCat] [WebUi] WebUi Publish Panel Url: http://${data.IP.IP}:${config.port}${config.prefix}/webui/?token=${config.token}`
);
})
.catch((err) => {
logger.logError.bind(logger)(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
});
});
}