mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
170 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 | ||
![]() |
5065a052fb | ||
![]() |
45603bb78c | ||
![]() |
40948995b4 | ||
![]() |
4ccdd8d1d3 | ||
![]() |
30d0174f47 | ||
![]() |
5a986ba25c | ||
![]() |
fe63c24ac3 | ||
![]() |
c384bd6875 | ||
![]() |
dcbff3f569 | ||
![]() |
7d91e05a69 | ||
![]() |
a5ce424a40 | ||
![]() |
47c36ca062 | ||
![]() |
c4c5b3bf8b | ||
![]() |
b1a81b0d12 | ||
![]() |
ad9fe64850 | ||
![]() |
f236349dc6 | ||
![]() |
5f56c8a7d4 | ||
![]() |
309d8a9f18 | ||
![]() |
2981799803 | ||
![]() |
00f8e1c0da | ||
![]() |
e9482e2ec4 | ||
![]() |
9bff327377 | ||
![]() |
ae009f98c1 | ||
![]() |
77505a6f5b | ||
![]() |
19c729aa23 | ||
![]() |
595888128a | ||
![]() |
51589d0eae | ||
![]() |
f1643ac549 | ||
![]() |
3f24461612 | ||
![]() |
b5deb198de | ||
![]() |
78452cf6a9 | ||
![]() |
4b4a784f56 | ||
![]() |
3e53cbcf8f | ||
![]() |
f34740f1f0 | ||
![]() |
b406bdfc37 | ||
![]() |
03c056702c | ||
![]() |
9c5f3f1946 | ||
![]() |
b50d7c24e7 | ||
![]() |
f05cf68945 | ||
![]() |
efc1875e35 | ||
![]() |
df063e6762 | ||
![]() |
e5c55b4339 | ||
![]() |
bee9095d6f | ||
![]() |
92f8eaaac9 | ||
![]() |
f5e7288fe5 | ||
![]() |
214aa7b6e4 | ||
![]() |
5b5d5b41f5 | ||
![]() |
23d613321e | ||
![]() |
0b6be0923f | ||
![]() |
aba748ea13 | ||
![]() |
f1f1ac582d | ||
![]() |
54a7cbc3f4 | ||
![]() |
2f4dbaec4c | ||
![]() |
578f518aaf | ||
![]() |
077ba74b22 | ||
![]() |
e0efe635c7 | ||
![]() |
1a06841de0 | ||
![]() |
3987e0ee0b | ||
![]() |
9f53bea02f | ||
![]() |
737709f9e7 | ||
![]() |
39477aa6a0 | ||
![]() |
f097050b56 | ||
![]() |
f14726ed1a | ||
![]() |
e1e4d038d9 | ||
![]() |
d2db4cf887 | ||
![]() |
2f3ece9ca3 | ||
![]() |
9f82007116 | ||
![]() |
f79198a472 | ||
![]() |
ce3d35d7ec | ||
![]() |
f4d40f0466 | ||
![]() |
a2fa085d5f | ||
![]() |
a598266a6e | ||
![]() |
f5fe33cee7 | ||
![]() |
200c7226ef | ||
![]() |
53475a6a0e | ||
![]() |
b4ec1ad6c0 | ||
![]() |
ef511a729d | ||
![]() |
275c4ce226 | ||
![]() |
45f9c029c8 | ||
![]() |
db5e4ad5d9 | ||
![]() |
f05d0a9727 | ||
![]() |
04593e9d9a | ||
![]() |
b1ecf13f8e | ||
![]() |
e91e054f20 | ||
![]() |
130ff7517e | ||
![]() |
c7042d9684 | ||
![]() |
5752e45dd1 | ||
![]() |
1a034ecb53 | ||
![]() |
025da8fb76 | ||
![]() |
2027da1db5 | ||
![]() |
7732f28ca8 | ||
![]() |
7f9da8cc2d | ||
![]() |
c6342b80a7 | ||
![]() |
f99c82de4b | ||
![]() |
56fa57ea02 | ||
![]() |
cc85985d08 | ||
![]() |
bd1751903e | ||
![]() |
03a298a70f | ||
![]() |
2722ca2b0e | ||
![]() |
179c4b800e | ||
![]() |
6bdf14223d | ||
![]() |
1b8252aa4f | ||
![]() |
8219889154 | ||
![]() |
df4ac5dcce | ||
![]() |
738eaf9de9 | ||
![]() |
c483ccbbbc | ||
![]() |
0d65f846ae | ||
![]() |
f47e75c423 | ||
![]() |
c008e58fb8 | ||
![]() |
26e0f17bc5 | ||
![]() |
6543f28bdb | ||
![]() |
a86851b338 | ||
![]() |
3a03e455c6 | ||
![]() |
3d39fd1580 | ||
![]() |
601b0add26 | ||
![]() |
4f974cc913 | ||
![]() |
f691320453 | ||
![]() |
be39fc3a21 | ||
![]() |
d2fafaf33a | ||
![]() |
27ae331352 | ||
![]() |
3f2dcfbacc | ||
![]() |
8565aee8b6 | ||
![]() |
f983add599 | ||
![]() |
030192afeb | ||
![]() |
c8b6a158f1 | ||
![]() |
e71f7849a7 | ||
![]() |
b64d1ff4ff | ||
![]() |
5a0028be26 | ||
![]() |
926d7deb43 | ||
![]() |
6384b50bae | ||
![]() |
9feb0f4b53 | ||
![]() |
43ec1b7cfd | ||
![]() |
05b7a59f8d | ||
![]() |
17e680f7af | ||
![]() |
035d256d4e | ||
![]() |
8939adf886 | ||
![]() |
027ffbffa6 | ||
![]() |
3cca06712b | ||
![]() |
2b9359dbf4 |
@@ -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.
|
||||||
|
@@ -4,7 +4,7 @@ module.exports = {
|
|||||||
'es2021': true,
|
'es2021': true,
|
||||||
'node': true
|
'node': true
|
||||||
},
|
},
|
||||||
'ignorePatterns': ['src/proto/'],
|
'ignorePatterns': ['src/core/proto/'],
|
||||||
'extends': [
|
'extends': [
|
||||||
'eslint:recommended',
|
'eslint:recommended',
|
||||||
'plugin:@typescript-eslint/recommended'
|
'plugin:@typescript-eslint/recommended'
|
||||||
|
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@@ -1,15 +1,11 @@
|
|||||||
name: "Build Action"
|
name: "Build Action"
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
Build-LiteLoader:
|
Build-LiteLoader:
|
||||||
if: ${{ startsWith(github.event.head_commit.message, 'build:') }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Main Repository
|
- name: Clone Main Repository
|
||||||
@@ -37,7 +33,6 @@ jobs:
|
|||||||
name: NapCat.Framework
|
name: NapCat.Framework
|
||||||
path: dist
|
path: dist
|
||||||
Build-Shell:
|
Build-Shell:
|
||||||
if: ${{ startsWith(github.event.head_commit.message, 'build:') }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Main Repository
|
- name: Clone Main Repository
|
||||||
|
@@ -7,10 +7,14 @@
|
|||||||
NapCatQQ (aka 猫猫框架) 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
NapCatQQ (aka 猫猫框架) 是现代化的基于 NTQQ 的 Bot 协议端实现。
|
||||||
|
|
||||||
## 猫猫技能
|
## 猫猫技能
|
||||||
|
- [x] **高性能**:1K+ 群聊数目、20 线程并行发送消息毫无压力
|
||||||
- [x] **多种启动方式**:支持以无头、LiteLoader 插件、仅 QQ GUI 三种方式启动
|
- [x] **多种启动方式**:支持以无头、LiteLoader 插件、仅 QQ GUI 三种方式启动
|
||||||
|
- [x] **多平台支持**: 支持Windows/Linux(可选Docker)/Android Termux/MacOs覆盖全平台
|
||||||
|
- [x] **安装简单**: 支持一键脚本/程序自动部署/镜像部署等多种覆盖范围
|
||||||
- [x] **低占用**:无头模式占用资源极低,适合在服务器上运行
|
- [x] **低占用**:无头模式占用资源极低,适合在服务器上运行
|
||||||
- [x] **超多接口**:在实现大部分Onebot接口上扩展了一套私有API
|
- [x] **超多接口**:实现大部分 OneBot 和 go-cqhttp 接口,超多扩展 API
|
||||||
- [x] **WebUI**:自带 WebUI 支持,远程管理更加便捷
|
- [x] **WebUI**:自带 WebUI 支持,远程管理更加便捷
|
||||||
|
- [x] **低故障率**:快速适配最新版本,日常保证 0 Issue
|
||||||
|
|
||||||
## 使用猫猫
|
## 使用猫猫
|
||||||
|
|
||||||
|
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.
39
launcher/launcher-win10.bat
Normal file
39
launcher/launcher-win10.bat
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
@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
|
||||||
|
|
||||||
|
REM 拿不到QQ路径则退出
|
||||||
|
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%"
|
39
launcher/launcher.bat
Normal file
39
launcher/launcher.bat
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
@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
|
||||||
|
:: %RetString% 增加引号,解决QQ目录包含空格的问题,比如安装在:C:\Program Files\Tencent\QQNT
|
||||||
|
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%"
|
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.15",
|
"version": "2.3.0",
|
||||||
"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.15",
|
"version": "2.3.0",
|
||||||
"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",
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
"@types/node": "^22.0.1",
|
"@types/node": "^22.0.1",
|
||||||
"@types/qrcode-terminal": "^0.12.2",
|
"@types/qrcode-terminal": "^0.12.2",
|
||||||
"@types/ws": "^8.5.12",
|
"@types/ws": "^8.5.12",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
||||||
"@typescript-eslint/parser": "^7.4.0",
|
"@typescript-eslint/parser": "^8.3.0",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"eslint-import-resolver-typescript": "^3.6.1",
|
"eslint-import-resolver-typescript": "^3.6.1",
|
||||||
"eslint-plugin-import": "^2.29.1",
|
"eslint-plugin-import": "^2.29.1",
|
||||||
|
Binary file not shown.
@@ -22,10 +22,15 @@ 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`;
|
||||||
|
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);
|
return path.join(this.configPath, filename);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
read(): T {
|
read(): T {
|
||||||
const logger = this.core.context.logger;
|
const logger = this.core.context.logger;
|
@@ -1,4 +1,4 @@
|
|||||||
import type { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper/wrapper';
|
import type { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper';
|
||||||
import EventEmitter from 'node:events';
|
import EventEmitter from 'node:events';
|
||||||
|
|
||||||
export type ListenerClassBase = Record<string, string>;
|
export type ListenerClassBase = Record<string, string>;
|
||||||
@@ -10,7 +10,7 @@ export interface ListenerIBase {
|
|||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NTEventChannel extends EventEmitter {
|
export class NTEventWrapperV2 extends EventEmitter {
|
||||||
private wrapperApi: WrapperNodeApi;
|
private wrapperApi: WrapperNodeApi;
|
||||||
private wrapperSession: NodeIQQNTWrapperSession;
|
private wrapperSession: NodeIQQNTWrapperSession;
|
||||||
private listenerRefStorage = new Map<string, ListenerIBase>();
|
private listenerRefStorage = new Map<string, ListenerIBase>();
|
@@ -1,4 +1,4 @@
|
|||||||
import { NodeIQQNTWrapperSession } from '@/core/wrapper/wrapper';
|
import { NodeIQQNTWrapperSession } from '@/core/wrapper';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { ListenerNamingMapping, ServiceNamingMapping } from '@/core';
|
import { ListenerNamingMapping, ServiceNamingMapping } from '@/core';
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ interface InternalMapKey {
|
|||||||
|
|
||||||
export type ListenerClassBase = Record<string, string>;
|
export type ListenerClassBase = Record<string, string>;
|
||||||
|
|
||||||
export class LegacyNTEventWrapper {
|
export class NTEventWrapper {
|
||||||
private WrapperSession: NodeIQQNTWrapperSession | undefined; //WrapperSession
|
private WrapperSession: NodeIQQNTWrapperSession | undefined; //WrapperSession
|
||||||
private listenerManager: Map<string, ListenerClassBase> = new Map<string, ListenerClassBase>(); //ListenerName-Unique -> Listener实例
|
private listenerManager: Map<string, ListenerClassBase> = new Map<string, ListenerClassBase>(); //ListenerName-Unique -> Listener实例
|
||||||
private EventTask = new Map<string, Map<string, Map<string, InternalMapKey>>>(); //tasks ListenerMainName -> ListenerSubName-> uuid -> {timeout,createtime,func}
|
private EventTask = new Map<string, Map<string, Map<string, InternalMapKey>>>(); //tasks ListenerMainName -> ListenerSubName-> uuid -> {timeout,createtime,func}
|
@@ -1,7 +1,7 @@
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import { QQLevel } from '@/core';
|
import { Peer, QQLevel } from '@/core';
|
||||||
|
|
||||||
export async function solveProblem<T extends (...arg: any[]) => any>(func: T, ...args: Parameters<T>): Promise<ReturnType<T> | undefined> {
|
export async function solveProblem<T extends (...arg: any[]) => any>(func: T, ...args: Parameters<T>): Promise<ReturnType<T> | undefined> {
|
||||||
return new Promise<ReturnType<T> | undefined>((resolve) => {
|
return new Promise<ReturnType<T> | undefined>((resolve) => {
|
||||||
@@ -24,25 +24,51 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//下面这个类是用于将uid+msgid合并的类
|
export class FileNapCatOneBotUUID {
|
||||||
export class UUIDConverter {
|
static encodeModelId(peer: Peer, modelId: string, fileId: string): string {
|
||||||
static encode(highStr: string, lowStr: string): string {
|
return `NapCatOneBot|ModelIdFile|${peer.chatType}|${peer.peerUid}|${modelId}|${fileId}`;
|
||||||
const high = BigInt(highStr);
|
|
||||||
const low = BigInt(lowStr);
|
|
||||||
const highHex = high.toString(16).padStart(16, '0');
|
|
||||||
const lowHex = low.toString(16).padStart(16, '0');
|
|
||||||
const combinedHex = highHex + lowHex;
|
|
||||||
return `${combinedHex.substring(0, 8)}-${combinedHex.substring(8, 12)}-${combinedHex.substring(
|
|
||||||
12,
|
|
||||||
16,
|
|
||||||
)}-${combinedHex.substring(16, 20)}-${combinedHex.substring(20)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static decode(uuid: string): { high: string; low: string } {
|
static decodeModelId(uuid: string): undefined | {
|
||||||
const hex = uuid.replace(/-/g, '');
|
peer: Peer,
|
||||||
const high = BigInt('0x' + hex.substring(0, 16));
|
modelId: string,
|
||||||
const low = BigInt('0x' + hex.substring(16));
|
fileId: string
|
||||||
return { high: high.toString(), low: low.toString() };
|
} {
|
||||||
|
if (!uuid.startsWith('NapCatOneBot|ModelIdFile|')) return undefined;
|
||||||
|
const data = uuid.split('|');
|
||||||
|
if (data.length !== 6) return undefined;
|
||||||
|
const [, , chatType, peerUid, modelId, fileId] = data;
|
||||||
|
return {
|
||||||
|
peer: {
|
||||||
|
chatType: chatType as any,
|
||||||
|
peerUid: peerUid,
|
||||||
|
},
|
||||||
|
modelId,
|
||||||
|
fileId
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static encode(peer: Peer, msgId: string, elementId: string): string {
|
||||||
|
return `NapCatOneBot|MsgFile|${peer.chatType}|${peer.peerUid}|${msgId}|${elementId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
static decode(uuid: string): undefined | {
|
||||||
|
peer: Peer,
|
||||||
|
msgId: string,
|
||||||
|
elementId: string
|
||||||
|
} {
|
||||||
|
if (!uuid.startsWith('NapCatOneBot|MsgFile|')) return undefined;
|
||||||
|
const data = uuid.split('|');
|
||||||
|
if (data.length !== 6) return undefined;
|
||||||
|
const [, , chatType, peerUid, msgId, elementId] = data;
|
||||||
|
return {
|
||||||
|
peer: {
|
||||||
|
chatType: chatType as any,
|
||||||
|
peerUid: peerUid,
|
||||||
|
},
|
||||||
|
msgId,
|
||||||
|
elementId,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,26 +140,38 @@ export function isEqual(obj1: any, obj2: any) {
|
|||||||
export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
||||||
if (os.platform() === 'linux') {
|
if (os.platform() === 'linux') {
|
||||||
return {
|
return {
|
||||||
baseVersion: '3.2.12-27254',
|
baseVersion: '3.2.12-27597',
|
||||||
curVersion: '3.2.12-27254',
|
curVersion: '3.2.12-27597',
|
||||||
prevVersion: '',
|
prevVersion: '',
|
||||||
onErrorVersions: [],
|
onErrorVersions: [],
|
||||||
buildId: '27254',
|
buildId: '27597',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
baseVersion: '9.9.15-27391',
|
baseVersion: '9.9.15-27597',
|
||||||
curVersion: '9.9.15-27391',
|
curVersion: '9.9.15-27597',
|
||||||
prevVersion: '',
|
prevVersion: '',
|
||||||
onErrorVersions: [],
|
onErrorVersions: [],
|
||||||
buildId: '27391',
|
buildId: '27597',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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');
|
@@ -1,5 +1,5 @@
|
|||||||
import log4js, { Configuration } from 'log4js';
|
import log4js, { Configuration } from 'log4js';
|
||||||
import { truncateString } from '@/common/utils/helper';
|
import { truncateString } from '@/common/helper';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { AtType, ChatType, ElementType, MessageElement, RawMessage, SelfInfo } from '@/core';
|
import { AtType, ChatType, ElementType, MessageElement, RawMessage, SelfInfo } from '@/core';
|
@@ -91,7 +91,7 @@ class MessageUniqueWrapper {
|
|||||||
return ret.map((t) => t?.MsgId).filter((t) => t !== undefined);
|
return ret.map((t) => t?.MsgId).filter((t) => t !== undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
createMsg(peer: Peer, msgId: string) {
|
createUniqueMsgId(peer: Peer, msgId: string) {
|
||||||
const key = `${msgId}|${peer.chatType}|${peer.peerUid}`;
|
const key = `${msgId}|${peer.chatType}|${peer.peerUid}`;
|
||||||
const hash = crypto.createHash('md5').update(key).digest();
|
const hash = crypto.createHash('md5').update(key).digest();
|
||||||
//设置第一个bit为0 保证shortId为正数
|
//设置第一个bit为0 保证shortId为正数
|
@@ -1,8 +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 const napcat_version = '2.2.15';
|
|
||||||
|
|
||||||
export class NapCatPathWrapper {
|
export class NapCatPathWrapper {
|
||||||
binaryPath: string;
|
binaryPath: string;
|
||||||
@@ -13,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/utils/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,27 +52,40 @@ 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 } {
|
||||||
const appidTbale = AppidTable as unknown as QQAppidTableType;
|
const appidTbale = AppidTable as unknown as QQAppidTableType;
|
||||||
try {
|
|
||||||
const fullVersion = this.getFullQQVesion();
|
const fullVersion = this.getFullQQVesion();
|
||||||
if (!fullVersion) throw new Error('QQ版本获取失败');
|
if (fullVersion) {
|
||||||
const data = appidTbale[fullVersion];
|
const data = appidTbale[fullVersion];
|
||||||
if (data) {
|
if (data) {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
|
||||||
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
|
||||||
}
|
}
|
||||||
// 以下是兜底措施
|
|
||||||
this.context.logger.log(
|
// else
|
||||||
`[QQ版本兼容性检测] ${this.getFullQQVesion()} 版本兼容性不佳,可能会导致一些功能无法正常使用`,
|
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
||||||
);
|
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
||||||
return { appid: systemPlatform === 'linux' ? '537240795' : '537240709', qua: this.getQUAInternal() };
|
return { appid: this.getAppidInternal(), qua: this.getQUAInternal() };
|
||||||
}
|
}
|
||||||
}
|
}
|
1
src/common/version.ts
Normal file
1
src/common/version.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export const napCatVersion = '2.3.0';
|
@@ -16,7 +16,8 @@ export async function getVideoInfo(filePath: string, logger: LogWrapper) {
|
|||||||
filePath: string
|
filePath: string
|
||||||
}>((resolve, reject) => {
|
}>((resolve, reject) => {
|
||||||
const ffmpegPath = process.env.FFMPEG_PATH;
|
const ffmpegPath = process.env.FFMPEG_PATH;
|
||||||
ffmpegPath && ffmpeg.setFfmpegPath(ffmpegPath);
|
if (ffmpegPath)
|
||||||
|
ffmpeg.setFfmpegPath(ffmpegPath);
|
||||||
ffmpeg(filePath).ffprobe((err: any, metadata: ffmpeg.FfprobeData) => {
|
ffmpeg(filePath).ffprobe((err: any, metadata: ffmpeg.FfprobeData) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
63
src/core/apis/cache.ts
Normal file
63
src/core/apis/cache.ts
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@@ -10,7 +10,7 @@ export class NTQQCollectionApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createCollection(authorUin: string, authorUid: string, authorName: string, brief: string, rawData: string) {
|
async createCollection(authorUin: string, authorUid: string, authorName: string, brief: string, rawData: string) {
|
||||||
const param = {
|
return this.context.session.getCollectionService().createNewCollectionItem({
|
||||||
commInfo: {
|
commInfo: {
|
||||||
bid: 1,
|
bid: 1,
|
||||||
category: 2,
|
category: 2,
|
||||||
@@ -43,12 +43,11 @@ export class NTQQCollectionApi {
|
|||||||
fileList: [],
|
fileList: [],
|
||||||
},
|
},
|
||||||
need_share_url: false,
|
need_share_url: false,
|
||||||
};
|
});
|
||||||
return this.context.session.getCollectionService().createNewCollectionItem(param);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllCollection(category: number = 0, count: number = 50) {
|
async getAllCollection(category: number = 0, count: number = 50) {
|
||||||
const param = {
|
return this.context.session.getCollectionService().getCollectionItemList({
|
||||||
category: category,
|
category: category,
|
||||||
groupId: -1,
|
groupId: -1,
|
||||||
forceSync: true,
|
forceSync: true,
|
||||||
@@ -56,7 +55,6 @@ export class NTQQCollectionApi {
|
|||||||
timeStamp: '0',
|
timeStamp: '0',
|
||||||
count: count,
|
count: count,
|
||||||
searchDown: true,
|
searchDown: true,
|
||||||
};
|
});
|
||||||
return this.context.session.getCollectionService().getCollectionItemList(param);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
CacheFileListItem,
|
|
||||||
CacheFileType,
|
|
||||||
ChatCacheListItemBasic,
|
|
||||||
ChatType,
|
ChatType,
|
||||||
ElementType,
|
ElementType,
|
||||||
IMAGE_HTTP_HOST,
|
IMAGE_HTTP_HOST,
|
||||||
@@ -17,19 +14,16 @@ import {
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import fsPromises from 'fs/promises';
|
import fsPromises from 'fs/promises';
|
||||||
import { InstanceContext, NapCatCore } from '@/core';
|
import { InstanceContext, NapCatCore, SearchResultItem } from '@/core';
|
||||||
import * as fileType from 'file-type';
|
import * as fileType from 'file-type';
|
||||||
import imageSize from 'image-size';
|
import imageSize from 'image-size';
|
||||||
import { ISizeCalculationResult } from 'image-size/dist/types/interface';
|
import { ISizeCalculationResult } from 'image-size/dist/types/interface';
|
||||||
import { NodeIKernelSearchService } from '../services/NodeIKernelSearchService';
|
|
||||||
import { RkeyManager } from '../helper/rkey';
|
import { RkeyManager } from '../helper/rkey';
|
||||||
import { calculateFileMD5, isGIF } from '@/common/utils/file';
|
import { calculateFileMD5, isGIF } from '@/common/file';
|
||||||
import pathLib from 'node:path';
|
import pathLib from 'node:path';
|
||||||
import { defaultVideoThumbB64, getVideoInfo } from '@/common/utils/video';
|
import { defaultVideoThumbB64, getVideoInfo } from '@/common/video';
|
||||||
import ffmpeg from 'fluent-ffmpeg';
|
import ffmpeg from 'fluent-ffmpeg';
|
||||||
import fsnormal from 'node:fs';
|
import { encodeSilk } from '@/common/audio';
|
||||||
import { encodeSilk } from '@/common/utils/audio';
|
|
||||||
|
|
||||||
|
|
||||||
export class NTQQFileApi {
|
export class NTQQFileApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -42,10 +36,6 @@ export class NTQQFileApi {
|
|||||||
this.rkeyManager = new RkeyManager('http://napcat-sign.wumiao.wang:2082/rkey', this.context.logger);
|
this.rkeyManager = new RkeyManager('http://napcat-sign.wumiao.wang:2082/rkey', this.context.logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getFileType(filePath: string) {
|
|
||||||
return fileType.fileTypeFromFile(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
async copyFile(filePath: string, destPath: string) {
|
async copyFile(filePath: string, destPath: string) {
|
||||||
await this.core.util.copyFile(filePath, destPath);
|
await this.core.util.copyFile(filePath, destPath);
|
||||||
}
|
}
|
||||||
@@ -61,18 +51,15 @@ export class NTQQFileApi {
|
|||||||
})).urlResult.domainUrl;
|
})).urlResult.domainUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上传文件到QQ的文件夹
|
|
||||||
async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC, elementSubType: number = 0) {
|
async uploadFile(filePath: string, elementType: ElementType = ElementType.PIC, elementSubType: number = 0) {
|
||||||
// napCatCore.wrapper.util.
|
|
||||||
const fileMd5 = await calculateFileMD5(filePath);
|
const fileMd5 = await calculateFileMD5(filePath);
|
||||||
let ext: string = (await this.getFileType(filePath))?.ext as string || '';
|
const extOrEmpty = (await fileType.fileTypeFromFile(filePath))?.ext;
|
||||||
if (ext) {
|
const ext = extOrEmpty ? `.${extOrEmpty}` : '';
|
||||||
ext = '.' + ext;
|
|
||||||
}
|
|
||||||
let fileName = `${path.basename(filePath)}`;
|
let fileName = `${path.basename(filePath)}`;
|
||||||
if (fileName.indexOf('.') === -1) {
|
if (fileName.indexOf('.') === -1) {
|
||||||
fileName += ext;
|
fileName += ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mediaPath = this.context.session.getMsgService().getRichMediaFilePathForGuild({
|
const mediaPath = this.context.session.getMsgService().getRichMediaFilePathForGuild({
|
||||||
md5HexStr: fileMd5,
|
md5HexStr: fileMd5,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
@@ -83,6 +70,7 @@ export class NTQQFileApi {
|
|||||||
downloadType: 1,
|
downloadType: 1,
|
||||||
file_uuid: '',
|
file_uuid: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.copyFile(filePath, mediaPath!);
|
await this.copyFile(filePath, mediaPath!);
|
||||||
const fileSize = await this.getFileSize(filePath);
|
const fileSize = await this.getFileSize(filePath);
|
||||||
return {
|
return {
|
||||||
@@ -94,11 +82,7 @@ export class NTQQFileApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async createValidSendFileElement(
|
async createValidSendFileElement(filePath: string, fileName: string = '', folderId: string = '',): Promise<SendFileElement> {
|
||||||
filePath: string,
|
|
||||||
fileName: string = '',
|
|
||||||
folderId: string = '',
|
|
||||||
): Promise<SendFileElement> {
|
|
||||||
const {
|
const {
|
||||||
fileName: _fileName,
|
fileName: _fileName,
|
||||||
path,
|
path,
|
||||||
@@ -119,26 +103,20 @@ export class NTQQFileApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async createValidSendPicElement(
|
async createValidSendPicElement(picPath: string, summary: string = '', subType: 0 | 1 = 0,): Promise<SendPicElement> {
|
||||||
picPath: string,
|
const { md5, fileName, path, fileSize } = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
|
||||||
summary: string = '',
|
|
||||||
subType: 0 | 1 = 0,
|
|
||||||
): Promise<SendPicElement> {
|
|
||||||
const {
|
|
||||||
md5,
|
|
||||||
fileName,
|
|
||||||
path,
|
|
||||||
fileSize,
|
|
||||||
} = await this.core.apis.FileApi.uploadFile(picPath, ElementType.PIC, subType);
|
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
throw new Error('文件异常,大小为0');
|
throw new Error('文件异常,大小为0');
|
||||||
}
|
}
|
||||||
const imageSize = await this.core.apis.FileApi.getImageSize(picPath);
|
const imageSize = await this.core.apis.FileApi.getImageSize(picPath);
|
||||||
const picElement: any = {
|
return {
|
||||||
|
elementType: ElementType.PIC,
|
||||||
|
elementId: '',
|
||||||
|
picElement: {
|
||||||
md5HexStr: md5,
|
md5HexStr: md5,
|
||||||
fileSize: fileSize.toString(),
|
fileSize: fileSize.toString(),
|
||||||
picWidth: imageSize?.width,
|
picWidth: imageSize.width,
|
||||||
picHeight: imageSize?.height,
|
picHeight: imageSize.height,
|
||||||
fileName: fileName,
|
fileName: fileName,
|
||||||
sourcePath: path,
|
sourcePath: path,
|
||||||
original: true,
|
original: true,
|
||||||
@@ -148,26 +126,13 @@ export class NTQQFileApi {
|
|||||||
fileSubId: '',
|
fileSubId: '',
|
||||||
thumbFileSize: 0,
|
thumbFileSize: 0,
|
||||||
summary,
|
summary,
|
||||||
};
|
} as PicElement,
|
||||||
return {
|
|
||||||
elementType: ElementType.PIC,
|
|
||||||
elementId: '',
|
|
||||||
picElement,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async createValidSendVideoElement(
|
async createValidSendVideoElement(filePath: string, fileName: string = '', diyThumbPath: string = ''): Promise<SendVideoElement> {
|
||||||
filePath: string,
|
|
||||||
fileName: string = '',
|
|
||||||
diyThumbPath: string = '',
|
|
||||||
): Promise<SendVideoElement> {
|
|
||||||
const logger = this.core.context.logger;
|
const logger = this.core.context.logger;
|
||||||
const {
|
const { fileName: _fileName, path, fileSize, md5 } = await this.core.apis.FileApi.uploadFile(filePath, ElementType.VIDEO);
|
||||||
fileName: _fileName,
|
|
||||||
path,
|
|
||||||
fileSize,
|
|
||||||
md5,
|
|
||||||
} = await this.core.apis.FileApi.uploadFile(filePath, ElementType.VIDEO);
|
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
throw new Error('文件异常,大小为0');
|
throw new Error('文件异常,大小为0');
|
||||||
}
|
}
|
||||||
@@ -183,9 +148,10 @@ export class NTQQFileApi {
|
|||||||
try {
|
try {
|
||||||
videoInfo = await getVideoInfo(path, logger);
|
videoInfo = await getVideoInfo(path, logger);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.logError('获取视频信息失败', e);
|
logger.logError('获取视频信息失败,将使用默认值', e);
|
||||||
}
|
}
|
||||||
const createThumb = new Promise<string | undefined>((resolve, reject) => {
|
const thumbPath = new Map();
|
||||||
|
const _thumbPath = await new Promise<string | undefined>((resolve, reject) => {
|
||||||
const thumbFileName = `${md5}_0.png`;
|
const thumbFileName = `${md5}_0.png`;
|
||||||
const thumbPath = pathLib.join(thumb, thumbFileName);
|
const thumbPath = pathLib.join(thumb, thumbFileName);
|
||||||
ffmpeg(filePath)
|
ffmpeg(filePath)
|
||||||
@@ -196,7 +162,7 @@ export class NTQQFileApi {
|
|||||||
resolve(thumbPath);
|
resolve(thumbPath);
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
} else {
|
} else {
|
||||||
fsnormal.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64'));
|
fs.writeFileSync(thumbPath, Buffer.from(defaultVideoThumbB64, 'base64'));
|
||||||
resolve(thumbPath);
|
resolve(thumbPath);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -205,31 +171,14 @@ export class NTQQFileApi {
|
|||||||
filename: thumbFileName,
|
filename: thumbFileName,
|
||||||
folder: thumb,
|
folder: thumb,
|
||||||
size: videoInfo.width + 'x' + videoInfo.height,
|
size: videoInfo.width + 'x' + videoInfo.height,
|
||||||
}).on('end', () => {
|
})
|
||||||
|
.on('end', () => {
|
||||||
resolve(thumbPath);
|
resolve(thumbPath);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
const thumbPath = new Map();
|
|
||||||
const _thumbPath = await createThumb;
|
|
||||||
const thumbSize = _thumbPath ? (await fsPromises.stat(_thumbPath)).size : 0;
|
const thumbSize = _thumbPath ? (await fsPromises.stat(_thumbPath)).size : 0;
|
||||||
// log("生成缩略图", _thumbPath)
|
|
||||||
thumbPath.set(0, _thumbPath);
|
thumbPath.set(0, _thumbPath);
|
||||||
const thumbMd5 = _thumbPath ? await calculateFileMD5(_thumbPath) : '';
|
const thumbMd5 = _thumbPath ? await calculateFileMD5(_thumbPath) : '';
|
||||||
// "fileElement": {
|
|
||||||
// "fileMd5": "",
|
|
||||||
// "fileName": "1.mp4",
|
|
||||||
// "filePath": "C:\\Users\\nanae\\OneDrive\\Desktop\\1.mp4",
|
|
||||||
// "fileSize": "1847007",
|
|
||||||
// "picHeight": 1280,
|
|
||||||
// "picWidth": 720,
|
|
||||||
// "picThumbPath": {},
|
|
||||||
// "file10MMd5": "",
|
|
||||||
// "fileSha": "",
|
|
||||||
// "fileSha3": "",
|
|
||||||
// "fileUuid": "",
|
|
||||||
// "fileSubId": "",
|
|
||||||
// "thumbFileSize": 750
|
|
||||||
// }
|
|
||||||
return {
|
return {
|
||||||
elementType: ElementType.VIDEO,
|
elementType: ElementType.VIDEO,
|
||||||
elementId: '',
|
elementId: '',
|
||||||
@@ -244,28 +193,12 @@ export class NTQQFileApi {
|
|||||||
thumbWidth: videoInfo.width,
|
thumbWidth: videoInfo.width,
|
||||||
thumbHeight: videoInfo.height,
|
thumbHeight: videoInfo.height,
|
||||||
fileSize: '' + fileSize,
|
fileSize: '' + fileSize,
|
||||||
// fileFormat: videotype
|
|
||||||
// fileUuid: "",
|
|
||||||
// transferStatus: 0,
|
|
||||||
// progress: 0,
|
|
||||||
// invalidState: 0,
|
|
||||||
// fileSubId: "",
|
|
||||||
// fileBizId: null,
|
|
||||||
// originVideoMd5: "",
|
|
||||||
// fileFormat: 2,
|
|
||||||
// import_rich_media_context: null,
|
|
||||||
// sourceVideoCodecFormat: 2
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async createValidSendPttElement(pttPath: string): Promise<SendPttElement> {
|
async createValidSendPttElement(pttPath: string): Promise<SendPttElement> {
|
||||||
const {
|
const { converted, path: silkPath, duration } = await encodeSilk(pttPath, this.core.NapCatTempPath, this.core.context.logger);
|
||||||
converted,
|
|
||||||
path: silkPath,
|
|
||||||
duration,
|
|
||||||
} = await encodeSilk(pttPath, this.core.NapCatTempPath, this.core.context.logger);
|
|
||||||
// 生成语音 Path: silkPath Time: duration
|
|
||||||
if (!silkPath) {
|
if (!silkPath) {
|
||||||
throw new Error('语音转换失败, 请检查语音文件是否正常');
|
throw new Error('语音转换失败, 请检查语音文件是否正常');
|
||||||
}
|
}
|
||||||
@@ -284,7 +217,6 @@ export class NTQQFileApi {
|
|||||||
filePath: path,
|
filePath: path,
|
||||||
md5HexStr: md5,
|
md5HexStr: md5,
|
||||||
fileSize: fileSize,
|
fileSize: fileSize,
|
||||||
// duration: Math.max(1, Math.round(fileSize / 1024 / 3)), // 一秒钟大概是3kb大小, 小于1秒的按1秒算
|
|
||||||
duration: duration ?? 1,
|
duration: duration ?? 1,
|
||||||
formatType: 1,
|
formatType: 1,
|
||||||
voiceType: 1,
|
voiceType: 1,
|
||||||
@@ -300,8 +232,17 @@ export class NTQQFileApi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async downloadMediaByUuid() {
|
async downloadFileForModelId(peer: Peer, modelId: string, unknown: string, timeout = 1000 * 60 * 2) {
|
||||||
//napCatCore.session.getRichMediaService().downloadFileForFileUuid();
|
const [, fileTransNotifyInfo] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
|
'NodeIKernelRichMediaService/downloadFileForModelId',
|
||||||
|
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||||
|
[peer, [modelId], unknown],
|
||||||
|
() => true,
|
||||||
|
(arg) => arg?.commonFileInfo?.fileModelId === modelId,
|
||||||
|
1,
|
||||||
|
timeout,
|
||||||
|
);
|
||||||
|
return fileTransNotifyInfo.filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
@@ -318,7 +259,7 @@ export class NTQQFileApi {
|
|||||||
return sourcePath;
|
return sourcePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const [, fileTransNotifyInfo] = await this.core.eventWrapper.callNormalEventV2(
|
const [, completeRetData] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelMsgService/downloadRichMedia',
|
'NodeIKernelMsgService/downloadRichMedia',
|
||||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||||
[{
|
[{
|
||||||
@@ -338,35 +279,21 @@ export class NTQQFileApi {
|
|||||||
1,
|
1,
|
||||||
timeout,
|
timeout,
|
||||||
);
|
);
|
||||||
const msg = await this.core.apis.MsgApi.getMsgsByMsgId({
|
return completeRetData.filePath;
|
||||||
guildId: '',
|
|
||||||
chatType: chatType,
|
|
||||||
peerUid: peerUid,
|
|
||||||
}, [msgId]);
|
|
||||||
if (msg.msgList.length === 0) {
|
|
||||||
return fileTransNotifyInfo.filePath;
|
|
||||||
}
|
|
||||||
//获取原始消息
|
|
||||||
const FileElements = msg?.msgList[0]?.elements?.find(e => e.elementId === elementId);
|
|
||||||
if (!FileElements) {
|
|
||||||
//失败则就乱来 Todo
|
|
||||||
return fileTransNotifyInfo.filePath;
|
|
||||||
}
|
|
||||||
//从原始消息获取文件路径
|
|
||||||
return FileElements?.fileElement?.filePath ??
|
|
||||||
FileElements?.pttElement?.filePath ??
|
|
||||||
FileElements?.videoElement?.filePath ??
|
|
||||||
FileElements?.picElement?.sourcePath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getImageSize(filePath: string): Promise<ISizeCalculationResult | undefined> {
|
async getImageSize(filePath: string): Promise<ISizeCalculationResult> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
imageSize(filePath, (err, dimensions) => {
|
imageSize(filePath, (err, dimensions) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
|
} else {
|
||||||
|
if (!dimensions) {
|
||||||
|
reject(new Error('获取图片尺寸失败'));
|
||||||
} else {
|
} else {
|
||||||
resolve(dimensions);
|
resolve(dimensions);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -430,17 +357,41 @@ export class NTQQFileApi {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async searchfile(keys: string[]) {
|
async searchForFile(keys: string[]): Promise<SearchResultItem | undefined> {
|
||||||
const Event = this.core.eventWrapper.createEventFunction('NodeIKernelSearchService/searchFileWithKeywords');
|
const randomResultId = 100000 + Math.floor(Math.random() * 10000);
|
||||||
const id = await Event!(keys, 12);
|
let searchId = 0;
|
||||||
const Listener = this.core.eventWrapper.registerListen(
|
const [, searchResult] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
|
'NodeIKernelFileAssistantService/searchFile',
|
||||||
1,
|
'NodeIKernelFileAssistantListener/onFileSearch',
|
||||||
20000,
|
[
|
||||||
(params) => id !== '' && params.searchId == id,
|
keys,
|
||||||
|
{ resultType: 2, pageLimit: 1 },
|
||||||
|
randomResultId,
|
||||||
|
],
|
||||||
|
(ret) => {
|
||||||
|
searchId = ret;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
result => result.searchId === searchId && result.resultId === randomResultId,
|
||||||
);
|
);
|
||||||
const [ret] = (await Listener);
|
return searchResult.resultItems[0];
|
||||||
return ret;
|
}
|
||||||
|
|
||||||
|
async downloadFileById(
|
||||||
|
fileId: string,
|
||||||
|
fileSize: number = 1024576,
|
||||||
|
estimatedTime: number = (fileSize * 1000 / 1024576) + 5000,
|
||||||
|
) {
|
||||||
|
const [, fileData] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
|
'NodeIKernelFileAssistantService/downloadFile',
|
||||||
|
'NodeIKernelFileAssistantListener/onFileStatusChanged',
|
||||||
|
[[fileId]],
|
||||||
|
ret => ret.result === 0,
|
||||||
|
status => status.fileStatus === 2 && status.fileProgress === '0',
|
||||||
|
1,
|
||||||
|
estimatedTime, // estimate 1MB/s
|
||||||
|
);
|
||||||
|
return fileData.filePath!;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getImageUrl(element: PicElement) {
|
async getImageUrl(element: PicElement) {
|
||||||
@@ -450,20 +401,19 @@ export class NTQQFileApi {
|
|||||||
const url: string = element.originImageUrl!; // 没有域名
|
const url: string = element.originImageUrl!; // 没有域名
|
||||||
const md5HexStr = element.md5HexStr;
|
const md5HexStr = element.md5HexStr;
|
||||||
const fileMd5 = element.md5HexStr;
|
const fileMd5 = element.md5HexStr;
|
||||||
// const fileUuid = element.fileUuid;
|
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
const UrlParse = new URL(IMAGE_HTTP_HOST + url);//临时解析拼接
|
const parsedUrl = new URL(IMAGE_HTTP_HOST + url);//临时解析拼接
|
||||||
const imageAppid = UrlParse.searchParams.get('appid');
|
const imageAppid = parsedUrl.searchParams.get('appid');
|
||||||
const isNewPic = imageAppid && ['1406', '1407'].includes(imageAppid);
|
const isNTFlavoredPic = imageAppid && ['1406', '1407'].includes(imageAppid);
|
||||||
if (isNewPic) {
|
if (isNTFlavoredPic) {
|
||||||
let UrlRkey = UrlParse.searchParams.get('rkey');
|
let rkey = parsedUrl.searchParams.get('rkey');
|
||||||
if (UrlRkey) {
|
if (rkey) {
|
||||||
return IMAGE_HTTP_HOST_NT + url;
|
return IMAGE_HTTP_HOST_NT + url;
|
||||||
}
|
}
|
||||||
const rkeyData = await this.rkeyManager.getRkey();
|
const rkeyData = await this.rkeyManager.getRkey();
|
||||||
UrlRkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
|
rkey = imageAppid === '1406' ? rkeyData.private_rkey : rkeyData.group_rkey;
|
||||||
return IMAGE_HTTP_HOST_NT + url + `${UrlRkey}`;
|
return IMAGE_HTTP_HOST_NT + url + `${rkey}`;
|
||||||
} else {
|
} else {
|
||||||
// 老的图片url,不需要rkey
|
// 老的图片url,不需要rkey
|
||||||
return IMAGE_HTTP_HOST + url;
|
return IMAGE_HTTP_HOST + url;
|
||||||
@@ -477,57 +427,3 @@ export class NTQQFileApi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class NTQQFileCacheApi {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { FriendV2 } from '@/core/entities';
|
import { FriendV2 } from '@/core/entities';
|
||||||
import { BuddyListReqType, InstanceContext, NapCatCore, NodeIKernelProfileService } from '@/core';
|
import { BuddyListReqType, InstanceContext, NapCatCore } from '@/core';
|
||||||
import { LimitedHashTable } from '@/common/utils/message-unique';
|
import { LimitedHashTable } from '@/common/message-unique';
|
||||||
|
|
||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -16,47 +16,42 @@ export class NTQQFriendApi {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
async getBuddyV2SimpleInfoMap(refresh = false) {
|
||||||
const uids: string[] = [];
|
|
||||||
const buddyService = this.context.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
const uids = buddyListV2.data.flatMap(item => item.buddyUids);
|
||||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
return await this.core.eventWrapper.callNoListenerEvent(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
'NodeIKernelProfileService/getCoreAndBaseInfo',
|
||||||
|
'nodeStore',
|
||||||
|
uids,
|
||||||
);
|
);
|
||||||
return Array.from(data.values());
|
}
|
||||||
|
|
||||||
|
async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
|
return Array.from((await this.getBuddyV2SimpleInfoMap(refresh)).values());
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
const uids: string[] = [];
|
|
||||||
const retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
const retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
||||||
const buddyService = this.context.session.getBuddyService();
|
const data = await this.getBuddyV2SimpleInfoMap(refresh);
|
||||||
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
data.forEach((value) => retMap.set(value.uin!, value.uid!));
|
||||||
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
|
||||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
|
||||||
);
|
|
||||||
data.forEach((value) => {
|
|
||||||
retMap.set(value.uin!, value.uid!);
|
|
||||||
});
|
|
||||||
//console.log('getBuddyIdMap', retMap.getValue);
|
|
||||||
return retMap;
|
return retMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBuddyV2ExWithCate(refresh = false) {
|
async getBuddyV2ExWithCate(refresh = false) {
|
||||||
const uids: string[] = [];
|
|
||||||
const categoryMap: Map<string, any> = new Map();
|
const categoryMap: Map<string, any> = new Map();
|
||||||
const buddyService = this.context.session.getBuddyService();
|
const buddyService = this.context.session.getBuddyService();
|
||||||
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
||||||
uids.push(
|
const uids = buddyListV2.flatMap(item => {
|
||||||
...buddyListV2.flatMap(item => {
|
|
||||||
item.buddyUids.forEach(uid => {
|
item.buddyUids.forEach(uid => {
|
||||||
categoryMap.set(uid, { categoryId: item.categoryId, categoryName: item.categroyName });
|
categoryMap.set(uid, { categoryId: item.categoryId, categoryName: item.categroyName });
|
||||||
});
|
});
|
||||||
return item.buddyUids;
|
return item.buddyUids;
|
||||||
}));
|
});
|
||||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
const data = await this.core.eventWrapper.callNoListenerEvent(
|
||||||
'NodeIKernelProfileService/getCoreAndBaseInfo', 'nodeStore', uids,
|
'NodeIKernelProfileService/getCoreAndBaseInfo',
|
||||||
|
'nodeStore',
|
||||||
|
uids,
|
||||||
);
|
);
|
||||||
return buddyListV2.map(category => ({
|
return buddyListV2.map(category => ({
|
||||||
categoryId: category.categoryId,
|
categoryId: category.categoryId,
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
ChatType,
|
|
||||||
GeneralCallResult,
|
GeneralCallResult,
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
@@ -9,9 +8,9 @@ import {
|
|||||||
KickMemberV2Req,
|
KickMemberV2Req,
|
||||||
MemberExtSourceType,
|
MemberExtSourceType,
|
||||||
NapCatCore,
|
NapCatCore,
|
||||||
NodeIKernelGroupService,
|
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { isNumeric, runAllWithTimeout, sleep } from '@/common/utils/helper';
|
import { isNumeric } from '@/common/helper';
|
||||||
|
import { LimitedHashTable } from '@/common/message-unique';
|
||||||
|
|
||||||
export class NTQQGroupApi {
|
export class NTQQGroupApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -19,25 +18,35 @@ export class NTQQGroupApi {
|
|||||||
groupCache: Map<string, Group> = new Map<string, Group>();
|
groupCache: Map<string, Group> = new Map<string, Group>();
|
||||||
groupMemberCache: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
groupMemberCache: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
||||||
groups: Group[] = [];
|
groups: Group[] = [];
|
||||||
|
essenceLRU = new LimitedHashTable<number, string>(1000);
|
||||||
|
|
||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
sleep(1000).then(() => {
|
|
||||||
this.initCache().then().catch(context.logger.logError);
|
this.initCache().then().catch(context.logger.logError);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async initCache() {
|
async initCache() {
|
||||||
this.groups = await this.getGroups();
|
this.groups = await this.getGroups();
|
||||||
for (const group of this.groups) {
|
for (const group of this.groups) {
|
||||||
this.groupCache.set(group.groupCode, group);
|
this.groupCache.set(group.groupCode, group);
|
||||||
const data = await this.getGroupMembers(group.groupCode, 3000);
|
|
||||||
this.groupMemberCache.set(group.groupCode, data);
|
|
||||||
}
|
}
|
||||||
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fetchGroupEssenceList(groupCode: string) {
|
||||||
|
const pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
||||||
|
return this.context.session.getGroupService().fetchGroupEssenceList({
|
||||||
|
groupCode: groupCode,
|
||||||
|
pageStart: 0,
|
||||||
|
pageLimit: 300,
|
||||||
|
}, pskey);
|
||||||
|
}
|
||||||
|
|
||||||
|
async clearGroupNotifiesUnreadCount(unk: boolean) {
|
||||||
|
return this.context.session.getGroupService().clearGroupNotifiesUnreadCount(unk);
|
||||||
|
}
|
||||||
|
|
||||||
async setGroupAvatar(gc: string, filePath: string) {
|
async setGroupAvatar(gc: string, filePath: string) {
|
||||||
return this.context.session.getGroupService().setHeader(gc, filePath);
|
return this.context.session.getGroupService().setHeader(gc, filePath);
|
||||||
}
|
}
|
||||||
@@ -50,6 +59,7 @@ 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,
|
||||||
@@ -86,11 +96,12 @@ export class NTQQGroupApi {
|
|||||||
showPlayTogetherSwitch: 1,
|
showPlayTogetherSwitch: 1,
|
||||||
starId: 1,
|
starId: 1,
|
||||||
todoSeq: 1,
|
todoSeq: 1,
|
||||||
viewedMsgDisappearTime: 1
|
viewedMsgDisappearTime: 1,
|
||||||
},
|
},
|
||||||
forced
|
forced,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroup(groupCode: string, forced = false) {
|
async getGroup(groupCode: string, forced = false) {
|
||||||
let group = this.groupCache.get(groupCode.toString());
|
let group = this.groupCache.get(groupCode.toString());
|
||||||
if (!group) {
|
if (!group) {
|
||||||
@@ -109,62 +120,6 @@ export class NTQQGroupApi {
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMemberLatestSendTimeCache(GroupCode: string, uids: string[]) {
|
|
||||||
return this.getGroupMemberLatestSendTime(GroupCode, uids);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通过QQ自带数据库获取群成员最后发言时间(仅返回有效数据 且消耗延迟大 需要进行缓存)
|
|
||||||
* @param GroupCode 群号
|
|
||||||
* @param uids QQ号
|
|
||||||
* @returns Map<string, string> key: uin value: sendTime
|
|
||||||
* @example
|
|
||||||
* let ret = await NTQQGroupApi.getGroupMemberLastestSendTime('123456');
|
|
||||||
* for (let [uin, sendTime] of ret) {
|
|
||||||
* console.log(uin, sendTime);
|
|
||||||
* }
|
|
||||||
*/
|
|
||||||
async getGroupMemberLatestSendTime(GroupCode: string, uids: string[]) {
|
|
||||||
const getdata = async (uid: string) => {
|
|
||||||
const NTRet = await this.getLatestMsgByUids(GroupCode, [uid]);
|
|
||||||
if (NTRet.result != 0 && NTRet.msgList.length < 1) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return { sendUin: NTRet.msgList[0].senderUin, sendTime: NTRet.msgList[0].msgTime };
|
|
||||||
};
|
|
||||||
const PromiseData: Promise<({
|
|
||||||
sendUin: string;
|
|
||||||
sendTime: string;
|
|
||||||
} | undefined)>[] = [];
|
|
||||||
const ret: Map<string, string> = new Map();
|
|
||||||
for (const uid of uids) {
|
|
||||||
PromiseData.push(getdata(uid).catch(() => undefined));
|
|
||||||
}
|
|
||||||
const allRet = await runAllWithTimeout(PromiseData, 2500);
|
|
||||||
for (const PromiseDo of allRet) {
|
|
||||||
if (PromiseDo) {
|
|
||||||
ret.set(PromiseDo.sendUin, PromiseDo.sendTime);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getLatestMsgByUids(GroupCode: string, uids: string[]) {
|
|
||||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
|
||||||
chatInfo: {
|
|
||||||
peerUid: GroupCode,
|
|
||||||
chatType: ChatType.KCHATTYPEGROUP,
|
|
||||||
},
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: uids,
|
|
||||||
filterMsgToTime: '0',
|
|
||||||
filterMsgFromTime: '0',
|
|
||||||
isReverseOrder: false,
|
|
||||||
isIncludeCurrent: true,
|
|
||||||
pageLimit: 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -175,7 +130,7 @@ export class NTQQGroupApi {
|
|||||||
let members = this.groupMemberCache.get(groupCodeStr);
|
let members = this.groupMemberCache.get(groupCodeStr);
|
||||||
if (!members) {
|
if (!members) {
|
||||||
try {
|
try {
|
||||||
members = await this.getGroupMembers(groupCodeStr);
|
members = await this.getGroupMembersV2(groupCodeStr);
|
||||||
// 更新群成员列表
|
// 更新群成员列表
|
||||||
this.groupMemberCache.set(groupCodeStr, members);
|
this.groupMemberCache.set(groupCodeStr, members);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -196,35 +151,11 @@ export class NTQQGroupApi {
|
|||||||
|
|
||||||
let member = getMember();
|
let member = getMember();
|
||||||
if (!member) {
|
if (!member) {
|
||||||
members = await this.getGroupMembers(groupCodeStr);
|
members = await this.getGroupMembersV2(groupCodeStr);
|
||||||
member = getMember();
|
member = getMember();
|
||||||
}
|
}
|
||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLatestMsg(GroupCode: string, uins: string[]) {
|
|
||||||
const uids: Array<string> = [];
|
|
||||||
for (const uin of uins) {
|
|
||||||
const uid = await this.core.apis.UserApi.getUidByUinV2(uin);
|
|
||||||
if (uid) {
|
|
||||||
uids.push(uid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
|
||||||
chatInfo: {
|
|
||||||
peerUid: GroupCode,
|
|
||||||
chatType: ChatType.KCHATTYPEGROUP,
|
|
||||||
},
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: uids,
|
|
||||||
filterMsgToTime: '0',
|
|
||||||
filterMsgFromTime: '0',
|
|
||||||
isReverseOrder: false,
|
|
||||||
isIncludeCurrent: true,
|
|
||||||
pageLimit: 1,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getGroupRecommendContactArkJson(GroupCode: string) {
|
async getGroupRecommendContactArkJson(GroupCode: string) {
|
||||||
return this.context.session.getGroupService().getGroupRecommendContactArkJson(GroupCode);
|
return this.context.session.getGroupService().getGroupRecommendContactArkJson(GroupCode);
|
||||||
}
|
}
|
||||||
@@ -242,8 +173,7 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addGroupEssence(GroupCode: string, msgId: string) {
|
async addGroupEssence(GroupCode: string, msgId: string) {
|
||||||
// 代码没测过
|
// 需要 ob11msgId -> msgId + (peer) -> msgSeq + msgRandom
|
||||||
// 需要 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: '',
|
||||||
@@ -254,7 +184,7 @@ 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),
|
||||||
};
|
};
|
||||||
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
// GetMsgByShortID(shortID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
||||||
return this.context.session.getGroupService().addGroupEssence(param);
|
return this.context.session.getGroupService().addGroupEssence(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,8 +193,8 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async deleteGroupBulletin(GroupCode: string, noticeId: string) {
|
async deleteGroupBulletin(GroupCode: string, noticeId: string) {
|
||||||
const _Pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
const psKey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
||||||
return this.context.session.getGroupService().deleteGroupBulletin(GroupCode, _Pskey, noticeId);
|
return this.context.session.getGroupService().deleteGroupBulletin(GroupCode, psKey, noticeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async quitGroupV2(GroupCode: string, needDeleteLocalMsg: boolean) {
|
async quitGroupV2(GroupCode: string, needDeleteLocalMsg: boolean) {
|
||||||
@@ -276,9 +206,16 @@ export class NTQQGroupApi {
|
|||||||
return this.context.session.getGroupService().quitGroupV2(param);
|
return this.context.session.getGroupService().quitGroupV2(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeGroupEssenceBySeq(GroupCode: string, msgRandom: string, msgSeq: string) {
|
||||||
|
const param = {
|
||||||
|
groupCode: GroupCode,
|
||||||
|
msgRandom: parseInt(msgRandom),
|
||||||
|
msgSeq: parseInt(msgSeq),
|
||||||
|
};
|
||||||
|
return this.context.session.getGroupService().removeGroupEssence(param);
|
||||||
|
}
|
||||||
|
|
||||||
async removeGroupEssence(GroupCode: string, msgId: string) {
|
async removeGroupEssence(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: '',
|
||||||
@@ -289,16 +226,15 @@ 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),
|
||||||
};
|
};
|
||||||
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
|
||||||
return this.context.session.getGroupService().removeGroupEssence(param);
|
return this.context.session.getGroupService().removeGroupEssence(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSingleScreenNotifies(num: number) {
|
async getSingleScreenNotifies(doubt: boolean, num: number) {
|
||||||
const [, , , notifies] = await this.core.eventWrapper.callNormalEventV2(
|
const [, , , notifies] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelGroupService/getSingleScreenNotifies',
|
'NodeIKernelGroupService/getSingleScreenNotifies',
|
||||||
'NodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
'NodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
||||||
[
|
[
|
||||||
false,
|
doubt,
|
||||||
'',
|
'',
|
||||||
num,
|
num,
|
||||||
],
|
],
|
||||||
@@ -307,12 +243,11 @@ export class NTQQGroupApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
||||||
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
|
||||||
const Listener = this.core.eventWrapper.registerListen(
|
const Listener = this.core.eventWrapper.registerListen(
|
||||||
'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
|
||||||
@@ -330,6 +265,38 @@ export class NTQQGroupApi {
|
|||||||
return member;
|
return member;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getGroupMembersV2(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
|
const groupService = this.context.session.getGroupService();
|
||||||
|
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||||
|
const listener = this.core.eventWrapper.registerListen(
|
||||||
|
'NodeIKernelGroupListener/onMemberListChange',
|
||||||
|
1,
|
||||||
|
500,
|
||||||
|
(params) => params.sceneId === sceneId,
|
||||||
|
);
|
||||||
|
try {
|
||||||
|
const [membersFromFunc, membersFromListener] = await Promise.allSettled([
|
||||||
|
groupService.getNextMemberList(sceneId, undefined, num),
|
||||||
|
listener,
|
||||||
|
]);
|
||||||
|
if (membersFromFunc.status === 'fulfilled' && membersFromListener.status === 'fulfilled') {
|
||||||
|
return new Map([
|
||||||
|
...membersFromFunc.value.result.infos,
|
||||||
|
...membersFromListener.value[0].infos,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (membersFromFunc.status === 'fulfilled') {
|
||||||
|
return membersFromFunc.value.result.infos;
|
||||||
|
}
|
||||||
|
if (membersFromListener.status === 'fulfilled') {
|
||||||
|
return membersFromListener.value[0].infos;
|
||||||
|
}
|
||||||
|
throw new Error('获取群成员列表失败');
|
||||||
|
} finally {
|
||||||
|
groupService.destroyMemberListScene(sceneId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
async getGroupMembers(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');
|
||||||
@@ -340,28 +307,12 @@ export class NTQQGroupApi {
|
|||||||
|
|
||||||
this.context.logger.logDebug(`获取群(${groupQQ})成员列表结果:`, `members: ${result.result.infos.size}`); //, Array.from(result.result.infos.values()));
|
this.context.logger.logDebug(`获取群(${groupQQ})成员列表结果:`, `members: ${result.result.infos.size}`); //, Array.from(result.result.infos.values()));
|
||||||
return result.result.infos;
|
return result.result.infos;
|
||||||
/*
|
|
||||||
console.log(sceneId);
|
|
||||||
const result = await napCatCore.getGroupService().getNextMemberList(sceneId, num);
|
|
||||||
console.log(result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupNotifies() {
|
async getGroupFileCount(Gids: Array<string>) {
|
||||||
// 获取管理员变更
|
|
||||||
// 加群通知,退出通知,需要管理员权限
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async GetGroupFileCount(Gids: Array<string>) {
|
|
||||||
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',
|
||||||
@@ -424,19 +375,12 @@ export class NTQQGroupApi {
|
|||||||
return this.context.session.getGroupService().modifyGroupName(groupQQ, groupName, false);
|
return this.context.session.getGroupService().modifyGroupName(groupQQ, groupName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 头衔不可用
|
|
||||||
/*
|
|
||||||
async setGroupTitle(groupQQ: string, uid: string, title: string) {
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
async publishGroupBulletin(groupQQ: string, content: string, picInfo: {
|
async publishGroupBulletin(groupQQ: string, content: string, picInfo: {
|
||||||
id: string,
|
id: string,
|
||||||
width: number,
|
width: number,
|
||||||
height: number
|
height: number
|
||||||
} | undefined = undefined, pinned: number = 0, confirmRequired: number = 0) {
|
} | undefined = undefined, pinned: number = 0, confirmRequired: number = 0) {
|
||||||
const _Pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com');
|
const psKey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com');
|
||||||
//text是content内容url编码
|
//text是content内容url编码
|
||||||
const data = {
|
const data = {
|
||||||
text: encodeURI(content),
|
text: encodeURI(content),
|
||||||
@@ -445,7 +389,7 @@ export class NTQQGroupApi {
|
|||||||
pinned: pinned,
|
pinned: pinned,
|
||||||
confirmRequired: confirmRequired,
|
confirmRequired: confirmRequired,
|
||||||
};
|
};
|
||||||
return this.context.session.getGroupService().publishGroupBulletin(groupQQ, _Pskey!, data);
|
return this.context.session.getGroupService().publishGroupBulletin(groupQQ, psKey!, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupRemainAtTimes(GroupCode: string) {
|
async getGroupRemainAtTimes(GroupCode: string) {
|
||||||
|
@@ -6,3 +6,4 @@ export * from './user';
|
|||||||
export * from './webapi';
|
export * from './webapi';
|
||||||
export * from './sign';
|
export * from './sign';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
|
export * from './cache';
|
||||||
|
@@ -3,6 +3,10 @@ import { InstanceContext, NapCatCore } from '@/core';
|
|||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
export class NTQQMsgApi {
|
export class NTQQMsgApi {
|
||||||
|
// 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
|
||||||
|
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
core: NapCatCore;
|
core: NapCatCore;
|
||||||
|
|
||||||
@@ -11,6 +15,14 @@ export class NTQQMsgApi {
|
|||||||
this.core = core;
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getAioFirstViewLatestMsgs(peer: Peer, MsgCount: number) {
|
||||||
|
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) {
|
async FetchLongMsg(peer: Peer, msgId: string) {
|
||||||
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
||||||
}
|
}
|
||||||
@@ -20,19 +32,10 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
//console.log(peer, msgSeq, emojiId, emojiType, count);
|
|
||||||
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
//注意此处emojiType 可选值一般为1-2 2好像是unicode表情dec值 大部分情况 Taged M likiowa
|
||||||
return this.context.session.getMsgService().getMsgEmojiLikesList(peer, msgSeq, emojiId, emojiType, '', false, count);
|
return this.context.session.getMsgService().getMsgEmojiLikesList(peer, msgSeq, emojiId, emojiType, '', false, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// napCatCore: NapCatCore | null = null;
|
|
||||||
// enum BaseEmojiType {
|
|
||||||
// NORMAL_EMOJI,
|
|
||||||
// SUPER_EMOJI,
|
|
||||||
// RANDOM_SUPER_EMOJI,
|
|
||||||
// CHAIN_SUPER_EMOJI,
|
|
||||||
// EMOJI_EMOJI
|
|
||||||
// }
|
|
||||||
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//sysface_res/apng/ 下可以看到所有QQ表情预览
|
||||||
// nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid
|
// nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid
|
||||||
@@ -51,23 +54,10 @@ export class NTQQMsgApi {
|
|||||||
return this.context.session.getMsgService().forwardMsg(msgIds, peer, [peer], new Map());
|
return this.context.session.getMsgService().forwardMsg(msgIds, peer, [peer], new Map());
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLastestMsgByUids(peer: Peer, count: number = 20, isReverseOrder: boolean = false) {
|
|
||||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
|
||||||
chatInfo: peer,
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: [],
|
|
||||||
filterMsgToTime: '0',
|
|
||||||
filterMsgFromTime: '0',
|
|
||||||
isReverseOrder: isReverseOrder,//此参数有点离谱 注意不是本次查询的排序 而是全部消历史信息的排序 默认false 从新消息拉取到旧消息
|
|
||||||
isIncludeCurrent: true,
|
|
||||||
pageLimit: count,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getMsgsByMsgId(peer: Peer | undefined, msgIds: string[] | undefined) {
|
async getMsgsByMsgId(peer: Peer | undefined, msgIds: string[] | undefined) {
|
||||||
if (!peer) throw new Error('peer is not allowed');
|
if (!peer) throw new Error('peer is not allowed');
|
||||||
if (!msgIds) throw new Error('msgIds is not allowed');
|
if (!msgIds) throw new Error('msgIds is not allowed');
|
||||||
//Mlikiowa: 参数不合规会导致NC异常崩溃 原因是TX未对进入参数判断 对应Android标记@NotNull AndroidJADX分析可得
|
//MliKiowa: 参数不合规会导致NC异常崩溃 原因是TX未对进入参数判断 对应Android标记@NotNull AndroidJADX分析可得
|
||||||
return await this.context.session.getMsgService().getMsgsByMsgId(peer, msgIds);
|
return await this.context.session.getMsgService().getMsgsByMsgId(peer, msgIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +71,7 @@ export class NTQQMsgApi {
|
|||||||
|
|
||||||
async queryMsgsWithFilterExWithSeq(peer: Peer, msgSeq: string) {
|
async queryMsgsWithFilterExWithSeq(peer: Peer, msgSeq: string) {
|
||||||
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
||||||
chatInfo: peer,//此处为Peer 为关键查询参数 没有啥也没有 by mlik iowa
|
chatInfo: peer,
|
||||||
filterMsgType: [],
|
filterMsgType: [],
|
||||||
filterSendersUid: [],
|
filterSendersUid: [],
|
||||||
filterMsgToTime: '0',
|
filterMsgToTime: '0',
|
||||||
@@ -91,11 +81,41 @@ export class NTQQMsgApi {
|
|||||||
pageLimit: 1,
|
pageLimit: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
async queryMsgsWithFilterExWithSeqV2(peer: Peer, msgSeq: string, MsgTime: string, SendersUid: string[]) {
|
||||||
|
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
||||||
|
chatInfo: peer,
|
||||||
|
filterMsgType: [],
|
||||||
|
filterSendersUid: SendersUid,
|
||||||
|
filterMsgToTime: MsgTime,
|
||||||
|
filterMsgFromTime: MsgTime,
|
||||||
|
isReverseOrder: false,
|
||||||
|
isIncludeCurrent: true,
|
||||||
|
pageLimit: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
async queryFirstMsgBySeq(peer: Peer, msgSeq: string) {
|
||||||
|
return await this.context.session.getMsgService().queryMsgsWithFilterEx('0', '0', msgSeq, {
|
||||||
|
chatInfo: peer,
|
||||||
|
filterMsgType: [],
|
||||||
|
filterSendersUid: [],
|
||||||
|
filterMsgToTime: '0',
|
||||||
|
filterMsgFromTime: '0',
|
||||||
|
isReverseOrder: true,
|
||||||
|
isIncludeCurrent: true,
|
||||||
|
pageLimit: 1,
|
||||||
|
});
|
||||||
|
}
|
||||||
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();
|
||||||
@@ -125,10 +145,7 @@ export class NTQQMsgApi {
|
|||||||
params,
|
params,
|
||||||
],
|
],
|
||||||
() => true,
|
() => true,
|
||||||
( /* groupFileListResult: GroupFileInfoUpdateParamType */) => {
|
() => true, // Todo: 应当通过 groupFileListResult 判断
|
||||||
//Developer Mlikiowa Todo: 此处有问题 无法判断是否成功
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
1,
|
1,
|
||||||
5000,
|
5000,
|
||||||
);
|
);
|
||||||
@@ -148,14 +165,6 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
|
async PrepareTempChat(toUserUid: string, GroupCode: string, nickname: string) {
|
||||||
//By Jadx/Ida Mlikiowa
|
|
||||||
const TempGameSession = {
|
|
||||||
nickname: '',
|
|
||||||
gameAppId: '',
|
|
||||||
selfTinyId: '',
|
|
||||||
peerRoleId: '',
|
|
||||||
peerOpenId: '',
|
|
||||||
};
|
|
||||||
return this.context.session.getMsgService().prepareTempChat({
|
return this.context.session.getMsgService().prepareTempChat({
|
||||||
chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP,
|
chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP,
|
||||||
peerUid: toUserUid,
|
peerUid: toUserUid,
|
||||||
@@ -164,7 +173,13 @@ export class NTQQMsgApi {
|
|||||||
sig: '',
|
sig: '',
|
||||||
selfPhone: '',
|
selfPhone: '',
|
||||||
selfUid: this.core.selfInfo.uid,
|
selfUid: this.core.selfInfo.uid,
|
||||||
gameSession: TempGameSession,
|
gameSession: {
|
||||||
|
nickname: '',
|
||||||
|
gameAppId: '',
|
||||||
|
selfTinyId: '',
|
||||||
|
peerRoleId: '',
|
||||||
|
peerOpenId: '',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +188,7 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
//唉? !我有个想法
|
//唉?!我有个想法
|
||||||
if (peer.chatType === ChatType.KCHATTYPETEMPC2CFROMGROUP && peer.guildId && peer.guildId !== '') {
|
if (peer.chatType === ChatType.KCHATTYPETEMPC2CFROMGROUP && peer.guildId && peer.guildId !== '') {
|
||||||
const member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
|
const member = await this.core.apis.GroupApi.getGroupMember(peer.guildId, peer.peerUid!);
|
||||||
if (member) {
|
if (member) {
|
||||||
@@ -191,7 +206,7 @@ export class NTQQMsgApi {
|
|||||||
msgElements,
|
msgElements,
|
||||||
new Map(),
|
new Map(),
|
||||||
],
|
],
|
||||||
() => true,
|
(ret) => ret.result === 0,
|
||||||
msgRecords => {
|
msgRecords => {
|
||||||
for (const msgRecord of msgRecords) {
|
for (const msgRecord of msgRecords) {
|
||||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === SendStatusType.KSEND_STATUS_SUCCESS) {
|
if (msgRecord.guildId === msgId && msgRecord.sendStatus === SendStatusType.KSEND_STATUS_SUCCESS) {
|
||||||
@@ -203,11 +218,7 @@ export class NTQQMsgApi {
|
|||||||
1,
|
1,
|
||||||
timeout,
|
timeout,
|
||||||
);
|
);
|
||||||
return msgList.find(msgRecord => {
|
return msgList.find(msgRecord => msgRecord.guildId === msgId);
|
||||||
if (msgRecord.guildId === msgId) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateMsgUniqueId(chatType: number, time: string) {
|
async generateMsgUniqueId(chatType: number, time: string) {
|
||||||
@@ -237,14 +248,10 @@ export class NTQQMsgApi {
|
|||||||
new Map(),
|
new Map(),
|
||||||
],
|
],
|
||||||
() => true,
|
() => true,
|
||||||
(msgRecords) => {
|
(msgRecords) => msgRecords.some(
|
||||||
for (const msgRecord of msgRecords) {
|
msgRecord => msgRecord.peerUid === destPeer.peerUid
|
||||||
if (msgRecord.peerUid == destPeer.peerUid && msgRecord.senderUid == this.core.selfInfo.uid) {
|
&& msgRecord.senderUid === this.core.selfInfo.uid
|
||||||
return true;
|
),
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
for (const msg of msgList) {
|
for (const msg of msgList) {
|
||||||
const arkElement = msg.elements.find(ele => ele.arkElement);
|
const arkElement = msg.elements.find(ele => ele.arkElement);
|
||||||
@@ -262,7 +269,7 @@ export class NTQQMsgApi {
|
|||||||
throw new Error('转发消息超时');
|
throw new Error('转发消息超时');
|
||||||
}
|
}
|
||||||
|
|
||||||
async markallMsgAsRead() {
|
async markAllMsgAsRead() {
|
||||||
return this.context.session.getMsgService().setAllC2CAndGroupMsgRead();
|
return this.context.session.getMsgService().setAllC2CAndGroupMsgRead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
import { MiniAppLuaJsonType } from '@/core';
|
import { MiniAppLuaJsonType } from '@/core';
|
||||||
import { InstanceContext, NapCatCore } from '..';
|
import { InstanceContext, NapCatCore } from '..';
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { GeneralCallResult, InstanceContext, NapCatCore } from '@/core';
|
import { InstanceContext, NapCatCore } from '@/core';
|
||||||
|
|
||||||
export class NTQQSystemApi {
|
export class NTQQSystemApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -13,7 +13,7 @@ export class NTQQSystemApi {
|
|||||||
return this.core.util.hasOtherRunningQQProcess();
|
return this.core.util.hasOtherRunningQQProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
async ORCImage(filePath: string) {
|
async ocrImage(filePath: string) {
|
||||||
return this.context.session.getNodeMiscService().wantWinScreenOCR(filePath);
|
return this.context.session.getNodeMiscService().wantWinScreenOCR(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,20 +21,16 @@ export class NTQQSystemApi {
|
|||||||
return this.context.session.getRichMediaService().translateEnWordToZn(words);
|
return this.context.session.getRichMediaService().translateEnWordToZn(words);
|
||||||
}
|
}
|
||||||
|
|
||||||
//调用会超时 没灯用 (好像是通知listener的) onLineDev
|
|
||||||
async getOnlineDev() {
|
async getOnlineDev() {
|
||||||
return this.context.session.getMsgService().getOnLineDev();
|
return this.context.session.getMsgService().getOnLineDev();
|
||||||
}
|
}
|
||||||
|
|
||||||
//1-2-162b9b42-65b9-4405-a8ed-2e256ec8aa50
|
|
||||||
async getArkJsonCollection(cid: string) {
|
async getArkJsonCollection(cid: string) {
|
||||||
return await this.core.eventWrapper.callNoListenerEvent('NodeIKernelCollectionService/collectionArkShare', '1717662698058');
|
return await this.core.eventWrapper.callNoListenerEvent('NodeIKernelCollectionService/collectionArkShare', '1717662698058');
|
||||||
}
|
}
|
||||||
|
|
||||||
async BootMiniApp(appfile: string, params: string) {
|
async bootMiniApp(appFile: string, params: string) {
|
||||||
await this.context.session.getNodeMiscService().setMiniAppVersion('2.16.4');
|
await this.context.session.getNodeMiscService().setMiniAppVersion('2.16.4');
|
||||||
// const c = await this.context.session.getNodeMiscService().getMiniAppPath();
|
return this.context.session.getNodeMiscService().startNewMiniApp(appFile, params);
|
||||||
|
|
||||||
return this.context.session.getNodeMiscService().startNewMiniApp(appfile, params);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import type { ModifyProfileParams, User, UserDetailInfoByUinV2 } from '@/core/entities';
|
import type { ModifyProfileParams, User } from '@/core/entities';
|
||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
import { ProfileBizType, UserDetailSource } from '@/core/services';
|
import { ProfileBizType, UserDetailSource } from '@/core/services';
|
||||||
import { InstanceContext, NapCatCore } from '..';
|
import { InstanceContext, NapCatCore } from '..';
|
||||||
import { solveAsyncProblem } from '@/common/utils/helper';
|
import { solveAsyncProblem } from '@/common/helper';
|
||||||
|
|
||||||
export class NTQQUserApi {
|
export class NTQQUserApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
@@ -15,9 +15,7 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
async getProfileLike(uid: string) {
|
async getProfileLike(uid: string) {
|
||||||
return this.context.session.getProfileLikeService().getBuddyProfileLike({
|
return this.context.session.getProfileLikeService().getBuddyProfileLike({
|
||||||
friendUids: [
|
friendUids: [uid],
|
||||||
uid,
|
|
||||||
],
|
|
||||||
basic: 1,
|
basic: 1,
|
||||||
vote: 1,
|
vote: 1,
|
||||||
favorite: 0,
|
favorite: 0,
|
||||||
@@ -63,41 +61,6 @@ export class NTQQUserApi {
|
|||||||
return this.context.session.getGroupService().setHeader(gc, filePath);
|
return this.context.session.getGroupService().setHeader(gc, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchUserDetailInfos(uids: string[]) {
|
|
||||||
// TODO: 26702 以上使用新接口 .Dev MliKiowa
|
|
||||||
const retData: User[] = [];
|
|
||||||
const [_retData, _retListener] = await this.core.eventWrapper.callNormalEventV2(
|
|
||||||
'NodeIKernelProfileService/fetchUserDetailInfo',
|
|
||||||
'NodeIKernelProfileListener/onUserDetailInfoChanged',
|
|
||||||
[
|
|
||||||
'BuddyProfileStore',
|
|
||||||
uids,
|
|
||||||
UserDetailSource.KSERVER,
|
|
||||||
[ProfileBizType.KALL],
|
|
||||||
],
|
|
||||||
() => true,
|
|
||||||
(profile) => {
|
|
||||||
if (uids.includes(profile.uid)) {
|
|
||||||
const RetUser: User = {
|
|
||||||
...profile.simpleInfo.coreInfo,
|
|
||||||
...profile.simpleInfo.status,
|
|
||||||
...profile.simpleInfo.vasInfo,
|
|
||||||
...profile.commonExt,
|
|
||||||
...profile.simpleInfo.baseInfo,
|
|
||||||
qqLevel: profile.commonExt.qqLevel,
|
|
||||||
pendantId: '',
|
|
||||||
};
|
|
||||||
retData.push(RetUser);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
uids.length,
|
|
||||||
);
|
|
||||||
|
|
||||||
return retData;
|
|
||||||
}
|
|
||||||
|
|
||||||
async fetchUserDetailInfo(uid: string, mode: UserDetailSource = UserDetailSource.KDB) {
|
async fetchUserDetailInfo(uid: string, mode: UserDetailSource = UserDetailSource.KDB) {
|
||||||
const [_retData, profile] = await this.core.eventWrapper.callNormalEventV2(
|
const [_retData, profile] = await this.core.eventWrapper.callNormalEventV2(
|
||||||
'NodeIKernelProfileService/fetchUserDetailInfo',
|
'NodeIKernelProfileService/fetchUserDetailInfo',
|
||||||
@@ -112,7 +75,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,
|
||||||
@@ -120,17 +82,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) {
|
||||||
@@ -156,7 +123,6 @@ export class NTQQUserApi {
|
|||||||
version: 0,
|
version: 0,
|
||||||
aioKeywordVersion: 0,
|
aioKeywordVersion: 0,
|
||||||
});
|
});
|
||||||
// console.log(robotUinRanges?.response?.robotUinRanges);
|
|
||||||
return robotUinRanges?.response?.robotUinRanges;
|
return robotUinRanges?.response?.robotUinRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +136,7 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
//需要异常处理
|
//需要异常处理
|
||||||
|
|
||||||
async getSkey(): Promise<string | undefined> {
|
async getSKey(): Promise<string | undefined> {
|
||||||
const ClientKeyData = await this.forceFetchClientKey();
|
const ClientKeyData = await this.forceFetchClientKey();
|
||||||
if (ClientKeyData.result !== 0) {
|
if (ClientKeyData.result !== 0) {
|
||||||
throw new Error('getClientKey Error');
|
throw new Error('getClientKey Error');
|
||||||
@@ -181,7 +147,7 @@ export class NTQQUserApi {
|
|||||||
const cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
const cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
||||||
const skey = cookies['skey'];
|
const skey = cookies['skey'];
|
||||||
if (!skey) {
|
if (!skey) {
|
||||||
throw new Error('getSkey Skey is Empty');
|
throw new Error('SKey is Empty');
|
||||||
}
|
}
|
||||||
return skey;
|
return skey;
|
||||||
}
|
}
|
||||||
@@ -194,8 +160,8 @@ export class NTQQUserApi {
|
|||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
uid = (await this.context.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
uid = (await this.context.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
||||||
if (uid) return uid;
|
if (uid) return uid;
|
||||||
const unveifyUid = (await this.getUserDetailInfoByUinV2(Uin)).detail.uid;//从QQ Native 特殊转换
|
const unverifiedUid = (await this.getUserDetailInfoByUinV2(Uin)).detail.uid;//从QQ Native 特殊转换
|
||||||
if (unveifyUid.indexOf('*') == -1) uid = unveifyUid;
|
if (unverifiedUid.indexOf('*') == -1) uid = unverifiedUid;
|
||||||
//if (uid) return uid;
|
//if (uid) return uid;
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
@@ -231,7 +197,10 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getUserDetailInfoByUinV2(Uin: string) {
|
async getUserDetailInfoByUinV2(Uin: string) {
|
||||||
return await this.core.eventWrapper.callNoListenerEvent('NodeIKernelProfileService/getUserDetailInfoByUin', Uin);
|
return await this.core.eventWrapper.callNoListenerEvent(
|
||||||
|
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
|
Uin
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async forceFetchClientKey() {
|
async forceFetchClientKey() {
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
import {
|
import {
|
||||||
GroupEssenceMsgRet,
|
GroupEssenceMsgRet,
|
||||||
InstanceContext,
|
InstanceContext,
|
||||||
@@ -26,35 +26,42 @@ export class NTQQWebApi {
|
|||||||
msg_seq: msgSeq,
|
msg_seq: msgSeq,
|
||||||
msg_random: msgRandom,
|
msg_random: msgRandom,
|
||||||
target_group_code: targetGroupCode,
|
target_group_code: targetGroupCode,
|
||||||
}).toString()
|
}).toString()}`;
|
||||||
}`;
|
|
||||||
try {
|
try {
|
||||||
return RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
return RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
async getGroupEssenceMsgAll(GroupCode: string) {
|
||||||
async getGroupEssenceMsg(GroupCode: string, page_start: string) {
|
const ret: GroupEssenceMsgRet[] = [];
|
||||||
|
for (let i = 0; i < 20; i++) {
|
||||||
|
const data = await this.getGroupEssenceMsg(GroupCode, i, 50);
|
||||||
|
if (!data) break;
|
||||||
|
ret.push(data);
|
||||||
|
if (data.data.is_end) break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
async getGroupEssenceMsg(GroupCode: string, page_start: number = 0, page_limit: number = 50) {
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${new URLSearchParams({
|
const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${new URLSearchParams({
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
|
page_start: page_start.toString(),
|
||||||
|
page_limit: page_limit.toString(),
|
||||||
group_code: GroupCode,
|
group_code: GroupCode,
|
||||||
page_start,
|
}).toString()}`;
|
||||||
page_limit: '20',
|
|
||||||
}).toString()
|
|
||||||
}`;
|
|
||||||
let ret;
|
|
||||||
try {
|
try {
|
||||||
ret = await RequestUtil.HttpGetJson<GroupEssenceMsgRet>
|
const ret = await RequestUtil.HttpGetJson<GroupEssenceMsgRet>(
|
||||||
(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
url,
|
||||||
|
'GET',
|
||||||
|
'',
|
||||||
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
|
);
|
||||||
|
return ret.retcode === 0 ? ret : undefined;
|
||||||
} catch {
|
} catch {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (ret.retcode !== 0) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGroupMembers(GroupCode: string, cached: boolean = true): Promise<WebApiGroupMember[]> {
|
async getGroupMembers(GroupCode: string, cached: boolean = true): Promise<WebApiGroupMember[]> {
|
||||||
@@ -62,15 +69,18 @@ export class NTQQWebApi {
|
|||||||
const memberData: Array<WebApiGroupMember> = new Array<WebApiGroupMember>();
|
const memberData: Array<WebApiGroupMember> = new Array<WebApiGroupMember>();
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
const retList: Promise<WebApiGroupMemberRet>[] = [];
|
const retList: Promise<WebApiGroupMemberRet>[] = [];
|
||||||
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>
|
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>(
|
||||||
(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||||
st: '0',
|
st: '0',
|
||||||
end: '40',
|
end: '40',
|
||||||
sort: '1',
|
sort: '1',
|
||||||
gc: GroupCode,
|
gc: GroupCode,
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
}).toString()
|
}).toString()}`,
|
||||||
}`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) });
|
'POST',
|
||||||
|
'',
|
||||||
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
|
);
|
||||||
if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) {
|
if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
} else {
|
||||||
@@ -82,15 +92,18 @@ export class NTQQWebApi {
|
|||||||
const PageNum = Math.ceil(fastRet.count / 40);
|
const PageNum = Math.ceil(fastRet.count / 40);
|
||||||
//遍历批量请求
|
//遍历批量请求
|
||||||
for (let i = 2; i <= PageNum; i++) {
|
for (let i = 2; i <= PageNum; i++) {
|
||||||
const ret = RequestUtil.HttpGetJson<WebApiGroupMemberRet>
|
const ret = RequestUtil.HttpGetJson<WebApiGroupMemberRet>(
|
||||||
(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||||
st: ((i - 1) * 40).toString(),
|
st: ((i - 1) * 40).toString(),
|
||||||
end: (i * 40).toString(),
|
end: (i * 40).toString(),
|
||||||
sort: '1',
|
sort: '1',
|
||||||
gc: GroupCode,
|
gc: GroupCode,
|
||||||
bkn: this.getBknFromCookie(cookieObject),
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
}).toString()
|
}).toString()}`,
|
||||||
}`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) });
|
'POST',
|
||||||
|
'',
|
||||||
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
|
);
|
||||||
retList.push(ret);
|
retList.push(ret);
|
||||||
}
|
}
|
||||||
//批量等待
|
//批量等待
|
||||||
@@ -118,20 +131,56 @@ 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>
|
let 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(),
|
||||||
|
};
|
||||||
|
let 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,
|
||||||
}).toString()
|
...(picId === '' ? {} : externalParam)
|
||||||
}`, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
}).toString()}`,
|
||||||
|
'POST',
|
||||||
|
'',
|
||||||
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
|
);
|
||||||
return ret;
|
return ret;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -140,16 +189,24 @@ export class NTQQWebApi {
|
|||||||
|
|
||||||
async getGroupNotice(GroupCode: string): Promise<undefined | WebApiGroupNoticeRet> {
|
async getGroupNotice(GroupCode: string): Promise<undefined | WebApiGroupNoticeRet> {
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
let ret: WebApiGroupNoticeRet | undefined = undefined;
|
|
||||||
try {
|
try {
|
||||||
const url = 'https://web.qun.qq.com/cgi-bin/announce/get_t_list?bkn=' +
|
const ret = await RequestUtil.HttpGetJson<WebApiGroupNoticeRet>(
|
||||||
this.getBknFromCookie(cookieObject) + '&qid=' + GroupCode + '&ft=23&ni=1&n=1&i=1&log_read=1&platform=1&s=-1&n=20';
|
`https://web.qun.qq.com/cgi-bin/announce/get_t_list?${new URLSearchParams({
|
||||||
|
bkn: this.getBknFromCookie(cookieObject),
|
||||||
ret = await RequestUtil.HttpGetJson<WebApiGroupNoticeRet>(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
qid: GroupCode,
|
||||||
if (ret?.ec !== 0) {
|
ft: '23',
|
||||||
return undefined;
|
ni: '1',
|
||||||
}
|
n: '1',
|
||||||
return ret;
|
i: '1',
|
||||||
|
log_read: '1',
|
||||||
|
platform: '1',
|
||||||
|
s: '-1',
|
||||||
|
}).toString()}&n=20`,
|
||||||
|
'GET',
|
||||||
|
'',
|
||||||
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
|
);
|
||||||
|
return ret?.ec === 0 ? ret : undefined;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -158,14 +215,17 @@ export class NTQQWebApi {
|
|||||||
async getGroupHonorInfo(groupCode: string, getType: WebHonorType) {
|
async getGroupHonorInfo(groupCode: string, getType: WebHonorType) {
|
||||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||||
const getDataInternal = async (Internal_groupCode: string, Internal_type: number) => {
|
const getDataInternal = async (Internal_groupCode: string, Internal_type: number) => {
|
||||||
const url = `https://qun.qq.com/interactive/honorlist?${new URLSearchParams({
|
|
||||||
gc: Internal_groupCode,
|
|
||||||
type: Internal_type.toString(),
|
|
||||||
}).toString()
|
|
||||||
}`;
|
|
||||||
let resJson;
|
let resJson;
|
||||||
try {
|
try {
|
||||||
const res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
const res = await RequestUtil.HttpGetText(
|
||||||
|
`https://qun.qq.com/interactive/honorlist?${new URLSearchParams({
|
||||||
|
gc: Internal_groupCode,
|
||||||
|
type: Internal_type.toString(),
|
||||||
|
}).toString()}`,
|
||||||
|
'GET',
|
||||||
|
'',
|
||||||
|
{ 'Cookie': this.cookieToString(cookieObject) }
|
||||||
|
);
|
||||||
const match = /window\.__INITIAL_STATE__=(.*?);/.exec(res);
|
const match = /window\.__INITIAL_STATE__=(.*?);/.exec(res);
|
||||||
if (match) {
|
if (match) {
|
||||||
resJson = JSON.parse(match[1].trim());
|
resJson = JSON.parse(match[1].trim());
|
||||||
@@ -176,7 +236,7 @@ export class NTQQWebApi {
|
|||||||
return resJson?.actorList;
|
return resJson?.actorList;
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.context.logger.logDebug('获取当前群荣耀失败', url, e);
|
this.context.logger.logDebug('获取当前群荣耀失败', e);
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
@@ -184,11 +244,8 @@ export class NTQQWebApi {
|
|||||||
const HonorInfo: any = { group_id: groupCode };
|
const HonorInfo: any = { group_id: groupCode };
|
||||||
|
|
||||||
if (getType === WebHonorType.TALKATIVE || getType === WebHonorType.ALL) {
|
if (getType === WebHonorType.TALKATIVE || getType === WebHonorType.ALL) {
|
||||||
try {
|
|
||||||
const RetInternal = await getDataInternal(groupCode, 1);
|
const RetInternal = await getDataInternal(groupCode, 1);
|
||||||
if (!RetInternal) {
|
if (RetInternal) {
|
||||||
throw new Error('获取龙王信息失败');
|
|
||||||
}
|
|
||||||
HonorInfo.current_talkative = {
|
HonorInfo.current_talkative = {
|
||||||
user_id: RetInternal[0]?.uin,
|
user_id: RetInternal[0]?.uin,
|
||||||
avatar: RetInternal[0]?.avatar,
|
avatar: RetInternal[0]?.avatar,
|
||||||
@@ -206,16 +263,13 @@ export class NTQQWebApi {
|
|||||||
nickname: talkative_ele?.name,
|
nickname: talkative_ele?.name,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} else {
|
||||||
this.context.logger.logDebug(e);
|
this.context.logger.logError('获取龙王信息失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getType === WebHonorType.PERFORMER || getType === WebHonorType.ALL) {
|
if (getType === WebHonorType.PERFORMER || getType === WebHonorType.ALL) {
|
||||||
try {
|
|
||||||
const RetInternal = await getDataInternal(groupCode, 2);
|
const RetInternal = await getDataInternal(groupCode, 2);
|
||||||
if (!RetInternal) {
|
if (RetInternal) {
|
||||||
throw new Error('获取群聊之火失败');
|
|
||||||
}
|
|
||||||
HonorInfo.performer_list = [];
|
HonorInfo.performer_list = [];
|
||||||
for (const performer_ele of RetInternal) {
|
for (const performer_ele of RetInternal) {
|
||||||
HonorInfo.performer_list.push({
|
HonorInfo.performer_list.push({
|
||||||
@@ -225,16 +279,13 @@ export class NTQQWebApi {
|
|||||||
description: performer_ele?.desc,
|
description: performer_ele?.desc,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} else {
|
||||||
this.context.logger.logDebug(e);
|
this.context.logger.logError('获取群聊之火失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getType === WebHonorType.PERFORMER || getType === WebHonorType.ALL) {
|
if (getType === WebHonorType.PERFORMER || getType === WebHonorType.ALL) {
|
||||||
try {
|
|
||||||
const RetInternal = await getDataInternal(groupCode, 3);
|
const RetInternal = await getDataInternal(groupCode, 3);
|
||||||
if (!RetInternal) {
|
if (RetInternal) {
|
||||||
throw new Error('获取群聊炽焰失败');
|
|
||||||
}
|
|
||||||
HonorInfo.legend_list = [];
|
HonorInfo.legend_list = [];
|
||||||
for (const legend_ele of RetInternal) {
|
for (const legend_ele of RetInternal) {
|
||||||
HonorInfo.legend_list.push({
|
HonorInfo.legend_list.push({
|
||||||
@@ -244,16 +295,13 @@ export class NTQQWebApi {
|
|||||||
desc: legend_ele?.description,
|
desc: legend_ele?.description,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} else {
|
||||||
this.context.logger.logDebug('获取群聊炽焰失败', e);
|
this.context.logger.logError('获取群聊炽焰失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||||
try {
|
|
||||||
const RetInternal = await getDataInternal(groupCode, 6);
|
const RetInternal = await getDataInternal(groupCode, 6);
|
||||||
if (!RetInternal) {
|
if (RetInternal) {
|
||||||
throw new Error('获取快乐源泉失败');
|
|
||||||
}
|
|
||||||
HonorInfo.emotion_list = [];
|
HonorInfo.emotion_list = [];
|
||||||
for (const emotion_ele of RetInternal) {
|
for (const emotion_ele of RetInternal) {
|
||||||
HonorInfo.emotion_list.push({
|
HonorInfo.emotion_list.push({
|
||||||
@@ -263,14 +311,16 @@ export class NTQQWebApi {
|
|||||||
desc: emotion_ele.description,
|
desc: emotion_ele.description,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} else {
|
||||||
this.context.logger.logDebug('获取快乐源泉失败', e);
|
this.context.logger.logError('获取快乐源泉失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//冒尖小春笋好像已经被tx扬了
|
|
||||||
|
// 冒尖小春笋好像已经被tx扬了 R.I.P.
|
||||||
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||||
HonorInfo.strong_newbie_list = [];
|
HonorInfo.strong_newbie_list = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return HonorInfo;
|
return HonorInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
206
src/core/core.ts
206
src/core/core.ts
@@ -1,206 +0,0 @@
|
|||||||
import { NodeQQNTWrapperUtil, StableNTApiWrapper, WrapperNodeApi } from '@/core/wrapper';
|
|
||||||
import path from 'node:path';
|
|
||||||
import fs from 'node:fs';
|
|
||||||
import { InstanceContext } from './wrapper';
|
|
||||||
import { proxiedListenerOf } from '@/common/utils/proxy-handler';
|
|
||||||
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from './listeners';
|
|
||||||
import { DataSource, GroupMember, SelfInfo } from './entities';
|
|
||||||
import { LegacyNTEventWrapper } from '@/common/framework/event-legacy';
|
|
||||||
import { NTQQFileApi, NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from './apis';
|
|
||||||
import os from 'node:os';
|
|
||||||
import { NTQQCollectionApi } from './apis/collection';
|
|
||||||
import { NapCatConfigLoader } from './helper/config';
|
|
||||||
import { LogLevel } from '@/common/utils/log';
|
|
||||||
|
|
||||||
export enum NapCatCoreWorkingEnv {
|
|
||||||
Unknown = 0,
|
|
||||||
Shell = 1,
|
|
||||||
Framework = 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
|
||||||
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
|
||||||
if (!fs.existsSync(wrapperNodePath)) {
|
|
||||||
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${QQVersion}/wrapper.node`);
|
|
||||||
}
|
|
||||||
const nativemodule: any = { exports: {} };
|
|
||||||
process.dlopen(nativemodule, wrapperNodePath);
|
|
||||||
return nativemodule.exports;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class NapCatCore {
|
|
||||||
readonly context: InstanceContext;
|
|
||||||
readonly apis: StableNTApiWrapper;
|
|
||||||
readonly eventWrapper: LegacyNTEventWrapper;
|
|
||||||
// readonly eventChannel: NTEventChannel;
|
|
||||||
NapCatDataPath: string;
|
|
||||||
NapCatTempPath: string;
|
|
||||||
// runtime info, not readonly
|
|
||||||
selfInfo: SelfInfo;
|
|
||||||
util: NodeQQNTWrapperUtil;
|
|
||||||
configLoader: NapCatConfigLoader;
|
|
||||||
|
|
||||||
// 通过构造器递过去的 runtime info 应该尽量少
|
|
||||||
constructor(context: InstanceContext, selfInfo: SelfInfo) {
|
|
||||||
this.selfInfo = selfInfo;
|
|
||||||
this.context = context;
|
|
||||||
this.util = this.context.wrapper.NodeQQNTWrapperUtil;
|
|
||||||
this.eventWrapper = new LegacyNTEventWrapper(context.session);
|
|
||||||
this.apis = {
|
|
||||||
FileApi: new NTQQFileApi(this.context, this),
|
|
||||||
SystemApi: new NTQQSystemApi(this.context, this),
|
|
||||||
CollectionApi: new NTQQCollectionApi(this.context, this),
|
|
||||||
WebApi: new NTQQWebApi(this.context, this),
|
|
||||||
FriendApi: new NTQQFriendApi(this.context, this),
|
|
||||||
MsgApi: new NTQQMsgApi(this.context, this),
|
|
||||||
UserApi: new NTQQUserApi(this.context, this),
|
|
||||||
GroupApi: new NTQQGroupApi(this.context, this),
|
|
||||||
};
|
|
||||||
this.configLoader = new NapCatConfigLoader(this, this.context.pathWrapper.configPath);
|
|
||||||
this.NapCatDataPath = path.join(this.dataPath, 'NapCat');
|
|
||||||
fs.mkdirSync(this.NapCatDataPath, { recursive: true });
|
|
||||||
this.NapCatTempPath = path.join(this.NapCatDataPath, 'temp');
|
|
||||||
// 创建临时目录
|
|
||||||
if (!fs.existsSync(this.NapCatTempPath)) {
|
|
||||||
fs.mkdirSync(this.NapCatTempPath, { recursive: true });
|
|
||||||
}
|
|
||||||
this.initNapCatCoreListeners().then().catch(this.context.logger.logError);
|
|
||||||
|
|
||||||
this.context.logger.setFileLogEnabled(
|
|
||||||
this.configLoader.configData.fileLog,
|
|
||||||
);
|
|
||||||
this.context.logger.setConsoleLogEnabled(
|
|
||||||
this.configLoader.configData.consoleLog,
|
|
||||||
);
|
|
||||||
this.context.logger.setFileAndConsoleLogLevel(
|
|
||||||
this.configLoader.configData.fileLogLevel as LogLevel,
|
|
||||||
this.configLoader.configData.consoleLogLevel as LogLevel,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
get dataPath(): string {
|
|
||||||
let result = this.context.wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
|
||||||
if (!result) {
|
|
||||||
result = path.resolve(os.homedir(), './.config/QQ');
|
|
||||||
fs.mkdirSync(result, { recursive: true });
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Renamed from 'InitDataListener'
|
|
||||||
async initNapCatCoreListeners() {
|
|
||||||
const msgListener = new NodeIKernelMsgListener();
|
|
||||||
msgListener.onRecvMsg = (msgs) => {
|
|
||||||
msgs.forEach(msg => this.context.logger.logMessage(msg, this.selfInfo));
|
|
||||||
};
|
|
||||||
msgListener.onAddSendMsg = (msg) => {
|
|
||||||
this.context.logger.logMessage(msg, this.selfInfo);
|
|
||||||
};
|
|
||||||
//await sleep(2500);
|
|
||||||
this.context.session.getMsgService().addKernelMsgListener(
|
|
||||||
proxiedListenerOf(msgListener, this.context.logger) as any,
|
|
||||||
);
|
|
||||||
|
|
||||||
const profileListener = new NodeIKernelProfileListener();
|
|
||||||
profileListener.onProfileDetailInfoChanged = (profile) => {
|
|
||||||
if (profile.uid === this.selfInfo.uid) {
|
|
||||||
Object.assign(this.selfInfo, profile);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
profileListener.onSelfStatusChanged = (/* Info: SelfStatusInfo */) => {
|
|
||||||
// if (Info.status == 20) {
|
|
||||||
// log("账号状态变更为离线")
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
this.context.session.getProfileService().addKernelProfileListener(
|
|
||||||
proxiedListenerOf(profileListener, this.context.logger),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 群相关
|
|
||||||
const groupListener = new NodeIKernelGroupListener();
|
|
||||||
groupListener.onGroupListUpdate = (updateType, groupList) => {
|
|
||||||
// console.log("onGroupListUpdate", updateType, groupList)
|
|
||||||
groupList.map(g => {
|
|
||||||
const existGroup = this.apis.GroupApi.groupCache.get(g.groupCode);
|
|
||||||
//群成员数量变化 应该刷新缓存
|
|
||||||
if (existGroup && g.memberCount === existGroup.memberCount) {
|
|
||||||
Object.assign(existGroup, g);
|
|
||||||
} else {
|
|
||||||
this.apis.GroupApi.groupCache.set(g.groupCode, g);
|
|
||||||
// 获取群成员
|
|
||||||
}
|
|
||||||
const sceneId = this.context.session.getGroupService().createMemberListScene(g.groupCode, 'groupMemberList_MainWindow');
|
|
||||||
this.context.session.getGroupService().getNextMemberList(sceneId!, undefined, 3000).then( /* r => {
|
|
||||||
// console.log(`get group ${g.groupCode} members`, r);
|
|
||||||
// r.result.infos.forEach(member => {
|
|
||||||
// });
|
|
||||||
// groupMembers.set(g.groupCode, r.result.infos);
|
|
||||||
} */);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
groupListener.onMemberListChange = (arg) => {
|
|
||||||
// todo: 应该加一个内部自己维护的成员变动callback,用于判断成员变化通知
|
|
||||||
const groupCode = arg.sceneId.split('_')[0];
|
|
||||||
if (this.apis.GroupApi.groupMemberCache.has(groupCode)) {
|
|
||||||
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode)!;
|
|
||||||
arg.infos.forEach((member, uid) => {
|
|
||||||
//console.log('onMemberListChange', member);
|
|
||||||
const existMember = existMembers.get(uid);
|
|
||||||
if (existMember) {
|
|
||||||
Object.assign(existMember, member);
|
|
||||||
} else {
|
|
||||||
existMembers!.set(uid, member);
|
|
||||||
}
|
|
||||||
//移除成员
|
|
||||||
if (member.isDelete) {
|
|
||||||
existMembers.delete(uid);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.apis.GroupApi.groupMemberCache.set(groupCode, arg.infos);
|
|
||||||
}
|
|
||||||
// console.log('onMemberListChange', groupCode, arg);
|
|
||||||
};
|
|
||||||
groupListener.onMemberInfoChange = (groupCode, dataSource, members) => {
|
|
||||||
//console.log('onMemberInfoChange', groupCode, changeType, members);
|
|
||||||
if (dataSource === DataSource.LOCAL && members.get(this.selfInfo.uid)?.isDelete) {
|
|
||||||
// 自身退群或者被踢退群 5s用于Api操作 之后不再出现
|
|
||||||
setTimeout(() => {
|
|
||||||
this.apis.GroupApi.groupCache.delete(groupCode);
|
|
||||||
}, 5000);
|
|
||||||
|
|
||||||
}
|
|
||||||
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode);
|
|
||||||
if (existMembers) {
|
|
||||||
members.forEach((member, uid) => {
|
|
||||||
const existMember = existMembers.get(uid);
|
|
||||||
if (existMember) {
|
|
||||||
// 检查管理变动
|
|
||||||
member.isChangeRole = this.checkAdminEvent(groupCode, member, existMember);
|
|
||||||
// 更新成员信息
|
|
||||||
Object.assign(existMember, member);
|
|
||||||
} else {
|
|
||||||
existMembers.set(uid, member);
|
|
||||||
}
|
|
||||||
//移除成员
|
|
||||||
if (member.isDelete) {
|
|
||||||
existMembers.delete(uid);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.apis.GroupApi.groupMemberCache.set(groupCode, members);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.context.session.getGroupService().addKernelGroupListener(
|
|
||||||
proxiedListenerOf(groupListener, this.context.logger) as any,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
checkAdminEvent(groupCode: string, memberNew: GroupMember, memberOld: GroupMember | undefined): boolean {
|
|
||||||
if (memberNew.role !== memberOld?.role) {
|
|
||||||
this.context.logger.logDebug(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -22,6 +22,7 @@ export interface GetFileListParam {
|
|||||||
startIndex: number;
|
startIndex: number;
|
||||||
sortOrder: number;
|
sortOrder: number;
|
||||||
showOnlinedocFolder: number;
|
showOnlinedocFolder: number;
|
||||||
|
folderId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum ElementType {
|
export enum ElementType {
|
||||||
@@ -369,7 +370,8 @@ export interface ReplyElement {
|
|||||||
replayMsgSeq: string;
|
replayMsgSeq: string;
|
||||||
replayMsgId: string;
|
replayMsgId: string;
|
||||||
senderUin: string;
|
senderUin: string;
|
||||||
senderUinStr: string;
|
senderUidStr?: string;
|
||||||
|
replyMsgTime?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SendReplyElement {
|
export interface SendReplyElement {
|
||||||
@@ -593,6 +595,7 @@ export const IMAGE_HTTP_HOST_NT = 'https://multimedia.nt.qq.com.cn';
|
|||||||
|
|
||||||
export interface PicElement {
|
export interface PicElement {
|
||||||
md5HexStr?: string;
|
md5HexStr?: string;
|
||||||
|
filePath?: string;
|
||||||
fileSize: number | string;//number
|
fileSize: number | string;//number
|
||||||
picWidth: number;
|
picWidth: number;
|
||||||
picHeight: number;
|
picHeight: number;
|
||||||
|
38
src/core/external/appid.json
vendored
38
src/core/external/appid.json
vendored
@@ -1,34 +1,14 @@
|
|||||||
{
|
{
|
||||||
"3.2.12-27187": {
|
"3.2.12-27597": {
|
||||||
"appid": 537240645,
|
"appid": 537243600,
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27187_GW_B"
|
"qua": "V1_LNX_NQ_3.2.12_27597_GW_B"
|
||||||
},
|
},
|
||||||
"3.2.12-27206": {
|
"9.9.15-27597": {
|
||||||
"appid": 537240645,
|
"appid": 537243441,
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27206_GW_B"
|
"qua": "V1_WIN_NQ_9.9.15_27597_GW_B"
|
||||||
},
|
},
|
||||||
"3.2.12-27254": {
|
"6.9.53-27597": {
|
||||||
"appid": 537240795,
|
"appid": 537243538,
|
||||||
"qua": "V1_LNX_NQ_3.2.12_27254_GW_B"
|
"qua": "V1_MAC_NQ_6.9.53_27597_GW_B"
|
||||||
},
|
|
||||||
"9.9.15-27187": {
|
|
||||||
"appid": 537240610,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27187_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27206": {
|
|
||||||
"appid": 537240610,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27206_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27254": {
|
|
||||||
"appid": 537240709,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27254_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27333": {
|
|
||||||
"appid": 537240709,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27333_GW_B"
|
|
||||||
},
|
|
||||||
"9.9.15-27391": {
|
|
||||||
"appid": 537240709,
|
|
||||||
"qua": "V1_WIN_NQ_9.9.15_27333_GW_B"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
import { ConfigBase } from '@/common/utils/config-base';
|
import { ConfigBase } from '@/common/config-base';
|
||||||
import napCatDefaultConfig from '@/core/external/napcat.json';
|
import napCatDefaultConfig from '@/core/external/napcat.json';
|
||||||
import { NapCatCore } from '@/core';
|
import { NapCatCore } from '@/core';
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
||||||
export type NapCatConfig = typeof napCatDefaultConfig;
|
export type NapCatConfig = typeof napCatDefaultConfig;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
||||||
export class NapCatConfigLoader extends ConfigBase<NapCatConfig> {
|
export class NapCatConfigLoader extends ConfigBase<NapCatConfig> {
|
||||||
constructor(core: NapCatCore, configPath: string) {
|
constructor(core: NapCatCore, configPath: string) {
|
||||||
super('napcat', core, configPath);
|
super('napcat', core, configPath);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { LogWrapper } from '@/common/utils/log';
|
import { LogWrapper } from '@/common/log';
|
||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/request';
|
||||||
|
|
||||||
interface ServerRkeyData {
|
interface ServerRkeyData {
|
||||||
group_rkey: string;
|
group_rkey: string;
|
||||||
|
@@ -1,5 +1,312 @@
|
|||||||
export * from './core';
|
import {
|
||||||
|
NTQQFileApi,
|
||||||
|
NTQQFriendApi,
|
||||||
|
NTQQGroupApi,
|
||||||
|
NTQQMsgApi,
|
||||||
|
NTQQSystemApi,
|
||||||
|
NTQQUserApi,
|
||||||
|
NTQQWebApi,
|
||||||
|
} from '@/core/apis';
|
||||||
|
import { NTQQCollectionApi } from '@/core/apis/collection';
|
||||||
|
import {
|
||||||
|
NodeIQQNTWrapperSession,
|
||||||
|
NodeQQNTWrapperUtil,
|
||||||
|
PlatformType,
|
||||||
|
VendorType,
|
||||||
|
WrapperNodeApi,
|
||||||
|
WrapperSessionInitConfig,
|
||||||
|
} from '@/core/wrapper';
|
||||||
|
import { LogLevel, LogWrapper } from '@/common/log';
|
||||||
|
import { NodeIKernelLoginService } from '@/core/services';
|
||||||
|
import { QQBasicInfoWrapper } from '@/common/qq-basic-info';
|
||||||
|
import { NapCatPathWrapper } from '@/common/path';
|
||||||
|
import path from 'node:path';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import { getMachineId, hostname, systemName, systemVersion } from '@/common/system';
|
||||||
|
import { NTEventWrapper } from '@/common/event';
|
||||||
|
import { DataSource, GroupMember, KickedOffLineInfo, SelfInfo, SelfStatusInfo } from '@/core/entities';
|
||||||
|
import { NapCatConfigLoader } from '@/core/helper/config';
|
||||||
|
import os from 'node:os';
|
||||||
|
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from '@/core/listeners';
|
||||||
|
import { proxiedListenerOf } from '@/common/proxy-handler';
|
||||||
|
|
||||||
export * from './wrapper';
|
export * from './wrapper';
|
||||||
export * from './entities';
|
export * from './entities';
|
||||||
export * from './services';
|
export * from './services';
|
||||||
export * from './listeners';
|
export * from './listeners';
|
||||||
|
|
||||||
|
export enum NapCatCoreWorkingEnv {
|
||||||
|
Unknown = 0,
|
||||||
|
Shell = 1,
|
||||||
|
Framework = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
||||||
|
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)) {
|
||||||
|
wrapperNodePath = path.join(appPath, `versions/${QQVersion}/wrapper.node`);
|
||||||
|
}
|
||||||
|
const nativemodule: any = { exports: {} };
|
||||||
|
process.dlopen(nativemodule, wrapperNodePath);
|
||||||
|
return nativemodule.exports;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NapCatCore {
|
||||||
|
readonly context: InstanceContext;
|
||||||
|
readonly apis: StableNTApiWrapper;
|
||||||
|
readonly eventWrapper: NTEventWrapper;
|
||||||
|
// readonly eventChannel: NTEventChannel;
|
||||||
|
NapCatDataPath: string;
|
||||||
|
NapCatTempPath: string;
|
||||||
|
// runtime info, not readonly
|
||||||
|
selfInfo: SelfInfo;
|
||||||
|
util: NodeQQNTWrapperUtil;
|
||||||
|
configLoader: NapCatConfigLoader;
|
||||||
|
|
||||||
|
// 通过构造器递过去的 runtime info 应该尽量少
|
||||||
|
constructor(context: InstanceContext, selfInfo: SelfInfo) {
|
||||||
|
this.selfInfo = selfInfo;
|
||||||
|
this.context = context;
|
||||||
|
this.util = this.context.wrapper.NodeQQNTWrapperUtil;
|
||||||
|
this.eventWrapper = new NTEventWrapper(context.session);
|
||||||
|
this.apis = {
|
||||||
|
FileApi: new NTQQFileApi(this.context, this),
|
||||||
|
SystemApi: new NTQQSystemApi(this.context, this),
|
||||||
|
CollectionApi: new NTQQCollectionApi(this.context, this),
|
||||||
|
WebApi: new NTQQWebApi(this.context, this),
|
||||||
|
FriendApi: new NTQQFriendApi(this.context, this),
|
||||||
|
MsgApi: new NTQQMsgApi(this.context, this),
|
||||||
|
UserApi: new NTQQUserApi(this.context, this),
|
||||||
|
GroupApi: new NTQQGroupApi(this.context, this),
|
||||||
|
};
|
||||||
|
this.configLoader = new NapCatConfigLoader(this, this.context.pathWrapper.configPath);
|
||||||
|
this.NapCatDataPath = path.join(this.dataPath, 'NapCat');
|
||||||
|
fs.mkdirSync(this.NapCatDataPath, { recursive: true });
|
||||||
|
this.NapCatTempPath = path.join(this.NapCatDataPath, 'temp');
|
||||||
|
// 创建临时目录
|
||||||
|
if (!fs.existsSync(this.NapCatTempPath)) {
|
||||||
|
fs.mkdirSync(this.NapCatTempPath, { recursive: true });
|
||||||
|
}
|
||||||
|
this.initNapCatCoreListeners().then().catch(this.context.logger.logError);
|
||||||
|
|
||||||
|
this.context.logger.setFileLogEnabled(
|
||||||
|
this.configLoader.configData.fileLog,
|
||||||
|
);
|
||||||
|
this.context.logger.setConsoleLogEnabled(
|
||||||
|
this.configLoader.configData.consoleLog,
|
||||||
|
);
|
||||||
|
this.context.logger.setFileAndConsoleLogLevel(
|
||||||
|
this.configLoader.configData.fileLogLevel as LogLevel,
|
||||||
|
this.configLoader.configData.consoleLogLevel as LogLevel,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
get dataPath(): string {
|
||||||
|
let result = this.context.wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
||||||
|
if (!result) {
|
||||||
|
result = path.resolve(os.homedir(), './.config/QQ');
|
||||||
|
fs.mkdirSync(result, { recursive: true });
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Renamed from 'InitDataListener'
|
||||||
|
async initNapCatCoreListeners() {
|
||||||
|
const msgListener = new NodeIKernelMsgListener();
|
||||||
|
msgListener.onKickedOffLine = (Info: KickedOffLineInfo) => {
|
||||||
|
// 下线通知
|
||||||
|
this.context.logger.logError('[KickedOffLine] [' + Info.tipsTitle + '] ' + Info.tipsDesc);
|
||||||
|
this.selfInfo.online = false;
|
||||||
|
};
|
||||||
|
msgListener.onRecvMsg = (msgs) => {
|
||||||
|
msgs.forEach(msg => this.context.logger.logMessage(msg, this.selfInfo));
|
||||||
|
};
|
||||||
|
msgListener.onAddSendMsg = (msg) => {
|
||||||
|
this.context.logger.logMessage(msg, this.selfInfo);
|
||||||
|
};
|
||||||
|
//await sleep(2500);
|
||||||
|
this.context.session.getMsgService().addKernelMsgListener(
|
||||||
|
proxiedListenerOf(msgListener, this.context.logger) as any,
|
||||||
|
);
|
||||||
|
|
||||||
|
const profileListener = new NodeIKernelProfileListener();
|
||||||
|
profileListener.onProfileDetailInfoChanged = (profile) => {
|
||||||
|
if (profile.uid === this.selfInfo.uid) {
|
||||||
|
Object.assign(this.selfInfo, profile);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
profileListener.onSelfStatusChanged = (Info: SelfStatusInfo) => {
|
||||||
|
if (Info.status == 20) {
|
||||||
|
this.selfInfo.online = false;
|
||||||
|
this.context.logger.log("账号状态变更为离线");
|
||||||
|
}
|
||||||
|
this.selfInfo.online = true;
|
||||||
|
};
|
||||||
|
this.context.session.getProfileService().addKernelProfileListener(
|
||||||
|
proxiedListenerOf(profileListener, this.context.logger),
|
||||||
|
);
|
||||||
|
|
||||||
|
// 群相关
|
||||||
|
const groupListener = new NodeIKernelGroupListener();
|
||||||
|
groupListener.onGroupListUpdate = (updateType, groupList) => {
|
||||||
|
// console.log("onGroupListUpdate", updateType, groupList)
|
||||||
|
groupList.map(g => {
|
||||||
|
const existGroup = this.apis.GroupApi.groupCache.get(g.groupCode);
|
||||||
|
//群成员数量变化 应该刷新缓存
|
||||||
|
if (existGroup && g.memberCount === existGroup.memberCount) {
|
||||||
|
Object.assign(existGroup, g);
|
||||||
|
} else {
|
||||||
|
this.apis.GroupApi.groupCache.set(g.groupCode, g);
|
||||||
|
// 获取群成员
|
||||||
|
}
|
||||||
|
const sceneId = this.context.session.getGroupService().createMemberListScene(g.groupCode, 'groupMemberList_MainWindow');
|
||||||
|
this.context.session.getGroupService().getNextMemberList(sceneId, undefined, 3000).then( /* r => {
|
||||||
|
// console.log(`get group ${g.groupCode} members`, r);
|
||||||
|
// r.result.infos.forEach(member => {
|
||||||
|
// });
|
||||||
|
// groupMembers.set(g.groupCode, r.result.infos);
|
||||||
|
} */);
|
||||||
|
this.context.session.getGroupService().destroyMemberListScene(sceneId);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
groupListener.onMemberListChange = (arg) => {
|
||||||
|
// todo: 应该加一个内部自己维护的成员变动callback,用于判断成员变化通知
|
||||||
|
const groupCode = arg.sceneId.split('_')[0];
|
||||||
|
if (this.apis.GroupApi.groupMemberCache.has(groupCode)) {
|
||||||
|
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode)!;
|
||||||
|
arg.infos.forEach((member, uid) => {
|
||||||
|
//console.log('onMemberListChange', member);
|
||||||
|
const existMember = existMembers.get(uid);
|
||||||
|
if (existMember) {
|
||||||
|
Object.assign(existMember, member);
|
||||||
|
} else {
|
||||||
|
existMembers!.set(uid, member);
|
||||||
|
}
|
||||||
|
//移除成员
|
||||||
|
if (member.isDelete) {
|
||||||
|
existMembers.delete(uid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.apis.GroupApi.groupMemberCache.set(groupCode, arg.infos);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
groupListener.onMemberInfoChange = (groupCode, dataSource, members) => {
|
||||||
|
if (dataSource === DataSource.LOCAL && members.get(this.selfInfo.uid)?.isDelete) {
|
||||||
|
// 自身退群或者被踢退群 5s用于Api操作 之后不再出现
|
||||||
|
setTimeout(() => {
|
||||||
|
this.apis.GroupApi.groupCache.delete(groupCode);
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
}
|
||||||
|
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode);
|
||||||
|
if (existMembers) {
|
||||||
|
members.forEach((member, uid) => {
|
||||||
|
const existMember = existMembers.get(uid);
|
||||||
|
if (existMember) {
|
||||||
|
// 检查管理变动
|
||||||
|
member.isChangeRole = this.checkAdminEvent(groupCode, member, existMember);
|
||||||
|
// 更新成员信息
|
||||||
|
Object.assign(existMember, member);
|
||||||
|
} else {
|
||||||
|
existMembers.set(uid, member);
|
||||||
|
}
|
||||||
|
//移除成员
|
||||||
|
if (member.isDelete) {
|
||||||
|
existMembers.delete(uid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.apis.GroupApi.groupMemberCache.set(groupCode, members);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.context.session.getGroupService().addKernelGroupListener(
|
||||||
|
proxiedListenerOf(groupListener, this.context.logger) as any,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkAdminEvent(groupCode: string, memberNew: GroupMember, memberOld: GroupMember | undefined): boolean {
|
||||||
|
if (memberNew.role !== memberOld?.role) {
|
||||||
|
this.context.logger.logDebug(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function genSessionConfig(QQVersionAppid: string, QQVersion: string, selfUin: string, selfUid: string, account_path: string): Promise<WrapperSessionInitConfig> {
|
||||||
|
const downloadPath = path.join(account_path, 'NapCat', 'temp');
|
||||||
|
fs.mkdirSync(downloadPath, { recursive: true });
|
||||||
|
const guid: string = await getMachineId();//26702 支持JS获取guid值 在LoginService中获取 TODO mlikiow a
|
||||||
|
return {
|
||||||
|
selfUin,
|
||||||
|
selfUid,
|
||||||
|
desktopPathConfig: {
|
||||||
|
account_path, // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
||||||
|
},
|
||||||
|
clientVer: QQVersion, // 9.9.8-22355
|
||||||
|
a2: '',
|
||||||
|
d2: '',
|
||||||
|
d2Key: '',
|
||||||
|
machineId: '',
|
||||||
|
platform: PlatformType.KWINDOWS, // 3是Windows?
|
||||||
|
platVer: systemVersion, // 系统版本号, 应该可以固定
|
||||||
|
appid: QQVersionAppid,
|
||||||
|
rdeliveryConfig: {
|
||||||
|
appKey: '',
|
||||||
|
systemId: 0,
|
||||||
|
appId: '',
|
||||||
|
logicEnvironment: '',
|
||||||
|
platform: PlatformType.KWINDOWS,
|
||||||
|
language: '',
|
||||||
|
sdkVersion: '',
|
||||||
|
userId: '',
|
||||||
|
appVersion: '',
|
||||||
|
osVersion: '',
|
||||||
|
bundleId: '',
|
||||||
|
serverUrl: '',
|
||||||
|
fixedAfterHitKeys: [''],
|
||||||
|
},
|
||||||
|
defaultFileDownloadPath: downloadPath,
|
||||||
|
deviceInfo: {
|
||||||
|
guid,
|
||||||
|
buildVer: QQVersion,
|
||||||
|
localId: 2052,
|
||||||
|
devName: hostname,
|
||||||
|
devType: systemName,
|
||||||
|
vendorName: '',
|
||||||
|
osVer: systemVersion,
|
||||||
|
vendorOsName: systemName,
|
||||||
|
setMute: false,
|
||||||
|
vendorType: VendorType.KNOSETONIOS,
|
||||||
|
},
|
||||||
|
deviceConfig: '{"appearance":{"isSplitViewMode":true},"msg":{}}',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface InstanceContext {
|
||||||
|
readonly workingEnv: NapCatCoreWorkingEnv;
|
||||||
|
readonly wrapper: WrapperNodeApi;
|
||||||
|
readonly session: NodeIQQNTWrapperSession;
|
||||||
|
readonly logger: LogWrapper;
|
||||||
|
readonly loginService: NodeIKernelLoginService;
|
||||||
|
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
||||||
|
readonly pathWrapper: NapCatPathWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StableNTApiWrapper {
|
||||||
|
FileApi: NTQQFileApi,
|
||||||
|
SystemApi: NTQQSystemApi,
|
||||||
|
CollectionApi: NTQQCollectionApi,
|
||||||
|
WebApi: NTQQWebApi,
|
||||||
|
FriendApi: NTQQFriendApi,
|
||||||
|
MsgApi: NTQQMsgApi,
|
||||||
|
UserApi: NTQQUserApi,
|
||||||
|
GroupApi: NTQQGroupApi
|
||||||
|
}
|
||||||
|
@@ -1,5 +1,13 @@
|
|||||||
export class NodeIKernelFileAssistantListener {
|
export class NodeIKernelFileAssistantListener {
|
||||||
onFileStatusChanged(...args: unknown[]) {
|
onFileStatusChanged(fileStatus: {
|
||||||
|
id: string,
|
||||||
|
fileStatus: number,
|
||||||
|
fileProgress: `${number}`,
|
||||||
|
fileSize: `${number}`,
|
||||||
|
fileSpeed: number,
|
||||||
|
thumbPath: string | null,
|
||||||
|
filePath: string | null,
|
||||||
|
}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSessionListChanged(...args: unknown[]) {
|
onSessionListChanged(...args: unknown[]) {
|
||||||
@@ -11,6 +19,42 @@ export class NodeIKernelFileAssistantListener {
|
|||||||
onFileListChanged(...args: unknown[]) {
|
onFileListChanged(...args: unknown[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onFileSearch(...args: unknown[]) {
|
onFileSearch(searchResult: SearchResultWrapper) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SearchResultWrapper = {
|
||||||
|
searchId: number,
|
||||||
|
resultId: number,
|
||||||
|
hasMore: boolean,
|
||||||
|
resultItems: SearchResultItem[],
|
||||||
|
};
|
||||||
|
|
||||||
|
export type SearchResultItem = {
|
||||||
|
id: string,
|
||||||
|
fileName: string,
|
||||||
|
fileNameHits: string[],
|
||||||
|
fileStatus: number,
|
||||||
|
fileSize: string,
|
||||||
|
isSend: boolean,
|
||||||
|
source: number,
|
||||||
|
fileTime: string,
|
||||||
|
expTime: string,
|
||||||
|
session: {
|
||||||
|
context: null,
|
||||||
|
uid: string,
|
||||||
|
nick: string,
|
||||||
|
remark: string,
|
||||||
|
memberCard: string,
|
||||||
|
groupCode: string,
|
||||||
|
groupName: string,
|
||||||
|
groupRemark: string,
|
||||||
|
count: number,
|
||||||
|
},
|
||||||
|
thumbPath: string,
|
||||||
|
filePath: string,
|
||||||
|
msgId: string,
|
||||||
|
chatType: number,
|
||||||
|
peerUid: string,
|
||||||
|
fileType: number,
|
||||||
|
};
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import { DataSource, Group, GroupListUpdateType, GroupMember, GroupNotify } from '@/core/entities';
|
import { DataSource, Group, GroupListUpdateType, GroupMember, GroupNotify } from '@/core/entities';
|
||||||
|
|
||||||
export class NodeIKernelGroupListener {
|
export class NodeIKernelGroupListener {
|
||||||
|
onGroupListInited(listEmpty: boolean): void { }
|
||||||
// 发现于Win 9.9.9 23159
|
// 发现于Win 9.9.9 23159
|
||||||
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
||||||
|
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { ChatType, RawMessage } from '@/core/entities';
|
import { ChatType, RawMessage } from '@/core/entities';
|
||||||
|
import { CommonFileInfo } from '@/core';
|
||||||
|
|
||||||
export interface OnRichMediaDownloadCompleteParams {
|
export interface OnRichMediaDownloadCompleteParams {
|
||||||
fileModelId: string,
|
fileModelId: string,
|
||||||
@@ -15,7 +16,7 @@ export interface OnRichMediaDownloadCompleteParams {
|
|||||||
totalSize: string,
|
totalSize: string,
|
||||||
trasferStatus: number,
|
trasferStatus: number,
|
||||||
step: number,
|
step: number,
|
||||||
commonFileInfo: unknown | null,
|
commonFileInfo?: CommonFileInfo,
|
||||||
fileSrvErrCode: string,
|
fileSrvErrCode: string,
|
||||||
clientMsg: string,
|
clientMsg: string,
|
||||||
businessId: number,
|
businessId: number,
|
||||||
@@ -28,7 +29,47 @@ export interface GroupFileInfoUpdateParamType {
|
|||||||
retMsg: string;
|
retMsg: string;
|
||||||
clientWording: string;
|
clientWording: string;
|
||||||
isEnd: boolean;
|
isEnd: boolean;
|
||||||
item: Array<any>;
|
item: Array<{
|
||||||
|
peerId: string;
|
||||||
|
type: number;
|
||||||
|
folderInfo?: {
|
||||||
|
folderId: string;
|
||||||
|
parentFolderId: string;
|
||||||
|
folderName: string;
|
||||||
|
createTime: number;
|
||||||
|
modifyTime: number;
|
||||||
|
createUin: string;
|
||||||
|
creatorName: string;
|
||||||
|
totalFileCount: number;
|
||||||
|
modifyUin: string;
|
||||||
|
modifyName: string;
|
||||||
|
usedSpace: string;
|
||||||
|
},
|
||||||
|
fileInfo?: {
|
||||||
|
fileModelId: string;
|
||||||
|
fileId: string;
|
||||||
|
fileName: string;
|
||||||
|
fileSize: string;
|
||||||
|
busId: number;
|
||||||
|
uploadedSize: string;
|
||||||
|
uploadTime: number;
|
||||||
|
deadTime: number;
|
||||||
|
modifyTime: number;
|
||||||
|
downloadTimes: number;
|
||||||
|
sha: string;
|
||||||
|
sha3: string;
|
||||||
|
md5: string;
|
||||||
|
uploaderLocalPath: string;
|
||||||
|
uploaderName: string;
|
||||||
|
uploaderUin: string;
|
||||||
|
parentFolderId: string;
|
||||||
|
localPath: string;
|
||||||
|
transStatus: number;
|
||||||
|
transType: number;
|
||||||
|
elementId: string;
|
||||||
|
isFolder: boolean;
|
||||||
|
},
|
||||||
|
}>;
|
||||||
allFileCount: string;
|
allFileCount: string;
|
||||||
nextIndex: string;
|
nextIndex: string;
|
||||||
reqId: string;
|
reqId: string;
|
||||||
|
@@ -19,10 +19,10 @@ import type {
|
|||||||
NodeIKernelMsgListener,
|
NodeIKernelMsgListener,
|
||||||
NodeIKernelProfileListener,
|
NodeIKernelProfileListener,
|
||||||
NodeIKernelRobotListener,
|
NodeIKernelRobotListener,
|
||||||
|
NodeIKernelSearchListener_Polyfill,
|
||||||
NodeIKernelSessionListener,
|
NodeIKernelSessionListener,
|
||||||
NodeIKernelStorageCleanListener,
|
NodeIKernelStorageCleanListener,
|
||||||
NodeIKernelTicketListener,
|
NodeIKernelTicketListener,
|
||||||
NodeIKernelSearchListener_Polyfill,
|
|
||||||
} from '.';
|
} from '.';
|
||||||
|
|
||||||
export type ListenerNamingMapping = {
|
export type ListenerNamingMapping = {
|
||||||
|
31
src/core/proto/EmojiLikeToOthers.proto
Normal file
31
src/core/proto/EmojiLikeToOthers.proto
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
syntax = 'proto3';
|
||||||
|
package SysMessage;
|
||||||
|
|
||||||
|
message EmojiLikeToOthersWrapper1 {
|
||||||
|
EmojiLikeToOthersWrapper2 wrapper = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EmojiLikeToOthersWrapper2 {
|
||||||
|
EmojiLikeToOthersWrapper3 body = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EmojiLikeToOthersWrapper3 {
|
||||||
|
EmojiLikeToOthersMsgSpec msgSpec = 2;
|
||||||
|
EmojiLikeToOthersAttributes attributes = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EmojiLikeToOthersMsgSpec {
|
||||||
|
uint32 msgSeq = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message EmojiLikeToOthersAttributes {
|
||||||
|
enum Operation {
|
||||||
|
FALLBACK = 0;
|
||||||
|
LIKE = 1;
|
||||||
|
UNLIKE = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
string emojiId = 1;
|
||||||
|
string senderUid = 4;
|
||||||
|
Operation operation = 5;
|
||||||
|
}
|
341
src/core/proto/EmojiLikeToOthers.ts
Normal file
341
src/core/proto/EmojiLikeToOthers.ts
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
// @generated by protobuf-ts 2.9.4
|
||||||
|
// @generated from protobuf file "EmojiLikeToOthers.proto" (package "SysMessage", syntax proto3)
|
||||||
|
// tslint:disable
|
||||||
|
import type {
|
||||||
|
BinaryReadOptions,
|
||||||
|
BinaryWriteOptions,
|
||||||
|
IBinaryReader,
|
||||||
|
IBinaryWriter,
|
||||||
|
PartialMessage,
|
||||||
|
} from '@protobuf-ts/runtime';
|
||||||
|
import { MessageType, reflectionMergePartial, UnknownFieldHandler, WireType } from '@protobuf-ts/runtime';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.EmojiLikeToOthersWrapper1
|
||||||
|
*/
|
||||||
|
export interface EmojiLikeToOthersWrapper1 {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: SysMessage.EmojiLikeToOthersWrapper2 wrapper = 1;
|
||||||
|
*/
|
||||||
|
wrapper?: EmojiLikeToOthersWrapper2;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.EmojiLikeToOthersWrapper2
|
||||||
|
*/
|
||||||
|
export interface EmojiLikeToOthersWrapper2 {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: SysMessage.EmojiLikeToOthersWrapper3 body = 1;
|
||||||
|
*/
|
||||||
|
body?: EmojiLikeToOthersWrapper3;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.EmojiLikeToOthersWrapper3
|
||||||
|
*/
|
||||||
|
export interface EmojiLikeToOthersWrapper3 {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: SysMessage.EmojiLikeToOthersMsgSpec msgSpec = 2;
|
||||||
|
*/
|
||||||
|
msgSpec?: EmojiLikeToOthersMsgSpec;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: SysMessage.EmojiLikeToOthersAttributes attributes = 3;
|
||||||
|
*/
|
||||||
|
attributes?: EmojiLikeToOthersAttributes;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.EmojiLikeToOthersMsgSpec
|
||||||
|
*/
|
||||||
|
export interface EmojiLikeToOthersMsgSpec {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 msgSeq = 1;
|
||||||
|
*/
|
||||||
|
msgSeq: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.EmojiLikeToOthersAttributes
|
||||||
|
*/
|
||||||
|
export interface EmojiLikeToOthersAttributes {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: string emojiId = 1;
|
||||||
|
*/
|
||||||
|
emojiId: string;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: string senderUid = 4;
|
||||||
|
*/
|
||||||
|
senderUid: string;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: SysMessage.EmojiLikeToOthersAttributes.Operation operation = 5;
|
||||||
|
*/
|
||||||
|
operation: EmojiLikeToOthersAttributes_Operation;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf enum SysMessage.EmojiLikeToOthersAttributes.Operation
|
||||||
|
*/
|
||||||
|
export enum EmojiLikeToOthersAttributes_Operation {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf enum value: FALLBACK = 0;
|
||||||
|
*/
|
||||||
|
FALLBACK = 0,
|
||||||
|
/**
|
||||||
|
* @generated from protobuf enum value: LIKE = 1;
|
||||||
|
*/
|
||||||
|
LIKE = 1,
|
||||||
|
/**
|
||||||
|
* @generated from protobuf enum value: UNLIKE = 2;
|
||||||
|
*/
|
||||||
|
UNLIKE = 2
|
||||||
|
}
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class EmojiLikeToOthersWrapper1$Type extends MessageType<EmojiLikeToOthersWrapper1> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.EmojiLikeToOthersWrapper1", [
|
||||||
|
{ no: 1, name: "wrapper", kind: "message", T: () => EmojiLikeToOthersWrapper2 }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<EmojiLikeToOthersWrapper1>): EmojiLikeToOthersWrapper1 {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<EmojiLikeToOthersWrapper1>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersWrapper1): EmojiLikeToOthersWrapper1 {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* SysMessage.EmojiLikeToOthersWrapper2 wrapper */ 1:
|
||||||
|
message.wrapper = EmojiLikeToOthersWrapper2.internalBinaryRead(reader, reader.uint32(), options, message.wrapper);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: EmojiLikeToOthersWrapper1, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* SysMessage.EmojiLikeToOthersWrapper2 wrapper = 1; */
|
||||||
|
if (message.wrapper)
|
||||||
|
EmojiLikeToOthersWrapper2.internalBinaryWrite(message.wrapper, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersWrapper1
|
||||||
|
*/
|
||||||
|
export const EmojiLikeToOthersWrapper1 = new EmojiLikeToOthersWrapper1$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class EmojiLikeToOthersWrapper2$Type extends MessageType<EmojiLikeToOthersWrapper2> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.EmojiLikeToOthersWrapper2", [
|
||||||
|
{ no: 1, name: "body", kind: "message", T: () => EmojiLikeToOthersWrapper3 }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<EmojiLikeToOthersWrapper2>): EmojiLikeToOthersWrapper2 {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<EmojiLikeToOthersWrapper2>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersWrapper2): EmojiLikeToOthersWrapper2 {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* SysMessage.EmojiLikeToOthersWrapper3 body */ 1:
|
||||||
|
message.body = EmojiLikeToOthersWrapper3.internalBinaryRead(reader, reader.uint32(), options, message.body);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: EmojiLikeToOthersWrapper2, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* SysMessage.EmojiLikeToOthersWrapper3 body = 1; */
|
||||||
|
if (message.body)
|
||||||
|
EmojiLikeToOthersWrapper3.internalBinaryWrite(message.body, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersWrapper2
|
||||||
|
*/
|
||||||
|
export const EmojiLikeToOthersWrapper2 = new EmojiLikeToOthersWrapper2$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class EmojiLikeToOthersWrapper3$Type extends MessageType<EmojiLikeToOthersWrapper3> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.EmojiLikeToOthersWrapper3", [
|
||||||
|
{ no: 2, name: "msgSpec", kind: "message", T: () => EmojiLikeToOthersMsgSpec },
|
||||||
|
{ no: 3, name: "attributes", kind: "message", T: () => EmojiLikeToOthersAttributes }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<EmojiLikeToOthersWrapper3>): EmojiLikeToOthersWrapper3 {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<EmojiLikeToOthersWrapper3>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersWrapper3): EmojiLikeToOthersWrapper3 {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* SysMessage.EmojiLikeToOthersMsgSpec msgSpec */ 2:
|
||||||
|
message.msgSpec = EmojiLikeToOthersMsgSpec.internalBinaryRead(reader, reader.uint32(), options, message.msgSpec);
|
||||||
|
break;
|
||||||
|
case /* SysMessage.EmojiLikeToOthersAttributes attributes */ 3:
|
||||||
|
message.attributes = EmojiLikeToOthersAttributes.internalBinaryRead(reader, reader.uint32(), options, message.attributes);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: EmojiLikeToOthersWrapper3, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* SysMessage.EmojiLikeToOthersMsgSpec msgSpec = 2; */
|
||||||
|
if (message.msgSpec)
|
||||||
|
EmojiLikeToOthersMsgSpec.internalBinaryWrite(message.msgSpec, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
/* SysMessage.EmojiLikeToOthersAttributes attributes = 3; */
|
||||||
|
if (message.attributes)
|
||||||
|
EmojiLikeToOthersAttributes.internalBinaryWrite(message.attributes, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersWrapper3
|
||||||
|
*/
|
||||||
|
export const EmojiLikeToOthersWrapper3 = new EmojiLikeToOthersWrapper3$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class EmojiLikeToOthersMsgSpec$Type extends MessageType<EmojiLikeToOthersMsgSpec> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.EmojiLikeToOthersMsgSpec", [
|
||||||
|
{ no: 1, name: "msgSeq", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<EmojiLikeToOthersMsgSpec>): EmojiLikeToOthersMsgSpec {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.msgSeq = 0;
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<EmojiLikeToOthersMsgSpec>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersMsgSpec): EmojiLikeToOthersMsgSpec {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* uint32 msgSeq */ 1:
|
||||||
|
message.msgSeq = reader.uint32();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: EmojiLikeToOthersMsgSpec, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* uint32 msgSeq = 1; */
|
||||||
|
if (message.msgSeq !== 0)
|
||||||
|
writer.tag(1, WireType.Varint).uint32(message.msgSeq);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersMsgSpec
|
||||||
|
*/
|
||||||
|
export const EmojiLikeToOthersMsgSpec = new EmojiLikeToOthersMsgSpec$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class EmojiLikeToOthersAttributes$Type extends MessageType<EmojiLikeToOthersAttributes> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.EmojiLikeToOthersAttributes", [
|
||||||
|
{ no: 1, name: "emojiId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||||
|
{ no: 4, name: "senderUid", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||||
|
{ no: 5, name: "operation", kind: "enum", T: () => ["SysMessage.EmojiLikeToOthersAttributes.Operation", EmojiLikeToOthersAttributes_Operation] }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<EmojiLikeToOthersAttributes>): EmojiLikeToOthersAttributes {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.emojiId = "";
|
||||||
|
message.senderUid = "";
|
||||||
|
message.operation = 0;
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<EmojiLikeToOthersAttributes>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersAttributes): EmojiLikeToOthersAttributes {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* string emojiId */ 1:
|
||||||
|
message.emojiId = reader.string();
|
||||||
|
break;
|
||||||
|
case /* string senderUid */ 4:
|
||||||
|
message.senderUid = reader.string();
|
||||||
|
break;
|
||||||
|
case /* SysMessage.EmojiLikeToOthersAttributes.Operation operation */ 5:
|
||||||
|
message.operation = reader.int32();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: EmojiLikeToOthersAttributes, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* string emojiId = 1; */
|
||||||
|
if (message.emojiId !== "")
|
||||||
|
writer.tag(1, WireType.LengthDelimited).string(message.emojiId);
|
||||||
|
/* string senderUid = 4; */
|
||||||
|
if (message.senderUid !== "")
|
||||||
|
writer.tag(4, WireType.LengthDelimited).string(message.senderUid);
|
||||||
|
/* SysMessage.EmojiLikeToOthersAttributes.Operation operation = 5; */
|
||||||
|
if (message.operation !== 0)
|
||||||
|
writer.tag(5, WireType.Varint).int32(message.operation);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersAttributes
|
||||||
|
*/
|
||||||
|
export const EmojiLikeToOthersAttributes = new EmojiLikeToOthersAttributes$Type();
|
9
src/core/proto/GreyTipWrapper.proto
Normal file
9
src/core/proto/GreyTipWrapper.proto
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
syntax = 'proto3';
|
||||||
|
package SysMessage;
|
||||||
|
|
||||||
|
message GreyTipWrapper {
|
||||||
|
uint32 subTypeId = 1;
|
||||||
|
uint32 groupCode = 4;
|
||||||
|
uint32 subTypeIdMinusOne = 13;
|
||||||
|
bytes rest = 44;
|
||||||
|
}
|
104
src/core/proto/GreyTipWrapper.ts
Normal file
104
src/core/proto/GreyTipWrapper.ts
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
// @generated by protobuf-ts 2.9.4
|
||||||
|
// @generated from protobuf file "GreyTipWrapper.proto" (package "SysMessage", syntax proto3)
|
||||||
|
// tslint:disable
|
||||||
|
import type {
|
||||||
|
BinaryReadOptions,
|
||||||
|
BinaryWriteOptions,
|
||||||
|
IBinaryReader,
|
||||||
|
IBinaryWriter,
|
||||||
|
PartialMessage,
|
||||||
|
} from '@protobuf-ts/runtime';
|
||||||
|
import { MessageType, reflectionMergePartial, UnknownFieldHandler, WireType } from '@protobuf-ts/runtime';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.GreyTipWrapper
|
||||||
|
*/
|
||||||
|
export interface GreyTipWrapper {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 subTypeId = 1;
|
||||||
|
*/
|
||||||
|
subTypeId: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 groupCode = 4;
|
||||||
|
*/
|
||||||
|
groupCode: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 subTypeIdMinusOne = 13;
|
||||||
|
*/
|
||||||
|
subTypeIdMinusOne: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: bytes rest = 44;
|
||||||
|
*/
|
||||||
|
rest: Uint8Array;
|
||||||
|
}
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class GreyTipWrapper$Type extends MessageType<GreyTipWrapper> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.GreyTipWrapper", [
|
||||||
|
{ no: 1, name: "subTypeId", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 4, name: "groupCode", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 13, name: "subTypeIdMinusOne", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 44, name: "rest", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<GreyTipWrapper>): GreyTipWrapper {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.subTypeId = 0;
|
||||||
|
message.groupCode = 0;
|
||||||
|
message.subTypeIdMinusOne = 0;
|
||||||
|
message.rest = new Uint8Array(0);
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<GreyTipWrapper>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GreyTipWrapper): GreyTipWrapper {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* uint32 subTypeId */ 1:
|
||||||
|
message.subTypeId = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint32 groupCode */ 4:
|
||||||
|
message.groupCode = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint32 subTypeIdMinusOne */ 13:
|
||||||
|
message.subTypeIdMinusOne = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* bytes rest */ 44:
|
||||||
|
message.rest = reader.bytes();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: GreyTipWrapper, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* uint32 subTypeId = 1; */
|
||||||
|
if (message.subTypeId !== 0)
|
||||||
|
writer.tag(1, WireType.Varint).uint32(message.subTypeId);
|
||||||
|
/* uint32 groupCode = 4; */
|
||||||
|
if (message.groupCode !== 0)
|
||||||
|
writer.tag(4, WireType.Varint).uint32(message.groupCode);
|
||||||
|
/* uint32 subTypeIdMinusOne = 13; */
|
||||||
|
if (message.subTypeIdMinusOne !== 0)
|
||||||
|
writer.tag(13, WireType.Varint).uint32(message.subTypeIdMinusOne);
|
||||||
|
/* bytes rest = 44; */
|
||||||
|
if (message.rest.length)
|
||||||
|
writer.tag(44, WireType.LengthDelimited).bytes(message.rest);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.GreyTipWrapper
|
||||||
|
*/
|
||||||
|
export const GreyTipWrapper = new GreyTipWrapper$Type();
|
36
src/core/proto/SysMessage.proto
Normal file
36
src/core/proto/SysMessage.proto
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
syntax = 'proto3';
|
||||||
|
package SysMessage;
|
||||||
|
|
||||||
|
message SysMessage {
|
||||||
|
repeated SysMessageHeader header = 1;
|
||||||
|
repeated SysMessageMsgSpec msgSpec = 2;
|
||||||
|
SysMessageBodyWrapper bodyWrapper = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SysMessageHeader {
|
||||||
|
uint32 PeerNumber = 1;
|
||||||
|
string PeerString = 2;
|
||||||
|
uint32 Uin = 5;
|
||||||
|
optional string Uid = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SysMessageMsgSpec {
|
||||||
|
uint32 msgType = 1;
|
||||||
|
uint32 subType = 2;
|
||||||
|
uint32 subSubType = 3;
|
||||||
|
uint32 msgSeq = 5;
|
||||||
|
uint32 time = 6;
|
||||||
|
uint64 msgId = 12;
|
||||||
|
uint32 other = 13;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SysMessageBodyWrapper {
|
||||||
|
bytes wrappedBody = 2;
|
||||||
|
// Find the first [08], or ignore the first 7 bytes?
|
||||||
|
// And it becomes another ProtoBuf message.
|
||||||
|
}
|
||||||
|
|
||||||
|
message KeyValuePair {
|
||||||
|
string key = 1;
|
||||||
|
string value = 2;
|
||||||
|
}
|
435
src/core/proto/SysMessage.ts
Normal file
435
src/core/proto/SysMessage.ts
Normal file
@@ -0,0 +1,435 @@
|
|||||||
|
// @generated by protobuf-ts 2.9.4
|
||||||
|
// @generated from protobuf file "SysMessage.proto" (package "SysMessage", syntax proto3)
|
||||||
|
// tslint:disable
|
||||||
|
import type {
|
||||||
|
BinaryReadOptions,
|
||||||
|
BinaryWriteOptions,
|
||||||
|
IBinaryReader,
|
||||||
|
IBinaryWriter,
|
||||||
|
PartialMessage,
|
||||||
|
} from '@protobuf-ts/runtime';
|
||||||
|
import { MessageType, reflectionMergePartial, UnknownFieldHandler, WireType } from '@protobuf-ts/runtime';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.SysMessage
|
||||||
|
*/
|
||||||
|
export interface SysMessage {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: repeated SysMessage.SysMessageHeader header = 1;
|
||||||
|
*/
|
||||||
|
header: SysMessageHeader[];
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: repeated SysMessage.SysMessageMsgSpec msgSpec = 2;
|
||||||
|
*/
|
||||||
|
msgSpec: SysMessageMsgSpec[];
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: SysMessage.SysMessageBodyWrapper bodyWrapper = 3;
|
||||||
|
*/
|
||||||
|
bodyWrapper?: SysMessageBodyWrapper;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.SysMessageHeader
|
||||||
|
*/
|
||||||
|
export interface SysMessageHeader {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 PeerNumber = 1 [json_name = "PeerNumber"];
|
||||||
|
*/
|
||||||
|
peerNumber: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: string PeerString = 2 [json_name = "PeerString"];
|
||||||
|
*/
|
||||||
|
peerString: string;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 Uin = 5 [json_name = "Uin"];
|
||||||
|
*/
|
||||||
|
uin: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: optional string Uid = 6 [json_name = "Uid"];
|
||||||
|
*/
|
||||||
|
uid?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.SysMessageMsgSpec
|
||||||
|
*/
|
||||||
|
export interface SysMessageMsgSpec {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 msgType = 1;
|
||||||
|
*/
|
||||||
|
msgType: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 subType = 2;
|
||||||
|
*/
|
||||||
|
subType: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 subSubType = 3;
|
||||||
|
*/
|
||||||
|
subSubType: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 msgSeq = 5;
|
||||||
|
*/
|
||||||
|
msgSeq: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 time = 6;
|
||||||
|
*/
|
||||||
|
time: number;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint64 msgId = 12;
|
||||||
|
*/
|
||||||
|
msgId: bigint;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: uint32 other = 13;
|
||||||
|
*/
|
||||||
|
other: number;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.SysMessageBodyWrapper
|
||||||
|
*/
|
||||||
|
export interface SysMessageBodyWrapper {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: bytes wrappedBody = 2;
|
||||||
|
*/
|
||||||
|
wrappedBody: Uint8Array; // Find the first [08], or ignore the first 7 bytes?
|
||||||
|
// And it becomes another ProtoBuf message.
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated from protobuf message SysMessage.KeyValuePair
|
||||||
|
*/
|
||||||
|
export interface KeyValuePair {
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: string key = 1;
|
||||||
|
*/
|
||||||
|
key: string;
|
||||||
|
/**
|
||||||
|
* @generated from protobuf field: string value = 2;
|
||||||
|
*/
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class SysMessage$Type extends MessageType<SysMessage> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.SysMessage", [
|
||||||
|
{ no: 1, name: "header", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => SysMessageHeader },
|
||||||
|
{ no: 2, name: "msgSpec", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => SysMessageMsgSpec },
|
||||||
|
{ no: 3, name: "bodyWrapper", kind: "message", T: () => SysMessageBodyWrapper }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<SysMessage>): SysMessage {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.header = [];
|
||||||
|
message.msgSpec = [];
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<SysMessage>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessage): SysMessage {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* repeated SysMessage.SysMessageHeader header */ 1:
|
||||||
|
message.header.push(SysMessageHeader.internalBinaryRead(reader, reader.uint32(), options));
|
||||||
|
break;
|
||||||
|
case /* repeated SysMessage.SysMessageMsgSpec msgSpec */ 2:
|
||||||
|
message.msgSpec.push(SysMessageMsgSpec.internalBinaryRead(reader, reader.uint32(), options));
|
||||||
|
break;
|
||||||
|
case /* SysMessage.SysMessageBodyWrapper bodyWrapper */ 3:
|
||||||
|
message.bodyWrapper = SysMessageBodyWrapper.internalBinaryRead(reader, reader.uint32(), options, message.bodyWrapper);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: SysMessage, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* repeated SysMessage.SysMessageHeader header = 1; */
|
||||||
|
for (let i = 0; i < message.header.length; i++)
|
||||||
|
SysMessageHeader.internalBinaryWrite(message.header[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
/* repeated SysMessage.SysMessageMsgSpec msgSpec = 2; */
|
||||||
|
for (let i = 0; i < message.msgSpec.length; i++)
|
||||||
|
SysMessageMsgSpec.internalBinaryWrite(message.msgSpec[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
/* SysMessage.SysMessageBodyWrapper bodyWrapper = 3; */
|
||||||
|
if (message.bodyWrapper)
|
||||||
|
SysMessageBodyWrapper.internalBinaryWrite(message.bodyWrapper, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.SysMessage
|
||||||
|
*/
|
||||||
|
export const SysMessage = new SysMessage$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class SysMessageHeader$Type extends MessageType<SysMessageHeader> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.SysMessageHeader", [
|
||||||
|
{ no: 1, name: "PeerNumber", kind: "scalar", jsonName: "PeerNumber", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 2, name: "PeerString", kind: "scalar", jsonName: "PeerString", T: 9 /*ScalarType.STRING*/ },
|
||||||
|
{ no: 5, name: "Uin", kind: "scalar", jsonName: "Uin", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 6, name: "Uid", kind: "scalar", jsonName: "Uid", opt: true, T: 9 /*ScalarType.STRING*/ }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<SysMessageHeader>): SysMessageHeader {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.peerNumber = 0;
|
||||||
|
message.peerString = "";
|
||||||
|
message.uin = 0;
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<SysMessageHeader>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessageHeader): SysMessageHeader {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* uint32 PeerNumber = 1 [json_name = "PeerNumber"];*/ 1:
|
||||||
|
message.peerNumber = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* string PeerString = 2 [json_name = "PeerString"];*/ 2:
|
||||||
|
message.peerString = reader.string();
|
||||||
|
break;
|
||||||
|
case /* uint32 Uin = 5 [json_name = "Uin"];*/ 5:
|
||||||
|
message.uin = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* optional string Uid = 6 [json_name = "Uid"];*/ 6:
|
||||||
|
message.uid = reader.string();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: SysMessageHeader, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* uint32 PeerNumber = 1 [json_name = "PeerNumber"]; */
|
||||||
|
if (message.peerNumber !== 0)
|
||||||
|
writer.tag(1, WireType.Varint).uint32(message.peerNumber);
|
||||||
|
/* string PeerString = 2 [json_name = "PeerString"]; */
|
||||||
|
if (message.peerString !== "")
|
||||||
|
writer.tag(2, WireType.LengthDelimited).string(message.peerString);
|
||||||
|
/* uint32 Uin = 5 [json_name = "Uin"]; */
|
||||||
|
if (message.uin !== 0)
|
||||||
|
writer.tag(5, WireType.Varint).uint32(message.uin);
|
||||||
|
/* optional string Uid = 6 [json_name = "Uid"]; */
|
||||||
|
if (message.uid !== undefined)
|
||||||
|
writer.tag(6, WireType.LengthDelimited).string(message.uid);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.SysMessageHeader
|
||||||
|
*/
|
||||||
|
export const SysMessageHeader = new SysMessageHeader$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class SysMessageMsgSpec$Type extends MessageType<SysMessageMsgSpec> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.SysMessageMsgSpec", [
|
||||||
|
{ no: 1, name: "msgType", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 2, name: "subType", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 3, name: "subSubType", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 5, name: "msgSeq", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 6, name: "time", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||||
|
{ no: 12, name: "msgId", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
|
||||||
|
{ no: 13, name: "other", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<SysMessageMsgSpec>): SysMessageMsgSpec {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.msgType = 0;
|
||||||
|
message.subType = 0;
|
||||||
|
message.subSubType = 0;
|
||||||
|
message.msgSeq = 0;
|
||||||
|
message.time = 0;
|
||||||
|
message.msgId = 0n;
|
||||||
|
message.other = 0;
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<SysMessageMsgSpec>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessageMsgSpec): SysMessageMsgSpec {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* uint32 msgType */ 1:
|
||||||
|
message.msgType = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint32 subType */ 2:
|
||||||
|
message.subType = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint32 subSubType */ 3:
|
||||||
|
message.subSubType = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint32 msgSeq */ 5:
|
||||||
|
message.msgSeq = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint32 time */ 6:
|
||||||
|
message.time = reader.uint32();
|
||||||
|
break;
|
||||||
|
case /* uint64 msgId */ 12:
|
||||||
|
message.msgId = reader.uint64().toBigInt();
|
||||||
|
break;
|
||||||
|
case /* uint32 other */ 13:
|
||||||
|
message.other = reader.uint32();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: SysMessageMsgSpec, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* uint32 msgType = 1; */
|
||||||
|
if (message.msgType !== 0)
|
||||||
|
writer.tag(1, WireType.Varint).uint32(message.msgType);
|
||||||
|
/* uint32 subType = 2; */
|
||||||
|
if (message.subType !== 0)
|
||||||
|
writer.tag(2, WireType.Varint).uint32(message.subType);
|
||||||
|
/* uint32 subSubType = 3; */
|
||||||
|
if (message.subSubType !== 0)
|
||||||
|
writer.tag(3, WireType.Varint).uint32(message.subSubType);
|
||||||
|
/* uint32 msgSeq = 5; */
|
||||||
|
if (message.msgSeq !== 0)
|
||||||
|
writer.tag(5, WireType.Varint).uint32(message.msgSeq);
|
||||||
|
/* uint32 time = 6; */
|
||||||
|
if (message.time !== 0)
|
||||||
|
writer.tag(6, WireType.Varint).uint32(message.time);
|
||||||
|
/* uint64 msgId = 12; */
|
||||||
|
if (message.msgId !== 0n)
|
||||||
|
writer.tag(12, WireType.Varint).uint64(message.msgId);
|
||||||
|
/* uint32 other = 13; */
|
||||||
|
if (message.other !== 0)
|
||||||
|
writer.tag(13, WireType.Varint).uint32(message.other);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.SysMessageMsgSpec
|
||||||
|
*/
|
||||||
|
export const SysMessageMsgSpec = new SysMessageMsgSpec$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class SysMessageBodyWrapper$Type extends MessageType<SysMessageBodyWrapper> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.SysMessageBodyWrapper", [
|
||||||
|
{ no: 2, name: "wrappedBody", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<SysMessageBodyWrapper>): SysMessageBodyWrapper {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.wrappedBody = new Uint8Array(0);
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<SysMessageBodyWrapper>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessageBodyWrapper): SysMessageBodyWrapper {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* bytes wrappedBody */ 2:
|
||||||
|
message.wrappedBody = reader.bytes();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: SysMessageBodyWrapper, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* bytes wrappedBody = 2; */
|
||||||
|
if (message.wrappedBody.length)
|
||||||
|
writer.tag(2, WireType.LengthDelimited).bytes(message.wrappedBody);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.SysMessageBodyWrapper
|
||||||
|
*/
|
||||||
|
export const SysMessageBodyWrapper = new SysMessageBodyWrapper$Type();
|
||||||
|
// @generated message type with reflection information, may provide speed optimized methods
|
||||||
|
class KeyValuePair$Type extends MessageType<KeyValuePair> {
|
||||||
|
constructor() {
|
||||||
|
super("SysMessage.KeyValuePair", [
|
||||||
|
{ no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||||
|
{ no: 2, name: "value", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
create(value?: PartialMessage<KeyValuePair>): KeyValuePair {
|
||||||
|
const message = globalThis.Object.create((this.messagePrototype!));
|
||||||
|
message.key = "";
|
||||||
|
message.value = "";
|
||||||
|
if (value !== undefined)
|
||||||
|
reflectionMergePartial<KeyValuePair>(this, message, value);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: KeyValuePair): KeyValuePair {
|
||||||
|
let message = target ?? this.create(), end = reader.pos + length;
|
||||||
|
while (reader.pos < end) {
|
||||||
|
let [fieldNo, wireType] = reader.tag();
|
||||||
|
switch (fieldNo) {
|
||||||
|
case /* string key */ 1:
|
||||||
|
message.key = reader.string();
|
||||||
|
break;
|
||||||
|
case /* string value */ 2:
|
||||||
|
message.value = reader.string();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
let u = options.readUnknownField;
|
||||||
|
if (u === "throw")
|
||||||
|
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||||
|
let d = reader.skip(wireType);
|
||||||
|
if (u !== false)
|
||||||
|
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
internalBinaryWrite(message: KeyValuePair, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||||
|
/* string key = 1; */
|
||||||
|
if (message.key !== "")
|
||||||
|
writer.tag(1, WireType.LengthDelimited).string(message.key);
|
||||||
|
/* string value = 2; */
|
||||||
|
if (message.value !== "")
|
||||||
|
writer.tag(2, WireType.LengthDelimited).string(message.value);
|
||||||
|
let u = options.writeUnknownFields;
|
||||||
|
if (u !== false)
|
||||||
|
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @generated MessageType for protobuf message SysMessage.KeyValuePair
|
||||||
|
*/
|
||||||
|
export const KeyValuePair = new KeyValuePair$Type();
|
@@ -1,5 +1,7 @@
|
|||||||
|
import { NodeIKernelFileAssistantListener } from '@/core';
|
||||||
|
|
||||||
export interface NodeIKernelFileAssistantService {
|
export interface NodeIKernelFileAssistantService {
|
||||||
addKernelFileAssistantListener(arg1: unknown[]): unknown;
|
addKernelFileAssistantListener(listener: NodeIKernelFileAssistantListener): unknown;
|
||||||
|
|
||||||
removeKernelFileAssistantListener(arg1: unknown[]): unknown;
|
removeKernelFileAssistantListener(arg1: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -9,7 +11,7 @@ export interface NodeIKernelFileAssistantService {
|
|||||||
|
|
||||||
getFileSessionList(): unknown;
|
getFileSessionList(): unknown;
|
||||||
|
|
||||||
searchFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
searchFile(keywords: string[], params: { resultType: number, pageLimit: number }, resultId: number): number;
|
||||||
|
|
||||||
resetSearchFileSortType(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
resetSearchFileSortType(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||||
|
|
||||||
@@ -17,7 +19,7 @@ export interface NodeIKernelFileAssistantService {
|
|||||||
|
|
||||||
cancelSearchFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
cancelSearchFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||||
|
|
||||||
downloadFile(arg1: unknown[]): unknown;
|
downloadFile(fileIds: string[]): { result: number, errMsg: string };
|
||||||
|
|
||||||
forwardFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
forwardFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@ import { NodeIKernelGroupListener } from '@/core/listeners/NodeIKernelGroupListe
|
|||||||
import {
|
import {
|
||||||
GroupExt0xEF0InfoFilter,
|
GroupExt0xEF0InfoFilter,
|
||||||
GroupExtParam,
|
GroupExtParam,
|
||||||
|
GroupInfoSource,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
GroupMemberRole,
|
GroupMemberRole,
|
||||||
GroupNotifyMsgType,
|
GroupNotifyMsgType,
|
||||||
@@ -13,9 +14,9 @@ import { GeneralCallResult } from '@/core/services/common';
|
|||||||
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
||||||
|
|
||||||
export interface NodeIKernelGroupService {
|
export interface NodeIKernelGroupService {
|
||||||
//getGroupExt0xEF0Info(this.$enableGroupCodes, this.$bannedGroupCodes, this.$filter, this.$forceFetch
|
|
||||||
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> } }>;
|
||||||
|
|
||||||
kickMemberV2(param: KickMemberV2Req): Promise<GeneralCallResult>;
|
kickMemberV2(param: KickMemberV2Req): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
quitGroupV2(param: { groupCode: string; needDeleteLocalMsg: boolean; }): Promise<GeneralCallResult>;
|
quitGroupV2(param: { groupCode: string; needDeleteLocalMsg: boolean; }): Promise<GeneralCallResult>;
|
||||||
@@ -39,11 +40,11 @@ export interface NodeIKernelGroupService {
|
|||||||
realSpecialTitleFlag: number
|
realSpecialTitleFlag: number
|
||||||
}): Promise<unknown>;
|
}): Promise<unknown>;
|
||||||
|
|
||||||
//26702
|
|
||||||
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>;
|
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>;
|
||||||
|
|
||||||
//26702
|
getGroupInfoForJoinGroup(groupCode: string, needPrivilegeFlag: boolean, serviceType: number): Promise<unknown>;
|
||||||
getGroupHonorList(groupCodes: Array<string>): unknown;
|
|
||||||
|
getGroupHonorList(req: { groupCodes: Array<string> }): Promise<unknown>;
|
||||||
|
|
||||||
getUinByUids(uins: string[]): Promise<{
|
getUinByUids(uins: string[]): Promise<{
|
||||||
errCode: number,
|
errCode: number,
|
||||||
@@ -57,13 +58,10 @@ export interface NodeIKernelGroupService {
|
|||||||
uids: Map<string, string>
|
uids: Map<string, string>
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
|
||||||
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>;
|
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>;
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
|
||||||
getGroupLatestEssenceList(groupCode: string): Promise<unknown>;
|
getGroupLatestEssenceList(groupCode: string): Promise<unknown>;
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
|
||||||
shareDigest(Req: {
|
shareDigest(Req: {
|
||||||
appId: string,
|
appId: string,
|
||||||
appType: number,
|
appType: number,
|
||||||
@@ -83,20 +81,17 @@ export interface NodeIKernelGroupService {
|
|||||||
}
|
}
|
||||||
}): Promise<unknown>;
|
}): Promise<unknown>;
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
|
||||||
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
|
||||||
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
||||||
|
|
||||||
//26702(其实更早 但是我不知道)
|
|
||||||
fetchGroupEssenceList(Req: {
|
fetchGroupEssenceList(Req: {
|
||||||
groupCode: string,
|
groupCode: string,
|
||||||
pageStart: number,
|
pageStart: number,
|
||||||
pageLimit: number
|
pageLimit: number
|
||||||
}, Arg: unknown): Promise<unknown>;
|
}, Arg: unknown): Promise<unknown>;
|
||||||
|
|
||||||
//26702
|
|
||||||
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
||||||
errCode: number,
|
errCode: number,
|
||||||
errMsg: string,
|
errMsg: string,
|
||||||
@@ -135,8 +130,6 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
getMemberInfo(group_id: string, uids: string[], forceFetch: boolean): Promise<GeneralCallResult>;
|
getMemberInfo(group_id: string, uids: string[], forceFetch: boolean): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
//getMemberInfo [ '56729xxxx', [ 'u_4Nj08cwW5Hxxxxx' ], true ]
|
|
||||||
|
|
||||||
kickMember(groupCode: string, memberUids: string[], refuseForever: boolean, kickReason: string): Promise<void>;
|
kickMember(groupCode: string, memberUids: string[], refuseForever: boolean, kickReason: string): Promise<void>;
|
||||||
|
|
||||||
modifyMemberRole(groupCode: string, uid: string, role: GroupMemberRole): void;
|
modifyMemberRole(groupCode: string, uid: string, role: GroupMemberRole): void;
|
||||||
@@ -151,7 +144,7 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
getGroupExtList(force: boolean): Promise<GeneralCallResult>;
|
getGroupExtList(force: boolean): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
getGroupDetailInfo(groupCode: string): unknown;
|
getGroupDetailInfo(groupCode: string, groupInfoSource: GroupInfoSource): Promise<unknown>;
|
||||||
|
|
||||||
getMemberExtInfo(param: GroupExtParam): Promise<unknown>;//req
|
getMemberExtInfo(param: GroupExtParam): Promise<unknown>;//req
|
||||||
|
|
||||||
@@ -189,14 +182,13 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
destroyGroup(groupCode: string): void;
|
destroyGroup(groupCode: string): void;
|
||||||
|
|
||||||
//获取单屏群通知列表
|
getSingleScreenNotifies(doubted: boolean, start_seq: string, num: number): Promise<GeneralCallResult>;
|
||||||
getSingleScreenNotifies(force: boolean, start_seq: string, num: number): Promise<GeneralCallResult>;
|
|
||||||
|
|
||||||
clearGroupNotifies(groupCode: string): void;
|
clearGroupNotifies(groupCode: string): void;
|
||||||
|
|
||||||
getGroupNotifiesUnreadCount(unknown: boolean): Promise<GeneralCallResult>;
|
getGroupNotifiesUnreadCount(unknown: boolean): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
clearGroupNotifiesUnreadCount(groupCode: string): void;
|
clearGroupNotifiesUnreadCount(unknown: boolean): void;
|
||||||
|
|
||||||
operateSysNotify(
|
operateSysNotify(
|
||||||
doubt: boolean,
|
doubt: boolean,
|
||||||
|
@@ -167,11 +167,17 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getAllOnlineFileMsgs(...args: unknown[]): unknown;
|
getAllOnlineFileMsgs(...args: unknown[]): unknown;
|
||||||
|
|
||||||
getLatestDbMsgs(peer: Peer, cnt: number): Promise<unknown>;
|
getLatestDbMsgs(peer: Peer, cnt: number): Promise<GeneralCallResult & {
|
||||||
|
msgList: RawMessage[]
|
||||||
|
}>;
|
||||||
|
|
||||||
getLastMessageList(peer: Peer[]): Promise<unknown>;
|
getLastMessageList(peer: Peer[]): Promise<GeneralCallResult & {
|
||||||
|
msgList: RawMessage[]
|
||||||
|
}>;
|
||||||
|
|
||||||
getAioFirstViewLatestMsgs(peer: Peer, num: number): unknown;
|
getAioFirstViewLatestMsgs(peer: Peer, num: number): Promise<GeneralCallResult & {
|
||||||
|
msgList: RawMessage[]
|
||||||
|
}>;
|
||||||
|
|
||||||
getMsgs(peer: Peer, msgId: string, count: unknown, queryOrder: boolean): Promise<unknown>;
|
getMsgs(peer: Peer, msgId: string, count: unknown, queryOrder: boolean): Promise<unknown>;
|
||||||
|
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import { AnyCnameRecord } from 'node:dns';
|
import { AnyCnameRecord } from 'node:dns';
|
||||||
import { BizKey, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '@/core';
|
import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, SimpleInfo, UserDetailInfoByUinV2 } from '@/core';
|
||||||
import { NodeIKernelProfileListener } from '@/core';
|
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
export enum UserDetailSource {
|
export enum UserDetailSource {
|
||||||
|
@@ -155,7 +155,7 @@ export interface NodeIKernelRichMediaService {
|
|||||||
}): unknown;
|
}): unknown;
|
||||||
|
|
||||||
//arg3为“”
|
//arg3为“”
|
||||||
downloadFileForModelId(peer: Peer, ModelId: string[], arg3: string): unknown;
|
downloadFileForModelId(peer: Peer, ModelId: string[], unknown: string): Promise<unknown>;
|
||||||
|
|
||||||
//第三个参数 Array<Type>
|
//第三个参数 Array<Type>
|
||||||
// this.fileId = "";
|
// this.fileId = "";
|
||||||
|
@@ -20,6 +20,7 @@ export * from './NodeIKernelCollectionService';
|
|||||||
import type {
|
import type {
|
||||||
NodeIKernelAvatarService,
|
NodeIKernelAvatarService,
|
||||||
NodeIKernelBuddyService,
|
NodeIKernelBuddyService,
|
||||||
|
NodeIKernelCollectionService,
|
||||||
NodeIKernelDbToolsService,
|
NodeIKernelDbToolsService,
|
||||||
NodeIKernelFileAssistantService,
|
NodeIKernelFileAssistantService,
|
||||||
NodeIKernelGroupService,
|
NodeIKernelGroupService,
|
||||||
@@ -30,11 +31,10 @@ import type {
|
|||||||
NodeIKernelProfileService,
|
NodeIKernelProfileService,
|
||||||
NodeIKernelRichMediaService,
|
NodeIKernelRichMediaService,
|
||||||
NodeIKernelRobotService,
|
NodeIKernelRobotService,
|
||||||
|
NodeIKernelSearchService,
|
||||||
NodeIKernelStorageCleanService,
|
NodeIKernelStorageCleanService,
|
||||||
NodeIKernelTicketService,
|
NodeIKernelTicketService,
|
||||||
NodeIKernelTipOffService,
|
NodeIKernelTipOffService,
|
||||||
NodeIKernelSearchService,
|
|
||||||
NodeIKernelCollectionService,
|
|
||||||
} from '.';
|
} from '.';
|
||||||
|
|
||||||
export type ServiceNamingMapping = {
|
export type ServiceNamingMapping = {
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { NodeIDependsAdapter, NodeIDispatcherAdapter, NodeIGlobalAdapter } from '../adapters';
|
import { NodeIDependsAdapter, NodeIDispatcherAdapter, NodeIGlobalAdapter } from './adapters';
|
||||||
import { NodeIKernelSessionListener } from '@/core';
|
|
||||||
import {
|
import {
|
||||||
NodeIKernelAvatarService,
|
NodeIKernelAvatarService,
|
||||||
NodeIKernelBuddyService,
|
NodeIKernelBuddyService,
|
||||||
@@ -9,23 +8,24 @@ import {
|
|||||||
NodeIKernelProfileLikeService,
|
NodeIKernelProfileLikeService,
|
||||||
NodeIKernelProfileService,
|
NodeIKernelProfileService,
|
||||||
NodeIKernelRichMediaService,
|
NodeIKernelRichMediaService,
|
||||||
|
NodeIKernelRobotService,
|
||||||
|
NodeIKernelSessionListener,
|
||||||
|
NodeIKernelStorageCleanService,
|
||||||
NodeIKernelTicketService,
|
NodeIKernelTicketService,
|
||||||
NodeIKernelTipOffService,
|
NodeIKernelTipOffService,
|
||||||
} from '@/core';
|
} from '@/core/index';
|
||||||
import { NodeIKernelStorageCleanService } from '@/core';
|
import { NodeIKernelNodeMiscService } from './services/NodeIKernelNodeMiscService';
|
||||||
import { NodeIKernelRobotService } from '@/core';
|
import { NodeIKernelUixConvertService } from './services/NodeIKernelUixConvertService';
|
||||||
import { NodeIKernelNodeMiscService } from '../services/NodeIKernelNodeMiscService';
|
import { NodeIKernelMsgBackupService } from './services/NodeIKernelMsgBackupService';
|
||||||
import { NodeIKernelUixConvertService } from '../services/NodeIKernelUixConvertService';
|
import { NodeIKernelAlbumService } from './services/NodeIKernelAlbumService';
|
||||||
import { NodeIKernelMsgBackupService } from '../services/NodeIKernelMsgBackupService';
|
import { NodeIKernelTianShuService } from './services/NodeIKernelTianShuService';
|
||||||
import { NodeIKernelAlbumService } from '../services/NodeIKernelAlbumService';
|
import { NodeIKernelUnitedConfigService } from './services/NodeIKernelUnitedConfigService';
|
||||||
import { NodeIKernelTianShuService } from '../services/NodeIKernelTianShuService';
|
import { NodeIKernelSearchService } from './services/NodeIKernelSearchService';
|
||||||
import { NodeIKernelUnitedConfigService } from '../services/NodeIKernelUnitedConfigService';
|
import { NodeIKernelCollectionService } from './services/NodeIKernelCollectionService';
|
||||||
import { NodeIKernelSearchService } from '../services/NodeIKernelSearchService';
|
import { NodeIKernelRecentContactService } from './services/NodeIKernelRecentContactService';
|
||||||
import { NodeIKernelCollectionService } from '../services/NodeIKernelCollectionService';
|
import { NodeIKernelMSFService } from './services/NodeIKernelMSFService';
|
||||||
import { NodeIKernelRecentContactService } from '../services/NodeIKernelRecentContactService';
|
import { NodeIkernelTestPerformanceService } from './services/NodeIkernelTestPerformanceService';
|
||||||
import { NodeIKernelMSFService } from '../services/NodeIKernelMSFService';
|
import { NodeIKernelECDHService } from './services/NodeIKernelECDHService';
|
||||||
import { NodeIkernelTestPerformanceService } from '../services/NodeIkernelTestPerformanceService';
|
|
||||||
import { NodeIKernelECDHService } from '../services/NodeIKernelECDHService';
|
|
||||||
|
|
||||||
export interface NodeQQNTWrapperUtil {
|
export interface NodeQQNTWrapperUtil {
|
||||||
get(): unknown;
|
get(): unknown;
|
@@ -1,27 +0,0 @@
|
|||||||
import { LogWrapper } from '@/common/utils/log';
|
|
||||||
import { QQBasicInfoWrapper } from '@/common/utils/qq-basic-info';
|
|
||||||
import { NapCatCoreWorkingEnv, NodeIKernelLoginService, NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core';
|
|
||||||
import { NTQQFileApi, NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from '../apis';
|
|
||||||
import { NTQQCollectionApi } from '../apis/collection';
|
|
||||||
import { NapCatPathWrapper } from '@/common/framework/napcat';
|
|
||||||
|
|
||||||
export interface InstanceContext {
|
|
||||||
readonly workingEnv: NapCatCoreWorkingEnv;
|
|
||||||
readonly wrapper: WrapperNodeApi;
|
|
||||||
readonly session: NodeIQQNTWrapperSession;
|
|
||||||
readonly logger: LogWrapper;
|
|
||||||
readonly loginService: NodeIKernelLoginService;
|
|
||||||
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
|
||||||
readonly pathWrapper: NapCatPathWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StableNTApiWrapper {
|
|
||||||
FileApi: NTQQFileApi,
|
|
||||||
SystemApi: NTQQSystemApi,
|
|
||||||
CollectionApi: NTQQCollectionApi,
|
|
||||||
WebApi: NTQQWebApi,
|
|
||||||
FriendApi: NTQQFriendApi,
|
|
||||||
MsgApi: NTQQMsgApi,
|
|
||||||
UserApi: NTQQUserApi,
|
|
||||||
GroupApi: NTQQGroupApi
|
|
||||||
}
|
|
@@ -1,55 +0,0 @@
|
|||||||
import path from 'node:path';
|
|
||||||
import fs from 'node:fs';
|
|
||||||
import { PlatformType, VendorType, WrapperSessionInitConfig } from './wrapper';
|
|
||||||
import { getMachineId, hostname, systemName, systemVersion } from '@/common/utils/system';
|
|
||||||
|
|
||||||
export async function genSessionConfig(QQVersionAppid: string, QQVersion: string, selfUin: string, selfUid: string, account_path: string): Promise<WrapperSessionInitConfig> {
|
|
||||||
const downloadPath = path.join(account_path, 'NapCat', 'temp');
|
|
||||||
fs.mkdirSync(downloadPath, { recursive: true });
|
|
||||||
const guid: string = await getMachineId();//26702 支持JS获取guid值 在LoginService中获取 TODO mlikiow a
|
|
||||||
const config: WrapperSessionInitConfig = {
|
|
||||||
selfUin,
|
|
||||||
selfUid,
|
|
||||||
desktopPathConfig: {
|
|
||||||
account_path, // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
|
||||||
},
|
|
||||||
clientVer: QQVersion, // 9.9.8-22355
|
|
||||||
a2: '',
|
|
||||||
d2: '',
|
|
||||||
d2Key: '',
|
|
||||||
machineId: '',
|
|
||||||
platform: PlatformType.KWINDOWS, // 3是Windows?
|
|
||||||
platVer: systemVersion, // 系统版本号, 应该可以固定
|
|
||||||
appid: QQVersionAppid,
|
|
||||||
rdeliveryConfig: {
|
|
||||||
appKey: '',
|
|
||||||
systemId: 0,
|
|
||||||
appId: '',
|
|
||||||
logicEnvironment: '',
|
|
||||||
platform: PlatformType.KWINDOWS,
|
|
||||||
language: '',
|
|
||||||
sdkVersion: '',
|
|
||||||
userId: '',
|
|
||||||
appVersion: '',
|
|
||||||
osVersion: '',
|
|
||||||
bundleId: '',
|
|
||||||
serverUrl: '',
|
|
||||||
fixedAfterHitKeys: [''],
|
|
||||||
},
|
|
||||||
defaultFileDownloadPath: downloadPath,
|
|
||||||
deviceInfo: {
|
|
||||||
guid,
|
|
||||||
buildVer: QQVersion,
|
|
||||||
localId: 2052,
|
|
||||||
devName: hostname,
|
|
||||||
devType: systemName,
|
|
||||||
vendorName: '',
|
|
||||||
osVer: systemVersion,
|
|
||||||
vendorOsName: systemName,
|
|
||||||
setMute: false,
|
|
||||||
vendorType: VendorType.KNOSETONIOS,
|
|
||||||
},
|
|
||||||
deviceConfig: '{"appearance":{"isSplitViewMode":true},"msg":{}}',
|
|
||||||
};
|
|
||||||
return config;
|
|
||||||
}
|
|
@@ -1,3 +0,0 @@
|
|||||||
export * from './wrapper';
|
|
||||||
export * from './helper';
|
|
||||||
export * from './context';
|
|
@@ -1,13 +1,12 @@
|
|||||||
import { NapCatPathWrapper } from '@/common/framework/napcat';
|
import { NapCatPathWrapper } from '@/common/path';
|
||||||
import { LogWrapper } from '@/common/utils/log';
|
import { LogWrapper } from '@/common/log';
|
||||||
import { proxiedListenerOf } from '@/common/utils/proxy-handler';
|
import { proxiedListenerOf } from '@/common/proxy-handler';
|
||||||
import { QQBasicInfoWrapper } from '@/common/utils/qq-basic-info';
|
import { QQBasicInfoWrapper } from '@/common/qq-basic-info';
|
||||||
import { loadQQWrapper, NapCatCore, NapCatCoreWorkingEnv } from '@/core/core';
|
import { InstanceContext, loadQQWrapper, NapCatCore, NapCatCoreWorkingEnv } from '@/core';
|
||||||
import { InstanceContext } from '@/core';
|
|
||||||
import { SelfInfo } from '@/core/entities';
|
import { SelfInfo } from '@/core/entities';
|
||||||
import { NodeIKernelLoginListener } from '@/core/listeners';
|
import { NodeIKernelLoginListener } from '@/core/listeners';
|
||||||
import { NodeIKernelLoginService } from '@/core/services';
|
import { NodeIKernelLoginService } from '@/core/services';
|
||||||
import { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper/wrapper';
|
import { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper';
|
||||||
import { InitWebUi, WebUiConfig } from '@/webui';
|
import { InitWebUi, WebUiConfig } from '@/webui';
|
||||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||||
|
|
||||||
|
@@ -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/utils/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> {
|
||||||
|
@@ -2,7 +2,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';
|
||||||
import { MessageUnique } from '@/common/utils/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -24,10 +24,9 @@ export class FetchEmojiLike extends BaseAction<Payload, any> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
|
||||||
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
const msgIdPeer = MessageUnique.getMsgIdAndPeerByShortId(parseInt(payload.message_id.toString()));
|
||||||
if (!msgIdPeer) throw new Error('消息不存在');
|
if (!msgIdPeer) throw new Error('消息不存在');
|
||||||
const msg = (await NTQQMsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
const msg = (await this.core.apis.MsgApi.getMsgsByMsgId(msgIdPeer.Peer, [msgIdPeer.MsgId])).msgList[0];
|
||||||
return await NTQQMsgApi.getMsgEmojiLikesList(msgIdPeer.Peer, msg.msgSeq, payload.emojiId, payload.emojiType, +(payload.count ?? 20));
|
return await this.core.apis.MsgApi.getMsgEmojiLikesList(msgIdPeer.Peer, msg.msgSeq, payload.emojiId, payload.emojiType, +(payload.count ?? 20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,6 @@ export class GetCollectionList extends BaseAction<Payload, any> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQCollectionApi = this.core.apis.CollectionApi;
|
return await this.core.apis.CollectionApi.getAllCollection(parseInt(payload.category.toString()), +(payload.count ?? 1));
|
||||||
return await NTQQCollectionApi.getAllCollection(parseInt(payload.category.toString()), +(payload.count ?? 1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { OB11Entities } from '@/onebot/helper/entities';
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
|
|
||||||
|
@@ -1,24 +1,22 @@
|
|||||||
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 { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: ['string', 'number'] },
|
group_id: { type: ['number', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['group_id'],
|
required: ['group_id'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class GetGroupFileCount extends BaseAction<Payload, { count: number }> {
|
export class GetGroupInfoEx extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.GetGroupFileCount;
|
actionName = ActionName.GetGroupInfoEx;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
return (await this.core.apis.GroupApi.getGroupExtFE0Info([payload.group_id.toString()])).result.groupExtInfos.get(payload.group_id.toString());
|
||||||
const ret = await NTQQGroupApi.GetGroupFileCount([payload.group_id?.toString()]);
|
|
||||||
return { count: ret.groupFileCounts[0] };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -5,11 +5,10 @@ export class GetProfileLike extends BaseAction<void, any> {
|
|||||||
actionName = ActionName.GetProfileLike;
|
actionName = ActionName.GetProfileLike;
|
||||||
|
|
||||||
async _handle(payload: void) {
|
async _handle(payload: void) {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
const ret = await this.core.apis.UserApi.getProfileLike(this.core.selfInfo.uid);
|
||||||
const ret = await NTQQUserApi.getProfileLike(this.core.selfInfo.uid);
|
|
||||||
const listdata: any[] = ret.info.userLikeInfos[0].favoriteInfo.userInfos;
|
const listdata: any[] = ret.info.userLikeInfos[0].favoriteInfo.userInfos;
|
||||||
for (let i = 0; i < listdata.length; i++) {
|
for (let i = 0; i < listdata.length; i++) {
|
||||||
listdata[i].uin = parseInt((await NTQQUserApi.getUinByUidV2(listdata[i].uid)) || '');
|
listdata[i].uin = parseInt((await this.core.apis.UserApi.getUinByUidV2(listdata[i].uid)) || '');
|
||||||
}
|
}
|
||||||
return listdata;
|
return listdata;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,6 @@ export class GetRobotUinRange extends BaseAction<void, Array<any>> {
|
|||||||
actionName = ActionName.GetRobotUinRange;
|
actionName = ActionName.GetRobotUinRange;
|
||||||
|
|
||||||
async _handle(payload: void) {
|
async _handle(payload: void) {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
return await this.core.apis.UserApi.getRobotUinRange();
|
||||||
return await NTQQUserApi.getRobotUinRange();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
import { checkFileReceived, uri2local } from '@/common/file';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
@@ -19,14 +19,13 @@ export class OCRImage extends BaseAction<Payload, any> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQSystemApi = this.core.apis.SystemApi;
|
|
||||||
const { path, isLocal, success } = (await uri2local(this.core.NapCatTempPath, payload.image));
|
const { path, isLocal, success } = (await uri2local(this.core.NapCatTempPath, payload.image));
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw `OCR ${payload.image}失败,image字段可能格式不正确`;
|
throw `OCR ${payload.image}失败,image字段可能格式不正确`;
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||||
const ret = await NTQQSystemApi.ORCImage(path);
|
const ret = await this.core.apis.SystemApi.ocrImage(path);
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
||||||
fs.unlink(path, () => {
|
fs.unlink(path, () => {
|
||||||
});
|
});
|
||||||
|
@@ -19,8 +19,6 @@ export class SetInputStatus extends BaseAction<Payload, any> {
|
|||||||
actionName = ActionName.SetInputStatus;
|
actionName = ActionName.SetInputStatus;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
|
||||||
let peer: Peer;
|
let peer: Peer;
|
||||||
if (payload.group_id) {
|
if (payload.group_id) {
|
||||||
peer = {
|
peer = {
|
||||||
@@ -28,7 +26,7 @@ export class SetInputStatus extends BaseAction<Payload, any> {
|
|||||||
peerUid: payload.group_id,
|
peerUid: payload.group_id,
|
||||||
};
|
};
|
||||||
} else if (payload.user_id) {
|
} else if (payload.user_id) {
|
||||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id);
|
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id);
|
||||||
if (!uid) throw new Error('uid is empty');
|
if (!uid) throw new Error('uid is empty');
|
||||||
peer = {
|
peer = {
|
||||||
chatType: ChatType.KCHATTYPEC2C,
|
chatType: ChatType.KCHATTYPEC2C,
|
||||||
@@ -38,6 +36,6 @@ export class SetInputStatus extends BaseAction<Payload, any> {
|
|||||||
throw new Error('请指定 group_id 或 user_id');
|
throw new Error('请指定 group_id 或 user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return await NTQQMsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType));
|
return await this.core.apis.MsgApi.sendShowInputStatusReq(peer, parseInt(payload.eventType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,8 +17,6 @@ export class SetLongNick extends BaseAction<Payload, any> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
return await this.core.apis.UserApi.setLongNick(payload.longNick);
|
||||||
const ret = await NTQQUserApi.setLongNick(payload.longNick);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,10 +7,10 @@ const SchemaData = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
status: { type: ['number', 'string'] },
|
status: { type: ['number', 'string'] },
|
||||||
extStatus: { type: ['number', 'string'] },
|
ext_status: { type: ['number', 'string'] },
|
||||||
batteryStatus: { type: ['number', 'string'] },
|
battery_status: { type: ['number', 'string'] },
|
||||||
},
|
},
|
||||||
required: ['status', 'extStatus', 'batteryStatus'],
|
required: ['status', 'ext_status', 'battery_status'],
|
||||||
} as const satisfies JSONSchema;
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
@@ -20,11 +20,10 @@ export class SetOnlineStatus extends BaseAction<Payload, null> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
const ret = await this.core.apis.UserApi.setSelfOnlineStatus(
|
||||||
const ret = await NTQQUserApi.setSelfOnlineStatus(
|
|
||||||
parseInt(payload.status.toString()),
|
parseInt(payload.status.toString()),
|
||||||
parseInt(payload.extStatus.toString()),
|
parseInt(payload.ext_status.toString()),
|
||||||
parseInt(payload.batteryStatus.toString()),
|
parseInt(payload.battery_status.toString()),
|
||||||
);
|
);
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error('设置在线状态失败');
|
throw new Error('设置在线状态失败');
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName, BaseCheckResult } from '../types';
|
import { ActionName, BaseCheckResult } from '../types';
|
||||||
import * as fs from 'node:fs';
|
import * as fs from 'node:fs';
|
||||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
import { checkFileReceived, uri2local } from '@/common/file';
|
||||||
|
|
||||||
interface Payload {
|
interface Payload {
|
||||||
file: string;
|
file: string;
|
||||||
@@ -24,14 +24,13 @@ export default class SetAvatar extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
const { path, isLocal, success } = (await uri2local(this.core.NapCatTempPath, payload.file));
|
||||||
const { path, isLocal, errMsg, success } = (await uri2local(this.core.NapCatTempPath, payload.file));
|
|
||||||
if (!success) {
|
if (!success) {
|
||||||
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
throw `头像${payload.file}设置失败,file字段可能格式不正确`;
|
||||||
}
|
}
|
||||||
if (path) {
|
if (path) {
|
||||||
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||||
const ret = await NTQQUserApi.setQQAvatar(path);
|
const ret = await this.core.apis.UserApi.setQQAvatar(path);
|
||||||
if (!isLocal) {
|
if (!isLocal) {
|
||||||
fs.unlink(path, () => {
|
fs.unlink(path, () => {
|
||||||
});
|
});
|
||||||
|
@@ -19,12 +19,10 @@ export class SharePeer extends BaseAction<Payload, any> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
|
||||||
if (payload.group_id) {
|
if (payload.group_id) {
|
||||||
return await NTQQGroupApi.getGroupRecommendContactArkJson(payload.group_id);
|
return await this.core.apis.GroupApi.getGroupRecommendContactArkJson(payload.group_id);
|
||||||
} else if (payload.user_id) {
|
} else if (payload.user_id) {
|
||||||
return await NTQQUserApi.getBuddyRecommendContactArkJson(payload.user_id, payload.phoneNumber || '');
|
return await this.core.apis.UserApi.getBuddyRecommendContactArkJson(payload.user_id, payload.phoneNumber || '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -44,7 +42,6 @@ export class ShareGroupEx extends BaseAction<PayloadGroupEx, any> {
|
|||||||
payloadSchema = SchemaDataGroupEx;
|
payloadSchema = SchemaDataGroupEx;
|
||||||
|
|
||||||
async _handle(payload: PayloadGroupEx) {
|
async _handle(payload: PayloadGroupEx) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
return await this.core.apis.GroupApi.getArkJsonGroupShare(payload.group_id);
|
||||||
return await NTQQGroupApi.getArkJsonGroupShare(payload.group_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,8 +20,7 @@ export class TranslateEnWordToZn extends BaseAction<Payload, Array<any> | null>
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQSystemApi = this.core.apis.SystemApi;
|
const ret = await this.core.apis.SystemApi.translateEnWordToZn(payload.words);
|
||||||
const ret = await NTQQSystemApi.translateEnWordToZn(payload.words);
|
|
||||||
if (ret.result !== 0) {
|
if (ret.result !== 0) {
|
||||||
throw new Error('翻译失败');
|
throw new Error('翻译失败');
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
import { UUIDConverter } from '@/common/utils/helper';
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { ChatType, ElementType, FileElement, Peer, RawMessage, VideoElement } from '@/core/entities';
|
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { OB11MessageImage, OB11MessageVideo } from '@/onebot/types';
|
||||||
|
|
||||||
export interface GetFilePayload {
|
export interface GetFilePayload {
|
||||||
file: string; // 文件名或者fileUuid
|
file: string; // 文件名或者fileUuid
|
||||||
@@ -29,167 +29,89 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
payloadSchema: any = GetFileBase_PayloadSchema;
|
payloadSchema: any = GetFileBase_PayloadSchema;
|
||||||
|
|
||||||
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||||
const NTQQFriendApi = this.core.apis.FriendApi;
|
//接收消息标记模式
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file);
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
if (contextMsgFile) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
const { peer, msgId, elementId } = contextMsgFile;
|
||||||
const NTQQFileApi = this.core.apis.FileApi;
|
const downloadPath = await this.core.apis.FileApi.downloadMedia(msgId, peer.chatType, peer.peerUid, elementId, '', '');
|
||||||
let UuidData: {
|
const rawMessage = (await this.core.apis.MsgApi.getMsgsByMsgId(peer, [msgId]))?.msgList
|
||||||
high: string;
|
.find(msg => msg.msgId === msgId);
|
||||||
low: string;
|
const mixElement = rawMessage?.elements.find(e => e.elementId === elementId);
|
||||||
} | undefined;
|
const mixElementInner = mixElement?.videoElement ?? mixElement?.fileElement ?? mixElement?.pttElement ?? mixElement?.picElement;
|
||||||
try {
|
if (!mixElementInner) throw new Error('element not found');
|
||||||
UuidData = UUIDConverter.decode(payload.file);
|
const fileSize = mixElementInner.fileSize?.toString() ?? '';
|
||||||
if (UuidData) {
|
const fileName = mixElementInner.fileName ?? '';
|
||||||
const peerUin = UuidData.high;
|
let url = '';
|
||||||
const msgId = UuidData.low;
|
if (mixElement?.picElement && rawMessage) {
|
||||||
const isGroup: boolean = !!(await NTQQGroupApi.getGroups(false)).find(e => e.groupCode == peerUin);
|
let tempData =
|
||||||
let peer: Peer | undefined;
|
await this.obContext.apis.MsgApi.rawToOb11Converters.picElement?.(mixElement?.picElement, rawMessage, mixElement) as OB11MessageImage | undefined;
|
||||||
//识别Peer
|
url = tempData?.data.url ?? '';
|
||||||
if (isGroup) {
|
|
||||||
peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: peerUin };
|
|
||||||
}
|
}
|
||||||
const PeerUid = await NTQQUserApi.getUidByUinV2(peerUin);
|
if (mixElement?.videoElement && rawMessage) {
|
||||||
if (PeerUid) {
|
let tempData =
|
||||||
const isBuddy = await NTQQFriendApi.isBuddy(PeerUid);
|
await this.obContext.apis.MsgApi.rawToOb11Converters.videoElement?.(mixElement?.videoElement, rawMessage, mixElement) as OB11MessageVideo | undefined;
|
||||||
if (isBuddy) {
|
url = tempData?.data.url ?? '';
|
||||||
peer = { chatType: ChatType.KCHATTYPEC2C, peerUid: PeerUid };
|
|
||||||
} else {
|
|
||||||
peer = { chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: PeerUid };
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!peer) {
|
|
||||||
throw new Error('chattype not support');
|
|
||||||
}
|
|
||||||
const msgList = await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]);
|
|
||||||
if (msgList.msgList.length == 0) {
|
|
||||||
throw new Error('msg not found');
|
|
||||||
}
|
|
||||||
const msg = msgList.msgList[0];
|
|
||||||
const findEle = msg.elements.find(e => e.elementType == ElementType.VIDEO || e.elementType == ElementType.FILE || e.elementType == ElementType.PTT);
|
|
||||||
if (!findEle) {
|
|
||||||
throw new Error('element not found');
|
|
||||||
}
|
|
||||||
const downloadPath = await NTQQFileApi.downloadMedia(msgId, msg.chatType, msg.peerUid, findEle.elementId, '', '');
|
|
||||||
const fileSize = findEle?.videoElement?.fileSize || findEle?.fileElement?.fileSize || findEle?.pttElement?.fileSize || '0';
|
|
||||||
const fileName = findEle?.videoElement?.fileName || findEle?.fileElement?.fileName || findEle?.pttElement?.fileName || '';
|
|
||||||
const res: GetFileResponse = {
|
const res: GetFileResponse = {
|
||||||
file: downloadPath,
|
file: downloadPath,
|
||||||
url: downloadPath,
|
url: url !== '' ? url : downloadPath,
|
||||||
file_size: fileSize,
|
file_size: fileSize,
|
||||||
file_name: fileName,
|
file_name: fileName,
|
||||||
};
|
};
|
||||||
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
|
||||||
|
if (this.obContext.configLoader.configData.enableLocalFile2Url && downloadPath) {
|
||||||
try {
|
try {
|
||||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('文件下载失败. ' + e);
|
throw new Error('文件下载失败. ' + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//不手动删除?文件持久化了
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
} catch {
|
|
||||||
this.core.context.logger.logDebug('GetFileBase Mode - 1 Error');
|
|
||||||
}
|
|
||||||
|
|
||||||
const NTSearchNameResult = (await NTQQFileApi.searchfile([payload.file])).resultItems;
|
//群文件模式
|
||||||
if (NTSearchNameResult.length !== 0) {
|
const contextModelIdFile = FileNapCatOneBotUUID.decodeModelId(payload.file);
|
||||||
const MsgId = NTSearchNameResult[0].msgId;
|
if (contextModelIdFile) {
|
||||||
let peer: Peer | undefined = undefined;
|
const { peer, modelId } = contextModelIdFile;
|
||||||
if (NTSearchNameResult[0].chatType == ChatType.KCHATTYPEGROUP) {
|
const downloadPath = await this.core.apis.FileApi.downloadFileForModelId(peer, modelId, '');
|
||||||
peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: NTSearchNameResult[0].groupChatInfo[0].groupCode };
|
|
||||||
}
|
|
||||||
if (!peer) {
|
|
||||||
throw new Error('chattype not support');
|
|
||||||
}
|
|
||||||
const msgList: RawMessage[] = (await NTQQMsgApi.getMsgsByMsgId(peer, [MsgId]))?.msgList;
|
|
||||||
if (!msgList || msgList.length == 0) {
|
|
||||||
throw new Error('msg not found');
|
|
||||||
}
|
|
||||||
const msg = msgList[0];
|
|
||||||
const file = msg.elements.filter(e => e.elementType == NTSearchNameResult[0].elemType);
|
|
||||||
if (file.length == 0) {
|
|
||||||
throw new Error('file not found');
|
|
||||||
}
|
|
||||||
const downloadPath = await NTQQFileApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid, file[0].elementId, '', '');
|
|
||||||
const res: GetFileResponse = {
|
const res: GetFileResponse = {
|
||||||
file: downloadPath,
|
file: downloadPath,
|
||||||
url: downloadPath,
|
url: downloadPath,
|
||||||
file_size: NTSearchNameResult[0].fileSize.toString(),
|
file_size: '',
|
||||||
file_name: NTSearchNameResult[0].fileName,
|
file_name: '',
|
||||||
};
|
};
|
||||||
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
|
||||||
|
if (this.obContext.configLoader.configData.enableLocalFile2Url && downloadPath) {
|
||||||
try {
|
try {
|
||||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error('文件下载失败. ' + e);
|
throw new Error('文件下载失败. ' + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//不手动删除?文件持久化了
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//搜索名字模式
|
||||||
|
const searchResult = (await this.core.apis.FileApi.searchForFile([payload.file]));
|
||||||
|
if (searchResult) {
|
||||||
|
const downloadPath = await this.core.apis.FileApi.downloadFileById(searchResult.id, parseInt(searchResult.fileSize));
|
||||||
|
const res: GetFileResponse = {
|
||||||
|
file: downloadPath,
|
||||||
|
url: downloadPath,
|
||||||
|
file_size: searchResult.fileSize.toString(),
|
||||||
|
file_name: searchResult.fileName,
|
||||||
|
};
|
||||||
|
if (this.obContext.configLoader.configData.enableLocalFile2Url && downloadPath) {
|
||||||
|
try {
|
||||||
|
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||||
|
} catch (e) {
|
||||||
|
throw new Error('文件下载失败. ' + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
throw new Error('file not found');
|
throw new Error('file not found');
|
||||||
// let cache = await dbUtil.getFileCacheByName(payload.file);
|
|
||||||
// if (!cache) {
|
|
||||||
// cache = await dbUtil.getFileCacheByUuid(payload.file);
|
|
||||||
// }
|
|
||||||
// if (!cache) {
|
|
||||||
// throw new Error('file not found');
|
|
||||||
// }
|
|
||||||
// const { enableLocalFile2Url } = ob11Config;
|
|
||||||
// try {
|
|
||||||
// await fs.access(cache.path, fs.constants.F_OK);
|
|
||||||
// } catch (e) {
|
|
||||||
// logDebug('local file not found, start download...');
|
|
||||||
// // if (cache.url) {
|
|
||||||
// // const downloadResult = await uri2local(cache.url);
|
|
||||||
// // if (downloadResult.success) {
|
|
||||||
// // cache.path = downloadResult.path;
|
|
||||||
// // dbUtil.updateFileCache(cache).then();
|
|
||||||
// // } else {
|
|
||||||
// // throw new Error('file download failed. ' + downloadResult.errMsg);
|
|
||||||
// // }
|
|
||||||
// // } else {
|
|
||||||
// // // 没有url的可能是私聊文件或者群文件,需要自己下载
|
|
||||||
// // log('需要调用 NTQQ 下载文件api');
|
|
||||||
// let peer = MessageUnique.getPeerByMsgId(cache.msgId);
|
|
||||||
// let msg = await NTQQMsgApi.getMsgsByMsgId(peer?.Peer!,cache.msgId);
|
|
||||||
// // log('文件 msg', msg);
|
|
||||||
// if (msg) {
|
|
||||||
// // 构建下载函数
|
|
||||||
// const downloadPath = await NTQQFileApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid,
|
|
||||||
// cache.elementId, '', '');
|
|
||||||
// // await sleep(1000);
|
|
||||||
|
|
||||||
// // log('download result', downloadPath);
|
|
||||||
// let peer = MessageUnique.getPeerByMsgId(cache.msgId);
|
|
||||||
// msg = await NTQQMsgApi.getMsgsByMsgId(peer?.Peer!,cache.msgId);
|
|
||||||
// // log('下载完成后的msg', msg);
|
|
||||||
// cache.path = downloadPath!;
|
|
||||||
// dbUtil.updateFileCache(cache).then();
|
|
||||||
// // log('下载完成后的msg', msg);
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// // log('file found', cache);
|
|
||||||
// const res: GetFileResponse = {
|
|
||||||
// file: cache.path,
|
|
||||||
// url: cache.url,
|
|
||||||
// file_size: cache.size.toString(),
|
|
||||||
// file_name: cache.name
|
|
||||||
// };
|
|
||||||
// if (enableLocalFile2Url) {
|
|
||||||
// if (!cache.url) {
|
|
||||||
// try {
|
|
||||||
// res.base64 = await fs.readFile(cache.path, 'base64');
|
|
||||||
// } catch (e) {
|
|
||||||
// throw new Error('文件下载失败. ' + e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//return res;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,34 +0,0 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
|
||||||
|
|
||||||
const SchemaData = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
group_id: { type: ['string', 'number'] },
|
|
||||||
start_index: { type: 'number' },
|
|
||||||
file_count: { type: 'number' },
|
|
||||||
},
|
|
||||||
required: ['group_id', 'start_index', 'file_count'],
|
|
||||||
} as const satisfies JSONSchema;
|
|
||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
|
||||||
|
|
||||||
export class GetGroupFileList extends BaseAction<Payload, { FileList: Array<any> }> {
|
|
||||||
actionName = ActionName.GetGroupFileList;
|
|
||||||
payloadSchema = SchemaData;
|
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
|
||||||
const ret = await NTQQMsgApi.getGroupFileList(payload.group_id.toString(), {
|
|
||||||
sortType: 1,
|
|
||||||
fileCount: payload.file_count,
|
|
||||||
startIndex: payload.start_index,
|
|
||||||
sortOrder: 2,
|
|
||||||
showOnlinedocFolder: 0,
|
|
||||||
}).catch((e) => {
|
|
||||||
return [];
|
|
||||||
});
|
|
||||||
return { FileList: ret };
|
|
||||||
}
|
|
||||||
}
|
|
@@ -13,12 +13,10 @@ const SchemaData = {
|
|||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class SetGroupFileFolder extends BaseAction<Payload, any> {
|
export class CreateGroupFileFolder extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.SetGroupFileFolder;
|
actionName = ActionName.GoCQHTTP_CreateGroupFileFolder;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
return (await this.core.apis.GroupApi.CreatGroupFileFolder(payload.group_id.toString(), payload.folder_name)).resultWithGroupItem;
|
||||||
return (await NTQQGroupApi.CreatGroupFileFolder(payload.group_id.toString(), payload.folder_name)).resultWithGroupItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -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';
|
||||||
|
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -13,12 +14,12 @@ const SchemaData = {
|
|||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class DelGroupFile extends BaseAction<Payload, any> {
|
export class DeleteGroupFile extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.DelGroupFile;
|
actionName = ActionName.GOCQHTTP_DeleteGroupFile;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
const data = FileNapCatOneBotUUID.decodeModelId(payload.file_id);
|
||||||
return await NTQQGroupApi.DelGroupFile(payload.group_id.toString(), [payload.file_id]);
|
if (!data) throw new Error('Invalid file_id');
|
||||||
|
return await this.core.apis.GroupApi.DelGroupFile(payload.group_id.toString(), [data.fileId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import BaseAction from '../BaseAction';
|
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -13,12 +13,11 @@ const SchemaData = {
|
|||||||
|
|
||||||
type Payload = FromSchema<typeof SchemaData>;
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
export class DelGroupFileFolder extends BaseAction<Payload, any> {
|
export class DeleteGroupFileFolder extends BaseAction<Payload, any> {
|
||||||
actionName = ActionName.DelGroupFileFolder;
|
actionName = ActionName.GoCQHTTP_DeleteGroupFileFolder;
|
||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
return (await this.core.apis.GroupApi.DelGroupFileFolder(
|
||||||
return (await NTQQGroupApi.DelGroupFileFolder(payload.group_id.toString(), payload.folder_id)).groupFileCommonResult;
|
payload.group_id.toString(), payload.folder_id)).groupFileCommonResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
|||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { join as joinPath } from 'node:path';
|
import { join as joinPath } from 'node:path';
|
||||||
import { calculateFileMD5, httpDownload } from '@/common/utils/file';
|
import { calculateFileMD5, httpDownload } from '@/common/file';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
|||||||
import { OB11ForwardMessage } from '@/onebot';
|
import { OB11ForwardMessage } from '@/onebot';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { MessageUnique } from '@/common/utils/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -19,7 +19,6 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<any> {
|
async _handle(payload: Payload): Promise<any> {
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
|
||||||
const msgId = payload.message_id || payload.id;
|
const msgId = payload.message_id || payload.id;
|
||||||
if (!msgId) {
|
if (!msgId) {
|
||||||
throw Error('message_id is required');
|
throw Error('message_id is required');
|
||||||
@@ -29,7 +28,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
|||||||
if (!rootMsg) {
|
if (!rootMsg) {
|
||||||
throw Error('msg not found');
|
throw Error('msg not found');
|
||||||
}
|
}
|
||||||
const data = await NTQQMsgApi.getMultiMsg(rootMsg.Peer, rootMsg.MsgId, rootMsg.MsgId);
|
const data = await this.core.apis.MsgApi.getMultiMsg(rootMsg.Peer, rootMsg.MsgId, rootMsg.MsgId);
|
||||||
if (!data || data.result !== 0) {
|
if (!data || data.result !== 0) {
|
||||||
throw Error('找不到相关的聊天记录' + data?.errMsg);
|
throw Error('找不到相关的聊天记录' + data?.errMsg);
|
||||||
}
|
}
|
||||||
@@ -38,7 +37,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
|||||||
const resMsg = await this.obContext.apis.MsgApi
|
const resMsg = await this.obContext.apis.MsgApi
|
||||||
.parseMessage(msg);
|
.parseMessage(msg);
|
||||||
if (!resMsg) return;
|
if (!resMsg) return;
|
||||||
resMsg.message_id = MessageUnique.createMsg({
|
resMsg.message_id = MessageUnique.createUniqueMsgId({
|
||||||
guildId: '',
|
guildId: '',
|
||||||
chatType: msg.chatType,
|
chatType: msg.chatType,
|
||||||
peerUid: msg.peerUid,
|
peerUid: msg.peerUid,
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { OB11Message } from '@/onebot';
|
import { OB11Message } from '@/onebot';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { ChatType, RawMessage } from '@/core/entities';
|
import { ChatType } from '@/core/entities';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { MessageUnique } from '@/common/utils/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
@@ -13,7 +13,7 @@ const SchemaData = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
user_id: { type: ['number', 'string'] },
|
user_id: { type: ['number', 'string'] },
|
||||||
message_seq: { type: 'number' },
|
message_seq: { type: ['number', 'string'] },
|
||||||
count: { type: ['number', 'string'] },
|
count: { type: ['number', 'string'] },
|
||||||
reverseOrder: { type: ['boolean', 'string'] },
|
reverseOrder: { type: ['boolean', 'string'] },
|
||||||
},
|
},
|
||||||
@@ -27,31 +27,25 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<Response> {
|
async _handle(payload: Payload): Promise<Response> {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
|
||||||
const NTQQFriendApi = this.core.apis.FriendApi;
|
|
||||||
//处理参数
|
//处理参数
|
||||||
const uid = await NTQQUserApi.getUidByUinV2(payload.user_id.toString());
|
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||||
const MsgCount = +(payload.count ?? 20);
|
const MsgCount = +(payload.count ?? 20);
|
||||||
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||||
if (!uid) throw `记录${payload.user_id}不存在`;
|
if (!uid) throw `记录${payload.user_id}不存在`;
|
||||||
const friend = await NTQQFriendApi.isBuddy(uid);
|
const friend = await this.core.apis.FriendApi.isBuddy(uid);
|
||||||
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
||||||
|
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||||
//拉取消息
|
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||||
let msgList: RawMessage[];
|
const msgList = hasMessageSeq ?
|
||||||
if (!payload.message_seq || payload.message_seq == 0) {
|
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, MsgCount)).msgList;
|
||||||
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, MsgCount)).msgList;
|
if (msgList.length === 0) throw `消息${payload.message_seq}不存在`;
|
||||||
} else {
|
//翻转消息
|
||||||
const startMsgId = MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq)?.MsgId;
|
|
||||||
if (!startMsgId) throw `消息${payload.message_seq}不存在`;
|
|
||||||
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList;
|
|
||||||
}
|
|
||||||
if (isReverseOrder) msgList.reverse();
|
if (isReverseOrder) msgList.reverse();
|
||||||
|
//转换序号
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||||
}));
|
}));
|
||||||
//转换消息
|
//烘焙消息
|
||||||
const ob11MsgList = (await Promise.all(
|
const ob11MsgList = (await Promise.all(
|
||||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
||||||
).filter(msg => msg !== undefined);
|
).filter(msg => msg !== undefined);
|
||||||
|
35
src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts
Normal file
35
src/onebot/action/go-cqhttp/GetGroupFileSystemInfo.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
group_id: { type: ['string', 'number'] },
|
||||||
|
},
|
||||||
|
required: ['group_id'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class GetGroupFileSystemInfo extends BaseAction<Payload, {
|
||||||
|
file_count: number,
|
||||||
|
limit_count: number, // unimplemented
|
||||||
|
used_space: number, // todo: unimplemented, but can be implemented later
|
||||||
|
total_space: number, // unimplemented, 10 GB by default
|
||||||
|
}> {
|
||||||
|
actionName = ActionName.GoCQHTTP_GetGroupFileSystemInfo;
|
||||||
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
return {
|
||||||
|
file_count:
|
||||||
|
(await this.core.apis.GroupApi
|
||||||
|
.getGroupFileCount([payload.group_id.toString()]))
|
||||||
|
.groupFileCounts[0],
|
||||||
|
limit_count: 10000,
|
||||||
|
used_space: 0,
|
||||||
|
total_space: 10 * 1024 * 1024 * 1024,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
37
src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts
Normal file
37
src/onebot/action/go-cqhttp/GetGroupFilesByFolder.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
group_id: { type: ['string', 'number'] },
|
||||||
|
folder_id: { type: 'string' },
|
||||||
|
file_count: { type: ['string', 'number'] },
|
||||||
|
},
|
||||||
|
required: ['group_id', 'folder_id'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class GetGroupFilesByFolder extends BaseAction<any, any> {
|
||||||
|
actionName = ActionName.GoCQHTTP_GetGroupFilesByFolder;
|
||||||
|
payloadSchema = SchemaData;
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
|
||||||
|
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
||||||
|
sortType: 1,
|
||||||
|
fileCount: +(payload.file_count ?? 50),
|
||||||
|
startIndex: 0,
|
||||||
|
sortOrder: 2,
|
||||||
|
showOnlinedocFolder: 0,
|
||||||
|
folderId: payload.folder_id,
|
||||||
|
}).catch(() => []);
|
||||||
|
return {
|
||||||
|
files: ret.filter(item => item.fileInfo)
|
||||||
|
.map(item => OB11Entities.file(item.peerId, item.fileInfo!)),
|
||||||
|
folders: [] as [],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@@ -22,7 +22,6 @@ export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
|
|||||||
if (!payload.type) {
|
if (!payload.type) {
|
||||||
payload.type = WebHonorType.ALL;
|
payload.type = WebHonorType.ALL;
|
||||||
}
|
}
|
||||||
const NTQQWebApi = this.core.apis.WebApi;
|
return await this.core.apis.WebApi.getGroupHonorInfo(payload.group_id.toString(), payload.type);
|
||||||
return await NTQQWebApi.getGroupHonorInfo(payload.group_id.toString(), payload.type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { OB11Message } from '@/onebot';
|
import { OB11Message } from '@/onebot';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { ChatType, Peer, RawMessage } from '@/core/entities';
|
import { ChatType, Peer } from '@/core/entities';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { MessageUnique } from '@/common/utils/message-unique';
|
import { MessageUnique } from '@/common/message-unique';
|
||||||
|
|
||||||
interface Response {
|
interface Response {
|
||||||
messages: OB11Message[];
|
messages: OB11Message[];
|
||||||
@@ -13,7 +13,7 @@ const SchemaData = {
|
|||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
group_id: { type: ['number', 'string'] },
|
group_id: { type: ['number', 'string'] },
|
||||||
message_seq: { type: 'number' },
|
message_seq: { type: ['number', 'string'] },
|
||||||
count: { type: ['number', 'string'] },
|
count: { type: ['number', 'string'] },
|
||||||
reverseOrder: { type: ['boolean', 'string'] },
|
reverseOrder: { type: ['boolean', 'string'] },
|
||||||
},
|
},
|
||||||
@@ -27,26 +27,23 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
|||||||
payloadSchema = SchemaData;
|
payloadSchema = SchemaData;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<Response> {
|
async _handle(payload: Payload): Promise<Response> {
|
||||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
|
||||||
//处理参数
|
//处理参数
|
||||||
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||||
const MsgCount = +(payload.count ?? 20);
|
const MsgCount = +(payload.count ?? 20);
|
||||||
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||||
|
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||||
//拉取消息
|
//拉取消息
|
||||||
let msgList: RawMessage[];
|
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||||
if (!payload.message_seq || payload.message_seq == 0) {
|
const msgList = hasMessageSeq ?
|
||||||
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, MsgCount)).msgList;
|
(await this.core.apis.MsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList : (await this.core.apis.MsgApi.getAioFirstViewLatestMsgs(peer, MsgCount)).msgList;
|
||||||
} else {
|
if (msgList.length === 0) throw `消息${payload.message_seq}不存在`;
|
||||||
const startMsgId = MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq)?.MsgId;
|
//翻转消息
|
||||||
if (!startMsgId) throw `消息${payload.message_seq}不存在`;
|
|
||||||
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList;
|
|
||||||
}
|
|
||||||
if (isReverseOrder) msgList.reverse();
|
if (isReverseOrder) msgList.reverse();
|
||||||
|
//转换序号
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||||
}));
|
}));
|
||||||
|
//烘焙消息
|
||||||
//转换消息
|
|
||||||
const ob11MsgList = (await Promise.all(
|
const ob11MsgList = (await Promise.all(
|
||||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
||||||
).filter(msg => msg !== undefined);
|
).filter(msg => msg !== undefined);
|
||||||
|
40
src/onebot/action/go-cqhttp/GetGroupRootFiles.ts
Normal file
40
src/onebot/action/go-cqhttp/GetGroupRootFiles.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
import { OB11GroupFile, OB11GroupFileFolder } from '@/onebot';
|
||||||
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
group_id: { type: ['string', 'number'] },
|
||||||
|
file_count: { type: ['string', 'number'] },
|
||||||
|
},
|
||||||
|
required: ['group_id'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export class GetGroupRootFiles extends BaseAction<Payload, {
|
||||||
|
files: OB11GroupFile[],
|
||||||
|
folders: OB11GroupFileFolder[],
|
||||||
|
}> {
|
||||||
|
actionName = ActionName.GoCQHTTP_GetGroupRootFiles;
|
||||||
|
payloadSchema = SchemaData;
|
||||||
|
async _handle(payload: Payload) {
|
||||||
|
const ret = await this.core.apis.MsgApi.getGroupFileList(payload.group_id.toString(), {
|
||||||
|
sortType: 1,
|
||||||
|
fileCount: +(payload.file_count ?? 50),
|
||||||
|
startIndex: 0,
|
||||||
|
sortOrder: 2,
|
||||||
|
showOnlinedocFolder: 0,
|
||||||
|
}).catch(() => []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
files: ret.filter(item => item.fileInfo)
|
||||||
|
.map(item => OB11Entities.file(item.peerId, item.fileInfo!)),
|
||||||
|
folders: ret.filter(item => item.folderInfo)
|
||||||
|
.map(item => OB11Entities.folder(item.peerId, item.folderInfo!)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { JSONSchema } from 'json-schema-to-ts';
|
import { JSONSchema } from 'json-schema-to-ts';
|
||||||
import { sleep } from '@/common/utils/helper';
|
import { sleep } from '@/common/helper';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -15,8 +15,7 @@ export class GetOnlineClient extends BaseAction<void, Array<any>> {
|
|||||||
|
|
||||||
async _handle(payload: void) {
|
async _handle(payload: void) {
|
||||||
//注册监听
|
//注册监听
|
||||||
const NTQQSystemApi = this.core.apis.SystemApi;
|
this.core.apis.SystemApi.getOnlineDev();
|
||||||
NTQQSystemApi.getOnlineDev();
|
|
||||||
await sleep(500);
|
await sleep(500);
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { OB11User, OB11UserSex } from '@/onebot';
|
import { OB11User, OB11UserSex } from '@/onebot';
|
||||||
import { OB11Entities } from '@/onebot/helper/entities';
|
import { OB11Entities } from '@/onebot/entities';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { calcQQLevel } from '@/common/utils/helper';
|
import { calcQQLevel } from '@/common/helper';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -19,10 +19,9 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||||
|
|
||||||
async _handle(payload: Payload): Promise<OB11User> {
|
async _handle(payload: Payload): Promise<OB11User> {
|
||||||
const NTQQUserApi = this.core.apis.UserApi;
|
|
||||||
const user_id = payload.user_id.toString();
|
const user_id = payload.user_id.toString();
|
||||||
const extendData = await NTQQUserApi.getUserDetailInfoByUinV2(user_id);
|
const extendData = await this.core.apis.UserApi.getUserDetailInfoByUinV2(user_id);
|
||||||
const uid = (await NTQQUserApi.getUidByUinV2(user_id))!;
|
const uid = (await this.core.apis.UserApi.getUidByUinV2(user_id))!;
|
||||||
if (!uid || uid.indexOf('*') != -1) {
|
if (!uid || uid.indexOf('*') != -1) {
|
||||||
return {
|
return {
|
||||||
...extendData.detail.simpleInfo.coreInfo,
|
...extendData.detail.simpleInfo.coreInfo,
|
||||||
@@ -38,7 +37,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
login_days: 0,
|
login_days: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
const data = { ...extendData, ...(await this.core.apis.UserApi.getUserDetailInfo(uid)) };
|
||||||
return OB11Entities.stranger(data);
|
return OB11Entities.stranger(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,7 +13,7 @@ export class GoCQHTTPHandleQuickAction extends BaseAction<Payload, null> {
|
|||||||
async _handle(payload: Payload): Promise<null> {
|
async _handle(payload: Payload): Promise<null> {
|
||||||
this.obContext.apis.QuickActionApi
|
this.obContext.apis.QuickActionApi
|
||||||
.handleQuickOperation(payload.context, payload.operation)
|
.handleQuickOperation(payload.context, payload.operation)
|
||||||
.catch(this.core.context.logger.logError);
|
.catch(this.core.context.logger.logError.bind(this.core.context.logger));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
import { checkFileReceived, uri2local } from '@/common/file';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { unlink } from 'node:fs';
|
import { unlink } from 'node:fs';
|
||||||
@@ -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,12 +25,11 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
actionName = ActionName.GoCQHTTP_SendGroupNotice;
|
||||||
|
|
||||||
async _handle(payload: Payload) {
|
async _handle(payload: Payload) {
|
||||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
|
||||||
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) {
|
||||||
//公告图逻辑
|
//公告图逻辑
|
||||||
const {
|
const {
|
||||||
errMsg,
|
|
||||||
path,
|
path,
|
||||||
isLocal,
|
isLocal,
|
||||||
success,
|
success,
|
||||||
@@ -39,7 +41,7 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
throw `群公告${payload.image}设置失败,获取资源失败`;
|
throw `群公告${payload.image}设置失败,获取资源失败`;
|
||||||
}
|
}
|
||||||
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
await checkFileReceived(path, 5000); // 文件不存在QQ会崩溃,需要提前判断
|
||||||
const ImageUploadResult = await NTQQGroupApi.uploadGroupBulletinPic(payload.group_id.toString(), path);
|
const ImageUploadResult = await this.core.apis.GroupApi.uploadGroupBulletinPic(payload.group_id.toString(), path);
|
||||||
if (ImageUploadResult.errCode != 0) {
|
if (ImageUploadResult.errCode != 0) {
|
||||||
throw `群公告${payload.image}设置失败,图片上传失败`;
|
throw `群公告${payload.image}设置失败,图片上传失败`;
|
||||||
}
|
}
|
||||||
@@ -49,12 +51,28 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
|||||||
}
|
}
|
||||||
UploadImage = ImageUploadResult.picInfo;
|
UploadImage = ImageUploadResult.picInfo;
|
||||||
}
|
}
|
||||||
let noticePinned = +(payload.pinned ?? 0);
|
|
||||||
let noticeConfirmRequired = +(payload.confirm_required ?? 0);
|
|
||||||
const publishGroupBulletinResult = await NTQQGroupApi.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;
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user