mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
Compare commits
No commits in common. "5d2d8c7123b7591e200474523d7b819e8cb211d6" and "3a6748ae377f2e2766a5078c42d2e030e06758fa" have entirely different histories.
5d2d8c7123
...
3a6748ae37
@ -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) 对本项目的大力支持 参考部分代码 已获授权
|
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持 参考部分代码 已获授权
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "4.1.12",
|
"version": "4.1.8",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"eslint-plugin-prettier": "^5.2.1",
|
"eslint-plugin-prettier": "^5.2.1",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"tdesign-icons-vue-next": "^0.3.3",
|
|
||||||
"tdesign-vue-next": "^1.10.3",
|
"tdesign-vue-next": "^1.10.3",
|
||||||
"vue": "^3.5.12",
|
"vue": "^3.5.12",
|
||||||
"vue-router": "^4.4.5"
|
"vue-router": "^4.4.5"
|
||||||
@ -21,12 +20,10 @@
|
|||||||
"@eslint/eslintrc": "^3.1.0",
|
"@eslint/eslintrc": "^3.1.0",
|
||||||
"@eslint/js": "^9.14.0",
|
"@eslint/js": "^9.14.0",
|
||||||
"@types/qrcode": "^1.5.5",
|
"@types/qrcode": "^1.5.5",
|
||||||
"@vitejs/plugin-legacy": "^5.4.3",
|
|
||||||
"@vitejs/plugin-vue": "^5.1.4",
|
"@vitejs/plugin-vue": "^5.1.4",
|
||||||
"eslint-config-prettier": "^9.1.0",
|
"eslint-config-prettier": "^9.1.0",
|
||||||
"eslint-plugin-vue": "^9.31.0",
|
"eslint-plugin-vue": "^9.31.0",
|
||||||
"globals": "^15.12.0",
|
"globals": "^15.12.0",
|
||||||
"terser": "^5.36.0",
|
|
||||||
"typescript": "~5.6.2",
|
"typescript": "~5.6.2",
|
||||||
"vite": "^5.4.10",
|
"vite": "^5.4.10",
|
||||||
"vue-tsc": "^2.1.8"
|
"vue-tsc": "^2.1.8"
|
||||||
|
@ -1,17 +1,10 @@
|
|||||||
import { defineConfig } from 'vite';
|
import { defineConfig } from 'vite';
|
||||||
import vue from '@vitejs/plugin-vue';
|
import vue from '@vitejs/plugin-vue';
|
||||||
import legacy from '@vitejs/plugin-legacy';
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [vue()],
|
||||||
vue(),
|
|
||||||
legacy({
|
|
||||||
targets: ['defaults', 'not IE 11'],
|
|
||||||
modernPolyfills: ['web.structured-clone'],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
base: './',
|
base: './',
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
@ -24,18 +17,14 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
chunkSizeWarningLimit: 4000,
|
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
chunkFileNames: 'static/js/[name]-[hash].js',
|
manualChunks(id) {
|
||||||
entryFileNames: 'static/js/[name]-[hash].js',
|
|
||||||
assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
|
|
||||||
manualChunks(id: string) {
|
|
||||||
if (id.includes('node_modules')) {
|
if (id.includes('node_modules')) {
|
||||||
return id.toString().split('node_modules/')[1].split('/')[0].toString();
|
return id.toString().split('node_modules/')[1].split('/')[0].toString();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
});
|
});
|
@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "4.1.12",
|
"version": "4.1.8",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:framework": "npm run build:webui && vite build --mode framework",
|
"build:framework": "npm run build:webui && vite build --mode framework",
|
||||||
"build:shell": "npm run build:webui && vite build --mode shell",
|
"build:shell": "npm run build:webui && vite build --mode shell",
|
||||||
|
@ -1 +1 @@
|
|||||||
export const napCatVersion = '4.1.12';
|
export const napCatVersion = '4.1.8';
|
||||||
|
@ -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);
|
const { md5, fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
throw new Error('文件异常,大小为0');
|
throw new Error('文件异常,大小为0');
|
||||||
@ -412,17 +412,15 @@ export class NTQQFileApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const url: string = element.originImageUrl ?? '';
|
const url: string = element.originImageUrl ?? '';
|
||||||
|
|
||||||
const md5HexStr = element.md5HexStr;
|
const md5HexStr = element.md5HexStr;
|
||||||
const fileMd5 = element.md5HexStr;
|
const fileMd5 = element.md5HexStr;
|
||||||
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
|
|
||||||
const imageAppid = parsedUrl.searchParams.get('appid');
|
if (url) {
|
||||||
const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid);
|
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
|
||||||
const imageFileId = parsedUrl.searchParams.get('fileid');
|
|
||||||
if (url && isNTV2 && imageFileId) {
|
|
||||||
const rkeyData = await this.getRkeyData();
|
const rkeyData = await this.getRkeyData();
|
||||||
return this.getImageUrlFromParsedUrl(imageFileId, imageAppid, rkeyData);
|
return this.getImageUrlFromParsedUrl(parsedUrl, rkeyData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getImageUrlFromMd5(fileMd5, md5HexStr);
|
return this.getImageUrlFromMd5(fileMd5, md5HexStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,12 +462,19 @@ export class NTQQFileApi {
|
|||||||
return rkeyData;
|
return rkeyData;
|
||||||
}
|
}
|
||||||
|
|
||||||
private getImageUrlFromParsedUrl(imageFileId: string, appid: string, rkeyData: any): string {
|
private getImageUrlFromParsedUrl(parsedUrl: URL, rkeyData: any): string {
|
||||||
const rkey = appid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
|
const imageAppid = parsedUrl.searchParams.get('appid');
|
||||||
if (rkeyData.online_rkey) {
|
const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid);
|
||||||
return IMAGE_HTTP_HOST_NT + `/download?appid=${appid}&fileid=${imageFileId}&rkey=${rkey}`;
|
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 {
|
private getImageUrlFromMd5(fileMd5: string | undefined, md5HexStr: string | undefined): string {
|
||||||
|
@ -867,11 +867,9 @@ export class OneBotMsgApi {
|
|||||||
guildId: '',
|
guildId: '',
|
||||||
peerUid: peer.peerUid,
|
peerUid: peer.peerUid,
|
||||||
}, returnMsg.msgId);
|
}, returnMsg.msgId);
|
||||||
setTimeout(() => {
|
deleteAfterSentFiles.forEach(file => {
|
||||||
deleteAfterSentFiles.forEach(file => {
|
fsPromise.unlink(file).then().catch(e => this.core.context.logger.logError.bind(this.core.context.logger)('发送消息删除文件失败', e));
|
||||||
fsPromise.unlink(file).then().catch(e => this.core.context.logger.logError.bind(this.core.context.logger)('发送消息删除文件失败', e));
|
});
|
||||||
});
|
|
||||||
}, 60000);
|
|
||||||
return returnMsg;
|
return returnMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,9 +149,6 @@ export function mergeOneBotConfigs(
|
|||||||
if (userConfig.musicSignUrl !== undefined) {
|
if (userConfig.musicSignUrl !== undefined) {
|
||||||
mergedConfig.musicSignUrl = userConfig.musicSignUrl;
|
mergedConfig.musicSignUrl = userConfig.musicSignUrl;
|
||||||
}
|
}
|
||||||
if(userConfig.enableLocalFile2Url !== undefined) {
|
|
||||||
mergedConfig.enableLocalFile2Url = userConfig.enableLocalFile2Url;
|
|
||||||
}
|
|
||||||
return mergedConfig;
|
return mergedConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import { LogWrapper } from '@/common/log';
|
|||||||
import { NapCatPathWrapper } from '@/common/path';
|
import { NapCatPathWrapper } from '@/common/path';
|
||||||
import { WebUiConfigWrapper } from './src/helper/config';
|
import { WebUiConfigWrapper } from './src/helper/config';
|
||||||
import { RequestUtil } from '@/common/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
import { isIP } from "node:net";
|
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@ -47,29 +46,24 @@ export async function InitWebUi(logger: LogWrapper, pathWrapper: NapCatPathWrapp
|
|||||||
});
|
});
|
||||||
app.use(config.prefix + '/api', ALLRouter);
|
app.use(config.prefix + '/api', ALLRouter);
|
||||||
app.listen(config.port, config.host, async () => {
|
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] Current WebUi is running at http://${config.host}:${config.port}${config.prefix}`);
|
||||||
log(`[NapCat] [WebUi] Login Token is ${config.token}`);
|
log(`[NapCat] [WebUi] Login Token is ${config.token}`);
|
||||||
log(`[NapCat] [WebUi] WebUi User Panel Url: ${createUrl(config.host, '/webui', config.token)}`);
|
log(
|
||||||
log(`[NapCat] [WebUi] WebUi Local Panel Url: ${createUrl('127.0.0.1', '/webui', config.token)}`);
|
`[NapCat] [WebUi] WebUi User Panel Url: http://${config.host}:${config.port}${config.prefix}/webui?token=${config.token}`
|
||||||
try {
|
);
|
||||||
const publishUrl = 'https://ip.011102.xyz/';
|
log(
|
||||||
const data = await RequestUtil.HttpGetJson<{ IP: { IP: string } }>(publishUrl, 'GET', {}, {}, true, true);
|
`[NapCat] [WebUi] WebUi Local Panel Url: http://127.0.0.1:${config.port}${config.prefix}/webui?token=${config.token}`
|
||||||
log("IP data", data);
|
);
|
||||||
log(`[NapCat] [WebUi] WebUi Publish Panel Url: ${createUrl(data.IP.IP, '/webui', config.token)}`);
|
//获取上网Ip
|
||||||
} catch (err) {
|
//https://www.ip.cn/api/index?ip&type=0
|
||||||
logger.logError(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
|
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}`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user