mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
87 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
964014fc5c | ||
![]() |
fc2bb6d8c3 | ||
![]() |
1b10252d76 | ||
![]() |
ad8af12a10 | ||
![]() |
b040c9b118 | ||
![]() |
f6da7da90b | ||
![]() |
a745185408 | ||
![]() |
d3336f9027 | ||
![]() |
daf42c8203 | ||
![]() |
0a18bae3b5 | ||
![]() |
919705966c | ||
![]() |
2c54aee63e | ||
![]() |
3f80bdf2a3 | ||
![]() |
1c429b8dd3 | ||
![]() |
5669e2b0b7 | ||
![]() |
1a6a43babf | ||
![]() |
2650db5ddc | ||
![]() |
255491a107 | ||
![]() |
5c64147dfa | ||
![]() |
39f4118577 | ||
![]() |
f7f6e4736a | ||
![]() |
c635da7ebb | ||
![]() |
58124b006a | ||
![]() |
563aeccd0f | ||
![]() |
bd1a95a7f5 | ||
![]() |
cdb25828f2 | ||
![]() |
45803b3b23 | ||
![]() |
0e5e3d3383 | ||
![]() |
4672930037 | ||
![]() |
09be7131c3 | ||
![]() |
a804f90b9c | ||
![]() |
264cb6bbd2 | ||
![]() |
b7772e867b | ||
![]() |
cc0e77abfb | ||
![]() |
537d1c6f4f | ||
![]() |
80facadd67 | ||
![]() |
ba097dad23 | ||
![]() |
c13c15d046 | ||
![]() |
4f52128a06 | ||
![]() |
500b2d0e6d | ||
![]() |
e59d094feb | ||
![]() |
a8372f14f8 | ||
![]() |
5174ff422d | ||
![]() |
5c06751c3b | ||
![]() |
ac2b0118a6 | ||
![]() |
3eb8fd4abe | ||
![]() |
48b389ebe3 | ||
![]() |
065adeb2cd | ||
![]() |
269d0a06fe | ||
![]() |
8eca26b1a5 | ||
![]() |
3019ef7de4 | ||
![]() |
522311b547 | ||
![]() |
21061561ec | ||
![]() |
b83c41ad56 | ||
![]() |
e80a1cc64a | ||
![]() |
a01e4ca89f | ||
![]() |
c20362e9b6 | ||
![]() |
c90cfb99bd | ||
![]() |
7bcea14799 | ||
![]() |
b415c1a6d1 | ||
![]() |
452c72d280 | ||
![]() |
48350be625 | ||
![]() |
ab824fb219 | ||
![]() |
043d8a1861 | ||
![]() |
074ac15d0f | ||
![]() |
d36a28fa81 | ||
![]() |
ba12bc6c91 | ||
![]() |
87332778e5 | ||
![]() |
453feb8473 | ||
![]() |
8ff469974c | ||
![]() |
994ec5ac0f | ||
![]() |
43f7f9a363 | ||
![]() |
4a11ebc9b9 | ||
![]() |
d76a1305e7 | ||
![]() |
6a0d592491 | ||
![]() |
9898c2196d | ||
![]() |
41a8dc840f | ||
![]() |
c3eaae9d88 | ||
![]() |
3ca959b7a6 | ||
![]() |
1d2e2b6e5c | ||
![]() |
31d963c4d1 | ||
![]() |
7e96118cdc | ||
![]() |
709a0744bd | ||
![]() |
f59248cc5a | ||
![]() |
8647c5c607 | ||
![]() |
6699ff38a1 | ||
![]() |
d79b98bd55 |
@@ -17,5 +17,8 @@ charset = utf-8
|
|||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
|
|
||||||
|
[*.bat]
|
||||||
|
charset = latin1
|
||||||
|
|
||||||
# Unfortunately, EditorConfig doesn't support space configuration inside import braces directly.
|
# Unfortunately, EditorConfig doesn't support space configuration inside import braces directly.
|
||||||
# You'll need to rely on your linter/formatter like ESLint or Prettier for that.
|
# You'll need to rely on your linter/formatter like ESLint or Prettier for that.
|
||||||
|
3
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
3
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@@ -10,6 +10,7 @@ body:
|
|||||||
在提交新的 Bug 反馈前,请确保您:
|
在提交新的 Bug 反馈前,请确保您:
|
||||||
* 已经搜索了现有的 issues,并且没有找到可以解决您问题的方法
|
* 已经搜索了现有的 issues,并且没有找到可以解决您问题的方法
|
||||||
* 不与现有的某一 issue 重复
|
* 不与现有的某一 issue 重复
|
||||||
|
* 不涉及[已经停止维护的特性](https://github.com/NapNeko/NapCatQQ?tab=readme-ov-file#挥别昨日),例如 CQ 码
|
||||||
- type: input
|
- type: input
|
||||||
id: system-version
|
id: system-version
|
||||||
attributes:
|
attributes:
|
||||||
@@ -78,4 +79,4 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: OneBot 客户端运行日志
|
label: OneBot 客户端运行日志
|
||||||
description: 粘贴 OneBot 客户端的相关日志内容到此处
|
description: 粘贴 OneBot 客户端的相关日志内容到此处
|
||||||
render: shell
|
render: shell
|
||||||
|
@@ -9,6 +9,8 @@ NapCatQQ (aka 猫猫框架) 是现代化的基于 NTQQ 的 Bot 协议端实现
|
|||||||
## 猫猫技能
|
## 猫猫技能
|
||||||
- [x] **高性能**:1K+ 群聊数目、20 线程并行发送消息毫无压力
|
- [x] **高性能**:1K+ 群聊数目、20 线程并行发送消息毫无压力
|
||||||
- [x] **多种启动方式**:支持以无头、LiteLoader 插件、仅 QQ GUI 三种方式启动
|
- [x] **多种启动方式**:支持以无头、LiteLoader 插件、仅 QQ GUI 三种方式启动
|
||||||
|
- [x] **多平台支持**: 覆盖 Windows / Linux (可选 Docker) / Android Termux / MacOS
|
||||||
|
- [x] **安装简单**: 支持一键脚本/程序自动部署/镜像部署等多种覆盖范围
|
||||||
- [x] **低占用**:无头模式占用资源极低,适合在服务器上运行
|
- [x] **低占用**:无头模式占用资源极低,适合在服务器上运行
|
||||||
- [x] **超多接口**:实现大部分 OneBot 和 go-cqhttp 接口,超多扩展 API
|
- [x] **超多接口**:实现大部分 OneBot 和 go-cqhttp 接口,超多扩展 API
|
||||||
- [x] **WebUI**:自带 WebUI 支持,远程管理更加便捷
|
- [x] **WebUI**:自带 WebUI 支持,远程管理更加便捷
|
||||||
@@ -26,14 +28,16 @@ NapCatQQ (aka 猫猫框架) 是现代化的基于 NTQQ 的 Bot 协议端实现
|
|||||||
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
[Telegram Link](https://t.me/+nLZEnpne-pQ1OWFl)
|
||||||
|
|
||||||
## 猫猫朋友
|
## 猫猫朋友
|
||||||
感谢 [LLOneBot](https://github.com/LLOneBot/LLOneBot) 提供初始版本基础
|
感谢 [LLOneBot](https://github.com/LLOneBot/LLOneBot) 提供部分参考
|
||||||
|
|
||||||
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持
|
感谢 [Lagrange](https://github.com/LagrangeDev/Lagrange.Core) 对本项目的大力支持
|
||||||
|
|
||||||
|
不过最最重要的 还是需要感谢屏幕前的你哦~
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 约法三章
|
## 约法三章
|
||||||
> [!CAUTION]\
|
> [!CAUTION]\
|
||||||
> **请不要在 QQ 官方群聊和任何影响力较大的简中互联网平台(包括但不限于: 哔哩哔哩,微博,知乎,抖音等)发布和讨论*任何*与本项目存在相关性的信息**
|
> **请不要在 QQ 官方群聊和任何影响力较大的简中互联网平台(包括但不限于: 哔哩哔哩,微博,知乎,抖音等)发布和讨论*任何*与本项目存在相关性的信息**
|
||||||
|
|
||||||
任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**此外,禁止任何项目未经授权二次分发或基于 NapCat 代码开发。**
|
任何使用本仓库代码的地方,都应当严格遵守[本仓库开源许可](./LICENSE)。**此外,禁止任何项目未经授权二次分发或基于 NapCat 代码开发。**
|
BIN
launcher/NapCatWinBootHook.dll
Normal file
BIN
launcher/NapCatWinBootHook.dll
Normal file
Binary file not shown.
BIN
launcher/NapCatWinBootMain.exe
Normal file
BIN
launcher/NapCatWinBootMain.exe
Normal file
Binary file not shown.
40
launcher/launcher-win10.bat
Normal file
40
launcher/launcher-win10.bat
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001
|
||||||
|
net session >nul 2>&1
|
||||||
|
if %errorLevel% == 0 (
|
||||||
|
echo Administrator mode detected.
|
||||||
|
) else (
|
||||||
|
echo Please run this script in administrator mode.
|
||||||
|
powershell -Command "Start-Process 'cmd.exe' -ArgumentList '/c cd /d \"%cd%\" && \"%~f0\"' -Verb runAs"
|
||||||
|
exit
|
||||||
|
)
|
||||||
|
|
||||||
|
set NAPCAT_PATCH_PATH=%cd%\patchNapCat.js
|
||||||
|
set NAPCAT_LOAD_PATH=%cd%\loadNapCat.js
|
||||||
|
set NAPCAT_INJECT_PATH=%cd%\NapCatWinBootHook.dll
|
||||||
|
set NAPCAT_LAUNCHER_PATH=%cd%\NapCatWinBootMain.exe
|
||||||
|
set NAPCAT_MAIN_PATH=%cd%\napcat.mjs
|
||||||
|
:loop_read
|
||||||
|
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do (
|
||||||
|
set RetString=%%b
|
||||||
|
goto :napcat_boot
|
||||||
|
)
|
||||||
|
|
||||||
|
:napcat_boot
|
||||||
|
for %%a in ("%RetString%") do (
|
||||||
|
set "pathWithoutUninstall=%%~dpa"
|
||||||
|
)
|
||||||
|
|
||||||
|
SET QQPath=%pathWithoutUninstall%QQ.exe
|
||||||
|
|
||||||
|
if not exist "%QQpath%" (
|
||||||
|
echo provided QQ path is invalid: %QQpath%
|
||||||
|
pause
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
set NAPCAT_MAIN_PATH=%NAPCAT_MAIN_PATH:\=/%
|
||||||
|
echo (async () =^> {await import("file:///%NAPCAT_MAIN_PATH%")})() > %NAPCAT_LOAD_PATH%
|
||||||
|
|
||||||
|
"%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%"
|
||||||
|
|
||||||
|
REM "%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%" 123456
|
41
launcher/launcher.bat
Normal file
41
launcher/launcher.bat
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
@echo off
|
||||||
|
chcp 65001
|
||||||
|
net session >nul 2>&1
|
||||||
|
if %errorLevel% == 0 (
|
||||||
|
echo Administrator mode detected.
|
||||||
|
) else (
|
||||||
|
echo Please run this script in administrator mode.
|
||||||
|
powershell -Command "Start-Process 'wt.exe' -ArgumentList 'cmd /c cd /d \"%cd%\" && \"%~f0\"' -Verb runAs"
|
||||||
|
exit
|
||||||
|
)
|
||||||
|
|
||||||
|
set NAPCAT_PATCH_PATH=%cd%\patchNapCat.js
|
||||||
|
set NAPCAT_LOAD_PATH=%cd%\loadNapCat.js
|
||||||
|
set NAPCAT_INJECT_PATH=%cd%\NapCatWinBootHook.dll
|
||||||
|
set NAPCAT_LAUNCHER_PATH=%cd%\NapCatWinBootMain.exe
|
||||||
|
set NAPCAT_MAIN_PATH=%cd%\napcat.mjs
|
||||||
|
:loop_read
|
||||||
|
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do (
|
||||||
|
set RetString=%%b
|
||||||
|
goto :napcat_boot
|
||||||
|
)
|
||||||
|
|
||||||
|
:napcat_boot
|
||||||
|
for %%a in ("%RetString%") do (
|
||||||
|
set "pathWithoutUninstall=%%~dpa"
|
||||||
|
)
|
||||||
|
|
||||||
|
SET QQPath=%pathWithoutUninstall%QQ.exe
|
||||||
|
|
||||||
|
if not exist "%QQpath%" (
|
||||||
|
echo provided QQ path is invalid: %QQpath%
|
||||||
|
pause
|
||||||
|
exit /b
|
||||||
|
)
|
||||||
|
|
||||||
|
set NAPCAT_MAIN_PATH=%NAPCAT_MAIN_PATH:\=/%
|
||||||
|
echo (async () =^> {await import("file:///%NAPCAT_MAIN_PATH%")})() > %NAPCAT_LOAD_PATH%
|
||||||
|
|
||||||
|
"%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%"
|
||||||
|
|
||||||
|
REM "%NAPCAT_LAUNCHER_PATH%" "%QQPath%" "%NAPCAT_INJECT_PATH%" 123456
|
5
launcher/loadNapCat.js
Normal file
5
launcher/loadNapCat.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const CurrentPath = path.dirname(__filename);
|
||||||
|
(async () => {
|
||||||
|
await import("file://" + path.join(CurrentPath, './napcat/napcat.mjs'));
|
||||||
|
})();
|
1
launcher/patchNapCat.js
Normal file
1
launcher/patchNapCat.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
require('./launcher.node').load('external_index', module);
|
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "2.2.42",
|
"version": "2.4.4",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.2.42",
|
"version": "2.4.4",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:framework": "vite build --mode framework",
|
"build:framework": "vite build --mode framework",
|
||||||
"build:shell": "vite build --mode shell",
|
"build:shell": "vite build --mode shell",
|
||||||
|
@@ -1,66 +1,64 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { encode, getDuration, getWavFileInfo, isSilk, isWav } from 'silk-wasm';
|
|
||||||
import fsPromise from 'fs/promises';
|
import fsPromise from 'fs/promises';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { spawn } from 'node:child_process';
|
import { spawn } from 'node:child_process';
|
||||||
|
import { encode, getDuration, getWavFileInfo, isSilk, isWav } from 'silk-wasm';
|
||||||
import { LogWrapper } from './log';
|
import { LogWrapper } from './log';
|
||||||
|
|
||||||
export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: LogWrapper) {
|
const ALLOW_SAMPLE_RATE = [8000, 12000, 16000, 24000, 32000, 44100, 48000];
|
||||||
async function guessDuration(pttPath: string) {
|
const EXIT_CODES = [0, 255];
|
||||||
const pttFileInfo = await fsPromise.stat(pttPath);
|
const FFMPEG_PATH = process.env.FFMPEG_PATH || 'ffmpeg';
|
||||||
let duration = pttFileInfo.size / 1024 / 3; // 3kb/s
|
|
||||||
duration = Math.floor(duration);
|
|
||||||
duration = Math.max(1, duration);
|
|
||||||
logger.log('通过文件大小估算语音的时长:', duration);
|
|
||||||
return duration;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
async function guessDuration(pttPath: string, logger: LogWrapper) {
|
||||||
|
const pttFileInfo = await fsPromise.stat(pttPath);
|
||||||
|
let duration = Math.max(1, Math.floor(pttFileInfo.size / 1024 / 3)); // 3kb/s
|
||||||
|
logger.log('通过文件大小估算语音的时长:', duration);
|
||||||
|
return duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function convert(filePath: string, pcmPath: string, logger: LogWrapper): Promise<Buffer> {
|
||||||
|
return new Promise<Buffer>((resolve, reject) => {
|
||||||
|
const cp = spawn(FFMPEG_PATH, ['-y', '-i', filePath, '-ar', '24000', '-ac', '1', '-f', 's16le', pcmPath]);
|
||||||
|
cp.on('error', err => {
|
||||||
|
logger.log('FFmpeg处理转换出错: ', err.message);
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
cp.on('exit', async (code, signal) => {
|
||||||
|
if (code == null || EXIT_CODES.includes(code)) {
|
||||||
|
try {
|
||||||
|
const data = await fsPromise.readFile(pcmPath);
|
||||||
|
await fsPromise.unlink(pcmPath);
|
||||||
|
resolve(data);
|
||||||
|
} catch (err) {
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.log(`FFmpeg exit: code=${code ?? 'unknown'} sig=${signal ?? 'unknown'}`);
|
||||||
|
reject(new Error('FFmpeg处理转换失败'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleWavFile(file: Buffer, filePath: string, pcmPath: string, logger: LogWrapper): Promise<Buffer> {
|
||||||
|
const { fmt } = getWavFileInfo(file);
|
||||||
|
if (!ALLOW_SAMPLE_RATE.includes(fmt.sampleRate)) {
|
||||||
|
return await convert(filePath, pcmPath, logger);
|
||||||
|
}
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: LogWrapper) {
|
||||||
try {
|
try {
|
||||||
const file = await fsPromise.readFile(filePath);
|
const file = await fsPromise.readFile(filePath);
|
||||||
const pttPath = path.join(TEMP_DIR, randomUUID());
|
const pttPath = path.join(TEMP_DIR, randomUUID());
|
||||||
if (!isSilk(file)) {
|
if (!isSilk(file)) {
|
||||||
logger.log(`语音文件${filePath}需要转换成silk`);
|
logger.log(`语音文件${filePath}需要转换成silk`);
|
||||||
const _isWav = isWav(file);
|
const pcmPath = `${pttPath}.pcm`;
|
||||||
const pcmPath = pttPath + '.pcm';
|
const input = isWav(file) ? await handleWavFile(file, filePath, pcmPath, logger) : await convert(filePath, pcmPath, logger);
|
||||||
let sampleRate = 0;
|
const silk = await encode(input, 24000);
|
||||||
const convert = () => {
|
await fsPromise.writeFile(pttPath, silk.data);
|
||||||
return new Promise<Buffer>((resolve, reject) => {
|
|
||||||
// todo: 通过配置文件获取ffmpeg路径
|
|
||||||
const ffmpegPath = process.env.FFMPEG_PATH || 'ffmpeg';
|
|
||||||
const cp = spawn(ffmpegPath, ['-y', '-i', filePath, '-ar', '24000', '-ac', '1', '-f', 's16le', pcmPath]);
|
|
||||||
cp.on('error', err => {
|
|
||||||
logger.log('FFmpeg处理转换出错: ', err.message);
|
|
||||||
return reject(err);
|
|
||||||
});
|
|
||||||
cp.on('exit', (code, signal) => {
|
|
||||||
const EXIT_CODES = [0, 255];
|
|
||||||
if (code == null || EXIT_CODES.includes(code)) {
|
|
||||||
sampleRate = 24000;
|
|
||||||
const data = fs.readFileSync(pcmPath);
|
|
||||||
fs.unlink(pcmPath, (err) => {
|
|
||||||
});
|
|
||||||
return resolve(data);
|
|
||||||
}
|
|
||||||
logger.log(`FFmpeg exit: code=${code ?? 'unknown'} sig=${signal ?? 'unknown'}`);
|
|
||||||
reject(Error('FFmpeg处理转换失败'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
let input: Buffer;
|
|
||||||
if (!_isWav) {
|
|
||||||
input = await convert();
|
|
||||||
} else {
|
|
||||||
input = file;
|
|
||||||
const allowSampleRate = [8000, 12000, 16000, 24000, 32000, 44100, 48000];
|
|
||||||
const { fmt } = getWavFileInfo(input);
|
|
||||||
// log(`wav文件信息`, fmt)
|
|
||||||
if (!allowSampleRate.includes(fmt.sampleRate)) {
|
|
||||||
input = await convert();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const silk = await encode(input, sampleRate);
|
|
||||||
fs.writeFileSync(pttPath, silk.data);
|
|
||||||
logger.log(`语音文件${filePath}转换成功!`, pttPath, '时长:', silk.duration);
|
logger.log(`语音文件${filePath}转换成功!`, pttPath, '时长:', silk.duration);
|
||||||
return {
|
return {
|
||||||
converted: true,
|
converted: true,
|
||||||
@@ -68,15 +66,13 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log
|
|||||||
duration: silk.duration / 1000,
|
duration: silk.duration / 1000,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
const silk = file;
|
|
||||||
let duration = 0;
|
let duration = 0;
|
||||||
try {
|
try {
|
||||||
duration = getDuration(silk) / 1000;
|
duration = getDuration(file) / 1000;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
logger.log('获取语音文件时长失败, 使用文件大小推测时长', filePath, e.stack);
|
logger.log('获取语音文件时长失败, 使用文件大小推测时长', filePath, e.stack);
|
||||||
duration = await guessDuration(filePath);
|
duration = await guessDuration(filePath, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
converted: false,
|
converted: false,
|
||||||
path: filePath,
|
path: filePath,
|
||||||
@@ -87,4 +83,4 @@ export async function encodeSilk(filePath: string, TEMP_DIR: string, logger: Log
|
|||||||
logger.logError('convert silk failed', error.stack);
|
logger.logError('convert silk failed', error.stack);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -22,9 +22,14 @@ export abstract class ConfigBase<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getConfigPath(pathName: string | undefined): string {
|
getConfigPath(pathName: string | undefined): string {
|
||||||
const suffix = pathName ? `_${pathName}` : '';
|
if (!pathName) {
|
||||||
const filename = `${this.name}${suffix}.json`;
|
const filename = `${this.name}.json`;
|
||||||
return path.join(this.configPath, filename);
|
const mainPath = this.core.context.pathWrapper.binaryPath;
|
||||||
|
return path.join(mainPath, 'config', filename);
|
||||||
|
} else {
|
||||||
|
const filename = `${this.name}_${pathName}.json`;
|
||||||
|
return path.join(this.configPath, filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
read(): T {
|
read(): T {
|
||||||
|
@@ -215,6 +215,10 @@ export async function checkUriType(Uri: string) {
|
|||||||
}
|
}
|
||||||
return { Uri: filePath, Type: FileUriType.Local };
|
return { Uri: filePath, Type: FileUriType.Local };
|
||||||
}
|
}
|
||||||
|
if (uri.startsWith('data:')) {
|
||||||
|
const data = uri.split(',')[1];
|
||||||
|
if (data) return { Uri: data, Type: FileUriType.Base64 };
|
||||||
|
}
|
||||||
}, Uri);
|
}, Uri);
|
||||||
if (OtherFileRet) return OtherFileRet;
|
if (OtherFileRet) return OtherFileRet;
|
||||||
|
|
||||||
@@ -231,7 +235,8 @@ export async function uri2local(dir: string, uri: string, filename: string | und
|
|||||||
//解析File协议和本地文件
|
//解析File协议和本地文件
|
||||||
if (UriType == FileUriType.Local) {
|
if (UriType == FileUriType.Local) {
|
||||||
const fileExt = path.extname(HandledUri);
|
const fileExt = path.extname(HandledUri);
|
||||||
const filename = path.basename(HandledUri, fileExt);
|
let filename = path.basename(HandledUri, fileExt);
|
||||||
|
filename += fileExt;
|
||||||
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: HandledUri, isLocal: true };
|
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: HandledUri, isLocal: true };
|
||||||
}
|
}
|
||||||
//接下来都要有文件名
|
//接下来都要有文件名
|
||||||
@@ -251,7 +256,7 @@ export async function uri2local(dir: string, uri: string, filename: string | und
|
|||||||
const filePath = path.join(dir, filename);
|
const filePath = path.join(dir, filename);
|
||||||
const buffer = await httpDownload(HandledUri);
|
const buffer = await httpDownload(HandledUri);
|
||||||
fs.writeFileSync(filePath, buffer);
|
fs.writeFileSync(filePath, buffer);
|
||||||
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: true };
|
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: false };
|
||||||
}
|
}
|
||||||
//解析Base64
|
//解析Base64
|
||||||
if (UriType == FileUriType.Base64) {
|
if (UriType == FileUriType.Base64) {
|
||||||
@@ -266,7 +271,7 @@ export async function uri2local(dir: string, uri: string, filename: string | und
|
|||||||
fileExt = ext;
|
fileExt = ext;
|
||||||
filename = filename + '.' + ext;
|
filename = filename + '.' + ext;
|
||||||
}
|
}
|
||||||
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: true };
|
return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath, isLocal: false };
|
||||||
}
|
}
|
||||||
return { success: false, errMsg: '未知文件类型', fileName: '', ext: '', path: '', isLocal: false };
|
return { success: false, errMsg: '未知文件类型', fileName: '', ext: '', path: '', isLocal: false };
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,13 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class FileNapCatOneBotUUID {
|
export class FileNapCatOneBotUUID {
|
||||||
static encodeModelId(peer: Peer, modelId: string, fileId: string): string {
|
static encodeModelId(peer: Peer, modelId: string, fileId: string, endString: string = ""): string {
|
||||||
return `NapCatOneBot|ModelIdFile|${peer.chatType}|${peer.peerUid}|${modelId}|${fileId}`;
|
const data = `NapCatOneBot|ModelIdFile|${peer.chatType}|${peer.peerUid}|${modelId}|${fileId}`;
|
||||||
|
//前四个字节塞data长度
|
||||||
|
const length = Buffer.alloc(4 + data.length);
|
||||||
|
length.writeUInt32BE(data.length * 2, 0);//储存data的hex长度
|
||||||
|
length.write(data, 4);
|
||||||
|
return length.toString('hex') + endString;
|
||||||
}
|
}
|
||||||
|
|
||||||
static decodeModelId(uuid: string): undefined | {
|
static decodeModelId(uuid: string): undefined | {
|
||||||
@@ -34,10 +39,16 @@ export class FileNapCatOneBotUUID {
|
|||||||
modelId: string,
|
modelId: string,
|
||||||
fileId: string
|
fileId: string
|
||||||
} {
|
} {
|
||||||
if (!uuid.startsWith('NapCatOneBot|ModelIdFile|')) return undefined;
|
//前四个字节是data长度
|
||||||
const data = uuid.split('|');
|
const length = Buffer.from(uuid.slice(0, 8), 'hex').readUInt32BE(0);
|
||||||
|
//根据length计算需要读取的长度
|
||||||
|
const dataId = uuid.slice(8, 8 + length);
|
||||||
|
//hex还原为string
|
||||||
|
const realData = Buffer.from(dataId, 'hex').toString();
|
||||||
|
if (!realData.startsWith('NapCatOneBot|ModelIdFile|')) return undefined;
|
||||||
|
const data = realData.split('|');
|
||||||
if (data.length !== 6) return undefined;
|
if (data.length !== 6) return undefined;
|
||||||
const [, , chatType, peerUid, modelId,fileId] = data;
|
const [, , chatType, peerUid, modelId, fileId] = data;
|
||||||
return {
|
return {
|
||||||
peer: {
|
peer: {
|
||||||
chatType: chatType as any,
|
chatType: chatType as any,
|
||||||
@@ -48,8 +59,14 @@ export class FileNapCatOneBotUUID {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static encode(peer: Peer, msgId: string, elementId: string): string {
|
static encode(peer: Peer, msgId: string, elementId: string, endString: string = ""): string {
|
||||||
return `NapCatOneBot|MsgFile|${peer.chatType}|${peer.peerUid}|${msgId}|${elementId}`;
|
const data = `NapCatOneBot|MsgFile|${peer.chatType}|${peer.peerUid}|${msgId}|${elementId}`;
|
||||||
|
//前四个字节塞data长度
|
||||||
|
//一个字节8位 一个ascii字符1字节 一个hex字符4位 表示一个ascii字符需要两个hex字符
|
||||||
|
const length = Buffer.alloc(4 + data.length);
|
||||||
|
length.writeUInt32BE(data.length * 2, 0);
|
||||||
|
length.write(data, 4);
|
||||||
|
return length.toString('hex') + endString;
|
||||||
}
|
}
|
||||||
|
|
||||||
static decode(uuid: string): undefined | {
|
static decode(uuid: string): undefined | {
|
||||||
@@ -57,8 +74,14 @@ export class FileNapCatOneBotUUID {
|
|||||||
msgId: string,
|
msgId: string,
|
||||||
elementId: string
|
elementId: string
|
||||||
} {
|
} {
|
||||||
if (!uuid.startsWith('NapCatOneBot|MsgFile|')) return undefined;
|
//前四个字节是data长度
|
||||||
const data = uuid.split('|');
|
const length = Buffer.from(uuid.slice(0, 8), 'hex').readUInt32BE(0);
|
||||||
|
//根据length计算需要读取的长度
|
||||||
|
const dataId = uuid.slice(8, 8 + length);
|
||||||
|
//hex还原为string
|
||||||
|
const realData = Buffer.from(dataId, 'hex').toString();
|
||||||
|
if (!realData.startsWith('NapCatOneBot|MsgFile|')) return undefined;
|
||||||
|
const data = realData.split('|');
|
||||||
if (data.length !== 6) return undefined;
|
if (data.length !== 6) return undefined;
|
||||||
const [, , chatType, peerUid, msgId, elementId] = data;
|
const [, , chatType, peerUid, msgId, elementId] = data;
|
||||||
return {
|
return {
|
||||||
@@ -156,10 +179,22 @@ export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getQQPackageInfoPath(exePath: string = ''): string {
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
return path.join(path.dirname(exePath), '..', 'Resources', 'app', 'package.json');
|
||||||
|
} else {
|
||||||
|
return path.join(path.dirname(exePath), 'resources', 'app', 'package.json');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getQQVersionConfigPath(exePath: string = ''): string | undefined {
|
export function getQQVersionConfigPath(exePath: string = ''): string | undefined {
|
||||||
let configVersionInfoPath;
|
let configVersionInfoPath;
|
||||||
if (os.platform() !== 'linux') {
|
if (os.platform() === 'win32') {
|
||||||
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
||||||
|
} else if (os.platform() === 'darwin') {
|
||||||
|
const userPath = os.homedir();
|
||||||
|
const appDataPath = path.resolve(userPath, './Library/Application Support/QQ');
|
||||||
|
configVersionInfoPath = path.resolve(appDataPath, './versions/config.json');
|
||||||
} else {
|
} else {
|
||||||
const userPath = os.homedir();
|
const userPath = os.homedir();
|
||||||
const appDataPath = path.resolve(userPath, './.config/QQ');
|
const appDataPath = path.resolve(userPath, './.config/QQ');
|
||||||
|
@@ -167,7 +167,8 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
|||||||
function msgElementToText(element: MessageElement) {
|
function msgElementToText(element: MessageElement) {
|
||||||
if (element.textElement) {
|
if (element.textElement) {
|
||||||
if (element.textElement.atType === AtType.notAt) {
|
if (element.textElement.atType === AtType.notAt) {
|
||||||
return element.textElement.content;
|
const originalContentLines = element.textElement.content.split('\n');
|
||||||
|
return `${originalContentLines[0]}${originalContentLines.length > 1 ? ' ...' : ''}`;
|
||||||
} else if (element.textElement.atType === AtType.atAll) {
|
} else if (element.textElement.atType === AtType.atAll) {
|
||||||
return `@全体成员`;
|
return `@全体成员`;
|
||||||
} else if (element.textElement.atType === AtType.atUser) {
|
} else if (element.textElement.atType === AtType.atUser) {
|
||||||
@@ -189,7 +190,7 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (element.picElement) {
|
if (element.picElement) {
|
||||||
return `[图片 ${element.picElement.fileName}]`;
|
return '[图片]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.fileElement) {
|
if (element.fileElement) {
|
||||||
@@ -197,7 +198,7 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (element.videoElement) {
|
if (element.videoElement) {
|
||||||
return `[视频 ${element.videoElement.fileName}]`;
|
return '[视频]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.pttElement) {
|
if (element.pttElement) {
|
||||||
@@ -205,7 +206,7 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (element.arkElement) {
|
if (element.arkElement) {
|
||||||
return `[卡片消息 ${element.arkElement.bytesData}]`;
|
return '[卡片消息]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.faceElement) {
|
if (element.faceElement) {
|
||||||
@@ -213,19 +214,19 @@ export function rawMessageToText(msg: RawMessage, recursiveLevel = 0): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (element.marketFaceElement) {
|
if (element.marketFaceElement) {
|
||||||
return `[商城表情 ${element.marketFaceElement.faceName}]`;
|
return element.marketFaceElement.faceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.markdownElement) {
|
if (element.markdownElement) {
|
||||||
return `[Markdown ${element.markdownElement.content}]`;
|
return '[Markdown 消息]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.multiForwardMsgElement) {
|
if (element.multiForwardMsgElement) {
|
||||||
return `[转发消息]`;
|
return '[转发消息]';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element.elementType === ElementType.GreyTip) {
|
if (element.elementType === ElementType.GreyTip) {
|
||||||
return `[灰条消息]`; // TODO: resolve the text
|
return '[灰条消息]';
|
||||||
}
|
}
|
||||||
|
|
||||||
return `[未实现 (ElementType = ${element.elementType})]`;
|
return `[未实现 (ElementType = ${element.elementType})]`;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import path, { dirname } from 'path';
|
import path, { dirname } from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
@@ -11,17 +12,23 @@ export class NapCatPathWrapper {
|
|||||||
|
|
||||||
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
||||||
this.binaryPath = mainPath;
|
this.binaryPath = mainPath;
|
||||||
this.logsPath = path.join(this.binaryPath, 'logs');
|
let writePath: string;
|
||||||
this.configPath = path.join(this.binaryPath, 'config');
|
if (os.platform() === 'darwin') {
|
||||||
this.cachePath = path.join(this.binaryPath, 'cache');
|
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
||||||
|
} else {
|
||||||
|
writePath = this.binaryPath;
|
||||||
|
}
|
||||||
|
this.logsPath = path.join(writePath, 'logs');
|
||||||
|
this.configPath = path.join(writePath, 'config');
|
||||||
|
this.cachePath = path.join(writePath, 'cache');
|
||||||
this.staticPath = path.join(this.binaryPath, 'static');
|
this.staticPath = path.join(this.binaryPath, 'static');
|
||||||
if (fs.existsSync(this.logsPath)) {
|
if (!fs.existsSync(this.logsPath)) {
|
||||||
fs.mkdirSync(this.logsPath, { recursive: true });
|
fs.mkdirSync(this.logsPath, { recursive: true });
|
||||||
}
|
}
|
||||||
if (fs.existsSync(this.configPath)) {
|
if (!fs.existsSync(this.configPath)) {
|
||||||
fs.mkdirSync(this.configPath, { recursive: true });
|
fs.mkdirSync(this.configPath, { recursive: true });
|
||||||
}
|
}
|
||||||
if (fs.existsSync(this.cachePath)) {
|
if (!fs.existsSync(this.cachePath)) {
|
||||||
fs.mkdirSync(this.cachePath, { recursive: true });
|
fs.mkdirSync(this.cachePath, { recursive: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import path from 'node:path';
|
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { systemPlatform } from '@/common/system';
|
import { systemPlatform } from '@/common/system';
|
||||||
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
|
import { getDefaultQQVersionConfigInfo, getQQPackageInfoPath, getQQVersionConfigPath } from './helper';
|
||||||
import AppidTable from '@/core/external/appid.json';
|
import AppidTable from '@/core/external/appid.json';
|
||||||
import { LogWrapper } from './log';
|
import { LogWrapper } from './log';
|
||||||
|
|
||||||
@@ -20,7 +19,7 @@ export class QQBasicInfoWrapper {
|
|||||||
//基础目录获取
|
//基础目录获取
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.QQMainPath = process.execPath;
|
this.QQMainPath = process.execPath;
|
||||||
this.QQPackageInfoPath = path.join(path.dirname(this.QQMainPath), 'resources', 'app', 'package.json');
|
this.QQPackageInfoPath = getQQPackageInfoPath(this.QQMainPath);
|
||||||
this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath);
|
this.QQVersionConfigPath = getQQVersionConfigPath(this.QQMainPath);
|
||||||
|
|
||||||
//基础信息获取 无快更则启用默认模板填充
|
//基础信息获取 无快更则启用默认模板填充
|
||||||
@@ -53,9 +52,25 @@ export class QQBasicInfoWrapper {
|
|||||||
|
|
||||||
//此方法不要直接使用
|
//此方法不要直接使用
|
||||||
getQUAInternal() {
|
getQUAInternal() {
|
||||||
return systemPlatform === 'linux'
|
switch (systemPlatform) {
|
||||||
? `V1_LNX_NQ_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`
|
case 'linux':
|
||||||
: `V1_WIN_NQ_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
return `V1_LNX_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
||||||
|
case 'darwin':
|
||||||
|
return `V1_MAC_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
||||||
|
default:
|
||||||
|
return `V1_WIN_${this.getFullQQVesion()}_${this.getQQBuildStr()}_GW_B`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getAppidInternal() {
|
||||||
|
switch (systemPlatform) {
|
||||||
|
case 'linux':
|
||||||
|
return '537243600';
|
||||||
|
case 'darwin':
|
||||||
|
return '537243441';
|
||||||
|
default:
|
||||||
|
return '537243538';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAppidV2(): { appid: string; qua: string } {
|
getAppidV2(): { appid: string; qua: string } {
|
||||||
@@ -71,6 +86,6 @@ export class QQBasicInfoWrapper {
|
|||||||
// else
|
// else
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
||||||
return { appid: systemPlatform === 'linux' ? '537243600' : '537243441', qua: this.getQUAInternal() };
|
return { appid: this.getAppidInternal(), qua: this.getQUAInternal() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '2.2.42';
|
export const napCatVersion = '2.4.4';
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
|
import { MsfChangeReasonType, MsfStatusType } from "../entities/adapter";
|
||||||
|
|
||||||
export class NodeIDependsAdapter {
|
export class NodeIDependsAdapter {
|
||||||
onMSFStatusChange(arg1: number, arg2: number) {
|
onMSFStatusChange(statusType: MsfStatusType, changeReasonType: MsfChangeReasonType) {
|
||||||
// console.log(arg1, arg2);
|
|
||||||
// if (arg1 == 2 && arg2 == 2) {
|
|
||||||
// log("NapCat丢失网络连接,请检查网络")
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMSFSsoError(args: unknown) {
|
onMSFSsoError(args: unknown) {
|
||||||
|
@@ -1,63 +0,0 @@
|
|||||||
import {
|
|
||||||
CacheFileListItem,
|
|
||||||
CacheFileType,
|
|
||||||
ChatCacheListItemBasic,
|
|
||||||
ChatType,
|
|
||||||
InstanceContext,
|
|
||||||
NapCatCore,
|
|
||||||
} from '@/core';
|
|
||||||
|
|
||||||
export class NTQQCacheApi {
|
|
||||||
context: InstanceContext;
|
|
||||||
core: NapCatCore;
|
|
||||||
|
|
||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
|
||||||
this.context = context;
|
|
||||||
this.core = core;
|
|
||||||
}
|
|
||||||
|
|
||||||
async setCacheSilentScan(isSilent: boolean = true) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
getCacheSessionPathList() {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
clearCache(cacheKeys: Array<string> = ['tmp', 'hotUpdate']) {
|
|
||||||
// 参数未验证
|
|
||||||
return this.context.session.getStorageCleanService().clearCacheDataByKeys(cacheKeys);
|
|
||||||
}
|
|
||||||
|
|
||||||
addCacheScannedPaths(pathMap: object = {}) {
|
|
||||||
return this.context.session.getStorageCleanService().addCacheScanedPaths(pathMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
scanCache() {
|
|
||||||
//return (await this.context.session.getStorageCleanService().scanCache()).size;
|
|
||||||
}
|
|
||||||
|
|
||||||
getHotUpdateCachePath() {
|
|
||||||
// 未实现
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
getDesktopTmpPath() {
|
|
||||||
// 未实现
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
getChatCacheList(type: ChatType, pageSize: number = 1000, pageIndex: number = 0) {
|
|
||||||
return this.context.session.getStorageCleanService().getChatCacheInfo(type, pageSize, 1, pageIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
getFileCacheInfo(fileType: CacheFileType, pageSize: number = 1000, lastRecord?: CacheFileListItem) {
|
|
||||||
// const _lastRecord = lastRecord ? lastRecord : { fileType: fileType };
|
|
||||||
// 需要五个参数
|
|
||||||
// return napCatCore.session.getStorageCleanService().getFileCacheInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
async clearChatCache(chats: ChatCacheListItemBasic[] = [], fileKeys: string[] = []) {
|
|
||||||
return this.context.session.getStorageCleanService().clearChatCacheInfo(chats, fileKeys);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -33,7 +33,7 @@ export class NTQQFileApi {
|
|||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
this.rkeyManager = new RkeyManager('http://napcat-sign.wumiao.wang:2082/rkey', this.context.logger);
|
this.rkeyManager = new RkeyManager('https://llob.linyuchen.net/rkey', this.context.logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
async copyFile(filePath: string, destPath: string) {
|
async copyFile(filePath: string, destPath: string) {
|
||||||
@@ -207,7 +207,9 @@ export class NTQQFileApi {
|
|||||||
throw new Error('文件异常,大小为0');
|
throw new Error('文件异常,大小为0');
|
||||||
}
|
}
|
||||||
if (converted) {
|
if (converted) {
|
||||||
fsPromises.unlink(silkPath);
|
fsPromises.unlink(silkPath).then().catch(
|
||||||
|
(e) => this.context.logger.logError('删除临时文件失败', e)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
elementType: ElementType.PTT,
|
elementType: ElementType.PTT,
|
||||||
@@ -246,7 +248,6 @@ export class NTQQFileApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) {
|
async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) {
|
||||||
//logDebug('receive downloadMedia task', msgId, chatType, peerUid, elementId, thumbPath, sourcePath, timeout, force);
|
|
||||||
// 用于下载收到的消息中的图片等
|
// 用于下载收到的消息中的图片等
|
||||||
if (sourcePath && fs.existsSync(sourcePath)) {
|
if (sourcePath && fs.existsSync(sourcePath)) {
|
||||||
if (force) {
|
if (force) {
|
||||||
@@ -298,65 +299,6 @@ export class NTQQFileApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async addFileCache(peer: Peer, msgId: string, msgSeq: string, senderUid: string, elemId: string, elemType: string, fileSize: string, fileName: string) {
|
|
||||||
let GroupData;
|
|
||||||
let BuddyData;
|
|
||||||
if (peer.chatType === ChatType.KCHATTYPEGROUP) {
|
|
||||||
GroupData =
|
|
||||||
[{
|
|
||||||
groupCode: peer.peerUid,
|
|
||||||
isConf: false,
|
|
||||||
hasModifyConfGroupFace: true,
|
|
||||||
hasModifyConfGroupName: true,
|
|
||||||
groupName: 'NapCat.Cached',
|
|
||||||
remark: 'NapCat.Cached',
|
|
||||||
}];
|
|
||||||
} else if (peer.chatType === ChatType.KCHATTYPEC2C) {
|
|
||||||
BuddyData = [{
|
|
||||||
category_name: 'NapCat.Cached',
|
|
||||||
peerUid: peer.peerUid,
|
|
||||||
peerUin: peer.peerUid,
|
|
||||||
remark: 'NapCat.Cached',
|
|
||||||
}];
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.context.session.getSearchService().addSearchHistory({
|
|
||||||
type: 4,
|
|
||||||
contactList: [],
|
|
||||||
id: -1,
|
|
||||||
groupInfos: [],
|
|
||||||
msgs: [],
|
|
||||||
fileInfos: [
|
|
||||||
{
|
|
||||||
chatType: peer.chatType,
|
|
||||||
buddyChatInfo: BuddyData || [],
|
|
||||||
discussChatInfo: [],
|
|
||||||
groupChatInfo: GroupData || [],
|
|
||||||
dataLineChatInfo: [],
|
|
||||||
tmpChatInfo: [],
|
|
||||||
msgId: msgId,
|
|
||||||
msgSeq: msgSeq,
|
|
||||||
msgTime: Math.floor(Date.now() / 1000).toString(),
|
|
||||||
senderUid: senderUid,
|
|
||||||
senderNick: 'NapCat.Cached',
|
|
||||||
senderRemark: 'NapCat.Cached',
|
|
||||||
senderCard: 'NapCat.Cached',
|
|
||||||
elemId: elemId,
|
|
||||||
elemType: elemType,
|
|
||||||
fileSize: fileSize,
|
|
||||||
filePath: '',
|
|
||||||
fileName: fileName,
|
|
||||||
hits: [{
|
|
||||||
start: 12,
|
|
||||||
end: 14,
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async searchForFile(keys: string[]): Promise<SearchResultItem | undefined> {
|
async searchForFile(keys: string[]): Promise<SearchResultItem | undefined> {
|
||||||
const randomResultId = 100000 + Math.floor(Math.random() * 10000);
|
const randomResultId = 100000 + Math.floor(Math.random() * 10000);
|
||||||
let searchId = 0;
|
let searchId = 0;
|
||||||
@@ -398,15 +340,15 @@ export class NTQQFileApi {
|
|||||||
if (!element) {
|
if (!element) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
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;
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);//临时解析拼接
|
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);
|
||||||
const imageAppid = parsedUrl.searchParams.get('appid');
|
const imageAppid = parsedUrl.searchParams.get('appid');
|
||||||
const isNTFlavoredPic = imageAppid && ['1406', '1407'].includes(imageAppid);
|
const isNTV2 = imageAppid && ['1406', '1407'].includes(imageAppid);
|
||||||
if (isNTFlavoredPic) {
|
if (isNTV2) {
|
||||||
let rkey = parsedUrl.searchParams.get('rkey');
|
let rkey = parsedUrl.searchParams.get('rkey');
|
||||||
if (rkey) {
|
if (rkey) {
|
||||||
return IMAGE_HTTP_HOST_NT + url;
|
return IMAGE_HTTP_HOST_NT + url;
|
||||||
@@ -415,11 +357,9 @@ export class NTQQFileApi {
|
|||||||
rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
|
rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
|
||||||
return IMAGE_HTTP_HOST_NT + url + `${rkey}`;
|
return IMAGE_HTTP_HOST_NT + url + `${rkey}`;
|
||||||
} else {
|
} else {
|
||||||
// 老的图片url,不需要rkey
|
|
||||||
return IMAGE_HTTP_HOST + url;
|
return IMAGE_HTTP_HOST + url;
|
||||||
}
|
}
|
||||||
} else if (fileMd5 || md5HexStr) {
|
} else if (fileMd5 || md5HexStr) {
|
||||||
// 没有url,需要自己拼接
|
|
||||||
return `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${(fileMd5 ?? md5HexStr)!.toUpperCase()}/0`;
|
return `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${(fileMd5 ?? md5HexStr)!.toUpperCase()}/0`;
|
||||||
}
|
}
|
||||||
this.context.logger.logDebug('图片url获取失败', element);
|
this.context.logger.logDebug('图片url获取失败', element);
|
||||||
|
@@ -6,14 +6,9 @@ export class NTQQFriendApi {
|
|||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
core: NapCatCore;
|
core: NapCatCore;
|
||||||
|
|
||||||
// friends: Map<string, Friend> = new Map<string, FriendV2>();
|
|
||||||
|
|
||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
// if (!this.context.basicInfoWrapper.requireMinNTQQBuild('26702')) {
|
|
||||||
// this.getFriends(true);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2SimpleInfoMap(refresh = false) {
|
async getBuddyV2SimpleInfoMap(refresh = false) {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
ChatType,
|
|
||||||
GeneralCallResult,
|
GeneralCallResult,
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
@@ -10,8 +9,9 @@ import {
|
|||||||
MemberExtSourceType,
|
MemberExtSourceType,
|
||||||
NapCatCore,
|
NapCatCore,
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { isNumeric, runAllWithTimeout } from '@/common/helper';
|
import { isNumeric, solveAsyncProblem } from '@/common/helper';
|
||||||
import { LimitedHashTable } from '@/common/message-unique';
|
import { LimitedHashTable } from '@/common/message-unique';
|
||||||
|
import { NTEventWrapper } from '@/common/event';
|
||||||
|
|
||||||
export class NTQQGroupApi {
|
export class NTQQGroupApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -32,6 +32,10 @@ export class NTQQGroupApi {
|
|||||||
for (const group of this.groups) {
|
for (const group of this.groups) {
|
||||||
this.groupCache.set(group.groupCode, group);
|
this.groupCache.set(group.groupCode, group);
|
||||||
}
|
}
|
||||||
|
// let text = await this.context.session.getMsgService().sendSsoCmdReqByContend(
|
||||||
|
// 'LightAppSvc.mini_app_share.AdaptShareInfo',
|
||||||
|
// JSON.stringify({ data: 'test' }));
|
||||||
|
// console.log(text);
|
||||||
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +48,8 @@ export class NTQQGroupApi {
|
|||||||
}, pskey);
|
}, pskey);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clearGroupNotifiesUnreadCount(unk: boolean) {
|
async clearGroupNotifiesUnreadCount(uk: boolean) {
|
||||||
return this.context.session.getGroupService().clearGroupNotifiesUnreadCount(unk);
|
return this.context.session.getGroupService().clearGroupNotifiesUnreadCount(uk);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setGroupAvatar(gc: string, filePath: string) {
|
async setGroupAvatar(gc: string, filePath: string) {
|
||||||
@@ -61,9 +65,9 @@ export class NTQQGroupApi {
|
|||||||
return groupList;
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupExtFE0Info(GroupCode: string[], forced = true) {
|
async getGroupExtFE0Info(groupCode: string[], forced = true) {
|
||||||
return this.context.session.getGroupService().getGroupExt0xEF0Info(
|
return this.context.session.getGroupService().getGroupExt0xEF0Info(
|
||||||
GroupCode,
|
groupCode,
|
||||||
[],
|
[],
|
||||||
{
|
{
|
||||||
bindGuildId: 1,
|
bindGuildId: 1,
|
||||||
@@ -121,8 +125,8 @@ export class NTQQGroupApi {
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMemberAll(GroupCode: string, forced = false) {
|
async getGroupMemberAll(groupCode: string, forced = false) {
|
||||||
return this.context.session.getGroupService().getAllMemberList(GroupCode, forced);
|
return this.context.session.getGroupService().getAllMemberList(groupCode, forced);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMember(groupCode: string | number, memberUinOrUid: string | number) {
|
async getGroupMember(groupCode: string | number, memberUinOrUid: string | number) {
|
||||||
@@ -157,8 +161,8 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
async getGroupRecommendContactArkJson(GroupCode: string) {
|
async getGroupRecommendContactArkJson(groupCode: string) {
|
||||||
return this.context.session.getGroupService().getGroupRecommendContactArkJson(GroupCode);
|
return this.context.session.getGroupService().getGroupRecommendContactArkJson(groupCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
async CreatGroupFileFolder(groupCode: string, folderName: string) {
|
async CreatGroupFileFolder(groupCode: string, folderName: string) {
|
||||||
@@ -174,7 +178,6 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addGroupEssence(GroupCode: string, msgId: string) {
|
async addGroupEssence(GroupCode: string, msgId: string) {
|
||||||
// 需要 ob11msgId -> msgId + (peer) -> msgSeq + msgRandom
|
|
||||||
const MsgData = await this.context.session.getMsgService().getMsgsIncludeSelf({
|
const MsgData = await this.context.session.getMsgService().getMsgsIncludeSelf({
|
||||||
chatType: 2,
|
chatType: 2,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
@@ -185,7 +188,6 @@ export class NTQQGroupApi {
|
|||||||
msgRandom: parseInt(MsgData.msgList[0].msgRandom),
|
msgRandom: parseInt(MsgData.msgList[0].msgRandom),
|
||||||
msgSeq: parseInt(MsgData.msgList[0].msgSeq),
|
msgSeq: parseInt(MsgData.msgList[0].msgSeq),
|
||||||
};
|
};
|
||||||
// GetMsgByShortID(shortID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
|
||||||
return this.context.session.getGroupService().addGroupEssence(param);
|
return this.context.session.getGroupService().addGroupEssence(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +205,6 @@ export class NTQQGroupApi {
|
|||||||
groupCode: GroupCode,
|
groupCode: GroupCode,
|
||||||
needDeleteLocalMsg: needDeleteLocalMsg,
|
needDeleteLocalMsg: needDeleteLocalMsg,
|
||||||
};
|
};
|
||||||
//应该是直接返回不需要Listener的 未经测试 需测试再发布
|
|
||||||
return this.context.session.getGroupService().quitGroupV2(param);
|
return this.context.session.getGroupService().quitGroupV2(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,7 +249,7 @@ export class NTQQGroupApi {
|
|||||||
'NodeIKernelGroupListener/onMemberInfoChange',
|
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||||
1,
|
1,
|
||||||
forced ? 5000 : 250,
|
forced ? 5000 : 250,
|
||||||
(params) => params === GroupCode,
|
(params, _, members) => params === GroupCode && members.size > 0,
|
||||||
);
|
);
|
||||||
const retData = await (
|
const retData = await (
|
||||||
this.core.eventWrapper
|
this.core.eventWrapper
|
||||||
@@ -265,14 +266,34 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
async getGroupMemberEx(GroupCode: string, uid: string, forced = false, retry = 2) {
|
||||||
|
const data = await solveAsyncProblem((eventWrapper: NTEventWrapper, GroupCode: string, uid: string, forced = false) => {
|
||||||
|
return eventWrapper.callNormalEventV2(
|
||||||
|
'NodeIKernelGroupService/getMemberInfo',
|
||||||
|
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||||
|
[GroupCode, [uid], forced],
|
||||||
|
(ret) => ret.result === 0,
|
||||||
|
(params, _, members) => params === GroupCode && members.size > 0 && members.has(uid),
|
||||||
|
1,
|
||||||
|
forced ? 2500 : 250
|
||||||
|
);
|
||||||
|
}, this.core.eventWrapper, GroupCode, uid, forced);
|
||||||
|
if (data && data[3] instanceof Map && data[3].has(uid)) {
|
||||||
|
return data[3].get(uid);
|
||||||
|
}
|
||||||
|
if (retry > 0) {
|
||||||
|
const trydata = await this.getGroupMemberEx(GroupCode, uid, true, retry - 1) as GroupMember | undefined;
|
||||||
|
if (trydata) return trydata;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
async getGroupMembersV2(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
async getGroupMembersV2(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
const groupService = this.context.session.getGroupService();
|
const groupService = this.context.session.getGroupService();
|
||||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||||
const listener = this.core.eventWrapper.registerListen(
|
const listener = this.core.eventWrapper.registerListen(
|
||||||
'NodeIKernelGroupListener/onMemberListChange',
|
'NodeIKernelGroupListener/onMemberListChange',
|
||||||
1,
|
1,
|
||||||
500,
|
5000,
|
||||||
(params) => params.sceneId === sceneId,
|
(params) => params.sceneId === sceneId,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@@ -305,8 +326,7 @@ export class NTQQGroupApi {
|
|||||||
if (result.errCode !== 0) {
|
if (result.errCode !== 0) {
|
||||||
throw new Error('获取群成员列表出错,' + result.errMsg);
|
throw new Error('获取群成员列表出错,' + result.errMsg);
|
||||||
}
|
}
|
||||||
|
this.context.logger.logDebug(`获取群(${groupQQ})成员列表结果:`, `members: ${result.result.infos.size}`);
|
||||||
this.context.logger.logDebug(`获取群(${groupQQ})成员列表结果:`, `members: ${result.result.infos.size}`); //, Array.from(result.result.infos.values()));
|
|
||||||
return result.result.infos;
|
return result.result.infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,9 +334,6 @@ export class NTQQGroupApi {
|
|||||||
return this.context.session.getRichMediaService().batchGetGroupFileCount(Gids);
|
return this.context.session.getRichMediaService().batchGetGroupFileCount(Gids);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupIgnoreNotifies() {
|
|
||||||
}
|
|
||||||
|
|
||||||
async getArkJsonGroupShare(GroupCode: string) {
|
async getArkJsonGroupShare(GroupCode: string) {
|
||||||
const ret = await this.core.eventWrapper.callNoListenerEvent(
|
const ret = await this.core.eventWrapper.callNoListenerEvent(
|
||||||
'NodeIKernelGroupService/getGroupRecommendContactArkJson',
|
'NodeIKernelGroupService/getGroupRecommendContactArkJson',
|
||||||
@@ -340,12 +357,12 @@ export class NTQQGroupApi {
|
|||||||
return this.context.session.getGroupService().operateSysNotify(
|
return this.context.session.getGroupService().operateSysNotify(
|
||||||
false,
|
false,
|
||||||
{
|
{
|
||||||
'operateType': operateType, // 2 拒绝
|
operateType: operateType, // 2 拒绝
|
||||||
'targetMsg': {
|
targetMsg: {
|
||||||
'seq': seq, // 通知序列号
|
seq: seq, // 通知序列号
|
||||||
'type': type,
|
type: type,
|
||||||
'groupCode': groupCode,
|
groupCode: groupCode,
|
||||||
'postscript': reason ?? ' ', // 仅传空值可能导致处理失败,故默认给个空格
|
postscript: reason ?? ' ', // 仅传空值可能导致处理失败,故默认给个空格
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -401,7 +418,6 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getMemberExtInfo(groupCode: string, uin: string) {
|
async getMemberExtInfo(groupCode: string, uin: string) {
|
||||||
// 仅NTQQ 9.9.11 24568测试 容易炸开谨慎使用
|
|
||||||
return this.context.session.getGroupService().getMemberExtInfo(
|
return this.context.session.getGroupService().getMemberExtInfo(
|
||||||
{
|
{
|
||||||
groupCode: groupCode,
|
groupCode: groupCode,
|
||||||
|
@@ -5,5 +5,4 @@ export * from './msg';
|
|||||||
export * from './user';
|
export * from './user';
|
||||||
export * from './webapi';
|
export * from './webapi';
|
||||||
export * from './sign';
|
export * from './sign';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
export * from './cache';
|
|
@@ -19,27 +19,16 @@ export class NTQQMsgApi {
|
|||||||
return this.context.session.getMsgService().getAioFirstViewLatestMsgs(peer, MsgCount);
|
return this.context.session.getMsgService().getAioFirstViewLatestMsgs(peer, MsgCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLatestDbMsgs(peer: Peer, MsgCount: number) {
|
|
||||||
return this.context.session.getMsgService().getLatestDbMsgs(peer, MsgCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
async FetchLongMsg(peer: Peer, msgId: string) {
|
|
||||||
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
|
||||||
}
|
|
||||||
|
|
||||||
async sendShowInputStatusReq(peer: Peer, eventType: number) {
|
async sendShowInputStatusReq(peer: Peer, eventType: number) {
|
||||||
return this.context.session.getMsgService().sendShowInputStatusReq(peer.chatType, eventType, peer.peerUid);
|
return this.context.session.getMsgService().sendShowInputStatusReq(peer.chatType, eventType, peer.peerUid);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) {
|
async getMsgEmojiLikesList(peer: Peer, msgSeq: string, emojiId: string, emojiType: string, count: number = 20) {
|
||||||
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged Mlikiowa
|
||||||
return this.context.session.getMsgService().getMsgEmojiLikesList(peer, msgSeq, emojiId, emojiType, '', false, count);
|
return this.context.session.getMsgService().getMsgEmojiLikesList(peer, msgSeq, emojiId, emojiType, '', false, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, set: boolean = true) {
|
async setEmojiLike(peer: Peer, msgSeq: string, emojiId: string, set: boolean = true) {
|
||||||
// nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览
|
|
||||||
// nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid
|
|
||||||
// 其实以官方文档为准是最好的,https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#EmojiType
|
|
||||||
emojiId = emojiId.toString();
|
emojiId = emojiId.toString();
|
||||||
return this.context.session.getMsgService().setMsgEmojiLikes(peer, msgSeq, emojiId, emojiId.length > 3 ? '2' : '1', set);
|
return this.context.session.getMsgService().setMsgEmojiLikes(peer, msgSeq, emojiId, emojiId.length > 3 ? '2' : '1', set);
|
||||||
}
|
}
|
||||||
@@ -108,14 +97,6 @@ export class NTQQMsgApi {
|
|||||||
async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
||||||
return await this.context.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
return await this.context.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
||||||
}
|
}
|
||||||
async getMsgBySeqList(peer: Peer, msgSeqList: string[]) {
|
|
||||||
//坏的
|
|
||||||
return await this.context.session.getMsgService().getMsgsBySeqList(peer, msgSeqList);
|
|
||||||
}
|
|
||||||
async getMsgBySeqExFirstMsg(peer: Peer, rootMsgId: string, replyMsgId: string) {
|
|
||||||
let reply = await this.context.session.getMsgService().getSourceOfReplyMsgV2(peer, rootMsgId, replyMsgId);
|
|
||||||
console.log(reply);
|
|
||||||
}
|
|
||||||
async getMsgExBySeq(peer: Peer, msgSeq: string) {
|
async getMsgExBySeq(peer: Peer, msgSeq: string) {
|
||||||
const DateNow = Math.floor(Date.now() / 1000);
|
const DateNow = Math.floor(Date.now() / 1000);
|
||||||
const filterMsgFromTime = (DateNow - 300).toString();
|
const filterMsgFromTime = (DateNow - 300).toString();
|
||||||
@@ -157,11 +138,16 @@ export class NTQQMsgApi {
|
|||||||
return this.context.session.getMsgService().getMsgsIncludeSelf(peer, msgId, count, isReverseOrder);
|
return this.context.session.getMsgService().getMsgsIncludeSelf(peer, msgId, count, isReverseOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
async recallMsg(peer: Peer, msgIds: string[]) {
|
async recallMsg(peer: Peer, msgId: string) {
|
||||||
await this.context.session.getMsgService().recallMsg({
|
await this.core.eventWrapper.callNormalEventV2(
|
||||||
chatType: peer.chatType,
|
'NodeIKernelMsgService/recallMsg',
|
||||||
peerUid: peer.peerUid,
|
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
}, msgIds);
|
[peer, [msgId]],
|
||||||
|
() => true,
|
||||||
|
(updatedList) => updatedList.find(m => m.msgId === msgId && m.recallTime !== '0') !== undefined,
|
||||||
|
1,
|
||||||
|
1000,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
|
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
|
||||||
@@ -195,7 +181,7 @@ export class NTQQMsgApi {
|
|||||||
await this.PrepareTempChat(peer.peerUid, peer.guildId, member.nick);
|
await this.PrepareTempChat(peer.peerUid, peer.guildId, member.nick);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const msgId = await this.generateMsgUniqueId(peer.chatType, await this.getServerTime());
|
const msgId = await this.generateMsgUniqueId(peer.chatType);
|
||||||
peer.guildId = msgId;
|
peer.guildId = msgId;
|
||||||
const [, msgList] = await this.core.eventWrapper.callNormalEventV2(
|
const [, msgList] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelMsgService/sendMsg',
|
'NodeIKernelMsgService/sendMsg',
|
||||||
@@ -221,12 +207,8 @@ export class NTQQMsgApi {
|
|||||||
return msgList.find(msgRecord => msgRecord.guildId === msgId);
|
return msgList.find(msgRecord => msgRecord.guildId === msgId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateMsgUniqueId(chatType: number, time: string) {
|
async generateMsgUniqueId(chatType: number) {
|
||||||
return this.context.session.getMsgService().generateMsgUniqueId(chatType, time);
|
return this.context.session.getMsgService().generateMsgUniqueId(chatType, this.context.session.getMSFService().getServerTime());
|
||||||
}
|
|
||||||
|
|
||||||
async getServerTime() {
|
|
||||||
return this.context.session.getMSFService().getServerTime();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
async forwardMsg(srcPeer: Peer, destPeer: Peer, msgIds: string[]) {
|
||||||
|
@@ -214,11 +214,6 @@ export class NTQQMusicSignApi {
|
|||||||
//console.log(MusicReal);
|
//console.log(MusicReal);
|
||||||
return { ...MusicReal.data, mid: signedMid };
|
return { ...MusicReal.data, mid: signedMid };
|
||||||
}
|
}
|
||||||
|
|
||||||
async CreateMusicThirdWay1(id: string = '', mid: string = '') {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//转换外域名为 https://qq.ugcimg.cn/v1/cpqcbu4b8870i61bde6k7cbmjgejq8mr3in82qir4qi7ielffv5slv8ck8g42novtmev26i233ujtuab6tvu2l2sjgtupfr389191v00s1j5oh5325j5eqi40774jv1i/khovifoh7jrqd6eahoiv7koh8o
|
//转换外域名为 https://qq.ugcimg.cn/v1/cpqcbu4b8870i61bde6k7cbmjgejq8mr3in82qir4qi7ielffv5slv8ck8g42novtmev26i233ujtuab6tvu2l2sjgtupfr389191v00s1j5oh5325j5eqi40774jv1i/khovifoh7jrqd6eahoiv7koh8o
|
||||||
//https://cgi.connect.qq.com/qqconnectopen/openapi/change_image_url?url=https://th.bing.com/th?id=OSK.b8ed36f1fb1889de6dc84fd81c187773&w=46&h=46&c=11&rs=1&qlt=80&o=6&dpr=2&pid=SANGAM
|
//https://cgi.connect.qq.com/qqconnectopen/openapi/change_image_url?url=https://th.bing.com/th?id=OSK.b8ed36f1fb1889de6dc84fd81c187773&w=46&h=46&c=11&rs=1&qlt=80&o=6&dpr=2&pid=SANGAM
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@ export class NTQQSystemApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getOnlineDev() {
|
async getOnlineDev() {
|
||||||
return this.context.session.getMsgService().getOnLineDev();
|
this.context.session.getMsgService().getOnLineDev();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getArkJsonCollection(cid: string) {
|
async getArkJsonCollection(cid: string) {
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
import type { ModifyProfileParams, User } from '@/core/entities';
|
import { ModifyProfileParams, User, UserDetailSource } from '@/core/entities';
|
||||||
import { RequestUtil } from '@/common/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
import { ProfileBizType, UserDetailSource } from '@/core/services';
|
import { InstanceContext, NapCatCore, ProfileBizType } from '..';
|
||||||
import { InstanceContext, NapCatCore } from '..';
|
|
||||||
import { solveAsyncProblem } from '@/common/helper';
|
import { solveAsyncProblem } from '@/common/helper';
|
||||||
|
|
||||||
export class NTQQUserApi {
|
export class NTQQUserApi {
|
||||||
@@ -75,7 +74,6 @@ export class NTQQUserApi {
|
|||||||
(profile) => profile.uid === uid,
|
(profile) => profile.uid === uid,
|
||||||
);
|
);
|
||||||
const RetUser: User = {
|
const RetUser: User = {
|
||||||
...profile.simpleInfo.coreInfo,
|
|
||||||
...profile.simpleInfo.status,
|
...profile.simpleInfo.status,
|
||||||
...profile.simpleInfo.vasInfo,
|
...profile.simpleInfo.vasInfo,
|
||||||
...profile.commonExt,
|
...profile.commonExt,
|
||||||
@@ -83,17 +81,22 @@ export class NTQQUserApi {
|
|||||||
qqLevel: profile.commonExt?.qqLevel,
|
qqLevel: profile.commonExt?.qqLevel,
|
||||||
age: profile.simpleInfo.baseInfo.age,
|
age: profile.simpleInfo.baseInfo.age,
|
||||||
pendantId: '',
|
pendantId: '',
|
||||||
|
...profile.simpleInfo.coreInfo
|
||||||
};
|
};
|
||||||
return RetUser;
|
return RetUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfo(uid: string): Promise<User> {
|
async getUserDetailInfo(uid: string): Promise<User> {
|
||||||
const retUser = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfo(uid, UserDetailSource.KDB), uid);
|
let retUser = await solveAsyncProblem(async (uid) => this.fetchUserDetailInfo(uid, UserDetailSource.KDB), uid);
|
||||||
if (retUser && retUser.uin !== '0') {
|
if (retUser && retUser.uin !== '0') {
|
||||||
return retUser;
|
return retUser;
|
||||||
}
|
}
|
||||||
this.context.logger.logDebug('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.');
|
this.context.logger.logDebug('[NapCat] [Mark] getUserDetailInfo Mode1 Failed.');
|
||||||
return this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER);
|
retUser = await this.fetchUserDetailInfo(uid, UserDetailSource.KSERVER);
|
||||||
|
if (retUser && retUser.uin === '0') {
|
||||||
|
retUser.uin = await this.core.apis.UserApi.getUidByUinV2(uid) ?? '0';
|
||||||
|
}
|
||||||
|
return retUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
async modifySelfProfile(param: ModifyProfileParams) {
|
async modifySelfProfile(param: ModifyProfileParams) {
|
||||||
|
@@ -131,20 +131,53 @@ export class NTQQWebApi {
|
|||||||
// return await res.json();
|
// return await res.json();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
async setGroupNotice(GroupCode: string, Content: string) {
|
async setGroupNotice(
|
||||||
|
GroupCode: string,
|
||||||
|
Content: string,
|
||||||
|
pinned: number = 0,
|
||||||
|
type: number = 1,
|
||||||
|
is_show_edit_card: number = 1,
|
||||||
|
tip_window_type: number = 1,
|
||||||
|
confirm_required: number = 1,
|
||||||
|
picId: string = '',
|
||||||
|
imgWidth: number = 540,
|
||||||
|
imgHeight: number = 300,
|
||||||
|
) {
|
||||||
|
interface SetNoticeRetSuccess {
|
||||||
|
ec: number;
|
||||||
|
em: string;
|
||||||
|
id: number;
|
||||||
|
ltsm: number;
|
||||||
|
new_fid: string;
|
||||||
|
read_only: number;
|
||||||
|
role: number;
|
||||||
|
srv_code: number;
|
||||||
|
}
|
||||||
|
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
let ret: any = undefined;
|
|
||||||
try {
|
try {
|
||||||
ret = await RequestUtil.HttpGetJson<any>(
|
const settings = JSON.stringify({
|
||||||
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice${new URLSearchParams({
|
is_show_edit_card: is_show_edit_card,
|
||||||
|
tip_window_type: tip_window_type,
|
||||||
|
confirm_required: confirm_required
|
||||||
|
});
|
||||||
|
const externalParam = {
|
||||||
|
pic: picId,
|
||||||
|
imgWidth: imgWidth.toString(),
|
||||||
|
imgHeight: imgHeight.toString(),
|
||||||
|
};
|
||||||
|
const ret: SetNoticeRetSuccess = await RequestUtil.HttpGetJson<SetNoticeRetSuccess>(
|
||||||
|
`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
qid: GroupCode,
|
qid: GroupCode,
|
||||||
text: Content,
|
text: Content,
|
||||||
pinned: '0',
|
pinned: pinned.toString(),
|
||||||
type: '1',
|
type: type.toString(),
|
||||||
settings: '{"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}',
|
settings: settings,
|
||||||
|
...(picId === '' ? {} : externalParam)
|
||||||
}).toString()}`,
|
}).toString()}`,
|
||||||
'GET',
|
'POST',
|
||||||
'',
|
'',
|
||||||
{ 'Cookie': this.cookieToString(cookieObject) }
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
);
|
);
|
||||||
|
11
src/core/entities/adapter.ts
Normal file
11
src/core/entities/adapter.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export enum MsfStatusType {
|
||||||
|
KUNKNOWN,
|
||||||
|
KDISCONNECTED,
|
||||||
|
KCONNECTED
|
||||||
|
}
|
||||||
|
export enum MsfChangeReasonType {
|
||||||
|
KUNKNOWN,
|
||||||
|
KUSERLOGININ,
|
||||||
|
KUSERLOGINOUT,
|
||||||
|
KAUTO
|
||||||
|
}
|
12
src/core/entities/contact.ts
Normal file
12
src/core/entities/contact.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
export interface FSABRecentContactParams {
|
||||||
|
anchorPointContact: {
|
||||||
|
contactId: string;
|
||||||
|
sortField: string;
|
||||||
|
pos: number;
|
||||||
|
};
|
||||||
|
relativeMoveCount: number;
|
||||||
|
listType: number;
|
||||||
|
count: number;
|
||||||
|
fetchOld: boolean;
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
import { GroupMemberRole } from '@/core';
|
import { GroupMemberRole, Peer } from '@/core';
|
||||||
|
|
||||||
export interface Peer {
|
export interface Peer {
|
||||||
chatType: ChatType;
|
chatType: ChatType;
|
||||||
@@ -934,3 +934,28 @@ export interface RawMessage {
|
|||||||
|
|
||||||
elements: MessageElement[];
|
elements: MessageElement[];
|
||||||
}
|
}
|
||||||
|
export interface QueryMsgsParams {
|
||||||
|
chatInfo: Peer;
|
||||||
|
filterMsgType: [];
|
||||||
|
filterSendersUid: string[];
|
||||||
|
filterMsgFromTime: string;
|
||||||
|
filterMsgToTime: string;
|
||||||
|
pageLimit: number;
|
||||||
|
isReverseOrder: boolean;
|
||||||
|
isIncludeCurrent: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TmpChatInfoApi {
|
||||||
|
errMsg: string;
|
||||||
|
result: number;
|
||||||
|
tmpChatInfo?: TmpChatInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TmpChatInfo {
|
||||||
|
chatType: number;
|
||||||
|
fromNick: string;
|
||||||
|
groupCode: string;
|
||||||
|
peerUid: string;
|
||||||
|
sessionType: number;
|
||||||
|
sig: string;
|
||||||
|
}
|
||||||
|
@@ -153,7 +153,10 @@ interface CommonExt {
|
|||||||
labels: any[];
|
labels: any[];
|
||||||
qqLevel: QQLevel;
|
qqLevel: QQLevel;
|
||||||
}
|
}
|
||||||
|
export enum BuddyListReqType {
|
||||||
|
KNOMAL,
|
||||||
|
KLETTER
|
||||||
|
}
|
||||||
interface Pic {
|
interface Pic {
|
||||||
picId: string;
|
picId: string;
|
||||||
picTime: number;
|
picTime: number;
|
||||||
@@ -364,3 +367,15 @@ export interface UserDetailInfoByUin {
|
|||||||
vipNameColorId: string
|
vipNameColorId: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export enum UserDetailSource {
|
||||||
|
KDB,
|
||||||
|
KSERVER
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum ProfileBizType {
|
||||||
|
KALL,
|
||||||
|
KBASEEXTEND,
|
||||||
|
KVAS,
|
||||||
|
KQZONE,
|
||||||
|
KOTHER
|
||||||
|
}
|
4
src/core/external/appid.json
vendored
4
src/core/external/appid.json
vendored
@@ -6,5 +6,9 @@
|
|||||||
"9.9.15-27597": {
|
"9.9.15-27597": {
|
||||||
"appid": 537243441,
|
"appid": 537243441,
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27597_GW_B"
|
"qua": "V1_WIN_NQ_9.9.15_27597_GW_B"
|
||||||
|
},
|
||||||
|
"6.9.53-27597": {
|
||||||
|
"appid": 537243538,
|
||||||
|
"qua": "V1_MAC_NQ_6.9.53_27597_GW_B"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,9 +42,15 @@ export enum NapCatCoreWorkingEnv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
||||||
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
let appPath;
|
||||||
|
if (os.platform() === 'darwin') {
|
||||||
|
appPath = path.resolve(path.dirname(process.execPath), '../Resources/app');
|
||||||
|
} else {
|
||||||
|
appPath = path.resolve(path.dirname(process.execPath), './resources/app');
|
||||||
|
}
|
||||||
|
let wrapperNodePath = path.resolve(appPath, 'wrapper.node');
|
||||||
if (!fs.existsSync(wrapperNodePath)) {
|
if (!fs.existsSync(wrapperNodePath)) {
|
||||||
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${QQVersion}/wrapper.node`);
|
wrapperNodePath = path.join(appPath, `versions/${QQVersion}/wrapper.node`);
|
||||||
}
|
}
|
||||||
const nativemodule: any = { exports: {} };
|
const nativemodule: any = { exports: {} };
|
||||||
process.dlopen(nativemodule, wrapperNodePath);
|
process.dlopen(nativemodule, wrapperNodePath);
|
||||||
@@ -139,8 +145,10 @@ export class NapCatCore {
|
|||||||
if (Info.status == 20) {
|
if (Info.status == 20) {
|
||||||
this.selfInfo.online = false;
|
this.selfInfo.online = false;
|
||||||
this.context.logger.log("账号状态变更为离线");
|
this.context.logger.log("账号状态变更为离线");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.selfInfo.online = true;
|
||||||
}
|
}
|
||||||
this.selfInfo.online = true;
|
|
||||||
};
|
};
|
||||||
this.context.session.getProfileService().addKernelProfileListener(
|
this.context.session.getProfileService().addKernelProfileListener(
|
||||||
proxiedListenerOf(profileListener, this.context.logger),
|
proxiedListenerOf(profileListener, this.context.logger),
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
export interface NodeIKernelAlbumService {
|
export interface NodeIKernelAlbumService {
|
||||||
|
|
||||||
setAlbumServiceInfo(...args: any[]): unknown;// needs 3 arguments
|
setAlbumServiceInfo(...args: any[]): unknown;// needs 3 arguments
|
||||||
|
|
||||||
getMainPage(...args: any[]): unknown;// needs 2 arguments
|
getMainPage(...args: any[]): unknown;// needs 2 arguments
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
export interface NodeIKernelAvatarService {
|
export interface NodeIKernelAvatarService {
|
||||||
addAvatarListener(arg: unknown): unknown;
|
addAvatarListener(listener: unknown): void;
|
||||||
|
|
||||||
removeAvatarListener(arg: unknown): unknown;
|
removeAvatarListener(listenerId: number): void;
|
||||||
|
|
||||||
getAvatarPath(arg1: unknown, arg2: unknown): unknown;
|
getAvatarPath(arg1: unknown, arg2: unknown): unknown;
|
||||||
|
|
||||||
|
@@ -1,13 +1,8 @@
|
|||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
import { NodeIKernelBuddyListener } from '@/core/listeners';
|
import { NodeIKernelBuddyListener } from '@/core/listeners';
|
||||||
|
import { BuddyListReqType } from '../entities/user';
|
||||||
export enum BuddyListReqType {
|
|
||||||
KNOMAL,
|
|
||||||
KLETTER
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeIKernelBuddyService {
|
export interface NodeIKernelBuddyService {
|
||||||
// 26702 以上
|
|
||||||
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
|
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
|
||||||
data: Array<{
|
data: Array<{
|
||||||
categoryId: number,
|
categoryId: number,
|
||||||
@@ -19,8 +14,7 @@ export interface NodeIKernelBuddyService {
|
|||||||
}>
|
}>
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
//26702 以上
|
getBuddyListFromCache(reqType: BuddyListReqType): Promise<Array<
|
||||||
getBuddyListFromCache(callFrom: string): Promise<Array<
|
|
||||||
{
|
{
|
||||||
categoryId: number,//9999应该跳过 那是兜底数据吧
|
categoryId: number,//9999应该跳过 那是兜底数据吧
|
||||||
categorySortId: number,//排序方式
|
categorySortId: number,//排序方式
|
||||||
@@ -30,18 +24,13 @@ export interface NodeIKernelBuddyService {
|
|||||||
buddyUids: Array<string>//Uids
|
buddyUids: Array<string>//Uids
|
||||||
}>>;
|
}>>;
|
||||||
|
|
||||||
// 以下为原生方法
|
|
||||||
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
|
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
|
||||||
|
|
||||||
getAllBuddyCount(): number;
|
getAllBuddyCount(): number;
|
||||||
|
|
||||||
removeKernelBuddyListener(listener: unknown): void;
|
removeKernelBuddyListener(listenerId: number): void;
|
||||||
|
|
||||||
/**
|
//getBuddyList(nocache: boolean): Promise<GeneralCallResult>;
|
||||||
* @deprecated
|
|
||||||
* @param nocache 使用缓存
|
|
||||||
*/
|
|
||||||
getBuddyList(nocache: boolean): Promise<GeneralCallResult>;
|
|
||||||
|
|
||||||
getBuddyNick(uid: number): string;
|
getBuddyNick(uid: number): string;
|
||||||
|
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import { GeneralCallResult } from './common';
|
import { GeneralCallResult } from './common';
|
||||||
|
|
||||||
export interface NodeIKernelCollectionService {
|
export interface NodeIKernelCollectionService {
|
||||||
addKernelCollectionListener(...args: any[]): unknown;//needs 1 arguments
|
addKernelCollectionListener(...args: any[]): void;//needs 1 arguments
|
||||||
|
|
||||||
removeKernelCollectionListener(...args: any[]): unknown;//needs 1 arguments
|
removeKernelCollectionListener(listenerId: number): void;
|
||||||
|
|
||||||
getCollectionItemList(param: {
|
getCollectionItemList(param: {
|
||||||
category: number,
|
category: number,
|
||||||
@@ -14,46 +14,46 @@ export interface NodeIKernelCollectionService {
|
|||||||
count: number,
|
count: number,
|
||||||
searchDown: boolean
|
searchDown: boolean
|
||||||
}): Promise<GeneralCallResult &
|
}): Promise<GeneralCallResult &
|
||||||
{
|
{
|
||||||
collectionSearchList: {
|
collectionSearchList: {
|
||||||
collectionItemList: Array<
|
collectionItemList: Array<
|
||||||
{
|
{
|
||||||
cid: string,
|
cid: string,
|
||||||
|
type: number,
|
||||||
|
status: number,
|
||||||
|
author: {
|
||||||
type: number,
|
type: number,
|
||||||
status: number,
|
numId: string,
|
||||||
author: {
|
strId: string,
|
||||||
type: number,
|
groupId: string,
|
||||||
numId: string,
|
groupName: string,
|
||||||
strId: string,
|
uid: string
|
||||||
groupId: string,
|
},
|
||||||
groupName: string,
|
bid: number,
|
||||||
uid: string
|
category: number,
|
||||||
},
|
createTime: string,
|
||||||
bid: number,
|
collectTime: string,
|
||||||
category: number,
|
modifyTime: string,
|
||||||
createTime: string,
|
sequence: string,
|
||||||
collectTime: string,
|
shareUrl: string,
|
||||||
modifyTime: string,
|
customGroupId: number,
|
||||||
sequence: string,
|
securityBeat: boolean,
|
||||||
shareUrl: string,
|
summary: {
|
||||||
customGroupId: number,
|
textSummary: unknown,
|
||||||
securityBeat: boolean,
|
linkSummary: unknown,
|
||||||
summary: {
|
gallerySummary: unknown,
|
||||||
textSummary: unknown,
|
audioSummary: unknown,
|
||||||
linkSummary: unknown,
|
videoSummary: unknown,
|
||||||
gallerySummary: unknown,
|
fileSummary: unknown,
|
||||||
audioSummary: unknown,
|
locationSummary: unknown,
|
||||||
videoSummary: unknown,
|
richMediaSummary: unknown,
|
||||||
fileSummary: unknown,
|
}
|
||||||
locationSummary: unknown,
|
}>,
|
||||||
richMediaSummary: unknown,
|
hasMore: boolean,
|
||||||
}
|
bottomTimeStamp: string
|
||||||
}>,
|
|
||||||
hasMore: boolean,
|
|
||||||
bottomTimeStamp: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
>;//needs 1 arguments
|
}
|
||||||
|
>;
|
||||||
|
|
||||||
getCollectionContent(...args: any[]): unknown;//needs 5 arguments
|
getCollectionContent(...args: any[]): unknown;//needs 5 arguments
|
||||||
|
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
export interface NodeIKernelDbToolsService {
|
export interface NodeIKernelDbToolsService {
|
||||||
|
|
||||||
depositDatabase(...args: unknown[]): unknown;
|
depositDatabase(...args: unknown[]): unknown;
|
||||||
|
|
||||||
backupDatabase(...args: unknown[]): unknown;
|
backupDatabase(...args: unknown[]): unknown;
|
||||||
|
|
||||||
retrieveDatabase(...args: unknown[]): unknown;
|
retrieveDatabase(...args: unknown[]): unknown;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,2 @@
|
|||||||
export interface NodeIKernelECDHService {
|
export interface NodeIKernelECDHService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -11,8 +11,6 @@ import {
|
|||||||
} from '@/core/entities';
|
} from '@/core/entities';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
|
||||||
|
|
||||||
export interface NodeIKernelGroupService {
|
export interface NodeIKernelGroupService {
|
||||||
getGroupExt0xEF0Info(enableGroupCodes: string[], bannedGroupCodes: string[], filter: GroupExt0xEF0InfoFilter, forceFetch: boolean):
|
getGroupExt0xEF0Info(enableGroupCodes: string[], bannedGroupCodes: string[], filter: GroupExt0xEF0InfoFilter, forceFetch: boolean):
|
||||||
Promise<GeneralCallResult & { result: { groupExtInfos: Map<string, any> } }>;
|
Promise<GeneralCallResult & { result: { groupExtInfos: Map<string, any> } }>;
|
||||||
@@ -82,11 +80,11 @@ export interface NodeIKernelGroupService {
|
|||||||
}): Promise<unknown>;
|
}): Promise<unknown>;
|
||||||
|
|
||||||
|
|
||||||
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
isEssenceMsg(req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
||||||
|
|
||||||
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
queryCachedEssenceMsg(req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
||||||
|
|
||||||
fetchGroupEssenceList(Req: {
|
fetchGroupEssenceList(req: {
|
||||||
groupCode: string,
|
groupCode: string,
|
||||||
pageStart: number,
|
pageStart: number,
|
||||||
pageLimit: number
|
pageLimit: number
|
||||||
@@ -110,13 +108,12 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
addKernelGroupListener(listener: NodeIKernelGroupListener): number;
|
addKernelGroupListener(listener: NodeIKernelGroupListener): number;
|
||||||
|
|
||||||
removeKernelGroupListener(listenerId: unknown): void;
|
removeKernelGroupListener(listenerId: number): void;
|
||||||
|
|
||||||
createMemberListScene(groupCode: string, scene: string): string;
|
createMemberListScene(groupCode: string, scene: string): string;
|
||||||
|
|
||||||
destroyMemberListScene(SceneId: string): void;
|
destroyMemberListScene(SceneId: string): void;
|
||||||
|
|
||||||
//About Arg (a) name: lastId 根据手Q来看为object {index:?(number),uid:string}
|
|
||||||
getNextMemberList(sceneId: string, a: undefined, num: number): Promise<{
|
getNextMemberList(sceneId: string, a: undefined, num: number): Promise<{
|
||||||
errCode: number, errMsg: string,
|
errCode: number, errMsg: string,
|
||||||
result: { ids: string[], infos: Map<string, GroupMember>, finish: boolean, hasRobot: boolean }
|
result: { ids: string[], infos: Map<string, GroupMember>, finish: boolean, hasRobot: boolean }
|
||||||
@@ -247,14 +244,12 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
modifyGroupExtInfo(groupCode: string, arg: unknown): void;
|
modifyGroupExtInfo(groupCode: string, arg: unknown): void;
|
||||||
|
|
||||||
//需要提前判断是否存在 高版本新增
|
|
||||||
addGroupEssence(param: {
|
addGroupEssence(param: {
|
||||||
groupCode: string
|
groupCode: string
|
||||||
msgRandom: number,
|
msgRandom: number,
|
||||||
msgSeq: number
|
msgSeq: number
|
||||||
}): Promise<unknown>;
|
}): Promise<unknown>;
|
||||||
|
|
||||||
//需要提前判断是否存在 高版本新增
|
|
||||||
removeGroupEssence(param: {
|
removeGroupEssence(param: {
|
||||||
groupCode: string
|
groupCode: string
|
||||||
msgRandom: number,
|
msgRandom: number,
|
||||||
|
@@ -59,6 +59,7 @@ export interface QuickLoginResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface NodeIKernelLoginService {
|
export interface NodeIKernelLoginService {
|
||||||
|
connect(): boolean;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
// eslint-disable-next-line @typescript-eslint/no-misused-new
|
||||||
new(): NodeIKernelLoginService;
|
new(): NodeIKernelLoginService;
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
export interface NodeIKernelMsgBackupService {
|
export interface NodeIKernelMsgBackupService {
|
||||||
addKernelMsgBackupListener(...args: any[]): unknown;// needs 1 arguments
|
addKernelMsgBackupListener(listener: unknown): number;
|
||||||
|
|
||||||
removeKernelMsgBackupListener(...args: any[]): unknown;// needs 1 arguments
|
removeKernelMsgBackupListener(listenerId: number): void;
|
||||||
|
|
||||||
getMsgBackupLocation(...args: any[]): unknown;// needs 0 arguments
|
getMsgBackupLocation(...args: any[]): unknown;// needs 0 arguments
|
||||||
|
|
||||||
|
@@ -1,32 +1,7 @@
|
|||||||
import { ElementType, MessageElement, Peer, RawMessage, SendMessageElement } from '@/core/entities';
|
import { ElementType, MessageElement, Peer, RawMessage, SendMessageElement } from '@/core/entities';
|
||||||
import { NodeIKernelMsgListener } from '@/core/listeners/NodeIKernelMsgListener';
|
import { NodeIKernelMsgListener } from '@/core/listeners/NodeIKernelMsgListener';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
import { QueryMsgsParams, TmpChatInfoApi } from '../entities/msg';
|
||||||
export interface QueryMsgsParams {
|
|
||||||
chatInfo: Peer,
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: string[],
|
|
||||||
filterMsgFromTime: string,
|
|
||||||
filterMsgToTime: string,
|
|
||||||
pageLimit: number,
|
|
||||||
isReverseOrder: boolean,
|
|
||||||
isIncludeCurrent: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TmpChatInfoApi {
|
|
||||||
errMsg: string;
|
|
||||||
result: number;
|
|
||||||
tmpChatInfo?: TmpChatInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TmpChatInfo {
|
|
||||||
chatType: number;
|
|
||||||
fromNick: string;
|
|
||||||
groupCode: string;
|
|
||||||
peerUid: string;
|
|
||||||
sessionType: number;
|
|
||||||
sig: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeIKernelMsgService {
|
export interface NodeIKernelMsgService {
|
||||||
|
|
||||||
@@ -76,18 +51,12 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
downloadOnlineStatusCommonByUrl(arg0: string, arg1: string): unknown;
|
downloadOnlineStatusCommonByUrl(arg0: string, arg1: string): unknown;
|
||||||
|
|
||||||
// this.tokenType = i2;
|
|
||||||
// this.apnsToken = bArr;
|
|
||||||
// this.voipToken = bArr2;
|
|
||||||
// this.profileId = str;
|
|
||||||
|
|
||||||
setToken(arg: unknown): unknown;
|
setToken(arg: unknown): unknown;
|
||||||
|
|
||||||
switchForeGround(): unknown;
|
switchForeGround(): unknown;
|
||||||
|
|
||||||
switchBackGround(arg: unknown): unknown;
|
switchBackGround(arg: unknown): unknown;
|
||||||
|
|
||||||
//hex
|
|
||||||
setTokenForMqq(token: string): unknown;
|
setTokenForMqq(token: string): unknown;
|
||||||
|
|
||||||
switchForeGroundForMqq(...args: unknown[]): unknown;
|
switchForeGroundForMqq(...args: unknown[]): unknown;
|
||||||
@@ -124,7 +93,6 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
forwardFile(...args: unknown[]): unknown;
|
forwardFile(...args: unknown[]): unknown;
|
||||||
|
|
||||||
//Array<Msg>, Peer from, Peer to
|
|
||||||
multiForwardMsg(...args: unknown[]): unknown;
|
multiForwardMsg(...args: unknown[]): unknown;
|
||||||
|
|
||||||
multiForwardMsgWithComment(...args: unknown[]): unknown;
|
multiForwardMsgWithComment(...args: unknown[]): unknown;
|
||||||
@@ -185,11 +153,6 @@ export interface NodeIKernelMsgService {
|
|||||||
msgList: RawMessage[]
|
msgList: RawMessage[]
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
// this.$peer = contact;
|
|
||||||
// this.$msgTime = j2;
|
|
||||||
// this.$clientSeq = j3;
|
|
||||||
// this.$cnt = i2;
|
|
||||||
|
|
||||||
getMsgsWithMsgTimeAndClientSeqForC2C(...args: unknown[]): Promise<GeneralCallResult & { msgList: RawMessage[] }>;
|
getMsgsWithMsgTimeAndClientSeqForC2C(...args: unknown[]): Promise<GeneralCallResult & { msgList: RawMessage[] }>;
|
||||||
|
|
||||||
getMsgsWithStatus(params: {
|
getMsgsWithStatus(params: {
|
||||||
@@ -226,7 +189,6 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getSourceOfReplyMsgByClientSeqAndTime(peer: Peer, clientSeq: string, time: string): unknown;
|
getSourceOfReplyMsgByClientSeqAndTime(peer: Peer, clientSeq: string, time: string): unknown;
|
||||||
|
|
||||||
//cnt clientSeq?并不是吧
|
|
||||||
getMsgsByTypeFilter(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilter: {
|
getMsgsByTypeFilter(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilter: {
|
||||||
type: number,
|
type: number,
|
||||||
subtype: Array<number>
|
subtype: Array<number>
|
||||||
@@ -241,49 +203,15 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
queryMsgsWithFilter(...args: unknown[]): unknown;
|
queryMsgsWithFilter(...args: unknown[]): unknown;
|
||||||
|
|
||||||
/**
|
//queryMsgsWithFilterVer2(MsgId: string, MsgTime: string, param: QueryMsgsParams): Promise<unknown>;
|
||||||
* @deprecated 该函数已被标记为废弃,请使用新的替代方法。
|
|
||||||
* 使用过滤条件查询消息列表的版本2接口。
|
|
||||||
*
|
|
||||||
* 该函数通过一系列过滤条件来查询特定聊天中的消息列表。这些条件包括消息类型、发送者、时间范围等。
|
|
||||||
* 函数返回一个Promise,解析为查询结果的未知类型对象。
|
|
||||||
*
|
|
||||||
* @param MsgId 消息ID,用于特定消息的查询。
|
|
||||||
* @param MsgTime 消息时间,用于指定消息的时间范围。
|
|
||||||
* @param param 查询参数对象,包含详细的过滤条件和分页信息。
|
|
||||||
* @param param.chatInfo 聊天信息,包括聊天类型和对方用户ID。
|
|
||||||
* @param param.filterMsgType 需要过滤的消息类型数组,留空表示不过滤。
|
|
||||||
* @param param.filterSendersUid 需要过滤的发送者用户ID数组。
|
|
||||||
* @param param.filterMsgFromTime 查询消息的起始时间。
|
|
||||||
* @param param.filterMsgToTime 查询消息的结束时间。
|
|
||||||
* @param param.pageLimit 每页的消息数量限制。
|
|
||||||
* @param param.isReverseOrder 是否按时间顺序倒序返回消息。
|
|
||||||
* @param param.isIncludeCurrent 是否包含当前页码。
|
|
||||||
* @returns 返回一个Promise,解析为查询结果的未知类型对象。
|
|
||||||
*/
|
|
||||||
queryMsgsWithFilterVer2(MsgId: string, MsgTime: string, param: QueryMsgsParams): Promise<unknown>;
|
|
||||||
|
|
||||||
// this.chatType = i2;
|
|
||||||
// this.peerUid = str;
|
|
||||||
|
|
||||||
// this.chatInfo = new ChatInfo();
|
|
||||||
// this.filterMsgType = new ArrayList<>();
|
|
||||||
// this.filterSendersUid = new ArrayList<>();
|
|
||||||
// this.chatInfo = chatInfo;
|
|
||||||
// this.filterMsgType = arrayList;
|
|
||||||
// this.filterSendersUid = arrayList2;
|
|
||||||
// this.filterMsgFromTime = j2;
|
|
||||||
// this.filterMsgToTime = j3;
|
|
||||||
// this.pageLimit = i2;
|
|
||||||
// this.isReverseOrder = z;
|
|
||||||
// this.isIncludeCurrent = z2;
|
|
||||||
//queryMsgsWithFilterEx(0L, 0L, 0L, new QueryMsgsParams(new ChatInfo(2, str), new ArrayList(), new ArrayList(), 0L, 0L, 250, false, true))
|
|
||||||
queryMsgsWithFilterEx(msgId: string, msgTime: string, megSeq: string, param: QueryMsgsParams): Promise<GeneralCallResult & {
|
queryMsgsWithFilterEx(msgId: string, msgTime: string, megSeq: string, param: QueryMsgsParams): Promise<GeneralCallResult & {
|
||||||
msgList: RawMessage[]
|
msgList: RawMessage[]
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
//queryMsgsWithFilterEx(this.$msgId, this.$msgTime, this.$msgSeq, this.$param)
|
queryFileMsgsDesktop(msgId: string, msgTime: string, msgSeq: string, param: QueryMsgsParams): Promise<GeneralCallResult & {
|
||||||
queryFileMsgsDesktop(...args: unknown[]): unknown;
|
msgList: RawMessage[]
|
||||||
|
}>;
|
||||||
|
|
||||||
setMsgRichInfoFlag(...args: unknown[]): unknown;
|
setMsgRichInfoFlag(...args: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -390,17 +318,11 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getFileThumbSavePath(...args: unknown[]): unknown;
|
getFileThumbSavePath(...args: unknown[]): unknown;
|
||||||
|
|
||||||
//猜测居多
|
translatePtt2Text(msgId: string, peer: Peer, msgElement: unknown): unknown;
|
||||||
translatePtt2Text(MsgId: string, Peer: Peer, MsgElement: unknown): unknown;
|
|
||||||
|
|
||||||
setPttPlayedState(...args: unknown[]): unknown;
|
setPttPlayedState(...args: unknown[]): unknown;
|
||||||
|
|
||||||
// NodeIQQNTWrapperSession fetchFavEmojiList [
|
//uk1 uk2 true
|
||||||
// "",
|
|
||||||
// 48,
|
|
||||||
// true,
|
|
||||||
// true
|
|
||||||
// ]
|
|
||||||
fetchFavEmojiList(str: string, num: number, uk1: boolean, uk2: boolean): Promise<GeneralCallResult & {
|
fetchFavEmojiList(str: string, num: number, uk1: boolean, uk2: boolean): Promise<GeneralCallResult & {
|
||||||
emojiInfoList: Array<{
|
emojiInfoList: Array<{
|
||||||
uin: string,
|
uin: string,
|
||||||
@@ -496,7 +418,7 @@ export interface NodeIKernelMsgService {
|
|||||||
getFirstUnreadMsgSeq(args: {
|
getFirstUnreadMsgSeq(args: {
|
||||||
peerUid: string
|
peerUid: string
|
||||||
guildId: string
|
guildId: string
|
||||||
}): unknown;
|
}): Promise<unknown>;
|
||||||
|
|
||||||
getFirstUnreadCommonMsg(...args: unknown[]): unknown;
|
getFirstUnreadCommonMsg(...args: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -590,7 +512,7 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getFirstUnreadAtMsg(peer: Peer): unknown;
|
getFirstUnreadAtMsg(peer: Peer): unknown;
|
||||||
|
|
||||||
clearMsgRecords(...args: unknown[]): unknown;//设置已读后调用我觉得比较好 清理记录 现在别了
|
clearMsgRecords(...args: unknown[]): unknown;
|
||||||
|
|
||||||
IsExistOldDb(...args: unknown[]): unknown;
|
IsExistOldDb(...args: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -626,25 +548,10 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
enterOrExitAio(...args: unknown[]): unknown;
|
enterOrExitAio(...args: unknown[]): unknown;
|
||||||
|
|
||||||
// this.peerUid = "";
|
prepareTempChat(args: unknown): unknown;
|
||||||
// this.peerNickname = "";
|
|
||||||
// this.fromGroupCode = "";
|
|
||||||
// this.sig = new byte[0];
|
|
||||||
// this.selfUid = "";
|
|
||||||
// this.selfPhone = "";
|
|
||||||
// this.chatType = i2;
|
|
||||||
// this.peerUid = str;
|
|
||||||
// this.peerNickname = str2;
|
|
||||||
// this.fromGroupCode = str3;
|
|
||||||
// this.sig = bArr;
|
|
||||||
// this.selfUid = str4;
|
|
||||||
// this.selfPhone = str5;
|
|
||||||
// this.gameSession = tempChatGameSession;
|
|
||||||
prepareTempChat(args: unknown): unknown;//主动临时消息 不做
|
|
||||||
|
|
||||||
sendSsoCmdReqByContend(cmd: string, param: string): Promise<unknown>;
|
sendSsoCmdReqByContend(cmd: string, param: string): Promise<unknown>;
|
||||||
|
|
||||||
//chattype,uid->Promise<any>
|
|
||||||
getTempChatInfo(ChatType: number, Uid: string): Promise<TmpChatInfoApi>;
|
getTempChatInfo(ChatType: number, Uid: string): Promise<TmpChatInfoApi>;
|
||||||
|
|
||||||
setContactLocalTop(...args: unknown[]): unknown;
|
setContactLocalTop(...args: unknown[]): unknown;
|
||||||
@@ -708,7 +615,6 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
dataMigrationStopOperation(...args: unknown[]): unknown;
|
dataMigrationStopOperation(...args: unknown[]): unknown;
|
||||||
|
|
||||||
//新的希望
|
|
||||||
dataMigrationImportMsgPbRecord(DataMigrationMsgInfo: Array<{
|
dataMigrationImportMsgPbRecord(DataMigrationMsgInfo: Array<{
|
||||||
extensionData: string//"Hex"
|
extensionData: string//"Hex"
|
||||||
extraData: string //""
|
extraData: string //""
|
||||||
@@ -760,6 +666,6 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getGuildMsgAbFlag(...args: unknown[]): unknown;
|
getGuildMsgAbFlag(...args: unknown[]): unknown;
|
||||||
|
|
||||||
getGroupMsgStorageTime(): unknown;//这是嘛啊
|
getGroupMsgStorageTime(): unknown;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { GeneralCallResult } from './common';
|
import { GeneralCallResult } from './common';
|
||||||
|
|
||||||
//没扒干净 因为用不着
|
|
||||||
export interface NodeIKernelNodeMiscService {
|
export interface NodeIKernelNodeMiscService {
|
||||||
getMiniAppPath(): unknown;
|
getMiniAppPath(): unknown;
|
||||||
|
|
||||||
@@ -11,7 +10,4 @@ export interface NodeIKernelNodeMiscService {
|
|||||||
SendMiniAppMsg(arg1: string, arg2: string, arg3: string): unknown;
|
SendMiniAppMsg(arg1: string, arg2: string, arg3: string): unknown;
|
||||||
|
|
||||||
startNewMiniApp(appfile: string, params: string): unknown;
|
startNewMiniApp(appfile: string, params: string): unknown;
|
||||||
|
|
||||||
// 我的计划是转发给一个新程序避免吃掉Electron_AS_Node的环境 然后重写启动MiniApp 挂载相应JS脚本 这样有个问题
|
|
||||||
// 需要自己转发ipc参数 然后必须处在gui环境 且完成校验破解 才能实现发包 有点抽象了
|
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
export interface NodeIKernelOnlineStatusService {
|
export interface NodeIKernelOnlineStatusService {
|
||||||
|
|
||||||
addKernelOnlineStatusListener(listener: unknown): void;
|
addKernelOnlineStatusListener(listener: unknown): number;
|
||||||
|
|
||||||
removeKernelOnlineStatusListener(listenerId: unknown): void;
|
removeKernelOnlineStatusListener(listenerId: number): void;
|
||||||
|
|
||||||
getShouldShowAIOStatusAnimation(arg: unknown): unknown;
|
getShouldShowAIOStatusAnimation(arg: unknown): unknown;
|
||||||
|
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
import { BuddyProfileLikeReq, GeneralCallResult } from '@/core';
|
import { BuddyProfileLikeReq, GeneralCallResult } from '@/core';
|
||||||
|
|
||||||
export interface NodeIKernelProfileLikeService {
|
export interface NodeIKernelProfileLikeService {
|
||||||
addKernelProfileLikeListener(listener: NodeIKernelProfileLikeService): void;
|
addKernelProfileLikeListener(listener: unknown): number;
|
||||||
|
|
||||||
removeKernelProfileLikeListener(listener: unknown): void;
|
removeKernelProfileLikeListener(listenerId: unknown): void;
|
||||||
|
|
||||||
setBuddyProfileLike(...args: unknown[]): { result: number, errMsg: string, succCounts: number };
|
setBuddyProfileLike(...args: unknown[]): { result: number, errMsg: string, succCounts: number };
|
||||||
|
|
||||||
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
getBuddyProfileLike(req: BuddyProfileLikeReq): Promise<GeneralCallResult & {
|
||||||
'info': {
|
info: {
|
||||||
'userLikeInfos': Array<any>,
|
userLikeInfos: Array<any>,
|
||||||
'friendMaxVotes': number,
|
friendMaxVotes: number,
|
||||||
'start': number
|
start: number
|
||||||
}
|
}
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
@@ -1,38 +1,21 @@
|
|||||||
import { AnyCnameRecord } from 'node:dns';
|
import { AnyCnameRecord } from 'node:dns';
|
||||||
import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, SimpleInfo, UserDetailInfoByUinV2 } from '@/core';
|
import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, ProfileBizType, SimpleInfo, UserDetailInfoByUinV2, UserDetailSource } from '@/core';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
export enum UserDetailSource {
|
|
||||||
KDB,
|
|
||||||
KSERVER
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum ProfileBizType {
|
|
||||||
KALL,
|
|
||||||
KBASEEXTEND,
|
|
||||||
KVAS,
|
|
||||||
KQZONE,
|
|
||||||
KOTHER
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeIKernelProfileService {
|
export interface NodeIKernelProfileService {
|
||||||
|
getOtherFlag(callfrom: string, uids: string[]): Promise<Map<string, any>>;
|
||||||
|
|
||||||
|
getVasInfo(callfrom: string, uids: string[]): Promise<Map<string, any>>;
|
||||||
|
|
||||||
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string, string>>;//uin->uid
|
getRelationFlag(callfrom: string, uids: string[]): Promise<Map<string, any>>;
|
||||||
|
|
||||||
|
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string, string>>;
|
||||||
|
|
||||||
getUinByUid(callfrom: string, uid: Array<string>): Promise<Map<string, string>>;
|
getUinByUid(callfrom: string, uid: Array<string>): Promise<Map<string, string>>;
|
||||||
|
|
||||||
// {
|
|
||||||
// coreInfo: CoreInfo,
|
|
||||||
// baseInfo: BaseInfo,
|
|
||||||
// status: null,
|
|
||||||
// vasInfo: null,
|
|
||||||
// relationFlags: null,
|
|
||||||
// otherFlags: null,
|
|
||||||
// intimate: null
|
|
||||||
// }
|
|
||||||
getCoreAndBaseInfo(callfrom: string, uids: string[]): Promise<Map<string, SimpleInfo>>;
|
getCoreAndBaseInfo(callfrom: string, uids: string[]): Promise<Map<string, SimpleInfo>>;
|
||||||
|
|
||||||
fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise<unknown>;
|
fetchUserDetailInfo(trace: string, uids: string[], source: UserDetailSource, bizType: ProfileBizType[]): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
addKernelProfileListener(listener: NodeIKernelProfileListener): number;
|
addKernelProfileListener(listener: NodeIKernelProfileListener): number;
|
||||||
|
|
||||||
@@ -44,30 +27,17 @@ export interface NodeIKernelProfileService {
|
|||||||
|
|
||||||
enumCountryOptions(): Array<string>;
|
enumCountryOptions(): Array<string>;
|
||||||
|
|
||||||
enumProvinceOptions(Country: string): Array<string>;
|
enumProvinceOptions(country: string): Array<string>;
|
||||||
|
|
||||||
enumCityOptions(Country: string, Province: string): unknown;
|
enumCityOptions(country: string, province: string): unknown;
|
||||||
|
|
||||||
enumAreaOptions(...args: unknown[]): unknown;
|
enumAreaOptions(...args: unknown[]): unknown;
|
||||||
|
|
||||||
//SimpleInfo
|
|
||||||
// this.uid = "";
|
|
||||||
// this.uid = str;
|
|
||||||
// this.uin = j2;
|
|
||||||
// this.isBuddy = z;
|
|
||||||
// this.coreInfo = coreInfo;
|
|
||||||
// this.baseInfo = baseInfo;
|
|
||||||
// this.status = statusInfo;
|
|
||||||
// this.vasInfo = vasInfo;
|
|
||||||
// this.relationFlags = relationFlag;
|
|
||||||
// this.otherFlags = otherFlag;
|
|
||||||
// this.intimate = intimate;
|
|
||||||
|
|
||||||
modifySelfProfile(...args: unknown[]): Promise<unknown>;
|
modifySelfProfile(...args: unknown[]): Promise<unknown>;
|
||||||
|
|
||||||
modifyDesktopMiniProfile(param: ModifyProfileParams): Promise<GeneralCallResult>;
|
modifyDesktopMiniProfile(param: ModifyProfileParams): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
setNickName(NickName: string): Promise<unknown>;
|
setNickName(nickName: string): Promise<unknown>;
|
||||||
|
|
||||||
setLongNick(longNick: string): Promise<unknown>;
|
setLongNick(longNick: string): Promise<unknown>;
|
||||||
|
|
||||||
@@ -95,14 +65,12 @@ export interface NodeIKernelProfileService {
|
|||||||
|
|
||||||
getSelfStatus(): Promise<unknown>;
|
getSelfStatus(): Promise<unknown>;
|
||||||
|
|
||||||
//
|
|
||||||
setdisableEmojiShortCuts(...args: unknown[]): unknown;
|
setdisableEmojiShortCuts(...args: unknown[]): unknown;
|
||||||
|
|
||||||
getProfileQzonePicInfo(uid: string, type: number, force: boolean): Promise<unknown>;
|
getProfileQzonePicInfo(uid: string, type: number, force: boolean): Promise<unknown>;
|
||||||
|
|
||||||
//profileService.getCoreInfo("UserRemarkServiceImpl::getStrangerRemarkByUid", arrayList);
|
// UserRemarkServiceImpl::getStrangerRemarkByUid []
|
||||||
getCoreInfo(name: string, arg: any[]): unknown;
|
getCoreInfo(sceneId: string, arg: any[]): unknown;
|
||||||
|
|
||||||
//m429253e12.getOtherFlag("FriendListInfoCache_getKernelDataAndPutCache", new ArrayList<>());
|
|
||||||
isNull(): boolean;
|
isNull(): boolean;
|
||||||
}
|
}
|
||||||
|
@@ -1,30 +1,8 @@
|
|||||||
import { ChatType, Peer } from '../entities';
|
import { ChatType, Peer } from '../entities';
|
||||||
import { NodeIKernelRecentContactListener } from '../listeners/NodeIKernelRecentContactListener';
|
import { NodeIKernelRecentContactListener } from '../listeners/NodeIKernelRecentContactListener';
|
||||||
import { GeneralCallResult } from './common';
|
import { GeneralCallResult } from './common';
|
||||||
|
import { FSABRecentContactParams } from '../entities/contact';
|
||||||
|
|
||||||
export interface FSABRecentContactParams {
|
|
||||||
anchorPointContact: {
|
|
||||||
contactId: string;
|
|
||||||
sortField: string;
|
|
||||||
pos: number;
|
|
||||||
},
|
|
||||||
relativeMoveCount: number;
|
|
||||||
listType: number;
|
|
||||||
count: number;
|
|
||||||
fetchOld: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
// {
|
|
||||||
// "anchorPointContact": {
|
|
||||||
// "contactId": "",
|
|
||||||
// "sortField": "",
|
|
||||||
// "pos": 0
|
|
||||||
// },
|
|
||||||
// "relativeMoveCount": 0,
|
|
||||||
// "listType": 1,
|
|
||||||
// "count": 200,
|
|
||||||
// "fetchOld": true
|
|
||||||
// }
|
|
||||||
export interface NodeIKernelRecentContactService {
|
export interface NodeIKernelRecentContactService {
|
||||||
setGuildDisplayStatus(...args: unknown[]): unknown; // 2 arguments
|
setGuildDisplayStatus(...args: unknown[]): unknown; // 2 arguments
|
||||||
|
|
||||||
@@ -36,7 +14,6 @@ export interface NodeIKernelRecentContactService {
|
|||||||
|
|
||||||
enterOrExitMsgList(...args: unknown[]): unknown; // 1 arguments
|
enterOrExitMsgList(...args: unknown[]): unknown; // 1 arguments
|
||||||
|
|
||||||
/*!---!*/
|
|
||||||
getRecentContactListSnapShot(count: number): Promise<GeneralCallResult & {
|
getRecentContactListSnapShot(count: number): Promise<GeneralCallResult & {
|
||||||
info: {
|
info: {
|
||||||
errCode: number,
|
errCode: number,
|
||||||
@@ -58,7 +35,6 @@ export interface NodeIKernelRecentContactService {
|
|||||||
|
|
||||||
jumpToSpecifyRecentContact(...args: unknown[]): unknown; // 1 arguments
|
jumpToSpecifyRecentContact(...args: unknown[]): unknown; // 1 arguments
|
||||||
|
|
||||||
/*!---!*/
|
|
||||||
fetchAndSubscribeABatchOfRecentContact(params: FSABRecentContactParams): unknown; // 1 arguments
|
fetchAndSubscribeABatchOfRecentContact(params: FSABRecentContactParams): unknown; // 1 arguments
|
||||||
|
|
||||||
addRecentContact(peer: Peer): unknown;
|
addRecentContact(peer: Peer): unknown;
|
||||||
|
@@ -99,23 +99,6 @@ export interface NodeIKernelRichMediaService {
|
|||||||
|
|
||||||
getRichMediaFileDir(elementType: number, downType: number, isTemp: boolean): unknown;
|
getRichMediaFileDir(elementType: number, downType: number, isTemp: boolean): unknown;
|
||||||
|
|
||||||
// this.senderUid = "";
|
|
||||||
// this.peerUid = "";
|
|
||||||
// this.guildId = "";
|
|
||||||
// this.elem = new MsgElement();
|
|
||||||
// this.downloadType = i2;
|
|
||||||
// this.thumbSize = i3;
|
|
||||||
// this.msgId = j2;
|
|
||||||
// this.msgRandom = j3;
|
|
||||||
// this.msgSeq = j4;
|
|
||||||
// this.msgTime = j5;
|
|
||||||
// this.chatType = i4;
|
|
||||||
// this.senderUid = str;
|
|
||||||
// this.peerUid = str2;
|
|
||||||
// this.guildId = str3;
|
|
||||||
// this.elem = msgElement;
|
|
||||||
// this.useHttps = num;
|
|
||||||
|
|
||||||
getVideoPlayUrlInVisit(arg: {
|
getVideoPlayUrlInVisit(arg: {
|
||||||
downloadType: number,
|
downloadType: number,
|
||||||
thumbSize: number,
|
thumbSize: number,
|
||||||
@@ -131,7 +114,6 @@ export interface NodeIKernelRichMediaService {
|
|||||||
useHttps: boolean
|
useHttps: boolean
|
||||||
}): Promise<unknown>;
|
}): Promise<unknown>;
|
||||||
|
|
||||||
//arg双端number
|
|
||||||
isFileExpired(arg: number): unknown;
|
isFileExpired(arg: number): unknown;
|
||||||
|
|
||||||
deleteGroupFolder(GroupCode: string, FolderId: string): Promise<GeneralCallResult & {
|
deleteGroupFolder(GroupCode: string, FolderId: string): Promise<GeneralCallResult & {
|
||||||
@@ -154,7 +136,6 @@ export interface NodeIKernelRichMediaService {
|
|||||||
useHttps: boolean
|
useHttps: boolean
|
||||||
}): unknown;
|
}): unknown;
|
||||||
|
|
||||||
//arg3为“”
|
|
||||||
downloadFileForModelId(peer: Peer, ModelId: string[], unknown: string): Promise<unknown>;
|
downloadFileForModelId(peer: Peer, ModelId: string[], unknown: string): Promise<unknown>;
|
||||||
|
|
||||||
//第三个参数 Array<Type>
|
//第三个参数 Array<Type>
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
import { ChatType } from '../entities';
|
import { ChatType } from '../entities';
|
||||||
|
|
||||||
export interface NodeIKernelSearchService {
|
export interface NodeIKernelSearchService {
|
||||||
addKernelSearchListener(...args: any[]): unknown;// needs 1 arguments
|
|
||||||
|
|
||||||
removeKernelSearchListener(...args: any[]): unknown;// needs 1 arguments
|
addKernelSearchListener(listener: unknown): number;
|
||||||
|
|
||||||
searchStranger(...args: any[]): unknown;// needs 3 arguments
|
removeKernelSearchListener(listenerId: number): void;
|
||||||
|
|
||||||
|
searchStranger(unknown: string, searchStranger: unknown, searchParams: unknown): Promise<unknown>;
|
||||||
|
|
||||||
searchGroup(...args: any[]): unknown;// needs 1 arguments
|
searchGroup(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
@@ -125,4 +126,5 @@ export interface NodeIKernelSearchService {
|
|||||||
searchCache(...args: any[]): unknown;// needs 3 arguments
|
searchCache(...args: any[]): unknown;// needs 3 arguments
|
||||||
|
|
||||||
clearSearchCache(...args: any[]): unknown;// needs 1 arguments
|
clearSearchCache(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,9 +3,9 @@ import { GeneralCallResult } from './common';
|
|||||||
|
|
||||||
export interface NodeIKernelStorageCleanService {
|
export interface NodeIKernelStorageCleanService {
|
||||||
|
|
||||||
addKernelStorageCleanListener(Listener: NodeIKernelStorageCleanListener): number;
|
addKernelStorageCleanListener(listener: NodeIKernelStorageCleanListener): number;
|
||||||
|
|
||||||
removeKernelStorageCleanListener(ListenerId: number): void;
|
removeKernelStorageCleanListener(listenerId: number): void;
|
||||||
|
|
||||||
addCacheScanedPaths(arg: unknown): unknown;
|
addCacheScanedPaths(arg: unknown): unknown;
|
||||||
|
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
export interface NodeIKernelTianShuService {
|
export interface NodeIKernelTianShuService {
|
||||||
addKernelTianShuListener(...args: any[]): unknown;// needs 1 arguments
|
addKernelTianShuListener(listener:unknown): number;
|
||||||
|
|
||||||
removeKernelTianShuListener(...args: any[]): unknown;// needs 1 arguments
|
removeKernelTianShuListener(listenerId:number): void;
|
||||||
|
|
||||||
requesTianShuNumeralRe(...args: any[]): unknown;//d needs 1 arguments
|
|
||||||
|
|
||||||
reportTianShuNumeralRed(...args: any[]): unknown;// needs 1 arguments
|
reportTianShuNumeralRed(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
|
@@ -2,9 +2,9 @@ import { ForceFetchClientKeyRetType } from './common';
|
|||||||
|
|
||||||
export interface NodeIKernelTicketService {
|
export interface NodeIKernelTicketService {
|
||||||
|
|
||||||
addKernelTicketListener(listener: unknown): void;
|
addKernelTicketListener(listener: unknown): number;
|
||||||
|
|
||||||
removeKernelTicketListener(listenerId: unknown): void;
|
removeKernelTicketListener(listenerId: number): void;
|
||||||
|
|
||||||
forceFetchClientKey(arg: string): Promise<ForceFetchClientKeyRetType>;
|
forceFetchClientKey(arg: string): Promise<ForceFetchClientKeyRetType>;
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import { GeneralCallResult } from './common';
|
|||||||
|
|
||||||
export interface NodeIKernelTipOffService {
|
export interface NodeIKernelTipOffService {
|
||||||
|
|
||||||
addKernelTipOffListener(listener: unknown): void;
|
addKernelTipOffListener(listener: unknown): number;
|
||||||
|
|
||||||
removeKernelTipOffListener(listenerId: unknown): void;
|
removeKernelTipOffListener(listenerId: unknown): void;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ export interface NodeIKernelTipOffService {
|
|||||||
|
|
||||||
getPskey(domainList: string[], nocache: boolean): Promise<GeneralCallResult & {
|
getPskey(domainList: string[], nocache: boolean): Promise<GeneralCallResult & {
|
||||||
domainPskeyMap: Map<string, string>
|
domainPskeyMap: Map<string, string>
|
||||||
}>;//2
|
}>;
|
||||||
|
|
||||||
tipOffSendJsData(args: unknown[]): Promise<unknown>;//2
|
tipOffSendJsData(args: unknown[]): Promise<unknown>;//2
|
||||||
|
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
export interface NodeIKernelUnitedConfigService {
|
export interface NodeIKernelUnitedConfigService {
|
||||||
addKernelUnitedConfigListener(...args: any[]): unknown;// needs 1 arguments
|
|
||||||
|
|
||||||
removeKernelUnitedConfigListener(...args: any[]): unknown;// needs 1 arguments
|
addKernelUnitedConfigListener(listener:unknown): number;
|
||||||
|
|
||||||
|
removeKernelUnitedConfigListener(listenerId:number): void;
|
||||||
|
|
||||||
fetchUnitedCommendConfig(...args: any[]): unknown;// needs 1 arguments
|
fetchUnitedCommendConfig(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
@@ -12,4 +13,5 @@ export interface NodeIKernelUnitedConfigService {
|
|||||||
isUnitedConfigSwitchOn(...args: any[]): unknown;// needs 1 arguments
|
isUnitedConfigSwitchOn(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
registerUnitedConfigPushGroupList(...args: any[]): unknown;// needs 1 arguments
|
registerUnitedConfigPushGroupList(...args: any[]): unknown;// needs 1 arguments
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
// public interface IYellowFaceForManagerService extends QRouteApi {
|
export interface NodeIYellowFaceService {
|
||||||
// void download(@NotNull String resourceConfigJson, @NotNull String resourceDir, @NotNull String cacheDir, boolean force, @NotNull IKernelYellowFaceDownloadCallback callback);
|
download(resourceConfigJson: string, resourceDir: string, cacheDir: string, force: boolean): void;
|
||||||
|
|
||||||
// void setHistory(@NotNull String fullMd5, @NotNull IOperateCallback callback);
|
setHistory(fullMd5: string): void;
|
||||||
// }
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { MessageElement, Peer } from '../entities';
|
import { MessageElement, Peer } from '../entities';
|
||||||
|
|
||||||
export interface NodeIkernelTestPerformanceService {
|
export interface NodeIkernelTestPerformanceService {
|
||||||
|
|
||||||
insertMsg(MsgParam: {
|
insertMsg(MsgParam: {
|
||||||
peer: Peer
|
peer: Peer
|
||||||
msgTime: string
|
msgTime: string
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
export enum GeneralCallResultStatus {
|
export enum GeneralCallResultStatus {
|
||||||
OK = 0,
|
OK = 0
|
||||||
// ERROR = 1,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GeneralCallResult {
|
export interface GeneralCallResult {
|
||||||
|
@@ -54,7 +54,7 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
|
|||||||
public async websocketHandle(payload: PayloadType, echo: any): Promise<OB11Return<ReturnDataType | null>> {
|
public async websocketHandle(payload: PayloadType, echo: any): Promise<OB11Return<ReturnDataType | null>> {
|
||||||
const result = await this.check(payload);
|
const result = await this.check(payload);
|
||||||
if (!result.valid) {
|
if (!result.valid) {
|
||||||
return OB11Response.error(result.message, 1400);
|
return OB11Response.error(result.message, 1400, echo);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const resData = await this._handle(payload);
|
const resData = await this._handle(payload);
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { OB11Return } from '../types';
|
import { OB11Return } from '../types';
|
||||||
|
|
||||||
import { isNull } from '../../common/helper';
|
import { isNull } from '@/common/helper';
|
||||||
|
|
||||||
export class OB11Response {
|
export class OB11Response {
|
||||||
static res<T>(data: T, status: string, retcode: number, message: string = ''): OB11Return<T> {
|
static res<T>(data: T, status: string, retcode: number, message: string = ''): OB11Return<T> {
|
||||||
|
@@ -11,7 +11,7 @@ export default class GetGroupAddRequest extends BaseAction<null, OB11GroupReques
|
|||||||
actionName = ActionName.GetGroupIgnoreAddRequest;
|
actionName = ActionName.GetGroupIgnoreAddRequest;
|
||||||
|
|
||||||
async _handle(payload: null): Promise<OB11GroupRequestNotify[] | null> {
|
async _handle(payload: null): Promise<OB11GroupRequestNotify[] | null> {
|
||||||
const data = await this.core.apis.GroupApi.getGroupIgnoreNotifies();
|
// const data = await this.core.apis.GroupApi.getGroupIgnoreNotifies();
|
||||||
// log(data);
|
// log(data);
|
||||||
// const notifies: GroupNotify[] = data.notifies.filter(notify => notify.status === GroupNotifyStatus.WAIT_HANDLE);
|
// const notifies: GroupNotify[] = data.notifies.filter(notify => notify.status === GroupNotifyStatus.WAIT_HANDLE);
|
||||||
// const returnData: OB11GroupRequestNotify[] = [];
|
// const returnData: OB11GroupRequestNotify[] = [];
|
||||||
|
@@ -43,12 +43,12 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
const fileName = mixElementInner.fileName ?? '';
|
const fileName = mixElementInner.fileName ?? '';
|
||||||
let url = '';
|
let url = '';
|
||||||
if (mixElement?.picElement && rawMessage) {
|
if (mixElement?.picElement && rawMessage) {
|
||||||
let tempData =
|
const tempData =
|
||||||
await this.obContext.apis.MsgApi.rawToOb11Converters.picElement?.(mixElement?.picElement, rawMessage, mixElement) as OB11MessageImage | undefined;
|
await this.obContext.apis.MsgApi.rawToOb11Converters.picElement?.(mixElement?.picElement, rawMessage, mixElement) as OB11MessageImage | undefined;
|
||||||
url = tempData?.data.url ?? '';
|
url = tempData?.data.url ?? '';
|
||||||
}
|
}
|
||||||
if (mixElement?.videoElement && rawMessage) {
|
if (mixElement?.videoElement && rawMessage) {
|
||||||
let tempData =
|
const tempData =
|
||||||
await this.obContext.apis.MsgApi.rawToOb11Converters.videoElement?.(mixElement?.videoElement, rawMessage, mixElement) as OB11MessageVideo | undefined;
|
await this.obContext.apis.MsgApi.rawToOb11Converters.videoElement?.(mixElement?.videoElement, rawMessage, mixElement) as OB11MessageVideo | undefined;
|
||||||
url = tempData?.data.url ?? '';
|
url = tempData?.data.url ?? '';
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
@@ -2,6 +2,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
@@ -2,6 +2,7 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { OB11Entities } from '@/onebot/entities';
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
@@ -28,6 +28,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
...extendData.detail.commonExt,
|
...extendData.detail.commonExt,
|
||||||
...extendData.detail.simpleInfo.baseInfo,
|
...extendData.detail.simpleInfo.baseInfo,
|
||||||
...extendData.detail.simpleInfo.relationFlags,
|
...extendData.detail.simpleInfo.relationFlags,
|
||||||
|
...extendData.detail.simpleInfo.status,
|
||||||
user_id: parseInt(extendData.detail.uin) || 0,
|
user_id: parseInt(extendData.detail.uin) || 0,
|
||||||
nickname: extendData.detail.simpleInfo.coreInfo.nick,
|
nickname: extendData.detail.simpleInfo.coreInfo.nick,
|
||||||
sex: OB11UserSex.unknown,
|
sex: OB11UserSex.unknown,
|
||||||
|
@@ -11,7 +11,10 @@ const SchemaData = {
|
|||||||
content: { type: 'string' },
|
content: { type: 'string' },
|
||||||
image: { type: 'string' },
|
image: { type: 'string' },
|
||||||
pinned: { type: ['number', 'string'] },
|
pinned: { type: ['number', 'string'] },
|
||||||
|
type: { type: ['number', 'string'] },
|
||||||
confirm_required: { type: ['number', 'string'] },
|
confirm_required: { type: ['number', 'string'] },
|
||||||
|
is_show_edit_card: { type: ['number', 'string'] },
|
||||||
|
tip_window_type: { type: ['number', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id', 'content'],
|
required: ['group_id', 'content'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
@@ -22,6 +25,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
|
|
||||||
let UploadImage: { id: string, width: number, height: number } | undefined = undefined;
|
let UploadImage: { id: string, width: number, height: number } | undefined = undefined;
|
||||||
if (payload.image) {
|
if (payload.image) {
|
||||||
//公告图逻辑
|
//公告图逻辑
|
||||||
@@ -47,12 +51,28 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
UploadImage = ImageUploadResult.picInfo;
|
UploadImage = ImageUploadResult.picInfo;
|
||||||
}
|
}
|
||||||
const noticePinned = +(payload.pinned ?? 0);
|
|
||||||
const noticeConfirmRequired = +(payload.confirm_required ?? 0);
|
|
||||||
const publishGroupBulletinResult = await this.core.apis.GroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, noticePinned, noticeConfirmRequired);
|
|
||||||
|
|
||||||
if (publishGroupBulletinResult.result != 0) {
|
const noticeType = +(payload.type ?? 1);
|
||||||
throw `设置群公告失败,错误信息:${publishGroupBulletinResult.errMsg}`;
|
const noticePinned = +(payload.pinned ?? 0);
|
||||||
|
|
||||||
|
const noticeShowEditCard = +(payload.is_show_edit_card ?? 0);
|
||||||
|
const noticeTipWindowType = +(payload.tip_window_type ?? 0);
|
||||||
|
const noticeConfirmRequired = +(payload.confirm_required ?? 1);
|
||||||
|
//const publishGroupBulletinResult = await this.core.apis.GroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, noticePinned, noticeConfirmRequired);
|
||||||
|
const publishGroupBulletinResult = await this.core.apis.WebApi.setGroupNotice(
|
||||||
|
payload.group_id.toString(),
|
||||||
|
payload.content,
|
||||||
|
noticePinned,
|
||||||
|
noticeType,
|
||||||
|
noticeShowEditCard,
|
||||||
|
noticeTipWindowType,
|
||||||
|
noticeConfirmRequired,
|
||||||
|
UploadImage?.id,
|
||||||
|
UploadImage?.width,
|
||||||
|
UploadImage?.height
|
||||||
|
);
|
||||||
|
if (!publishGroupBulletinResult || publishGroupBulletinResult.ec != 0) {
|
||||||
|
throw `设置群公告失败,错误信息:${publishGroupBulletinResult?.em}`;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@@ -51,7 +51,7 @@ export class GetGroupEssence extends BaseAction<Payload, any> {
|
|||||||
operator_nick: msg.add_digest_nick,
|
operator_nick: msg.add_digest_nick,
|
||||||
message_id: message_id,
|
message_id: message_id,
|
||||||
operator_time: msg.add_digest_time,
|
operator_time: msg.add_digest_time,
|
||||||
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage, 'array'))?.message
|
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage))?.message
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const msgTempData = JSON.stringify({
|
const msgTempData = JSON.stringify({
|
||||||
|
@@ -26,7 +26,7 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
if (!uid) throw new Error(`Uin2Uid Error ${payload.user_id}不存在`);
|
if (!uid) throw new Error(`Uin2Uid Error ${payload.user_id}不存在`);
|
||||||
const [member, info] = await Promise.allSettled([
|
const [member, info] = await Promise.allSettled([
|
||||||
this.core.apis.GroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache),
|
this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, isNocache),
|
||||||
this.core.apis.UserApi.getUserDetailInfo(uid),
|
this.core.apis.UserApi.getUserDetailInfo(uid),
|
||||||
]);
|
]);
|
||||||
if (member.status !== 'fulfilled') throw new Error(`群(${payload.group_id})成员${payload.user_id}获取失败 ${member.reason}`);
|
if (member.status !== 'fulfilled') throw new Error(`群(${payload.group_id})成员${payload.user_id}获取失败 ${member.reason}`);
|
||||||
|
@@ -83,6 +83,7 @@ import { DeleteGroupFileFolder } from '@/onebot/action/go-cqhttp/DeleteGroupFile
|
|||||||
import { GetGroupFileSystemInfo } from '@/onebot/action/go-cqhttp/GetGroupFileSystemInfo';
|
import { GetGroupFileSystemInfo } from '@/onebot/action/go-cqhttp/GetGroupFileSystemInfo';
|
||||||
import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
import { GetGroupRootFiles } from '@/onebot/action/go-cqhttp/GetGroupRootFiles';
|
||||||
import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder';
|
import { GetGroupFilesByFolder } from '@/onebot/action/go-cqhttp/GetGroupFilesByFolder';
|
||||||
|
import { GetGroupSystemMsg } from './system/GetSystemMsg';
|
||||||
|
|
||||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||||
|
|
||||||
@@ -176,6 +177,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new DeleteGroupFileFolder(obContext, core),
|
new DeleteGroupFileFolder(obContext, core),
|
||||||
new GetGroupFileSystemInfo(obContext, core),
|
new GetGroupFileSystemInfo(obContext, core),
|
||||||
new GetGroupFilesByFolder(obContext, core),
|
new GetGroupFilesByFolder(obContext, core),
|
||||||
|
new GetGroupSystemMsg(obContext, core),
|
||||||
];
|
];
|
||||||
const actionMap = new Map();
|
const actionMap = new Map();
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@@ -25,15 +25,7 @@ class DeleteMsg extends BaseAction<Payload, void> {
|
|||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
const msg = MessageUnique.getMsgIdAndPeerByShortId(Number(payload.message_id));
|
||||||
if (msg) {
|
if (msg) {
|
||||||
const ret = this.core.eventWrapper.registerListen(
|
await this.core.apis.MsgApi.recallMsg(msg.Peer, msg.MsgId);
|
||||||
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
|
||||||
1,
|
|
||||||
1000,
|
|
||||||
(msgs) => !!msgs.find(m => m.msgId === msg.MsgId && m.recallTime !== '0'),
|
|
||||||
).catch(() => undefined);
|
|
||||||
await this.core.apis.MsgApi.recallMsg(msg.Peer, [msg.MsgId]);
|
|
||||||
const data = await ret;
|
|
||||||
if (!data) throw new Error('Recall failed');
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Recall failed');
|
throw new Error('Recall failed');
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
|||||||
const msg = await this.core.apis.MsgApi.getMsgsByMsgId(
|
const msg = await this.core.apis.MsgApi.getMsgsByMsgId(
|
||||||
peer,
|
peer,
|
||||||
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
||||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg.msgList[0], 'array');
|
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg.msgList[0]);
|
||||||
if (!retMsg) throw Error('消息为空');
|
if (!retMsg) throw Error('消息为空');
|
||||||
try {
|
try {
|
||||||
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgList[0].msgId)!;
|
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgList[0].msgId)!;
|
||||||
|
50
src/onebot/action/system/GetSystemMsg.ts
Normal file
50
src/onebot/action/system/GetSystemMsg.ts
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import { GroupNotifyMsgStatus } from '@/core';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
group_id: { type: ['number', 'string'] },
|
||||||
|
},
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class GetGroupSystemMsg extends BaseAction<void, any> {
|
||||||
|
actionName = ActionName.GetGroupSystemMsg;
|
||||||
|
|
||||||
|
async _handle(payload: void) {
|
||||||
|
const NTQQUserApi = this.core.apis.UserApi;
|
||||||
|
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||||
|
// 默认10条 该api未完整实现 包括响应数据规范化 类型规范化
|
||||||
|
const SingleScreenNotifies = await NTQQGroupApi.getSingleScreenNotifies(false,10);
|
||||||
|
const retData: any = { InvitedRequest: [], join_requests: [] };
|
||||||
|
for (const SSNotify of SingleScreenNotifies) {
|
||||||
|
if (SSNotify.type == 1) {
|
||||||
|
retData.InvitedRequest.push({
|
||||||
|
request_id: SSNotify.seq,
|
||||||
|
invitor_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid),
|
||||||
|
invitor_nick: SSNotify.user1?.nickName,
|
||||||
|
group_id: SSNotify.group?.groupCode,
|
||||||
|
group_name: SSNotify.group?.groupName,
|
||||||
|
checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true,
|
||||||
|
actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
|
||||||
|
});
|
||||||
|
} else if (SSNotify.type == 7) {
|
||||||
|
retData.join_requests.push({
|
||||||
|
request_id: SSNotify.seq,
|
||||||
|
requester_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid),
|
||||||
|
requester_nick: SSNotify.user1?.nickName,
|
||||||
|
group_id: SSNotify.group?.groupCode,
|
||||||
|
group_name: SSNotify.group?.groupName,
|
||||||
|
checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true,
|
||||||
|
actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return retData;
|
||||||
|
}
|
||||||
|
}
|
@@ -116,5 +116,6 @@ export enum ActionName {
|
|||||||
SetInputStatus = 'set_input_status',
|
SetInputStatus = 'set_input_status',
|
||||||
GetCSRF = 'get_csrf_token',
|
GetCSRF = 'get_csrf_token',
|
||||||
DelGroupNotice = '_del_group_notice',
|
DelGroupNotice = '_del_group_notice',
|
||||||
GetGroupInfoEx = "get_group_info_ex"
|
GetGroupInfoEx = "get_group_info_ex",
|
||||||
|
GetGroupSystemMsg = 'get_group_system_msg',
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ export default class GetRecentContact extends BaseAction<Payload, any> {
|
|||||||
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
const FastMsg = await this.core.apis.MsgApi.getMsgsByMsgId({ chatType: t.chatType, peerUid: t.peerUid }, [t.msgId]);
|
||||||
if (FastMsg.msgList.length > 0) {
|
if (FastMsg.msgList.length > 0) {
|
||||||
//扩展ret.info.changedList
|
//扩展ret.info.changedList
|
||||||
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0], 'array');
|
const lastestMsg = await this.obContext.apis.MsgApi.parseMessage(FastMsg.msgList[0]);
|
||||||
return {
|
return {
|
||||||
lastestMsg: lastestMsg,
|
lastestMsg: lastestMsg,
|
||||||
peerUin: t.peerUin,
|
peerUin: t.peerUin,
|
||||||
|
@@ -18,7 +18,6 @@ export class OneBotFriendApi {
|
|||||||
let pokedetail: any[] = json.items;
|
let pokedetail: any[] = json.items;
|
||||||
//筛选item带有uid的元素
|
//筛选item带有uid的元素
|
||||||
pokedetail = pokedetail.filter(item => item.uid);
|
pokedetail = pokedetail.filter(item => item.uid);
|
||||||
//console.log("[NapCat] 群拍一拍 群:", pokedetail, parseInt(msg.peerUid), " ", await NTQQUserApi.getUinByUid(pokedetail[0].uid), "拍了拍", await NTQQUserApi.getUinByUid(pokedetail[1].uid));
|
|
||||||
if (pokedetail.length == 2) {
|
if (pokedetail.length == 2) {
|
||||||
return new OB11FriendPokeEvent(
|
return new OB11FriendPokeEvent(
|
||||||
this.core,
|
this.core,
|
||||||
|
@@ -19,6 +19,7 @@ import { OB11GroupPokeEvent } from '@/onebot/event/notice/OB11PokeEvent';
|
|||||||
import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent';
|
import { OB11GroupEssenceEvent } from '@/onebot/event/notice/OB11GroupEssenceEvent';
|
||||||
import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent';
|
import { OB11GroupTitleEvent } from '@/onebot/event/notice/OB11GroupTitleEvent';
|
||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
|
|
||||||
export class OneBotGroupApi {
|
export class OneBotGroupApi {
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
@@ -77,7 +78,8 @@ export class OneBotGroupApi {
|
|||||||
id: FileNapCatOneBotUUID.encode({
|
id: FileNapCatOneBotUUID.encode({
|
||||||
chatType: ChatType.KCHATTYPEGROUP,
|
chatType: ChatType.KCHATTYPEGROUP,
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
}, msg.msgId, element.elementId),
|
}, msg.msgId, element.elementId, "." + element.fileElement.fileName),
|
||||||
|
url: pathToFileURL(element.fileElement.filePath).href,
|
||||||
name: element.fileElement.fileName,
|
name: element.fileElement.fileName,
|
||||||
size: parseInt(element.fileElement.fileSize),
|
size: parseInt(element.fileElement.fileSize),
|
||||||
busid: element.fileElement.fileBizId || 0,
|
busid: element.fileElement.fileBizId || 0,
|
||||||
@@ -138,15 +140,25 @@ export class OneBotGroupApi {
|
|||||||
}
|
}
|
||||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 2407) {
|
if (element.grayTipElement.jsonGrayTipElement.busiId == 2407) {
|
||||||
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
||||||
const memberUin = json.items[1].param[0];
|
const type = json.items[json.items.length - 1]?.txt;
|
||||||
const title = json.items[3].txt;
|
switch (type) {
|
||||||
logger.logDebug('收到群成员新头衔消息', json);
|
case "头衔": {
|
||||||
return new OB11GroupTitleEvent(
|
const memberUin = json.items[1].param[0];
|
||||||
this.core,
|
const title = json.items[3].txt;
|
||||||
parseInt(msg.peerUid),
|
logger.logDebug('收到群成员新头衔消息', json);
|
||||||
parseInt(memberUin),
|
return new OB11GroupTitleEvent(
|
||||||
title,
|
this.core,
|
||||||
);
|
parseInt(msg.peerUid),
|
||||||
|
parseInt(memberUin),
|
||||||
|
title,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
case "移出":
|
||||||
|
logger.logDebug('收到机器人被踢消息', json);
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
logger.logWarn('收到未知的灰条消息', json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
import { MessageUnique } from '@/common/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
import { pathToFileURL } from 'node:url';
|
||||||
import {
|
import {
|
||||||
AtType,
|
AtType,
|
||||||
ChatType,
|
ChatType,
|
||||||
@@ -106,7 +107,7 @@ export class OneBotMsgApi {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId);
|
const encodedFileId = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + element.fileName);
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.image,
|
type: OB11MessageDataType.image,
|
||||||
data: {
|
data: {
|
||||||
@@ -114,7 +115,9 @@ export class OneBotMsgApi {
|
|||||||
sub_type: element.picSubType,
|
sub_type: element.picSubType,
|
||||||
file_id: encodedFileId,
|
file_id: encodedFileId,
|
||||||
url: await this.core.apis.FileApi.getImageUrl(element),
|
url: await this.core.apis.FileApi.getImageUrl(element),
|
||||||
|
path: element.filePath,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
|
file_unique: element.fileName
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -129,28 +132,15 @@ export class OneBotMsgApi {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
await this.core.apis.FileApi.addFileCache(
|
|
||||||
{
|
|
||||||
peerUid: msg.peerUid,
|
|
||||||
chatType: msg.chatType,
|
|
||||||
guildId: '',
|
|
||||||
},
|
|
||||||
msg.msgId,
|
|
||||||
msg.msgSeq,
|
|
||||||
msg.senderUid,
|
|
||||||
elementWrapper.elementId,
|
|
||||||
elementWrapper.elementType.toString(),
|
|
||||||
element.fileSize,
|
|
||||||
element.fileName,
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.file,
|
type: OB11MessageDataType.file,
|
||||||
data: {
|
data: {
|
||||||
file: element.fileName,
|
file: element.fileName,
|
||||||
path: element.filePath,
|
path: element.filePath,
|
||||||
url: element.filePath,
|
url: pathToFileURL(element.filePath).href,
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId),
|
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + element.fileName),
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
|
file_unique: element.fileName,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -182,32 +172,22 @@ export class OneBotMsgApi {
|
|||||||
},
|
},
|
||||||
|
|
||||||
marketFaceElement: async (_, msg, elementWrapper) => {
|
marketFaceElement: async (_, msg, elementWrapper) => {
|
||||||
await this.core.apis.FileApi.addFileCache(
|
|
||||||
{
|
|
||||||
peerUid: msg.peerUid,
|
|
||||||
chatType: msg.chatType,
|
|
||||||
guildId: '',
|
|
||||||
},
|
|
||||||
msg.msgId,
|
|
||||||
msg.msgSeq,
|
|
||||||
msg.senderUid,
|
|
||||||
elementWrapper.elementId,
|
|
||||||
elementWrapper.elementType.toString(),
|
|
||||||
'0',
|
|
||||||
'marketface',
|
|
||||||
);
|
|
||||||
const peer = {
|
const peer = {
|
||||||
chatType: msg.chatType,
|
chatType: msg.chatType,
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
|
const { emojiId } = _;
|
||||||
|
const dir = emojiId.substring(0, 2);
|
||||||
|
const url = `https://gxh.vip.qq.com/club/item/parcel/item/${dir}/${emojiId}/raw300.gif`;
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.image,
|
type: OB11MessageDataType.image,
|
||||||
data: {
|
data: {
|
||||||
file: 'marketface',
|
file: 'marketface',
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId),
|
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + _.key + ".jpg"),
|
||||||
path: elementWrapper.elementId,
|
path: elementWrapper.elementId,
|
||||||
url: elementWrapper.elementId,
|
url: url,
|
||||||
|
file_unique: _.key
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -234,7 +214,7 @@ export class OneBotMsgApi {
|
|||||||
if (records.peerUin === '284840486') {
|
if (records.peerUin === '284840486') {
|
||||||
return createReplyData(records.msgId);
|
return createReplyData(records.msgId);
|
||||||
}
|
}
|
||||||
let replyMsg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeqV2(peer, element.replayMsgSeq, element.replyMsgTime, [element.senderUidStr]))
|
const replyMsg = (await this.core.apis.MsgApi.queryMsgsWithFilterExWithSeqV2(peer, element.replayMsgSeq, element.replyMsgTime, [element.senderUidStr]))
|
||||||
.msgList.find(msg => msg.msgRandom === records.msgRandom);
|
.msgList.find(msg => msg.msgRandom === records.msgRandom);
|
||||||
|
|
||||||
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
if (!replyMsg || records.msgRandom !== replyMsg.msgRandom) {
|
||||||
@@ -282,30 +262,16 @@ export class OneBotMsgApi {
|
|||||||
if (!videoDownUrl) {
|
if (!videoDownUrl) {
|
||||||
videoDownUrl = element.filePath;
|
videoDownUrl = element.filePath;
|
||||||
}
|
}
|
||||||
|
const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + element.fileName);
|
||||||
await this.core.apis.FileApi.addFileCache(
|
|
||||||
{
|
|
||||||
peerUid: msg.peerUid,
|
|
||||||
chatType: msg.chatType,
|
|
||||||
guildId: '',
|
|
||||||
},
|
|
||||||
msg.msgId,
|
|
||||||
msg.msgSeq,
|
|
||||||
msg.senderUid,
|
|
||||||
elementWrapper.elementId,
|
|
||||||
elementWrapper.elementType.toString(),
|
|
||||||
element.fileSize ?? '0',
|
|
||||||
element.fileName,
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.video,
|
type: OB11MessageDataType.video,
|
||||||
data: {
|
data: {
|
||||||
file: element.fileName,
|
file: fileCode,
|
||||||
path: videoDownUrl,
|
path: videoDownUrl,
|
||||||
url: videoDownUrl,
|
url: videoDownUrl ?? pathToFileURL(element.filePath).href,
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId),
|
file_id: fileCode,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
|
file_unique: element.fileName,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -316,27 +282,16 @@ export class OneBotMsgApi {
|
|||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
guildId: '',
|
guildId: '',
|
||||||
};
|
};
|
||||||
await this.core.apis.FileApi.addFileCache(
|
const fileCode = FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId, "." + element.fileName);
|
||||||
{
|
|
||||||
peerUid: msg.peerUid,
|
|
||||||
chatType: msg.chatType,
|
|
||||||
guildId: '',
|
|
||||||
},
|
|
||||||
msg.msgId,
|
|
||||||
msg.msgSeq,
|
|
||||||
msg.senderUid,
|
|
||||||
elementWrapper.elementId,
|
|
||||||
elementWrapper.elementType.toString(),
|
|
||||||
element.fileSize || '0',
|
|
||||||
element.fileUuid || '',
|
|
||||||
);
|
|
||||||
return {
|
return {
|
||||||
type: OB11MessageDataType.voice,
|
type: OB11MessageDataType.voice,
|
||||||
data: {
|
data: {
|
||||||
file: element.fileName,
|
file: fileCode,
|
||||||
path: element.filePath,
|
path: element.filePath,
|
||||||
file_id: FileNapCatOneBotUUID.encode(peer, msg.msgId, elementWrapper.elementId),
|
url: pathToFileURL(element.filePath).href,
|
||||||
|
file_id: fileCode,
|
||||||
file_size: element.fileSize,
|
file_size: element.fileSize,
|
||||||
|
file_unique: element.fileName
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -730,8 +685,10 @@ export class OneBotMsgApi {
|
|||||||
if (ret.result === 0) {
|
if (ret.result === 0) {
|
||||||
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
resMsg.group_id = parseInt(ret.tmpChatInfo!.groupCode);
|
||||||
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick;
|
resMsg.sender.nickname = ret.tmpChatInfo!.fromNick;
|
||||||
|
resMsg.temp_source = resMsg.group_id;
|
||||||
} else {
|
} else {
|
||||||
resMsg.group_id = 284840486; //兜底数据
|
resMsg.group_id = 284840486; //兜底数据
|
||||||
|
resMsg.temp_source = resMsg.group_id;
|
||||||
resMsg.sender.nickname = '临时会话';
|
resMsg.sender.nickname = '临时会话';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -841,20 +798,18 @@ export class OneBotMsgApi {
|
|||||||
{ data: inputdata }: OB11MessageFileBase,
|
{ data: inputdata }: OB11MessageFileBase,
|
||||||
{ deleteAfterSentFiles }: MessageContext,
|
{ deleteAfterSentFiles }: MessageContext,
|
||||||
) {
|
) {
|
||||||
const isBlankUrl = !inputdata.url || inputdata.url === '';
|
const realUri = inputdata.url || inputdata.file || inputdata.path || '';
|
||||||
const isBlankFile = !inputdata.file || inputdata.file === '';
|
if (realUri.length === 0) {
|
||||||
if (isBlankUrl && isBlankFile) {
|
|
||||||
this.core.context.logger.logError('文件消息缺少参数', inputdata);
|
this.core.context.logger.logError('文件消息缺少参数', inputdata);
|
||||||
throw Error('文件消息缺少参数');
|
throw Error('文件消息缺少参数');
|
||||||
}
|
}
|
||||||
const fileOrUrl = (isBlankUrl ? inputdata.file : inputdata.url) ?? '';
|
|
||||||
const {
|
const {
|
||||||
path,
|
path,
|
||||||
isLocal,
|
isLocal,
|
||||||
fileName,
|
fileName,
|
||||||
errMsg,
|
errMsg,
|
||||||
success,
|
success,
|
||||||
} = (await uri2local(this.core.NapCatTempPath, fileOrUrl));
|
} = (await uri2local(this.core.NapCatTempPath, realUri));
|
||||||
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
this.core.context.logger.logError('文件下载失败', errMsg);
|
this.core.context.logger.logError('文件下载失败', errMsg);
|
||||||
|
@@ -66,10 +66,7 @@ export function encodeCQCode(data: OB11MessageData) {
|
|||||||
|
|
||||||
let result = '[CQ:' + data.type;
|
let result = '[CQ:' + data.type;
|
||||||
for (const name in data.data) {
|
for (const name in data.data) {
|
||||||
const value =
|
const value = (data.data as any)[name];
|
||||||
// eslint-disable-next-line
|
|
||||||
// @ts-ignore
|
|
||||||
data.data[name];
|
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -109,7 +109,7 @@ export class OB11Entities {
|
|||||||
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
static file(peerId: string, file: Exclude<GroupFileInfoUpdateParamType['item'][0]['fileInfo'], undefined>): OB11GroupFile {
|
||||||
return {
|
return {
|
||||||
group_id: parseInt(peerId),
|
group_id: parseInt(peerId),
|
||||||
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId, file.fileId),
|
file_id: FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: peerId }, file.fileModelId, file.fileId, file.fileName),
|
||||||
file_name: file.fileName,
|
file_name: file.fileName,
|
||||||
busid: file.busId,
|
busid: file.busId,
|
||||||
size: parseInt(file.fileSize),
|
size: parseInt(file.fileSize),
|
||||||
|
@@ -6,6 +6,7 @@ export interface GroupUploadFile {
|
|||||||
name: string,
|
name: string,
|
||||||
size: number,
|
size: number,
|
||||||
busid: number,
|
busid: number,
|
||||||
|
url:string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupUploadNoticeEvent extends OB11GroupNoticeEvent {
|
||||||
|
@@ -43,9 +43,6 @@ import { OB11FriendRecallNoticeEvent } from '@/onebot/event/notice/OB11FriendRec
|
|||||||
import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecallNoticeEvent';
|
import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecallNoticeEvent';
|
||||||
import { LRUCache } from '@/common/lru-cache';
|
import { LRUCache } from '@/common/lru-cache';
|
||||||
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
||||||
import { SysMessage } from '@/core/proto/SysMessage';
|
|
||||||
import { GreyTipWrapper } from '@/core/proto/GreyTipWrapper';
|
|
||||||
import { EmojiLikeToOthersWrapper1 } from '@/core/proto/EmojiLikeToOthers';
|
|
||||||
|
|
||||||
//OneBot实现类
|
//OneBot实现类
|
||||||
export class NapCatOneBot11Adapter {
|
export class NapCatOneBot11Adapter {
|
||||||
@@ -101,7 +98,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
if (ob11Config.http.enablePost) {
|
if (ob11Config.http.enablePost) {
|
||||||
ob11Config.http.postUrls.forEach(url => {
|
ob11Config.http.postUrls.forEach(url => {
|
||||||
this.networkManager.registerAdapter(new OB11ActiveHttpAdapter(
|
this.networkManager.registerAdapter(new OB11ActiveHttpAdapter(
|
||||||
url, ob11Config.token, this.core, this,
|
url, ob11Config.http.secret, this.core, this,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -171,7 +168,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
if (now.http.enablePost) {
|
if (now.http.enablePost) {
|
||||||
now.http.postUrls.forEach(url => {
|
now.http.postUrls.forEach(url => {
|
||||||
this.networkManager.registerAdapterAndOpen(new OB11ActiveHttpAdapter(
|
this.networkManager.registerAdapterAndOpen(new OB11ActiveHttpAdapter(
|
||||||
url, now.token, this.core, this,
|
url, now.http.secret, this.core, this,
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -185,7 +182,7 @@ export class NapCatOneBot11Adapter {
|
|||||||
);
|
);
|
||||||
for (const url of added) {
|
for (const url of added) {
|
||||||
await this.networkManager.registerAdapterAndOpen(new OB11ActiveHttpAdapter(
|
await this.networkManager.registerAdapterAndOpen(new OB11ActiveHttpAdapter(
|
||||||
url, now.token, this.core, this,
|
url, now.http.secret, this.core, this,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,33 +238,35 @@ export class NapCatOneBot11Adapter {
|
|||||||
private initMsgListener() {
|
private initMsgListener() {
|
||||||
const msgListener = new NodeIKernelMsgListener();
|
const msgListener = new NodeIKernelMsgListener();
|
||||||
|
|
||||||
msgListener.onRecvSysMsg = async msg => {
|
/*
|
||||||
// const sysMsg = SysMessage.fromBinary(Uint8Array.from(msg));
|
msgListener.onRecvSysMsg = async () => {
|
||||||
// if (sysMsg.msgSpec.length === 0) {
|
const sysMsg = SysMessage.fromBinary(Uint8Array.from(msg));
|
||||||
// return;
|
if (sysMsg.msgSpec.length === 0) {
|
||||||
// }
|
return;
|
||||||
// const { msgType, subType, subSubType } = sysMsg.msgSpec[0];
|
}
|
||||||
// if (msgType === 732 && subType === 16 && subSubType === 16) {
|
const { msgType, subType, subSubType } = sysMsg.msgSpec[0];
|
||||||
// const greyTip = GreyTipWrapper.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody.slice(7)));
|
if (msgType === 732 && subType === 16 && subSubType === 16) {
|
||||||
// if (greyTip.subTypeId === 36) {
|
const greyTip = GreyTipWrapper.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody.slice(7)));
|
||||||
// const emojiLikeToOthers = EmojiLikeToOthersWrapper1
|
if (greyTip.subTypeId === 36) {
|
||||||
// .fromBinary(greyTip.rest)
|
const emojiLikeToOthers = EmojiLikeToOthersWrapper1
|
||||||
// .wrapper!
|
.fromBinary(greyTip.rest)
|
||||||
// .body!;
|
.wrapper!
|
||||||
// if (emojiLikeToOthers.attributes?.operation !== 1) { // Un-like
|
.body!;
|
||||||
// return;
|
if (emojiLikeToOthers.attributes?.operation !== 1) { // Un-like
|
||||||
// }
|
return;
|
||||||
// const eventOrEmpty = await this.apis.GroupApi.createGroupEmojiLikeEvent(
|
}
|
||||||
// greyTip.groupCode.toString(),
|
const eventOrEmpty = await this.apis.GroupApi.createGroupEmojiLikeEvent(
|
||||||
// await this.core.apis.UserApi.getUinByUidV2(emojiLikeToOthers.attributes!.senderUid),
|
greyTip.groupCode.toString(),
|
||||||
// emojiLikeToOthers.msgSpec!.msgSeq.toString(),
|
await this.core.apis.UserApi.getUinByUidV2(emojiLikeToOthers.attributes!.senderUid),
|
||||||
// emojiLikeToOthers.attributes!.emojiId,
|
emojiLikeToOthers.msgSpec!.msgSeq.toString(),
|
||||||
// );
|
emojiLikeToOthers.attributes!.emojiId,
|
||||||
// // eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
);
|
||||||
// eventOrEmpty && await this.networkManager.emitEvent(eventOrEmpty);
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||||
// }
|
eventOrEmpty && await this.networkManager.emitEvent(eventOrEmpty);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
msgListener.onInputStatusPush = async data => {
|
msgListener.onInputStatusPush = async data => {
|
||||||
const uin = await this.core.apis.UserApi.getUinByUidV2(data.fromUin);
|
const uin = await this.core.apis.UserApi.getUinByUidV2(data.fromUin);
|
||||||
|
@@ -147,7 +147,7 @@ export class OB11ActiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
this.checkStateAndReply<any>(OB11Response.error('不支持的api ' + receiveData.action, 1404, echo));
|
this.checkStateAndReply<any>(OB11Response.error('不支持的api ' + receiveData.action, 1404, echo));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const retdata = await action?.websocketHandle(receiveData.params, echo ?? '');
|
const retdata = await action.websocketHandle(receiveData.params, echo ?? '');
|
||||||
const packet = Object.assign({}, retdata);
|
const packet = Object.assign({}, retdata);
|
||||||
this.checkStateAndReply<any>(packet);
|
this.checkStateAndReply<any>(packet);
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
core: NapCatCore;
|
core: NapCatCore;
|
||||||
logger: LogWrapper;
|
logger: LogWrapper;
|
||||||
private heartbeatIntervalId: NodeJS.Timeout | null = null;
|
private heartbeatIntervalId: NodeJS.Timeout | null = null;
|
||||||
|
wsClientWithEvent: WebSocket[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
ip: string,
|
ip: string,
|
||||||
@@ -46,7 +47,12 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
}
|
}
|
||||||
//鉴权
|
//鉴权
|
||||||
this.authorize(token, wsClient, wsReq);
|
this.authorize(token, wsClient, wsReq);
|
||||||
this.connectEvent(core, wsClient);
|
let paramUrl = wsReq.url?.indexOf('?') !== -1 ? wsReq.url?.substring(0, wsReq.url?.indexOf('?')) : wsReq.url;
|
||||||
|
const isEventConnect = paramUrl === '/event' || paramUrl === '' || paramUrl === '/';
|
||||||
|
if (isEventConnect) {
|
||||||
|
this.connectEvent(core, wsClient);
|
||||||
|
}
|
||||||
|
|
||||||
wsClient.on('error', (err) => this.logger.log('[OneBot] [WebSocket Server] Client Error:', err.message));
|
wsClient.on('error', (err) => this.logger.log('[OneBot] [WebSocket Server] Client Error:', err.message));
|
||||||
wsClient.on('message', (message) => {
|
wsClient.on('message', (message) => {
|
||||||
this.handleMessage(wsClient, message).then().catch(this.logger.logError);
|
this.handleMessage(wsClient, message).then().catch(this.logger.logError);
|
||||||
@@ -59,13 +65,21 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
});
|
});
|
||||||
wsClient.once('close', () => {
|
wsClient.once('close', () => {
|
||||||
this.wsClientsMutex.runExclusive(async () => {
|
this.wsClientsMutex.runExclusive(async () => {
|
||||||
const index = this.wsClients.indexOf(wsClient);
|
const NormolIndex = this.wsClients.indexOf(wsClient);
|
||||||
if (index !== -1) {
|
if (NormolIndex !== -1) {
|
||||||
this.wsClients.splice(index, 1);
|
this.wsClients.splice(NormolIndex, 1);
|
||||||
}
|
}
|
||||||
|
const EventIndex = this.wsClientWithEvent.indexOf(wsClient);
|
||||||
|
if (EventIndex !== -1) {
|
||||||
|
this.wsClientWithEvent.splice(EventIndex, 1);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
await this.wsClientsMutex.runExclusive(async () => {
|
await this.wsClientsMutex.runExclusive(async () => {
|
||||||
|
if(isEventConnect){
|
||||||
|
this.wsClientWithEvent.push(wsClient);
|
||||||
|
}
|
||||||
this.wsClients.push(wsClient);
|
this.wsClients.push(wsClient);
|
||||||
});
|
});
|
||||||
}).on('error', (err) => this.logger.log('[OneBot] [WebSocket Server] Server Error:', err.message));
|
}).on('error', (err) => this.logger.log('[OneBot] [WebSocket Server] Server Error:', err.message));
|
||||||
@@ -81,7 +95,7 @@ export class OB11PassiveWebSocketAdapter implements IOB11NetworkAdapter {
|
|||||||
|
|
||||||
onEvent<T extends OB11EmitEventContent>(event: T) {
|
onEvent<T extends OB11EmitEventContent>(event: T) {
|
||||||
this.wsClientsMutex.runExclusive(async () => {
|
this.wsClientsMutex.runExclusive(async () => {
|
||||||
this.wsClients.forEach((wsClient) => {
|
this.wsClientWithEvent.forEach((wsClient) => {
|
||||||
wsClient.send(JSON.stringify(event));
|
wsClient.send(JSON.stringify(event));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -8,6 +8,7 @@ export enum OB11MessageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface OB11Message {
|
export interface OB11Message {
|
||||||
|
temp_source?: number;
|
||||||
message_sent_type?: string;
|
message_sent_type?: string;
|
||||||
target_id?: number; // 自己发送的消息才有此字段
|
target_id?: number; // 自己发送的消息才有此字段
|
||||||
self_id?: number,
|
self_id?: number,
|
||||||
@@ -83,6 +84,8 @@ export interface OB11MessageText {
|
|||||||
|
|
||||||
export interface OB11MessageFileBase {
|
export interface OB11MessageFileBase {
|
||||||
data: {
|
data: {
|
||||||
|
file_unique?:string,
|
||||||
|
path?: string;
|
||||||
thumb?: string;
|
thumb?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
file: string,
|
file: string,
|
||||||
|
@@ -17,7 +17,6 @@ export interface QuickActionGroupMessage extends QuickActionPrivateMessage {
|
|||||||
kick?: boolean;
|
kick?: boolean;
|
||||||
ban?: boolean;
|
ban?: boolean;
|
||||||
ban_duration?: number;
|
ban_duration?: number;
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QuickActionFriendRequest {
|
export interface QuickActionFriendRequest {
|
||||||
|
@@ -49,12 +49,20 @@ export async function NCoreInitShell() {
|
|||||||
const session = new wrapper.NodeIQQNTWrapperSession();
|
const session = new wrapper.NodeIQQNTWrapperSession();
|
||||||
|
|
||||||
// from get dataPath
|
// from get dataPath
|
||||||
let dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
const [dataPath, dataPathGlobal] = (() => {
|
||||||
if (!dataPath) {
|
if (os.platform() === 'darwin') {
|
||||||
dataPath = path.resolve(os.homedir(), './.config/QQ');
|
const userPath = os.homedir();
|
||||||
fs.mkdirSync(dataPath, { recursive: true });
|
const appDataPath = path.resolve(userPath, './Library/Application Support/QQ');
|
||||||
}
|
return [appDataPath, path.join(appDataPath, 'global')];
|
||||||
const dataPathGlobal = path.resolve(dataPath, './nt_qq/global');
|
}
|
||||||
|
let dataPath = wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
||||||
|
if (!dataPath) {
|
||||||
|
dataPath = path.resolve(os.homedir(), './.config/QQ');
|
||||||
|
fs.mkdirSync(dataPath, { recursive: true });
|
||||||
|
}
|
||||||
|
const dataPathGlobal = path.resolve(dataPath, './nt_qq/global');
|
||||||
|
return [dataPath, dataPathGlobal];
|
||||||
|
})();
|
||||||
|
|
||||||
// from initConfig
|
// from initConfig
|
||||||
engine.initWithDeskTopConfig(
|
engine.initWithDeskTopConfig(
|
||||||
@@ -115,7 +123,7 @@ export async function NCoreInitShell() {
|
|||||||
const realBase64 = pngBase64QrcodeData.replace(/^data:image\/\w+;base64,/, '');
|
const realBase64 = pngBase64QrcodeData.replace(/^data:image\/\w+;base64,/, '');
|
||||||
const buffer = Buffer.from(realBase64, 'base64');
|
const buffer = Buffer.from(realBase64, 'base64');
|
||||||
logger.logWarn('请扫描下面的二维码,然后在手Q上授权登录:');
|
logger.logWarn('请扫描下面的二维码,然后在手Q上授权登录:');
|
||||||
const qrcodePath = path.join(pathWrapper.binaryPath, 'qrcode.png');
|
const qrcodePath = path.join(pathWrapper.cachePath, 'qrcode.png');
|
||||||
qrcode.generate(qrcodeUrl, { small: true }, (res) => {
|
qrcode.generate(qrcodeUrl, { small: true }, (res) => {
|
||||||
logger.logWarn([
|
logger.logWarn([
|
||||||
'\n',
|
'\n',
|
||||||
@@ -142,7 +150,12 @@ export async function NCoreInitShell() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
loginService.addKernelLoginListener(proxiedListenerOf(loginListener, logger) as any);
|
loginService.addKernelLoginListener(proxiedListenerOf(loginListener, logger) as any);
|
||||||
|
const isConnect = loginService.connect();
|
||||||
|
if (!isConnect) {
|
||||||
|
logger.logError('核心登录服务连接失败!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.log('核心登录服务连接成功!');
|
||||||
// 实现WebUi快速登录
|
// 实现WebUi快速登录
|
||||||
loginService.getLoginList().then((res) => {
|
loginService.getLoginList().then((res) => {
|
||||||
// 遍历 res.LocalLoginInfoList[x].isQuickLogin是否可以 res.LocalLoginInfoList[x].uin 转为string 加入string[] 最后遍历完成调用WebUiDataRuntime.setQQQuickLoginList
|
// 遍历 res.LocalLoginInfoList[x].isQuickLogin是否可以 res.LocalLoginInfoList[x].uin 转为string 加入string[] 最后遍历完成调用WebUiDataRuntime.setQQQuickLoginList
|
||||||
@@ -221,7 +234,7 @@ export async function NCoreInitShell() {
|
|||||||
sessionConfig,
|
sessionConfig,
|
||||||
new NodeIDependsAdapter(),
|
new NodeIDependsAdapter(),
|
||||||
new NodeIDispatcherAdapter(),
|
new NodeIDispatcherAdapter(),
|
||||||
sessionListener as any,
|
sessionListener,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
session.startNT(0);
|
session.startNT(0);
|
||||||
|
@@ -3,6 +3,7 @@ import { ALLRouter } from './src/router';
|
|||||||
import { LogWrapper } from '@/common/log';
|
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';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
@@ -38,7 +39,23 @@ 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 () => {
|
||||||
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 URL is http://${config.host}:${config.port}${config.prefix}/webui`);
|
|
||||||
log(`[NapCat] [WebUi] Login Token is ${config.token}`);
|
log(`[NapCat] [WebUi] Login Token is ${config.token}`);
|
||||||
|
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(`[NapCat] [WebUi] Get Publish Panel Url Error: ${err}`);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -30,7 +30,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
undefined,
|
undefined,
|
||||||
SettingButton('V2.2.42', 'napcat-update-button', 'secondary'),
|
SettingButton('V2.4.4', 'napcat-update-button', 'secondary'),
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -164,7 +164,7 @@ async function onSettingWindowCreated(view) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
void 0,
|
void 0,
|
||||||
SettingButton("V2.2.42", "napcat-update-button", "secondary")
|
SettingButton("V2.4.4", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type="text"] {
|
input[type="password"] {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
@@ -64,7 +64,7 @@
|
|||||||
<form id="token-form" onsubmit="event.preventDefault(); submitToken();">
|
<form id="token-form" onsubmit="event.preventDefault(); submitToken();">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label for="token-input">Enter Token:</label>
|
<label for="token-input">Enter Token:</label>
|
||||||
<input type="text" id="token-input" required>
|
<input type="password" id="token-input" required>
|
||||||
</div>
|
</div>
|
||||||
<p class="error-message hidden" id="error-message"></p>
|
<p class="error-message hidden" id="error-message"></p>
|
||||||
<button type="submit">Login</button>
|
<button type="submit">Login</button>
|
||||||
@@ -133,4 +133,4 @@
|
|||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
@@ -25,12 +25,6 @@
|
|||||||
"paths": {
|
"paths": {
|
||||||
"@*": [
|
"@*": [
|
||||||
"./src*"
|
"./src*"
|
||||||
],
|
|
||||||
"@/core": [
|
|
||||||
"./src/core/index",
|
|
||||||
],
|
|
||||||
"@/core/*": [
|
|
||||||
"./src/core/*"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -11,7 +11,6 @@ const nodeModules = [...builtinModules, builtinModules.map(m => `node:${m}`)].fl
|
|||||||
function genCpModule(module: string) {
|
function genCpModule(module: string) {
|
||||||
return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false };
|
return { src: `./node_modules/${module}`, dest: `dist/node_modules/${module}`, flatten: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
let startScripts: string[] | undefined = undefined;
|
let startScripts: string[] | undefined = undefined;
|
||||||
if (process.env.NAPCAT_BUILDSYS == 'linux') {
|
if (process.env.NAPCAT_BUILDSYS == 'linux') {
|
||||||
if (process.env.NAPCAT_BUILDARCH == 'x64') {
|
if (process.env.NAPCAT_BUILDARCH == 'x64') {
|
||||||
@@ -82,6 +81,7 @@ const ShellBaseConfigPlugin: PluginOption[] = [
|
|||||||
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
|
{ src: './src/core/external/napcat.json', dest: 'dist/config/' },
|
||||||
{ src: './src/onebot/config/onebot11.json', dest: 'dist/config/' },
|
{ src: './src/onebot/config/onebot11.json', dest: 'dist/config/' },
|
||||||
{ src: './package.json', dest: 'dist' },
|
{ src: './package.json', dest: 'dist' },
|
||||||
|
{ src: './launcher/', dest: 'dist', flatten: true },
|
||||||
// { src: './README.md', dest: 'dist' },
|
// { src: './README.md', dest: 'dist' },
|
||||||
// { src: './logo.png', dest: 'dist/logs' },
|
// { src: './logo.png', dest: 'dist/logs' },
|
||||||
...(startScripts.map((startScript) => {
|
...(startScripts.map((startScript) => {
|
||||||
|
Reference in New Issue
Block a user