mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
fix: rkey
This commit is contained in:
parent
a5e34645c5
commit
a7fe74bc0c
10
README.md
10
README.md
@ -155,6 +155,16 @@ $env:FFMPEG_PATH="d:\ffmpeg\bin\ffmpeg.exe"
|
|||||||
|
|
||||||
或者手机使用 VPN 等方式连接到服务器网络使其和服务器在同一网络
|
或者手机使用 VPN 等方式连接到服务器网络使其和服务器在同一网络
|
||||||
|
|
||||||
|
### Windows 运行出现 sqlite3 不是 win32 程序
|
||||||
|
|
||||||
|
运行时出现`node_sqlite3.node is not a valid Win32 application`
|
||||||
|
|
||||||
|
尝试自己用 npm 重新安装 sqlite3
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm uninstall sqlite3
|
||||||
|
npm install sqlite3
|
||||||
|
```
|
||||||
### 其他问题
|
### 其他问题
|
||||||
|
|
||||||
NapCat 是基于 QQ 22741 版本开发的,其他版本不敢保证是否会出现一些奇怪的问题,有问题可以尝试安装此版本的 QQ
|
NapCat 是基于 QQ 22741 版本开发的,其他版本不敢保证是否会出现一些奇怪的问题,有问题可以尝试安装此版本的 QQ
|
||||||
|
@ -260,7 +260,7 @@ class DBUtil extends DBUtilBase {
|
|||||||
async updateFileCache(file: DBFile) {
|
async updateFileCache(file: DBFile) {
|
||||||
const stmt = this.db!.prepare('UPDATE files SET path = ?, url = ? WHERE uuid = ?');
|
const stmt = this.db!.prepare('UPDATE files SET path = ?, url = ? WHERE uuid = ?');
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
stmt.run(file.path, file.url, function (err: any) {
|
stmt.run(file.path, file.url,file.uuid, function (err: any) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log('db could not update file cache', err);
|
log('db could not update file cache', err);
|
||||||
reject(err);
|
reject(err);
|
||||||
|
BIN
src/core.lib/MoeHook.node
Normal file
BIN
src/core.lib/MoeHook.node
Normal file
Binary file not shown.
@ -39,7 +39,9 @@ import { OB11GroupCardEvent } from './event/notice/OB11GroupCardEvent';
|
|||||||
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent';
|
import { OB11GroupDecreaseEvent } from './event/notice/OB11GroupDecreaseEvent';
|
||||||
import { ob11Config } from '@/onebot11/config';
|
import { ob11Config } from '@/onebot11/config';
|
||||||
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/common/data';
|
import { deleteGroup, getFriend, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/common/data';
|
||||||
import { NTQQGroupApi, NTQQUserApi } from '@/core/qqnt/apis';
|
import { NTQQFileApi, NTQQGroupApi, NTQQUserApi } from '@/core/qqnt/apis';
|
||||||
|
import { rkeyHook } from '@/core/qqnt/extends/rkey';
|
||||||
|
import http from 'http';
|
||||||
|
|
||||||
|
|
||||||
export class OB11Constructor {
|
export class OB11Constructor {
|
||||||
@ -143,9 +145,10 @@ export class OB11Constructor {
|
|||||||
const fileMd5 = element.picElement.md5HexStr;
|
const fileMd5 = element.picElement.md5HexStr;
|
||||||
const fileUuid = element.picElement.fileUuid;
|
const fileUuid = element.picElement.fileUuid;
|
||||||
// let currentRKey = config.imageRKey || "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
// let currentRKey = config.imageRKey || "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
||||||
const currentRKey = 'CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64';
|
|
||||||
if (url) {
|
if (url) {
|
||||||
if (url.startsWith('/download')) {
|
if (url.startsWith('/download')) {
|
||||||
|
let rkey = rkeyHook.GetRkey();
|
||||||
|
console.log('rkey', rkey);
|
||||||
if (url.includes('&rkey=')) {
|
if (url.includes('&rkey=')) {
|
||||||
// 正则提取rkey
|
// 正则提取rkey
|
||||||
// const rkey = url.match(/&rkey=([^&]+)/)[1]
|
// const rkey = url.match(/&rkey=([^&]+)/)[1]
|
||||||
@ -157,14 +160,57 @@ export class OB11Constructor {
|
|||||||
// getConfigUtil().setConfig(config)
|
// getConfigUtil().setConfig(config)
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
message_data['data']['url'] = IMAGE_HTTP_HOST + url;
|
message_data['data']['url'] = IMAGE_HTTP_HOST_NT + url;
|
||||||
} else {
|
} else {
|
||||||
// 有可能会碰到appid为1406的,这个不能使用新的NT域名,并且需要把appid改为1407才可访问
|
const getRkey = async () => {
|
||||||
let host = IMAGE_HTTP_HOST_NT;
|
await NTQQFileApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid, element.elementId, '', '');
|
||||||
if (url.includes('appid=1406')) {
|
rkey = rkeyHook.GetRkey();
|
||||||
host = IMAGE_HTTP_HOST;
|
};
|
||||||
|
if (!rkey) {
|
||||||
|
// 下载一次图片获取rkey
|
||||||
|
try {
|
||||||
|
await getRkey();
|
||||||
|
} catch (e) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
message_data['data']['url'] = `${host}/download?appid=1407&fileid=${fileUuid}&rkey=${currentRKey}&spec=0`;
|
}
|
||||||
|
let imageUrl = IMAGE_HTTP_HOST_NT + url + `${rkey}`;
|
||||||
|
// 调用head请求获取图片rkey是否正常
|
||||||
|
const checkUrl = new Promise((resolve, reject) => {
|
||||||
|
const options = {
|
||||||
|
method: 'HEAD',
|
||||||
|
host: new URL(imageUrl).host,
|
||||||
|
path: new URL(imageUrl).pathname
|
||||||
|
};
|
||||||
|
const req = http.request(options, (res) => {
|
||||||
|
console.log(`STATUS: ${res.statusCode}`);
|
||||||
|
console.log(`HEADERS: ${JSON.stringify(res.headers)}`);
|
||||||
|
|
||||||
|
if (res.statusCode == 200) {
|
||||||
|
console.log('The Image URL is accessible.');
|
||||||
|
resolve('ok');
|
||||||
|
} else {
|
||||||
|
reject('The Image URL is not accessible.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (e) => {
|
||||||
|
console.error(`problem with request: ${e.message}`);
|
||||||
|
reject(e.message);
|
||||||
|
});
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
await checkUrl;
|
||||||
|
} catch (e) {
|
||||||
|
try {
|
||||||
|
await getRkey();
|
||||||
|
imageUrl = IMAGE_HTTP_HOST_NT + url + `${rkey}`;
|
||||||
|
} catch (e) {
|
||||||
|
log('获取rkey失败', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message_data['data']['url'] = imageUrl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
message_data['data']['url'] = IMAGE_HTTP_HOST + url;
|
message_data['data']['url'] = IMAGE_HTTP_HOST + url;
|
||||||
@ -237,12 +283,10 @@ export class OB11Constructor {
|
|||||||
if (faceId === FaceIndex.dice) {
|
if (faceId === FaceIndex.dice) {
|
||||||
message_data['type'] = OB11MessageDataType.dice;
|
message_data['type'] = OB11MessageDataType.dice;
|
||||||
message_data['data']['result'] = element.faceElement.resultId;
|
message_data['data']['result'] = element.faceElement.resultId;
|
||||||
}
|
} else if (faceId === FaceIndex.RPS) {
|
||||||
else if (faceId === FaceIndex.RPS){
|
|
||||||
message_data['type'] = OB11MessageDataType.RPS;
|
message_data['type'] = OB11MessageDataType.RPS;
|
||||||
message_data['data']['result'] = element.faceElement.resultId;
|
message_data['data']['result'] = element.faceElement.resultId;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
message_data['type'] = OB11MessageDataType.face;
|
message_data['type'] = OB11MessageDataType.face;
|
||||||
message_data['data']['id'] = element.faceElement.faceIndex.toString();
|
message_data['data']['id'] = element.faceElement.faceIndex.toString();
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { rkeyHook } from '@/core/qqnt/extends/rkey';
|
||||||
import { napCatCore } from '@/core';
|
import { napCatCore } from '@/core';
|
||||||
import { MsgListener } from '@/core/qqnt/listeners';
|
import { MsgListener } from '@/core/qqnt/listeners';
|
||||||
import { NapCatOnebot11 } from '@/onebot11/main';
|
import { NapCatOnebot11 } from '@/onebot11/main';
|
||||||
@ -38,6 +39,12 @@ checkVersion().then((remoteVersion: string) => {
|
|||||||
new NapCatOnebot11();
|
new NapCatOnebot11();
|
||||||
napCatCore.addLoginSuccessCallback(() => {
|
napCatCore.addLoginSuccessCallback(() => {
|
||||||
console.log('login success');
|
console.log('login success');
|
||||||
|
try{
|
||||||
|
|
||||||
|
console.log(rkeyHook.HookRkey());
|
||||||
|
}catch (e) {
|
||||||
|
console.error();
|
||||||
|
}
|
||||||
postLoginStatus();
|
postLoginStatus();
|
||||||
const msgListener = new MsgListener();
|
const msgListener = new MsgListener();
|
||||||
msgListener.onRecvMsg = (msg) => {
|
msgListener.onRecvMsg = (msg) => {
|
||||||
|
@ -11,7 +11,7 @@ import os from 'node:os';
|
|||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
|
||||||
const external = ['silk-wasm', 'ws', 'express', 'uuid', 'fluent-ffmpeg', 'sqlite3', 'log4js',
|
const external = ['silk-wasm', 'ws', 'express', 'uuid', 'fluent-ffmpeg', 'sqlite3', 'log4js',
|
||||||
'qrcode-terminal'];
|
'qrcode-terminal', 'MoeHook'];
|
||||||
|
|
||||||
const nodeModules = [...builtinModules, builtinModules.map(m => `node:${m}`)].flat();
|
const nodeModules = [...builtinModules, builtinModules.map(m => `node:${m}`)].flat();
|
||||||
// let nodeModules = ["fs", "path", "events", "buffer", "url", "crypto", "fs/promise", "fsPromise", "os", "http", "net"]
|
// let nodeModules = ["fs", "path", "events", "buffer", "url", "crypto", "fs/promise", "fsPromise", "os", "http", "net"]
|
||||||
@ -37,6 +37,7 @@ const baseConfigPlugin: PluginOption[] = [
|
|||||||
{ src: './src/onebot11/onebot11.json', dest: 'dist/config/' },
|
{ src: './src/onebot11/onebot11.json', dest: 'dist/config/' },
|
||||||
{ src: './package.json', dest: 'dist' },
|
{ src: './package.json', dest: 'dist' },
|
||||||
{ src: './README.md', dest: 'dist' },
|
{ src: './README.md', dest: 'dist' },
|
||||||
|
{ src: './src/core.lib/MoeHook.node', dest: 'dist' },
|
||||||
...(startScripts.map((startScript) => {
|
...(startScripts.map((startScript) => {
|
||||||
return { src: startScript, dest: 'dist' };
|
return { src: startScript, dest: 'dist' };
|
||||||
})),
|
})),
|
||||||
|
Loading…
Reference in New Issue
Block a user