mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1c38833998 | ||
![]() |
38894177ee | ||
![]() |
dce8416942 | ||
![]() |
14219e9b42 | ||
![]() |
7b459e7502 | ||
![]() |
31824c0504 | ||
![]() |
e203abae85 | ||
![]() |
faf83b680b | ||
![]() |
67dcbcb842 | ||
![]() |
6533a25404 | ||
![]() |
4dc760b0e9 | ||
![]() |
25933b9043 | ||
![]() |
a53aaa456e | ||
![]() |
e8a7ea07a5 | ||
![]() |
8817dc6b10 | ||
![]() |
491ec04b46 | ||
![]() |
8a5d4a683b | ||
![]() |
dfc7c7357a | ||
![]() |
690a2f7d34 | ||
![]() |
58f22b24e4 | ||
![]() |
3cce9f528b | ||
![]() |
20fd5ac8cb | ||
![]() |
9e05e086eb | ||
![]() |
056e0adddf | ||
![]() |
b36388200d | ||
![]() |
9793e5741a | ||
![]() |
143380c012 | ||
![]() |
4b92254945 | ||
![]() |
f9c1d8b4a6 | ||
![]() |
c0c469339b | ||
![]() |
0ca6343ed7 | ||
![]() |
3db74c3427 | ||
![]() |
48d5cb53bd | ||
![]() |
fd7d2dbf53 | ||
![]() |
6609697752 | ||
![]() |
dcd6e1973e | ||
![]() |
3614a6e932 | ||
![]() |
931a0210e5 | ||
![]() |
f9e7de4b42 | ||
![]() |
8e0b79594e | ||
![]() |
17122c4360 | ||
![]() |
154f7b6a30 | ||
![]() |
52e5543d0b | ||
![]() |
3c304bd2ae | ||
![]() |
26609bb8fd | ||
![]() |
de3fa9aaa4 | ||
![]() |
788665f84c | ||
![]() |
3943782971 | ||
![]() |
8f899c40f2 | ||
![]() |
a1f582399e | ||
![]() |
440b63f662 | ||
![]() |
7d2cc3b56b | ||
![]() |
5fe3422469 | ||
![]() |
6c02cedb1e | ||
![]() |
3cc2f1dcad | ||
![]() |
773cdc5877 | ||
![]() |
361a7329d7 | ||
![]() |
29910f1236 | ||
![]() |
4a164016f5 | ||
![]() |
cebd3e62a4 | ||
![]() |
2562a38fa1 | ||
![]() |
d46c922bbf | ||
![]() |
66b59982f7 | ||
![]() |
ad397ccf7f | ||
![]() |
bdef80ede7 |
@@ -1,32 +0,0 @@
|
|||||||
# v1.6.8
|
|
||||||
|
|
||||||
QQ Version: Windows 9.9.12-26000 / Linux 3.2.9-26000
|
|
||||||
## 使用前警告
|
|
||||||
1. 在最近版本由于QQ本体大幅变动,为了保证NapCat可用性,NapCat近期启动与安装方式将将大幅变动,请关注文档和社群获取。
|
|
||||||
2. 在Core上完全执行开源,请不要用于违法用途,如此可能造成NapCat完全停止更新。
|
|
||||||
3. 针对原启动方式的围堵,NapCat研发了多种方式,除此其余理论与扩展的分析和思路将部分展示于Docs,以便各位参与开发与维护NapCat。
|
|
||||||
## 其余·备注
|
|
||||||
启动方式: WayBoot.03 (Electron Main进程为Node 直接注入代码 同理项目: LiteLoader)
|
|
||||||
|
|
||||||
## 修复与优化
|
|
||||||
1. 移除数据库文件读写 ~ 优化性能
|
|
||||||
2. 重构消息发送 极限速度优化 ~ 优化性能
|
|
||||||
3. WebUi配置热重载优化 ~ 修复问题
|
|
||||||
4. 修复偶现崩溃问题 ~ 修复问题
|
|
||||||
5. 修复群邀请通知事件多次推送问题 ~ 修复问题
|
|
||||||
6. 尝试修复因缓存引起的字段不全问题 ~ 修复问题
|
|
||||||
7. 修复在非常非常高并发的情况 上报自身消息 回复回错问题 ~ 修复问题
|
|
||||||
8. 修复图片SubType字段位置错误问题 ~ 修复问题
|
|
||||||
9. 修复Uid/Uin转换问题 ~ 修复问题
|
|
||||||
|
|
||||||
## 新增与调整
|
|
||||||
1. 最后发言时间重构 入群时间失效 ~ 替换功能
|
|
||||||
2. 重构文件发送/获取 ~ 优化性能
|
|
||||||
3. 支持GOCQ私聊上传接口 ~ 新增功能
|
|
||||||
4. 悄悄告诉你ws http可以同一个端口 ~ 新增功能
|
|
||||||
5. 根据config目录的默认配置初始化新的配置文件 ~ 新增功能
|
|
||||||
6. WebUi可以部署在nginx代理二级目录 配置端口设置为0可关闭WebUi ~ 新增功能
|
|
||||||
7. 新增收藏表情拉取接口 ~ 新增功能
|
|
||||||
8. 新增群头像设置接口 ~ 新增功能
|
|
||||||
|
|
||||||
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)
|
|
11
docs/changelogs/CHANGELOG.v1.7.7.md
Normal file
11
docs/changelogs/CHANGELOG.v1.7.7.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# v1.7.7
|
||||||
|
|
||||||
|
QQ Version: Windows 9.9.15-26702 / Linux 3.2.12-26702
|
||||||
|
|
||||||
|
## 启动的方式
|
||||||
|
Way03/Way05
|
||||||
|
|
||||||
|
## 新增与调整
|
||||||
|
1. 支持 9.9.15/3.2.12 版本QQ
|
||||||
|
|
||||||
|
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.7.3",
|
"version": "1.7.7",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch:dev": "vite --mode development",
|
"watch:dev": "vite --mode development",
|
||||||
"watch:prod": "vite --mode production",
|
"watch:prod": "vite --mode production",
|
||||||
|
@@ -86,7 +86,7 @@ export abstract class HttpServerBase {
|
|||||||
this.start(port, host);
|
this.start(port, host);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract handleFailed(res: Response, payload: any, err: any): void
|
abstract handleFailed(res: Response, payload: any, err: Error): void
|
||||||
|
|
||||||
registerRouter(method: 'post' | 'get' | string, url: string, handler: RegisterHandler) {
|
registerRouter(method: 'post' | 'get' | string, url: string, handler: RegisterHandler) {
|
||||||
if (!url.startsWith('/')) {
|
if (!url.startsWith('/')) {
|
||||||
@@ -111,7 +111,7 @@ export abstract class HttpServerBase {
|
|||||||
try {
|
try {
|
||||||
res.send(await handler(res, payload));
|
res.send(await handler(res, payload));
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this.handleFailed(res, payload, e.stack.toString());
|
this.handleFailed(res, payload, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,7 @@ export class NTEventWrapper {
|
|||||||
}
|
}
|
||||||
//统一回调清理事件
|
//统一回调清理事件
|
||||||
async DispatcherListener(ListenerMainName: string, ListenerSubName: string, ...args: any[]) {
|
async DispatcherListener(ListenerMainName: string, ListenerSubName: string, ...args: any[]) {
|
||||||
//console.log(ListenerMainName, ListenerSubName, ...args,this.EventTask.get(ListenerMainName)?.get(ListenerSubName));
|
//console.log("[EventDispatcher]",ListenerMainName, ListenerSubName, ...args);
|
||||||
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.forEach((task, uuid) => {
|
this.EventTask.get(ListenerMainName)?.get(ListenerSubName)?.forEach((task, uuid) => {
|
||||||
//console.log(task.func, uuid, task.createtime, task.timeout);
|
//console.log(task.func, uuid, task.createtime, task.timeout);
|
||||||
if (task.createtime + task.timeout < Date.now()) {
|
if (task.createtime + task.timeout < Date.now()) {
|
||||||
|
@@ -2,7 +2,7 @@ import { Peer } from '@/core';
|
|||||||
import crypto, { randomInt, randomUUID } from 'crypto';
|
import crypto, { randomInt, randomUUID } from 'crypto';
|
||||||
import { logError } from './log';
|
import { logError } from './log';
|
||||||
|
|
||||||
class LimitedHashTable<K, V> {
|
export class LimitedHashTable<K, V> {
|
||||||
private keyToValue: Map<K, V> = new Map();
|
private keyToValue: Map<K, V> = new Map();
|
||||||
private valueToKey: Map<V, K> = new Map();
|
private valueToKey: Map<V, K> = new Map();
|
||||||
private maxSize: number;
|
private maxSize: number;
|
||||||
|
@@ -1,62 +1,49 @@
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import os from 'node:os';
|
|
||||||
import { systemPlatform } from '@/common/utils/system';
|
import { systemPlatform } from '@/common/utils/system';
|
||||||
import { logError } from '@/common/utils/log';
|
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
|
||||||
|
import AppidTable from '@/core/external/appid.json';
|
||||||
|
import { log } from './log';
|
||||||
|
|
||||||
export const exePath = process.execPath;
|
//基础目录获取
|
||||||
|
export let QQMainPath = process.execPath;
|
||||||
|
export let QQPackageInfoPath: string = path.join(path.dirname(QQMainPath), 'resources', 'app', 'package.json');
|
||||||
|
export let QQVersionConfigPath: string | undefined = getQQVersionConfigPath(QQMainPath);
|
||||||
|
|
||||||
export const pkgInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'package.json');
|
//基础信息获取 无快更则启用默认模板填充
|
||||||
let configVersionInfoPath;
|
export let isQuickUpdate: boolean = !!QQVersionConfigPath;
|
||||||
|
export let QQVersionConfig: QQVersionConfigType = isQuickUpdate ? JSON.parse(fs.readFileSync(QQVersionConfigPath!).toString()) : getDefaultQQVersionConfigInfo();
|
||||||
|
export let QQPackageInfo: QQPackageInfoType = JSON.parse(fs.readFileSync(QQPackageInfoPath).toString());
|
||||||
|
export let { appid: QQVersionAppid, qua: QQVersionQua } = getAppidV2();
|
||||||
|
|
||||||
if (os.platform() !== 'linux') {
|
//基础函数
|
||||||
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
export function getQQBuildStr() {
|
||||||
} else {
|
return isQuickUpdate ? QQVersionConfig.buildId : QQPackageInfo.buildVersion;
|
||||||
const userPath = os.homedir();
|
|
||||||
const appDataPath = path.resolve(userPath, './.config/QQ');
|
|
||||||
configVersionInfoPath = path.resolve(appDataPath, './versions/config.json');
|
|
||||||
}
|
}
|
||||||
|
export function getFullQQVesion() {
|
||||||
if (typeof configVersionInfoPath !== 'string') {
|
return isQuickUpdate ? QQVersionConfig.curVersion : QQPackageInfo.version;
|
||||||
throw new Error('Something went wrong when load QQ info path');
|
|
||||||
}
|
}
|
||||||
|
export function requireMinNTQQBuild(buildStr: string) {
|
||||||
export { configVersionInfoPath };
|
return parseInt(getQQBuildStr()) >= parseInt(buildStr);
|
||||||
|
|
||||||
type QQPkgInfo = {
|
|
||||||
version: string;
|
|
||||||
buildVersion: string;
|
|
||||||
platform: string;
|
|
||||||
eleArch: string;
|
|
||||||
}
|
}
|
||||||
type QQVersionConfigInfo = {
|
//此方法不要直接使用
|
||||||
baseVersion: string;
|
export function getQUAInternal() {
|
||||||
curVersion: string;
|
return systemPlatform === 'linux' ? `V1_LNX_NQ_${getFullQQVesion()}_${getQQBuildStr()}_GW_B` : `V1_WIN_NQ_${getFullQQVesion()}_${getQQBuildStr()}_GW_B`;
|
||||||
prevVersion: string;
|
|
||||||
onErrorVersions: Array<any>;
|
|
||||||
buildId: string;
|
|
||||||
}
|
}
|
||||||
|
export function getAppidV2(): { appid: string, qua: string } {
|
||||||
let _qqVersionConfigInfo: QQVersionConfigInfo = {
|
let appidTbale = AppidTable as unknown as QQAppidTableType;
|
||||||
'baseVersion': '9.9.12-25765',
|
|
||||||
'curVersion': '9.9.12-25765',
|
|
||||||
'prevVersion': '',
|
|
||||||
'onErrorVersions': [],
|
|
||||||
'buildId': '25765'
|
|
||||||
};
|
|
||||||
|
|
||||||
if (fs.existsSync(configVersionInfoPath)) {
|
|
||||||
try {
|
try {
|
||||||
const _ =JSON.parse(fs.readFileSync(configVersionInfoPath).toString());
|
let data = appidTbale[getFullQQVesion()];
|
||||||
_qqVersionConfigInfo = Object.assign(_qqVersionConfigInfo, _);
|
if (data) {
|
||||||
} catch (e) {
|
return data;
|
||||||
logError('Load QQ version config info failed, Use default version', e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (e) {
|
||||||
export const qqVersionConfigInfo: QQVersionConfigInfo = _qqVersionConfigInfo;
|
log('[QQ版本兼容性检测] 版本兼容性不佳,可能会导致一些功能无法正常使用', e);
|
||||||
//V1_WIN_NQ_9.9.12_25765_GW_B
|
}
|
||||||
export const qqPkgInfo: QQPkgInfo = JSON.parse(fs.readFileSync(pkgInfoPath).toString());
|
// 以下是兜底措施
|
||||||
|
return { appid: systemPlatform === 'linux' ? '537237950' : '537237765', qua: getQUAInternal() };
|
||||||
|
}
|
||||||
// platform_type: 3,
|
// platform_type: 3,
|
||||||
// app_type: 4,
|
// app_type: 4,
|
||||||
// app_version: '9.9.12-25765',
|
// app_version: '9.9.12-25765',
|
||||||
@@ -64,14 +51,6 @@ export const qqPkgInfo: QQPkgInfo = JSON.parse(fs.readFileSync(pkgInfoPath).toSt
|
|||||||
// appid: '537234702',
|
// appid: '537234702',
|
||||||
// platVer: '10.0.26100',
|
// platVer: '10.0.26100',
|
||||||
// clientVer: '9.9.9-25765',
|
// clientVer: '9.9.9-25765',
|
||||||
|
|
||||||
// Linux
|
// Linux
|
||||||
// app_version: '3.2.9-25765',
|
// app_version: '3.2.9-25765',
|
||||||
// qua: 'V1_LNX_NQ_3.2.10_25765_GW_B',
|
// qua: 'V1_LNX_NQ_3.2.10_25765_GW_B',
|
||||||
|
|
||||||
let _appid: string = '537234702'; // 默认为 Windows 平台的 appid
|
|
||||||
if (systemPlatform === 'linux') {
|
|
||||||
_appid = '537234773';
|
|
||||||
}
|
|
||||||
// todo: mac 平台的 appid
|
|
||||||
export const appid = _appid;
|
|
@@ -1,10 +1,11 @@
|
|||||||
import crypto from 'node:crypto';
|
import crypto from 'node:crypto';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs';
|
||||||
import { log, logDebug } from './log';
|
import { log, logDebug } from './log';
|
||||||
import { dirname } from 'node:path';
|
import { dirname } from 'node:path';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
import * as fsPromise from 'node:fs/promises';
|
import * as fsPromise from 'node:fs/promises';
|
||||||
|
import os from 'node:os';
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
@@ -304,14 +305,14 @@ export function migrateConfig(oldConfig: any) {
|
|||||||
}
|
}
|
||||||
// 升级旧的配置到新的
|
// 升级旧的配置到新的
|
||||||
export async function UpdateConfig() {
|
export async function UpdateConfig() {
|
||||||
const configFiles = await fs.readdir(path.join(__dirname, 'config'));
|
const configFiles = await fsPromise.readdir(path.join(__dirname, 'config'));
|
||||||
for (const file of configFiles) {
|
for (const file of configFiles) {
|
||||||
if (file.match(/^onebot11_\d+.json$/)) {
|
if (file.match(/^onebot11_\d+.json$/)) {
|
||||||
const CurrentConfig = JSON.parse(await fs.readFile(path.join(__dirname, 'config', file), 'utf8'));
|
const CurrentConfig = JSON.parse(await fsPromise.readFile(path.join(__dirname, 'config', file), 'utf8'));
|
||||||
if (isValidOldConfig(CurrentConfig)) {
|
if (isValidOldConfig(CurrentConfig)) {
|
||||||
log('正在迁移旧配置到新配置 File:', file);
|
log('正在迁移旧配置到新配置 File:', file);
|
||||||
const NewConfig = migrateConfig(CurrentConfig);
|
const NewConfig = migrateConfig(CurrentConfig);
|
||||||
await fs.writeFile(path.join(__dirname, 'config', file), JSON.stringify(NewConfig, null, 2));
|
await fsPromise.writeFile(path.join(__dirname, 'config', file), JSON.stringify(NewConfig, null, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -331,7 +332,56 @@ export function isEqual(obj1: any, obj2: any) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
export function getDefaultQQVersionConfigInfo(): QQVersionConfigType {
|
||||||
|
if (os.platform() === 'linux') {
|
||||||
|
return {
|
||||||
|
baseVersion: '3.2.12-26702',
|
||||||
|
curVersion: '3.2.12-26702',
|
||||||
|
prevVersion: '',
|
||||||
|
onErrorVersions: [],
|
||||||
|
buildId: '26702'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
baseVersion: '9.9.15-26702',
|
||||||
|
curVersion: '9.9.15-26702',
|
||||||
|
prevVersion: '',
|
||||||
|
onErrorVersions: [],
|
||||||
|
buildId: '26702'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
export async function promisePipeline(promises: Promise<any>[], callback: (result: any) => boolean): Promise<void> {
|
||||||
|
let callbackCalled = false;
|
||||||
|
for (const promise of promises) {
|
||||||
|
if (callbackCalled) break;
|
||||||
|
try {
|
||||||
|
const result = await promise;
|
||||||
|
if (!callbackCalled) {
|
||||||
|
callbackCalled = callback(result);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in promise pipeline:", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getQQVersionConfigPath(exePath: string = ""): string | undefined {
|
||||||
|
let configVersionInfoPath;
|
||||||
|
if (os.platform() !== 'linux') {
|
||||||
|
configVersionInfoPath = path.join(path.dirname(exePath), 'resources', 'app', 'versions', 'config.json');
|
||||||
|
} else {
|
||||||
|
const userPath = os.homedir();
|
||||||
|
const appDataPath = path.resolve(userPath, './.config/QQ');
|
||||||
|
configVersionInfoPath = path.resolve(appDataPath, './versions/config.json');
|
||||||
|
}
|
||||||
|
if (typeof configVersionInfoPath !== 'string') {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (!fs.existsSync(configVersionInfoPath)) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return configVersionInfoPath;
|
||||||
|
}
|
||||||
export async function deleteOldFiles(directoryPath: string, daysThreshold: number) {
|
export async function deleteOldFiles(directoryPath: string, daysThreshold: number) {
|
||||||
try {
|
try {
|
||||||
const files = await fsPromise.readdir(directoryPath);
|
const files = await fsPromise.readdir(directoryPath);
|
||||||
|
@@ -1,31 +1,17 @@
|
|||||||
/**
|
//QQVersionType
|
||||||
* 运行时类型转换与检查类
|
type QQPackageInfoType = {
|
||||||
*/
|
version: string;
|
||||||
export class TypeCheck {
|
buildVersion: string;
|
||||||
static isEmpty(value: any): boolean {
|
platform: string;
|
||||||
return value === null || value === undefined || value === '' ||
|
eleArch: string;
|
||||||
(Array.isArray(value) && value.length === 0) || (typeof value === 'object' && Object.keys(value).length === 0);
|
|
||||||
}
|
}
|
||||||
|
type QQVersionConfigType = {
|
||||||
|
baseVersion: string;
|
||||||
|
curVersion: string;
|
||||||
|
prevVersion: string;
|
||||||
|
onErrorVersions: Array<any>;
|
||||||
|
buildId: string;
|
||||||
}
|
}
|
||||||
|
type QQAppidTableType = {
|
||||||
export class TypeConvert {
|
[key: string]: { appid: string, qua: string };
|
||||||
static toNumber(value: any): number {
|
|
||||||
const num = Number(value);
|
|
||||||
if (isNaN(num)) {
|
|
||||||
throw new Error(`无法将输入转换为数字: ${value}`);
|
|
||||||
}
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
static toString(value: any): string {
|
|
||||||
return String(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static toBoolean(value: any): boolean {
|
|
||||||
return Boolean(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static toArray(value: any): any[] {
|
|
||||||
return Array.isArray(value) ? value : [value];
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -1,11 +1,66 @@
|
|||||||
import { FriendRequest, User } from '@/core/entities';
|
import { FriendRequest, FriendV2, SimpleInfo, User } from '@/core/entities';
|
||||||
import { napCatCore, OnBuddyChangeParams } from '@/core';
|
import { BuddyListReqType, napCatCore, NodeIKernelBuddyListener, NodeIKernelProfileService, OnBuddyChangeParams } from '@/core';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
|
import { LimitedHashTable } from '@/common/utils/MessageUnique';
|
||||||
|
import { CacheClassFuncAsyncExtend } from '@/common/utils/helper';
|
||||||
export class NTQQFriendApi {
|
export class NTQQFriendApi {
|
||||||
|
static async getBuddyV2(refresh = false): Promise<FriendV2[]> {
|
||||||
|
let uids: string[] = [];
|
||||||
|
const buddyService = napCatCore.session.getBuddyService();
|
||||||
|
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||||
|
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
||||||
|
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
|
);
|
||||||
|
return Array.from(data.values());
|
||||||
|
}
|
||||||
|
@CacheClassFuncAsyncExtend(3600 * 1000, 'getBuddyIdMap', () => true)
|
||||||
|
static async getBuddyIdMapCache(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
|
return await NTQQFriendApi.getBuddyIdMap(refresh);
|
||||||
|
}
|
||||||
|
static async getBuddyIdMap(refresh = false): Promise<LimitedHashTable<string, string>> {
|
||||||
|
let uids: string[] = [];
|
||||||
|
let retMap: LimitedHashTable<string, string> = new LimitedHashTable<string, string>(5000);
|
||||||
|
const buddyService = napCatCore.session.getBuddyService();
|
||||||
|
const buddyListV2 = refresh ? await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL) : await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL);
|
||||||
|
uids.push(...buddyListV2.data.flatMap(item => item.buddyUids));
|
||||||
|
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
|
);
|
||||||
|
data.forEach((value, key) => {
|
||||||
|
retMap.set(value.uin!, value.uid!);
|
||||||
|
});
|
||||||
|
//console.log('getBuddyIdMap', retMap.getValue);
|
||||||
|
return retMap;
|
||||||
|
}
|
||||||
|
static async getBuddyV2ExWithCate(refresh = false) {
|
||||||
|
let uids: string[] = [];
|
||||||
|
let categoryMap: Map<string, any> = new Map();
|
||||||
|
const buddyService = napCatCore.session.getBuddyService();
|
||||||
|
const buddyListV2 = refresh ? (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data : (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
||||||
|
uids.push(
|
||||||
|
...buddyListV2.flatMap(item => {
|
||||||
|
item.buddyUids.forEach(uid => {
|
||||||
|
categoryMap.set(uid, { categoryId: item.categoryId, categroyName: item.categroyName });
|
||||||
|
});
|
||||||
|
return item.buddyUids
|
||||||
|
}));
|
||||||
|
const data = await NTEventDispatch.CallNoListenerEvent<NodeIKernelProfileService['getCoreAndBaseInfo']>(
|
||||||
|
'NodeIKernelProfileService/getCoreAndBaseInfo', 5000, 'nodeStore', uids
|
||||||
|
);
|
||||||
|
return Array.from(data).map(([key, value]) => {
|
||||||
|
const category = categoryMap.get(key);
|
||||||
|
return category ? { ...value, categoryId: category.categoryId, categroyName: category.categroyName } : value;
|
||||||
|
});
|
||||||
|
}
|
||||||
static async isBuddy(uid: string) {
|
static async isBuddy(uid: string) {
|
||||||
return napCatCore.session.getBuddyService().isBuddy(uid);
|
return napCatCore.session.getBuddyService().isBuddy(uid);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param forced
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
static async getFriends(forced = false): Promise<User[]> {
|
static async getFriends(forced = false): Promise<User[]> {
|
||||||
let [_retData, _BuddyArg] = await NTEventDispatch.CallNormalEvent
|
let [_retData, _BuddyArg] = await NTEventDispatch.CallNormalEvent
|
||||||
<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
<(force: boolean) => Promise<any>, (arg: OnBuddyChangeParams) => void>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { GroupMember, GroupRequestOperateTypes, GroupMemberRole, GroupNotify, Group, MemberExtSourceType, GroupNotifyTypes, ChatType, Peer } from '../entities';
|
import { GroupMember, GroupRequestOperateTypes, GroupMemberRole, GroupNotify, Group, MemberExtSourceType, GroupNotifyTypes, ChatType, Peer, GroupListUpdateType } from '../entities';
|
||||||
import { GeneralCallResult, NTQQUserApi, napCatCore } from '@/core';
|
import { GeneralCallResult, NTQQUserApi, NodeIKernelGroupListener, NodeIKernelGroupService, napCatCore } from '@/core';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
import { log } from '@/common/utils/log';
|
import { log } from '@/common/utils/log';
|
||||||
import { groupMembers } from '../data';
|
import { groupMembers } from '../data';
|
||||||
@@ -9,20 +9,21 @@ export class NTQQGroupApi {
|
|||||||
return napCatCore.session.getGroupService().setHeader(gc, filePath);
|
return napCatCore.session.getGroupService().setHeader(gc, filePath);
|
||||||
}
|
}
|
||||||
static async getGroups(forced = false) {
|
static async getGroups(forced = false) {
|
||||||
|
type ListenerType = NodeIKernelGroupListener['onGroupListUpdate'];
|
||||||
let [_retData, _updateType, groupList] = await NTEventDispatch.CallNormalEvent
|
let [_retData, _updateType, groupList] = await NTEventDispatch.CallNormalEvent
|
||||||
<(force: boolean) => Promise<any>, (updateType: number, groupList: Group[]) => void>
|
<(force: boolean) => Promise<any>, ListenerType>
|
||||||
(
|
(
|
||||||
'NodeIKernelGroupService/getGroupList',
|
'NodeIKernelGroupService/getGroupList',
|
||||||
'NodeIKernelGroupListener/onGroupListUpdate',
|
'NodeIKernelGroupListener/onGroupListUpdate',
|
||||||
1,
|
1,
|
||||||
5000,
|
5000,
|
||||||
() => true,
|
(updateType) => true,
|
||||||
forced
|
forced
|
||||||
);
|
);
|
||||||
return groupList;
|
return groupList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@CacheClassFuncAsyncExtend(600, "LastestSendTime", () => true)
|
@CacheClassFuncAsyncExtend(3600 * 1000, "LastestSendTime", () => true)
|
||||||
static async getGroupMemberLastestSendTimeCache(GroupCode: string) {
|
static async getGroupMemberLastestSendTimeCache(GroupCode: string) {
|
||||||
return NTQQGroupApi.getGroupMemberLastestSendTime(GroupCode);
|
return NTQQGroupApi.getGroupMemberLastestSendTime(GroupCode);
|
||||||
}
|
}
|
||||||
@@ -80,6 +81,9 @@ export class NTQQGroupApi {
|
|||||||
});
|
});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
static async getGroupMemberAll(GroupCode: string, forced = false) {
|
||||||
|
return napCatCore.session.getGroupService().getAllMemberList(GroupCode, forced);
|
||||||
|
}
|
||||||
static async getLastestMsg(GroupCode: string, uins: string[]) {
|
static async getLastestMsg(GroupCode: string, uins: string[]) {
|
||||||
let uids: Array<string> = [];
|
let uids: Array<string> = [];
|
||||||
for (let uin of uins) {
|
for (let uin of uins) {
|
||||||
@@ -154,6 +158,25 @@ export class NTQQGroupApi {
|
|||||||
);
|
);
|
||||||
return notifies;
|
return notifies;
|
||||||
}
|
}
|
||||||
|
static async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
||||||
|
type ListenerType = NodeIKernelGroupListener['onMemberInfoChange'];
|
||||||
|
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
||||||
|
// NTEventDispatch.CreatListenerFunction('NodeIKernelGroupListener/onGroupMemberInfoUpdate',
|
||||||
|
//return napCatCore.session.getGroupService().getMemberInfo(GroupCode, [uid], forced);
|
||||||
|
const [ret, _groupCode, _changeType, _members] = await NTEventDispatch.CallNormalEvent
|
||||||
|
<EventType, ListenerType>
|
||||||
|
(
|
||||||
|
'NodeIKernelGroupService/getMemberInfo',
|
||||||
|
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||||
|
1,
|
||||||
|
5000,
|
||||||
|
(groupCode: string, changeType: number, members: Map<string, GroupMember>) => {
|
||||||
|
return groupCode == GroupCode && members.has(uid);
|
||||||
|
},
|
||||||
|
GroupCode, [uid], forced
|
||||||
|
);
|
||||||
|
return _members.get(uid);
|
||||||
|
}
|
||||||
static async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
static async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||||
const groupService = napCatCore.session.getGroupService();
|
const groupService = napCatCore.session.getGroupService();
|
||||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||||
@@ -161,6 +184,7 @@ export class NTQQGroupApi {
|
|||||||
if (result.errCode !== 0) {
|
if (result.errCode !== 0) {
|
||||||
throw ('获取群成员列表出错,' + result.errMsg);
|
throw ('获取群成员列表出错,' + result.errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
//logDebug(`获取群(${groupQQ})成员列表结果:`, `finish: ${result.result.finish}`); //, Array.from(result.result.infos.values()));
|
//logDebug(`获取群(${groupQQ})成员列表结果:`, `finish: ${result.result.finish}`); //, Array.from(result.result.infos.values()));
|
||||||
return result.result.infos;
|
return result.result.infos;
|
||||||
/*
|
/*
|
||||||
|
@@ -1,15 +1,13 @@
|
|||||||
import { ElementType, GetFileListParam, MessageElement, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities';
|
import { GetFileListParam, Peer, RawMessage, SendMessageElement, SendMsgElementConstructor } from '@/core/entities';
|
||||||
import { friends, groups, selfInfo } from '@/core/data';
|
import { friends, groups, selfInfo } from '@/core/data';
|
||||||
import { log, logError, logWarn } from '@/common/utils/log';
|
import { log, logWarn } from '@/common/utils/log';
|
||||||
import { sleep } from '@/common/utils/helper';
|
import { sleep } from '@/common/utils/helper';
|
||||||
import { napCatCore, NodeIKernelMsgService, NTQQUserApi } from '@/core';
|
import { napCatCore, NTQQUserApi } from '@/core';
|
||||||
import { NodeIKernelMsgListener, onGroupFileInfoUpdateParamType } from '@/core/listeners';
|
import { onGroupFileInfoUpdateParamType } from '@/core/listeners';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
import { MessageUnique } from '../../../common/utils/MessageUnique';
|
import { MessageUnique } from '../../../common/utils/MessageUnique';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
import { logNotice } from '@/onebot11/log';
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
import { c } from 'vite/dist/node/types.d-aGj9QkWt';
|
|
||||||
//let MsgSendMode = 2;
|
|
||||||
|
|
||||||
async function LoadMessageIdList(Peer: Peer, msgId: string) {
|
async function LoadMessageIdList(Peer: Peer, msgId: string) {
|
||||||
let msgList = await NTQQMsgApi.getMsgHistory(Peer, msgId, 50);
|
let msgList = await NTQQMsgApi.getMsgHistory(Peer, msgId, 50);
|
||||||
@@ -45,6 +43,8 @@ setTimeout(() => {
|
|||||||
await sleep(100);
|
await sleep(100);
|
||||||
// NTQQMsgApi.CheckSendMode().then().catch();
|
// NTQQMsgApi.CheckSendMode().then().catch();
|
||||||
loadMessageUnique().then().catch();
|
loadMessageUnique().then().catch();
|
||||||
|
//let data = await napCatCore.session.getMsgService().sendSsoCmdReqByContend("LightAppSvc.mini_app_growguard.ReportExecute","1124343");
|
||||||
|
//console.log(data);
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
//歇菜LocalMsg压根不写Db
|
//歇菜LocalMsg压根不写Db
|
||||||
@@ -65,26 +65,8 @@ setTimeout(() => {
|
|||||||
// ));
|
// ));
|
||||||
// console.log(await NTQQMsgApi.multiForwardMsg(peer, peer, [MsgId]));
|
// console.log(await NTQQMsgApi.multiForwardMsg(peer, peer, [MsgId]));
|
||||||
// }, 25000)
|
// }, 25000)
|
||||||
|
|
||||||
export class NTQQMsgApi {
|
export class NTQQMsgApi {
|
||||||
// static async CheckSendMode() {
|
|
||||||
// try {
|
|
||||||
// NTQQMsgApi.sendMsgV2({ chatType: 1, peerUid: selfInfo.uid }, [SendMsgElementConstructor.text('消息队列模式测试')], true, 10000).then().catch();
|
|
||||||
// MsgSendMode = 2;
|
|
||||||
// logNotice('[消息队列] 消息模式确认: MsgId异步队列');
|
|
||||||
// return true;
|
|
||||||
// } catch (error) {
|
|
||||||
// logNotice('[消息队列] 消息模式失败: MsgId异步队列');
|
|
||||||
// }
|
|
||||||
// try {
|
|
||||||
// NTQQMsgApi.sendMsgV1({ chatType: 1, peerUid: selfInfo.uid }, [SendMsgElementConstructor.text('消息队列模式测试')], true, 10000).then().catch();
|
|
||||||
// MsgSendMode = 1;
|
|
||||||
// logNotice('[消息队列] 消息模式确认: MsgSeq异步队列');
|
|
||||||
// return true;
|
|
||||||
// } catch (error) {
|
|
||||||
// logNotice('[消息队列] 消息模式失败: MsgSeq异步队列');
|
|
||||||
// }
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// static napCatCore: NapCatCore | null = null;
|
// static napCatCore: NapCatCore | null = null;
|
||||||
// enum BaseEmojiType {
|
// enum BaseEmojiType {
|
||||||
// NORMAL_EMOJI,
|
// NORMAL_EMOJI,
|
||||||
@@ -105,7 +87,7 @@ export class NTQQMsgApi {
|
|||||||
} | undefined> {
|
} | undefined> {
|
||||||
return napCatCore.session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId);
|
return napCatCore.session.getMsgService().getMultiMsg(peer, rootMsgId, parentMsgId);
|
||||||
}
|
}
|
||||||
static async getLastestMsgByUids(peer: Peer) {
|
static async getLastestMsgByUids(peer: Peer, count: number = 20) {
|
||||||
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
let ret = await napCatCore.session.getMsgService().queryMsgsWithFilterEx('0', '0', '0', {
|
||||||
chatInfo: peer,
|
chatInfo: peer,
|
||||||
filterMsgType: [],
|
filterMsgType: [],
|
||||||
@@ -142,9 +124,6 @@ export class NTQQMsgApi {
|
|||||||
}
|
}
|
||||||
static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
static async getMsgsBySeqAndCount(peer: Peer, seq: string, count: number, desc: boolean, z: boolean) {
|
||||||
return await napCatCore.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
return await napCatCore.session.getMsgService().getMsgsBySeqAndCount(peer, seq, count, desc, z);
|
||||||
}
|
|
||||||
static async testMode() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
static async setMsgRead(peer: Peer) {
|
static async setMsgRead(peer: Peer) {
|
||||||
return napCatCore.session.getMsgService().setMsgRead(peer);
|
return napCatCore.session.getMsgService().setMsgRead(peer);
|
||||||
@@ -176,7 +155,7 @@ export class NTQQMsgApi {
|
|||||||
peerUid: peer.peerUid
|
peerUid: peer.peerUid
|
||||||
}, msgIds);
|
}, msgIds);
|
||||||
}
|
}
|
||||||
static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
static async sendMsgV2(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
// function generateMsgId() {
|
// function generateMsgId() {
|
||||||
// const timestamp = Math.floor(Date.now() / 1000);
|
// const timestamp = Math.floor(Date.now() / 1000);
|
||||||
// const random = Math.floor(Math.random() * Math.pow(2, 32));
|
// const random = Math.floor(Math.random() * Math.pow(2, 32));
|
||||||
@@ -187,7 +166,7 @@ export class NTQQMsgApi {
|
|||||||
// return msgId;
|
// return msgId;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
let msgId = await NTQQMsgApi.getMsgUnique(peer.chatType, await NTQQMsgApi.getServerTime());
|
||||||
let data = await NTEventDispatch.CallNormalEvent<
|
let data = await NTEventDispatch.CallNormalEvent<
|
||||||
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||||
(msgList: RawMessage[]) => void
|
(msgList: RawMessage[]) => void
|
||||||
@@ -219,56 +198,44 @@ export class NTQQMsgApi {
|
|||||||
static sendMsgEx(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
static sendMsgEx(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
//return NTQQMsgApi.sendMsgV1(peer, msgElements, waitComplete, timeout);
|
//return NTQQMsgApi.sendMsgV1(peer, msgElements, waitComplete, timeout);
|
||||||
}
|
}
|
||||||
static async sendMsgV1(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
static async sendMsg(peer: Peer, msgElements: SendMessageElement[], waitComplete = true, timeout = 10000) {
|
||||||
let msgList = await NTQQMsgApi.getLastestMsgByUids(peer);
|
//唉? !我有个想法
|
||||||
let msgCurrentSeq = 0n;
|
let msgId = await NTQQMsgApi.getMsgUnique(peer.chatType, await NTQQMsgApi.getServerTime());
|
||||||
if (msgList.msgList.length > 0) {
|
peer.guildId = msgId;
|
||||||
msgCurrentSeq = BigInt(msgList.msgList[0].msgSeq);
|
let data = await NTEventDispatch.CallNormalEvent<
|
||||||
}
|
(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>) => Promise<unknown>,
|
||||||
let rawMsg: RawMessage | undefined;
|
(msgList: RawMessage[]) => void
|
||||||
let onAddSendMsgListener = NTEventDispatch.RegisterListen<NodeIKernelMsgListener['onAddSendMsg']>('NodeIKernelMsgListener/onAddSendMsg', 1, timeout, (msg: RawMessage) => {
|
>(
|
||||||
//console.log("msgSeq:", msgCurrentSeq.toString(), JSON.stringify(msgList.msgList[0], null, 4));
|
'NodeIKernelMsgService/sendMsg',
|
||||||
if (msg.peerUid == peer.peerUid && (msgCurrentSeq == 0n || msgList.msgList[0].msgSeq == msgCurrentSeq.toString())) {
|
'NodeIKernelMsgListener/onMsgInfoListUpdate',
|
||||||
rawMsg = msg;
|
1,
|
||||||
return true;
|
timeout,
|
||||||
}
|
(msgRecords: RawMessage[]) => {
|
||||||
return false;
|
for (let msgRecord of msgRecords) {
|
||||||
}).catch(logError);
|
if (msgRecord.guildId === msgId && msgRecord.sendStatus === 2) {
|
||||||
let MsgInfoListUpdateListener = NTEventDispatch.RegisterListen<NodeIKernelMsgListener['onMsgInfoListUpdate']>('NodeIKernelMsgListener/onMsgInfoListUpdate', 1, timeout,
|
|
||||||
(msgList: RawMessage[]) => {
|
|
||||||
for (let msg of msgList) {
|
|
||||||
if (msg.peerUid == peer.peerUid && rawMsg && rawMsg.msgId == msg.msgId && msg.sendStatus == 2) {
|
|
||||||
rawMsg = msg;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}).catch(logError);
|
},
|
||||||
let data = await napCatCore.session.getMsgService().sendMsg("0", peer, msgElements, new Map());
|
"0",
|
||||||
//await NTEventDispatch.CallNoListenerEvent<NodeIKernelMsgService['sendMsg']>('NodeIKernelMsgService/sendMsg', timeout, "0", peer, msgElements, new Map());
|
peer,
|
||||||
await onAddSendMsgListener;
|
msgElements,
|
||||||
if (data.result !== 0 && rawMsg) {
|
new Map()
|
||||||
//发送失败msgid
|
);
|
||||||
await napCatCore.session.getMsgService().deleteMsg(peer, [rawMsg.msgId]);
|
let retMsg = data[1].find(msgRecord => {
|
||||||
throw new Error('发送消息失败');
|
if (msgRecord.guildId === msgId) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
await MsgInfoListUpdateListener;
|
});
|
||||||
// console.log("rawMsg", JSON.stringify(rawMsg, null, 4));
|
return retMsg;
|
||||||
if (rawMsg) {
|
|
||||||
return rawMsg;
|
|
||||||
}
|
}
|
||||||
throw new Error('发送消息超时');
|
static async getMsgUnique(chatType: number, time: string) {
|
||||||
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
return napCatCore.session.getMsgService().generateMsgUniqueId(chatType, time);
|
||||||
}
|
}
|
||||||
static async getMsgUniqueEx() {
|
|
||||||
let msgId = await NTQQMsgApi.getMsgUnique(await NTQQMsgApi.getServerTime());
|
|
||||||
return msgId;
|
|
||||||
}
|
|
||||||
static async getMsgUnique(time: string) {
|
|
||||||
return napCatCore.session.getMsgService().getMsgUniqueId(time);
|
return napCatCore.session.getMsgService().getMsgUniqueId(time);
|
||||||
}
|
}
|
||||||
static async getMsgUniqueByTimeV2() {
|
|
||||||
return NTEventDispatch.CallNoListenerEvent<NodeIKernelMsgService['getMsgUniqueId']>('NodeIKernelMsgService/getMsgUniqueId', 5000, await NTQQMsgApi.getServerTimeV2())
|
|
||||||
}
|
|
||||||
static async getServerTime() {
|
static async getServerTime() {
|
||||||
return napCatCore.session.getMSFService().getServerTime();
|
return napCatCore.session.getMSFService().getServerTime();
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,13 @@
|
|||||||
import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin } from '@/core/entities';
|
import { ModifyProfileParams, SelfInfo, User, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '@/core/entities';
|
||||||
import { friends, groupMembers, selfInfo } from '@/core/data';
|
import { friends, groupMembers, selfInfo } from '@/core/data';
|
||||||
import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper';
|
import { CacheClassFuncAsync, CacheClassFuncAsyncExtend } from '@/common/utils/helper';
|
||||||
import { napCatCore } from '@/core';
|
import { napCatCore, NTQQFriendApi } from '@/core';
|
||||||
import { NodeIKernelProfileListener, ProfileListener } from '@/core/listeners';
|
import { NodeIKernelProfileListener, ProfileListener } from '@/core/listeners';
|
||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/utils/request';
|
||||||
import { logWarn } from '@/common/utils/log';
|
import { logWarn } from '@/common/utils/log';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
import { NodeIKernelProfileService } from '@/core/services';
|
import { NodeIKernelProfileService, ProfileBizType, UserDetailSource } from '@/core/services';
|
||||||
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
export class NTQQUserApi {
|
export class NTQQUserApi {
|
||||||
static async getProfileLike(uid: string) {
|
static async getProfileLike(uid: string) {
|
||||||
@@ -50,21 +51,87 @@ export class NTQQUserApi {
|
|||||||
return napCatCore.session.getGroupService().setHeader(gc, filePath);
|
return napCatCore.session.getGroupService().setHeader(gc, filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getSelfInfo() {
|
static async fetchUserDetailInfos(uids: string[]) {
|
||||||
|
//26702 以上使用新接口 .Dev Mlikiowa
|
||||||
|
type EventService = NodeIKernelProfileService['fetchUserDetailInfo'];
|
||||||
|
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged'];
|
||||||
|
let retData: User[] = [];
|
||||||
|
let [_retData, _retListener] = await NTEventDispatch.CallNormalEvent
|
||||||
|
<EventService, EventListener>
|
||||||
|
(
|
||||||
|
'NodeIKernelProfileService/fetchUserDetailInfo',
|
||||||
|
'NodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||||
|
uids.length,
|
||||||
|
5000,
|
||||||
|
(profile) => {
|
||||||
|
if (uids.includes(profile.uid)) {
|
||||||
|
let 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;
|
||||||
|
},
|
||||||
|
"BuddyProfileStore",
|
||||||
|
uids,
|
||||||
|
UserDetailSource.KSERVER,
|
||||||
|
[
|
||||||
|
ProfileBizType.KALL
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
static async getUserInfo(uid: string) {
|
return retData;
|
||||||
|
}
|
||||||
|
static async fetchUserDetailInfo(uid: string) {
|
||||||
|
type EventService = NodeIKernelProfileService['fetchUserDetailInfo'];
|
||||||
|
type EventListener = NodeIKernelProfileListener['onUserDetailInfoChanged'];
|
||||||
|
let [_retData, profile] = await NTEventDispatch.CallNormalEvent
|
||||||
|
<EventService, EventListener>
|
||||||
|
(
|
||||||
|
'NodeIKernelProfileService/fetchUserDetailInfo',
|
||||||
|
'NodeIKernelProfileListener/onUserDetailInfoChanged',
|
||||||
|
1,
|
||||||
|
5000,
|
||||||
|
(profile) => {
|
||||||
|
if (profile.uid === uid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
"BuddyProfileStore",
|
||||||
|
[
|
||||||
|
uid
|
||||||
|
],
|
||||||
|
UserDetailSource.KSERVER,
|
||||||
|
[
|
||||||
|
ProfileBizType.KALL
|
||||||
|
]
|
||||||
|
);
|
||||||
|
let RetUser: User = {
|
||||||
|
...profile.simpleInfo.coreInfo,
|
||||||
|
...profile.simpleInfo.status,
|
||||||
|
...profile.simpleInfo.vasInfo,
|
||||||
|
...profile.commonExt,
|
||||||
|
...profile.simpleInfo.baseInfo,
|
||||||
|
qqLevel: profile.commonExt.qqLevel,
|
||||||
|
pendantId: ""
|
||||||
|
};
|
||||||
|
return RetUser;
|
||||||
}
|
}
|
||||||
// enum ProfileBizType {
|
|
||||||
// KALL,
|
|
||||||
// KBASEEXTEND,
|
|
||||||
// KVAS,
|
|
||||||
// KQZONE,
|
|
||||||
// KOTHER
|
|
||||||
// }
|
|
||||||
static async getUserDetailInfo(uid: string) {
|
static async getUserDetailInfo(uid: string) {
|
||||||
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
return this.fetchUserDetailInfo(uid);
|
||||||
|
}
|
||||||
|
return this.getUserDetailInfoOld(uid);
|
||||||
|
}
|
||||||
|
static async getUserDetailInfoOld(uid: string) {
|
||||||
type EventService = NodeIKernelProfileService['getUserDetailInfoWithBizInfo'];
|
type EventService = NodeIKernelProfileService['getUserDetailInfoWithBizInfo'];
|
||||||
type EventListener = NodeIKernelProfileListener['onProfileDetailInfoChanged'];
|
type EventListener = NodeIKernelProfileListener['onProfileDetailInfoChanged'];
|
||||||
let [_retData, profile] = await NTEventDispatch.CallNormalEvent
|
let [_retData, profile] = await NTEventDispatch.CallNormalEvent
|
||||||
@@ -135,22 +202,72 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
return skey;
|
return skey;
|
||||||
}
|
}
|
||||||
@CacheClassFuncAsyncExtend(3600, 'Uin2Uid', (Uin: string, Uid: string | undefined) => {
|
@CacheClassFuncAsyncExtend(3600 * 1000, 'Uin2Uid', (Uin: string, Uid: string | undefined) => {
|
||||||
if (Uid && Uid.indexOf('u_') != -1) {
|
if (Uid && Uid.indexOf('u_') != -1) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
logWarn("uin转换到uid时异常", Uin);
|
logWarn("uin转换到uid时异常", Uin, Uid);
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
static async getUidByUin(Uin: string) {
|
static async getUidByUin(Uin: string) {
|
||||||
//Uid 接口转
|
//此代码仅临时使用,后期会被废弃
|
||||||
let ret = await NTEventDispatch.CallNoListenerEvent
|
if (requireMinNTQQBuild('26702')) {
|
||||||
<(Uin: string[]) => Promise<{ uidInfo: Map<string, string> }>>(
|
return await NTQQUserApi.getUidByUinV2(Uin);
|
||||||
'NodeIKernelUixConvertService/getUid',
|
}
|
||||||
5000,
|
return await NTQQUserApi.getUidByUinV1(Uin);
|
||||||
[Uin]
|
}
|
||||||
);
|
@CacheClassFuncAsyncExtend(3600 * 1000, 'Uid2Uin', (Uid: string | undefined, Uin: number | undefined) => {
|
||||||
let uid = ret.uidInfo.get(Uin);
|
if (Uin && Uin != 0 && !isNaN(Uin)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
logWarn("uid转换到uin时异常", Uid, Uin);
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
static async getUinByUid(Uid: string) {
|
||||||
|
//此代码仅临时使用,后期会被废弃
|
||||||
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
return await NTQQUserApi.getUinByUidV2(Uid);
|
||||||
|
}
|
||||||
|
return await NTQQUserApi.getUinByUidV1(Uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
//后期改成流水线处理
|
||||||
|
static async getUidByUinV2(Uin: string) {
|
||||||
|
let uid = (await napCatCore.session.getProfileService().getUidByUin('FriendsServiceImpl', [Uin])).get(Uin);
|
||||||
|
if (uid) return uid;
|
||||||
|
uid = (await napCatCore.session.getGroupService().getUidByUins([Uin])).uids.get(Uin);
|
||||||
|
if (uid) return uid;
|
||||||
|
uid = (await napCatCore.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
||||||
|
if (uid) return uid;
|
||||||
|
console.log((await NTQQFriendApi.getBuddyIdMapCache(true)));
|
||||||
|
uid = (await NTQQFriendApi.getBuddyIdMapCache(true)).getValue(Uin);//从Buddy缓存获取Uid
|
||||||
|
if (uid) return uid;
|
||||||
|
uid = (await NTQQFriendApi.getBuddyIdMap(true)).getValue(Uin);
|
||||||
|
if (uid) return uid;
|
||||||
|
let unveifyUid = (await NTQQUserApi.getUserDetailInfoByUinV2(Uin)).detail.uid;//从QQ Native 特殊转换
|
||||||
|
if (unveifyUid.indexOf("*") == -1) uid = unveifyUid;
|
||||||
|
//if (uid) return uid;
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
//后期改成流水线处理
|
||||||
|
static async getUinByUidV2(Uid: string) {
|
||||||
|
let uin = (await napCatCore.session.getProfileService().getUinByUid('FriendsServiceImpl', [Uid])).get(Uid);
|
||||||
|
if (uin) return uin;
|
||||||
|
uin = (await napCatCore.session.getGroupService().getUinByUids([Uid])).uins.get(Uid);
|
||||||
|
if (uin) return uin;
|
||||||
|
uin = (await napCatCore.session.getUixConvertService().getUin([Uid])).uinInfo.get(Uid);
|
||||||
|
if (uin) return uin;
|
||||||
|
uin = (await NTQQFriendApi.getBuddyIdMapCache(true)).getKey(Uid);//从Buddy缓存获取Uin
|
||||||
|
if (uin) return uin;
|
||||||
|
uin = (await NTQQFriendApi.getBuddyIdMap(true)).getKey(Uid);
|
||||||
|
if (uin) return uin;
|
||||||
|
uin = (await NTQQUserApi.getUserDetailInfo(Uid)).uin; //从QQ Native 转换
|
||||||
|
return uin;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async getUidByUinV1(Uin: string) {
|
||||||
|
// 通用转换开始尝试
|
||||||
|
let uid = (await napCatCore.session.getUixConvertService().getUid([Uin])).uidInfo.get(Uin);
|
||||||
// Uid 好友转
|
// Uid 好友转
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
Array.from(friends.values()).forEach((t) => {
|
Array.from(friends.values()).forEach((t) => {
|
||||||
@@ -177,17 +294,7 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
@CacheClassFuncAsyncExtend(3600, 'Uid2Uin', (Uid: string | undefined, Uin: number | undefined) => {
|
static async getUinByUidV1(Uid: string) {
|
||||||
if (Uin && Uin != 0 && !isNaN(Uin)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
logWarn("uid转换到uin时异常", Uid);
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
static async getUinByUid(Uid: string | undefined) {
|
|
||||||
if (!Uid) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
let ret = await NTEventDispatch.CallNoListenerEvent
|
let ret = await NTEventDispatch.CallNoListenerEvent
|
||||||
<(Uin: string[]) => Promise<{ uinInfo: Map<string, string> }>>(
|
<(Uin: string[]) => Promise<{ uinInfo: Map<string, string> }>>(
|
||||||
'NodeIKernelUixConvertService/getUin',
|
'NodeIKernelUixConvertService/getUin',
|
||||||
@@ -227,6 +334,14 @@ export class NTQQUserApi {
|
|||||||
static async getRecentContactList() {
|
static async getRecentContactList() {
|
||||||
return await napCatCore.session.getRecentContactService().getRecentContactList();
|
return await napCatCore.session.getRecentContactService().getRecentContactList();
|
||||||
}
|
}
|
||||||
|
static async getUserDetailInfoByUinV2(Uin: string) {
|
||||||
|
return await NTEventDispatch.CallNoListenerEvent
|
||||||
|
<(Uin: string) => Promise<UserDetailInfoByUinV2>>(
|
||||||
|
'NodeIKernelProfileService/getUserDetailInfoByUin',
|
||||||
|
5000,
|
||||||
|
Uin
|
||||||
|
);
|
||||||
|
}
|
||||||
static async getUserDetailInfoByUin(Uin: string) {
|
static async getUserDetailInfoByUin(Uin: string) {
|
||||||
return NTEventDispatch.CallNoListenerEvent
|
return NTEventDispatch.CallNoListenerEvent
|
||||||
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
<(Uin: string) => Promise<UserDetailInfoByUin>>(
|
||||||
|
@@ -114,6 +114,22 @@ export interface GroupEssenceMsgRet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class WebApi {
|
export class WebApi {
|
||||||
|
static async shareDigest(groupCode: string, msgSeq: string, msgRandom: string, targetGroupCode: string) {
|
||||||
|
const CookiesObject = await NTQQUserApi.getCookies('qun.qq.com');
|
||||||
|
const CookieValue = Object.entries(CookiesObject).map(([key, value]) => `${key}=${value}`).join('; ');
|
||||||
|
const Bkn = WebApi.genBkn(CookiesObject.skey);
|
||||||
|
let ret: any = undefined;
|
||||||
|
const data = 'group_code=' + groupCode + '&msg_seq=' + msgSeq + '&msg_random=' + msgRandom + '&target_group_code=' + targetGroupCode;
|
||||||
|
const url = 'https://qun.qq.com/cgi-bin/group_digest/share_digest?bkn=' + Bkn + "&" + data;
|
||||||
|
//console.log(url);
|
||||||
|
try {
|
||||||
|
ret = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': CookieValue });
|
||||||
|
return ret;
|
||||||
|
} catch (e) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
@CacheClassFuncAsync(3600 * 1000, 'webapi_get_group_members')
|
@CacheClassFuncAsync(3600 * 1000, 'webapi_get_group_members')
|
||||||
static async getGroupEssenceMsg(GroupCode: string, page_start: string) {
|
static async getGroupEssenceMsg(GroupCode: string, page_start: string) {
|
||||||
const CookiesObject = await NTQQUserApi.getCookies('qun.qq.com');
|
const CookiesObject = await NTQQUserApi.getCookies('qun.qq.com');
|
||||||
|
@@ -15,12 +15,12 @@ import { DependsAdapter, DispatcherAdapter, GlobalAdapter, NodeIGlobalAdapter }
|
|||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
import { appid, qqVersionConfigInfo } from '@/common/utils/QQBasicInfo';
|
import { getFullQQVesion, QQVersionAppid, QQVersionQua, requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
import { hostname, systemVersion } from '@/common/utils/system';
|
import { hostname, systemVersion } from '@/common/utils/system';
|
||||||
import { genSessionConfig } from '@/core/sessionConfig';
|
import { genSessionConfig } from '@/core/sessionConfig';
|
||||||
import { sleep } from '@/common/utils/helper';
|
import { sleep } from '@/common/utils/helper';
|
||||||
import crypto from 'node:crypto';
|
import crypto from 'node:crypto';
|
||||||
import { rawFriends, friends, groupMembers, groups, selfInfo, stat } from '@/core/data';
|
import { groupMembers, groups, selfInfo, stat } from '@/core/data';
|
||||||
import { GroupMember, RawMessage } from '@/core/entities';
|
import { GroupMember, RawMessage } from '@/core/entities';
|
||||||
import { NTEventDispatch } from '@/common/utils/EventTask';
|
import { NTEventDispatch } from '@/common/utils/EventTask';
|
||||||
import {
|
import {
|
||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
setLogSelfInfo
|
setLogSelfInfo
|
||||||
} from '@/common/utils/log';
|
} from '@/common/utils/log';
|
||||||
import { napCatConfig } from '@/core/utils/config';
|
import { napCatConfig } from '@/core/utils/config';
|
||||||
|
import { NTQQFriendApi } from './apis';
|
||||||
|
|
||||||
export interface OnLoginSuccess {
|
export interface OnLoginSuccess {
|
||||||
(uin: string, uid: string): void | Promise<void>;
|
(uin: string, uid: string): void | Promise<void>;
|
||||||
@@ -84,7 +85,6 @@ export class NapCatCore {
|
|||||||
const dataPath = path.resolve(this.dataPath, './NapCat/data');
|
const dataPath = path.resolve(this.dataPath, './NapCat/data');
|
||||||
fs.mkdirSync(dataPath, { recursive: true });
|
fs.mkdirSync(dataPath, { recursive: true });
|
||||||
logDebug('本账号数据/缓存目录:', dataPath);
|
logDebug('本账号数据/缓存目录:', dataPath);
|
||||||
// dbUtil.init(path.resolve(dataPath, `./${arg.uin}-v2.db`)).then(() => {
|
|
||||||
this.initDataListener();
|
this.initDataListener();
|
||||||
this.onLoginSuccessFuncList.map(cb => {
|
this.onLoginSuccessFuncList.map(cb => {
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
@@ -94,11 +94,6 @@ export class NapCatCore {
|
|||||||
}
|
}
|
||||||
}).then();
|
}).then();
|
||||||
});
|
});
|
||||||
// }).catch((e) => {
|
|
||||||
// logError('数据库初始化失败', e);
|
|
||||||
// });
|
|
||||||
// this.initDataListener();
|
|
||||||
|
|
||||||
}).catch((e) => {
|
}).catch((e) => {
|
||||||
logError('initSession failed', e);
|
logError('initSession failed', e);
|
||||||
throw new Error(`启动失败: ${JSON.stringify(e)}`);
|
throw new Error(`启动失败: ${JSON.stringify(e)}`);
|
||||||
@@ -139,10 +134,10 @@ export class NapCatCore {
|
|||||||
base_path_prefix: '',
|
base_path_prefix: '',
|
||||||
platform_type: 3,
|
platform_type: 3,
|
||||||
app_type: 4,
|
app_type: 4,
|
||||||
app_version: qqVersionConfigInfo.curVersion,
|
app_version: getFullQQVesion(),
|
||||||
os_version: 'Windows 10 Pro',
|
os_version: 'Windows 10 Pro',
|
||||||
use_xlog: true,
|
use_xlog: true,
|
||||||
qua: `V1_WIN_NQ_${qqVersionConfigInfo.curVersion.replace('-', '_')}_GW_B`,
|
qua: QQVersionQua,
|
||||||
global_path_config: {
|
global_path_config: {
|
||||||
desktopGlobalPath: this.dataPathGlobal,
|
desktopGlobalPath: this.dataPathGlobal,
|
||||||
},
|
},
|
||||||
@@ -150,10 +145,10 @@ export class NapCatCore {
|
|||||||
}, new QQWrapper.NodeIGlobalAdapter(new GlobalAdapter()));
|
}, new QQWrapper.NodeIGlobalAdapter(new GlobalAdapter()));
|
||||||
this.loginService.initConfig({
|
this.loginService.initConfig({
|
||||||
machineId: '',
|
machineId: '',
|
||||||
appid,
|
appid: QQVersionAppid,
|
||||||
platVer: systemVersion,
|
platVer: systemVersion,
|
||||||
commonPath: this.dataPathGlobal,
|
commonPath: this.dataPathGlobal,
|
||||||
clientVer: qqVersionConfigInfo.curVersion,
|
clientVer: getFullQQVesion(),
|
||||||
hostName: hostname
|
hostName: hostname
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -260,29 +255,21 @@ export class NapCatCore {
|
|||||||
this.addListener(msgListener);
|
this.addListener(msgListener);
|
||||||
// 好友相关
|
// 好友相关
|
||||||
const buddyListener = new BuddyListener();
|
const buddyListener = new BuddyListener();
|
||||||
buddyListener.onBuddyListChange = arg => {
|
|
||||||
rawFriends.length = 0;
|
|
||||||
rawFriends.push(...arg);
|
|
||||||
// console.log('onBuddyListChange', arg);
|
|
||||||
for (const categoryItem of arg) {
|
|
||||||
for (const friend of categoryItem.buddyList) {
|
|
||||||
// console.log("onBuddyListChange", friend)
|
|
||||||
const existFriend = friends.get(friend.uid);
|
|
||||||
if (existFriend) {
|
|
||||||
Object.assign(existFriend, friend);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
friends.set(friend.uid, friend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log("onBuddyListChange", friend)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.addListener(buddyListener);
|
this.addListener(buddyListener);
|
||||||
// 刷新一次好友列表
|
// 刷新一次好友列表 26702版本以下需要手动刷新一次获取 高版本NTQQ自带缓存
|
||||||
|
if (!requireMinNTQQBuild('26702')) {
|
||||||
this.session.getBuddyService().getBuddyList(true).then(arg => {
|
this.session.getBuddyService().getBuddyList(true).then(arg => {
|
||||||
// console.log('getBuddyList', arg);
|
// console.log('getBuddyList', arg);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// NTQQFriendApi.getBuddyV2(true).then((res) => {
|
||||||
|
// res.forEach((item) => {
|
||||||
|
// CachedIdMap.set(item.uid!, item.uin!);
|
||||||
|
// });
|
||||||
|
// }).catch();
|
||||||
|
}
|
||||||
interface SelfStatusInfo {
|
interface SelfStatusInfo {
|
||||||
uid: string
|
uid: string
|
||||||
status: number
|
status: number
|
||||||
|
@@ -3,9 +3,11 @@ import {
|
|||||||
type Group,
|
type Group,
|
||||||
type GroupMember,
|
type GroupMember,
|
||||||
type SelfInfo,
|
type SelfInfo,
|
||||||
type BuddyCategoryType
|
type BuddyCategoryType,
|
||||||
|
FriendV2
|
||||||
} from './entities';
|
} from './entities';
|
||||||
import { isNumeric } from '@/common/utils/helper';
|
import { isNumeric } from '@/common/utils/helper';
|
||||||
|
import { LimitedHashTable } from '@/common/utils/MessageUnique';
|
||||||
import { NTQQGroupApi } from '@/core/apis';
|
import { NTQQGroupApi } from '@/core/apis';
|
||||||
|
|
||||||
export const selfInfo: SelfInfo = {
|
export const selfInfo: SelfInfo = {
|
||||||
@@ -14,8 +16,6 @@ export const selfInfo: SelfInfo = {
|
|||||||
nick: '',
|
nick: '',
|
||||||
online: true
|
online: true
|
||||||
};
|
};
|
||||||
// 未来只在此处保留 selfInfo stat
|
|
||||||
// groupCode -> Group
|
|
||||||
export const groups: Map<string, Group> = new Map<string, Group>();
|
export const groups: Map<string, Group> = new Map<string, Group>();
|
||||||
|
|
||||||
export function deleteGroup(groupQQ: string) {
|
export function deleteGroup(groupQQ: string) {
|
||||||
@@ -26,9 +26,10 @@ export function deleteGroup(groupQQ: string) {
|
|||||||
// 群号 -> 群成员map(uid=>GroupMember)
|
// 群号 -> 群成员map(uid=>GroupMember)
|
||||||
export const groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
export const groupMembers: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
||||||
|
|
||||||
// uid -> Friend 下面这俩个准备移除 QQ里面自带缓存
|
|
||||||
export const friends: Map<string, Friend> = new Map<string, Friend>();
|
export const friends: Map<string, Friend> = new Map<string, Friend>();
|
||||||
export const rawFriends: Array<BuddyCategoryType> = []; // 带分组的好友列表
|
|
||||||
|
//转换列表
|
||||||
|
//export const CachedIdMap = new LimitedHashTable<string, string>(1000);
|
||||||
|
|
||||||
export async function getGroup(qq: string | number): Promise<Group | undefined> {
|
export async function getGroup(qq: string | number): Promise<Group | undefined> {
|
||||||
let group = groups.get(qq.toString());
|
let group = groups.get(qq.toString());
|
||||||
|
@@ -1,12 +1,18 @@
|
|||||||
import { QQLevel, Sex } from './user';
|
import { QQLevel, Sex } from './user';
|
||||||
|
export enum GroupListUpdateType {
|
||||||
|
REFRESHALL,
|
||||||
|
GETALL,
|
||||||
|
MODIFIED,
|
||||||
|
REMOVE
|
||||||
|
}
|
||||||
export interface Group {
|
export interface Group {
|
||||||
groupCode: string,
|
groupCode: string,
|
||||||
|
createTime?:string,//高版本才有
|
||||||
maxMember: number,
|
maxMember: number,
|
||||||
memberCount: number,
|
memberCount: number,
|
||||||
groupName: string,
|
groupName: string,
|
||||||
groupStatus: 0,
|
groupStatus: number,
|
||||||
memberRole: 2,
|
memberRole: number,
|
||||||
isTop: boolean,
|
isTop: boolean,
|
||||||
toppedTimestamp: string,
|
toppedTimestamp: string,
|
||||||
privilegeFlag: number, //65760
|
privilegeFlag: number, //65760
|
||||||
|
@@ -731,6 +731,7 @@ export interface MultiForwardMsgElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface RawMessage {
|
export interface RawMessage {
|
||||||
|
guildId: string;
|
||||||
msgRandom: string;
|
msgRandom: string;
|
||||||
// int32, 自己维护的消息id
|
// int32, 自己维护的消息id
|
||||||
id?: number;
|
id?: number;
|
||||||
|
@@ -9,7 +9,181 @@ export interface BuddyCategoryType {
|
|||||||
categroyMbCount: number;
|
categroyMbCount: number;
|
||||||
buddyList: User[];
|
buddyList: User[];
|
||||||
}
|
}
|
||||||
|
export interface CoreInfo {
|
||||||
|
uid: string;
|
||||||
|
uin: string;
|
||||||
|
nick: string;
|
||||||
|
remark: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BaseInfo {
|
||||||
|
qid: string;
|
||||||
|
longNick: string;
|
||||||
|
birthday_year: number;
|
||||||
|
birthday_month: number;
|
||||||
|
birthday_day: number;
|
||||||
|
age: number;
|
||||||
|
sex: number;
|
||||||
|
eMail: string;
|
||||||
|
phoneNum: string;
|
||||||
|
categoryId: number;
|
||||||
|
richTime: number;
|
||||||
|
richBuffer: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MusicInfo {
|
||||||
|
buf: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VideoBizInfo {
|
||||||
|
cid: string;
|
||||||
|
tvUrl: string;
|
||||||
|
synchType: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VideoInfo {
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ExtOnlineBusinessInfo {
|
||||||
|
buf: string;
|
||||||
|
customStatus: any;
|
||||||
|
videoBizInfo: VideoBizInfo;
|
||||||
|
videoInfo: VideoInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ExtBuffer {
|
||||||
|
buf: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UserStatus {
|
||||||
|
uid: string;
|
||||||
|
uin: string;
|
||||||
|
status: number;
|
||||||
|
extStatus: number;
|
||||||
|
batteryStatus: number;
|
||||||
|
termType: number;
|
||||||
|
netType: number;
|
||||||
|
iconType: number;
|
||||||
|
customStatus: any;
|
||||||
|
setTime: string;
|
||||||
|
specialFlag: number;
|
||||||
|
abiFlag: number;
|
||||||
|
eNetworkType: number;
|
||||||
|
showName: string;
|
||||||
|
termDesc: string;
|
||||||
|
musicInfo: MusicInfo;
|
||||||
|
extOnlineBusinessInfo: ExtOnlineBusinessInfo;
|
||||||
|
extBuffer: ExtBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PrivilegeIcon {
|
||||||
|
jumpUrl: string;
|
||||||
|
openIconList: any[];
|
||||||
|
closeIconList: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface VasInfo {
|
||||||
|
vipFlag: boolean;
|
||||||
|
yearVipFlag: boolean;
|
||||||
|
svipFlag: boolean;
|
||||||
|
vipLevel: number;
|
||||||
|
bigClub: boolean;
|
||||||
|
bigClubLevel: number;
|
||||||
|
nameplateVipType: number;
|
||||||
|
grayNameplateFlag: number;
|
||||||
|
superVipTemplateId: number;
|
||||||
|
diyFontId: number;
|
||||||
|
pendantId: number;
|
||||||
|
pendantDiyId: number;
|
||||||
|
faceId: number;
|
||||||
|
vipFont: number;
|
||||||
|
vipFontType: number;
|
||||||
|
magicFont: number;
|
||||||
|
fontEffect: number;
|
||||||
|
newLoverDiamondFlag: number;
|
||||||
|
extendNameplateId: number;
|
||||||
|
diyNameplateIDs: any[];
|
||||||
|
vipStartFlag: number;
|
||||||
|
vipDataFlag: number;
|
||||||
|
gameNameplateId: string;
|
||||||
|
gameLastLoginTime: string;
|
||||||
|
gameRank: number;
|
||||||
|
gameIconShowFlag: boolean;
|
||||||
|
gameCardId: string;
|
||||||
|
vipNameColorId: string;
|
||||||
|
privilegeIcon: PrivilegeIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RelationFlags {
|
||||||
|
topTime: string;
|
||||||
|
isBlock: boolean;
|
||||||
|
isMsgDisturb: boolean;
|
||||||
|
isSpecialCareOpen: boolean;
|
||||||
|
isSpecialCareZone: boolean;
|
||||||
|
ringId: string;
|
||||||
|
isBlocked: boolean;
|
||||||
|
recommendImgFlag: number;
|
||||||
|
disableEmojiShortCuts: number;
|
||||||
|
qidianMasterFlag: number;
|
||||||
|
qidianCrewFlag: number;
|
||||||
|
qidianCrewFlag2: number;
|
||||||
|
isHideQQLevel: number;
|
||||||
|
isHidePrivilegeIcon: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
interface CommonExt {
|
||||||
|
constellation: number;
|
||||||
|
shengXiao: number;
|
||||||
|
kBloodType: number;
|
||||||
|
homeTown: string;
|
||||||
|
makeFriendCareer: number;
|
||||||
|
pos: string;
|
||||||
|
college: string;
|
||||||
|
country: string;
|
||||||
|
province: string;
|
||||||
|
city: string;
|
||||||
|
postCode: string;
|
||||||
|
address: string;
|
||||||
|
regTime: number;
|
||||||
|
interest: string;
|
||||||
|
labels: any[];
|
||||||
|
qqLevel: QQLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Pic {
|
||||||
|
picId: string;
|
||||||
|
picTime: number;
|
||||||
|
picUrlMap: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PhotoWall {
|
||||||
|
picList: Pic[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleInfo {
|
||||||
|
uid?: string;
|
||||||
|
uin?: string;
|
||||||
|
coreInfo: CoreInfo;
|
||||||
|
baseInfo: BaseInfo;
|
||||||
|
status: UserStatus | null;
|
||||||
|
vasInfo: VasInfo | null;
|
||||||
|
relationFlags: RelationFlags | null;
|
||||||
|
otherFlags: any | null;
|
||||||
|
intimate: any | null;
|
||||||
|
}
|
||||||
|
export interface FriendV2 extends SimpleInfo {
|
||||||
|
categoryId?: number;
|
||||||
|
categroyName?: string;
|
||||||
|
}
|
||||||
|
export interface UserDetailInfoListenerArg {
|
||||||
|
uid: string;
|
||||||
|
uin: string;
|
||||||
|
simpleInfo: SimpleInfo;
|
||||||
|
commonExt: CommonExt;
|
||||||
|
photoWall: PhotoWall;
|
||||||
|
}
|
||||||
export interface ModifyProfileParams {
|
export interface ModifyProfileParams {
|
||||||
nick: string,
|
nick: string,
|
||||||
longNick: string,
|
longNick: string,
|
||||||
@@ -102,6 +276,17 @@ export enum BizKey {
|
|||||||
KPRIVILEGEICON,
|
KPRIVILEGEICON,
|
||||||
KPHOTOWALL
|
KPHOTOWALL
|
||||||
}
|
}
|
||||||
|
export interface UserDetailInfoByUinV2 {
|
||||||
|
result: number,
|
||||||
|
errMsg: string,
|
||||||
|
detail: {
|
||||||
|
uid: string,
|
||||||
|
uin: string,
|
||||||
|
simpleInfo: SimpleInfo,
|
||||||
|
commonExt: CommonExt,
|
||||||
|
photoWall: null
|
||||||
|
}
|
||||||
|
}
|
||||||
export interface UserDetailInfoByUin {
|
export interface UserDetailInfoByUin {
|
||||||
result: number,
|
result: number,
|
||||||
errMsg: string,
|
errMsg: string,
|
||||||
|
42
src/core/src/external/appid.json
vendored
Normal file
42
src/core/src/external/appid.json
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"3.1.2-13107": {
|
||||||
|
"appid": 537146866,
|
||||||
|
"qua": "V1_LNX_NQ_3.1.2-13107_RDM_B"
|
||||||
|
},
|
||||||
|
"3.2.10-25765": {
|
||||||
|
"appid": 537234773,
|
||||||
|
"qua": "V1_LNX_NQ_3.2.10_25765_GW_B"
|
||||||
|
},
|
||||||
|
"3.2.12-26702": {
|
||||||
|
"appid": 537237950,
|
||||||
|
"qua": "V1_LNX_NQ_3.2.12_26702_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.11-24815": {
|
||||||
|
"appid": 537226656,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.11_24815_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.12-25493": {
|
||||||
|
"appid": 537231759,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.12_25493_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.12-25765": {
|
||||||
|
"appid": 537234702,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.12_25765_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.12-26299": {
|
||||||
|
"appid": 537234826,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.12_26299_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.12-26339": {
|
||||||
|
"appid": 537234826,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.12_26339_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.12-26466": {
|
||||||
|
"appid": 537234826,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.12_26466_GW_B"
|
||||||
|
},
|
||||||
|
"9.9.15-26702": {
|
||||||
|
"appid": 537237765,
|
||||||
|
"qua": "V1_WIN_NQ_9.9.15_26702_GW_B"
|
||||||
|
}
|
||||||
|
}
|
@@ -3,6 +3,8 @@ import { BuddyCategoryType, FriendRequestNotify } from '@/core/entities';
|
|||||||
export type OnBuddyChangeParams = BuddyCategoryType[]
|
export type OnBuddyChangeParams = BuddyCategoryType[]
|
||||||
|
|
||||||
interface IBuddyListener {
|
interface IBuddyListener {
|
||||||
|
onBuddyListChangedV2(arg: unknown): void,//V2版本 还没兼容
|
||||||
|
|
||||||
onBuddyListChange(arg: OnBuddyChangeParams): void,
|
onBuddyListChange(arg: OnBuddyChangeParams): void,
|
||||||
|
|
||||||
onBuddyInfoChange(arg: unknown): void,
|
onBuddyInfoChange(arg: unknown): void,
|
||||||
@@ -44,6 +46,9 @@ export interface NodeIKernelBuddyListener extends IBuddyListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class BuddyListener implements IBuddyListener {
|
export class BuddyListener implements IBuddyListener {
|
||||||
|
onBuddyListChangedV2(arg: unknown): void {
|
||||||
|
//throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
onAddBuddyNeedVerify(arg: unknown) {
|
onAddBuddyNeedVerify(arg: unknown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { Group, GroupMember, GroupNotify } from '@/core/entities';
|
import { Group, GroupListUpdateType, GroupMember, GroupNotify } from '@/core/entities';
|
||||||
|
|
||||||
interface IGroupListener {
|
interface IGroupListener {
|
||||||
onGroupListUpdate(updateType: number, groupList: Group[]): void;
|
onGroupListUpdate(updateType: GroupListUpdateType, groupList: Group[]): void;
|
||||||
|
|
||||||
onGroupExtListUpdate(...args: unknown[]): void;
|
onGroupExtListUpdate(...args: unknown[]): void;
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ export class GroupListener implements IGroupListener {
|
|||||||
onGroupFirstBulletinNotify(...args: unknown[]) {
|
onGroupFirstBulletinNotify(...args: unknown[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupListUpdate(updateType: number, groupList: Group[]) {
|
onGroupListUpdate(updateType: GroupListUpdateType, groupList: Group[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
onGroupNotifiesUpdated(dboubt: boolean, notifies: GroupNotify[]) {
|
onGroupNotifiesUpdated(dboubt: boolean, notifies: GroupNotify[]) {
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
import { User } from '@/core/entities';
|
import { User, UserDetailInfoListenerArg } from '@/core/entities';
|
||||||
|
|
||||||
interface IProfileListener {
|
interface IProfileListener {
|
||||||
onProfileSimpleChanged(...args: unknown[]): void;
|
onProfileSimpleChanged(...args: unknown[]): void;
|
||||||
|
onUserDetailInfoChanged(arg: UserDetailInfoListenerArg): void;
|
||||||
onProfileDetailInfoChanged(profile: User): void;
|
onProfileDetailInfoChanged(profile: User): void;
|
||||||
|
|
||||||
onStatusUpdate(...args: unknown[]): void;
|
onStatusUpdate(...args: unknown[]): void;
|
||||||
@@ -18,6 +18,9 @@ export interface NodeIKernelProfileListener extends IProfileListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ProfileListener implements IProfileListener {
|
export class ProfileListener implements IProfileListener {
|
||||||
|
onUserDetailInfoChanged(arg: UserDetailInfoListenerArg): void {
|
||||||
|
|
||||||
|
}
|
||||||
onProfileSimpleChanged(...args: unknown[]) {
|
onProfileSimpleChanged(...args: unknown[]) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,19 +1,44 @@
|
|||||||
import { Friend } from '@/core/entities';
|
import { Friend } from '@/core/entities';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
import { NodeIKernelBuddyListener } from '@/core/listeners';
|
import { NodeIKernelBuddyListener } from '@/core/listeners';
|
||||||
|
export enum BuddyListReqType {
|
||||||
|
KNOMAL,
|
||||||
|
KLETTER
|
||||||
|
}
|
||||||
export interface NodeIKernelBuddyService {
|
export interface NodeIKernelBuddyService {
|
||||||
// 以下为自行添加的,wrapper.node中并没有这些方法,目的是简化调用
|
// 26702 以上
|
||||||
friends: Friend[];
|
getBuddyListV2(callFrom: string, reqType: BuddyListReqType): Promise<GeneralCallResult & {
|
||||||
|
data: Array<{
|
||||||
getFriend(uidOrUin: string): Promise<Friend>;
|
categoryId: number,
|
||||||
|
categorySortId: number,
|
||||||
|
categroyName: string,
|
||||||
|
categroyMbCount: number,
|
||||||
|
onlineCount: number,
|
||||||
|
buddyUids: Array<string>
|
||||||
|
}>
|
||||||
|
}>;
|
||||||
|
//26702 以上
|
||||||
|
getBuddyListFromCache(callFrom: string): Promise<Array<
|
||||||
|
{
|
||||||
|
categoryId: number,//9999应该跳过 那是兜底数据吧
|
||||||
|
categorySortId: number,//排序方式
|
||||||
|
categroyName: string,//分类名
|
||||||
|
categroyMbCount: number,//不懂
|
||||||
|
onlineCount: number,//在线数目
|
||||||
|
buddyUids: Array<string>//Uids
|
||||||
|
}>>;
|
||||||
// 以下为原生方法
|
// 以下为原生方法
|
||||||
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
|
addKernelBuddyListener(listener: NodeIKernelBuddyListener): number;
|
||||||
|
|
||||||
|
getAllBuddyCount(): number;
|
||||||
|
|
||||||
removeKernelBuddyListener(listener: unknown): void;
|
removeKernelBuddyListener(listener: unknown): void;
|
||||||
|
|
||||||
getBuddyList(bool: boolean): Promise<GeneralCallResult>;
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param nocache 使用缓存
|
||||||
|
*/
|
||||||
|
getBuddyList(nocache: boolean): Promise<GeneralCallResult>;
|
||||||
|
|
||||||
getBuddyNick(uid: number): string;
|
getBuddyNick(uid: number): string;
|
||||||
|
|
||||||
|
3
src/core/src/services/NodeIKernelECDHService.ts
Normal file
3
src/core/src/services/NodeIKernelECDHService.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export interface NodeIKernelECDHService{
|
||||||
|
|
||||||
|
}
|
@@ -8,7 +8,89 @@ import {
|
|||||||
} from '@/core/entities';
|
} from '@/core/entities';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
|
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
||||||
|
|
||||||
export interface NodeIKernelGroupService {
|
export interface NodeIKernelGroupService {
|
||||||
|
getMemberCommonInfo(Req: {
|
||||||
|
groupCode: string,
|
||||||
|
startUin: string,
|
||||||
|
identifyFlag: string,
|
||||||
|
uinList: string[],
|
||||||
|
memberCommonFilter: {
|
||||||
|
memberUin: number,
|
||||||
|
uinFlag: number,
|
||||||
|
uinFlagExt: number,
|
||||||
|
uinMobileFlag: number,
|
||||||
|
shutUpTime: number,
|
||||||
|
privilege: number,
|
||||||
|
},
|
||||||
|
memberNum: number,
|
||||||
|
filterMethod: string,
|
||||||
|
onlineFlag: string,
|
||||||
|
realSpecialTitleFlag: number
|
||||||
|
}): Promise<unknown>;
|
||||||
|
//26702
|
||||||
|
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>;
|
||||||
|
//26702
|
||||||
|
getGroupHonorList(groupCodes: Array<string>): unknown;
|
||||||
|
|
||||||
|
getUinByUids(uins: string[]): Promise<{
|
||||||
|
errCode: number,
|
||||||
|
errMsg: string,
|
||||||
|
uins: Map<string, string>
|
||||||
|
}>;
|
||||||
|
|
||||||
|
getUidByUins(uins: string[]): Promise<{
|
||||||
|
errCode: number,
|
||||||
|
errMsg: string,
|
||||||
|
uids: Map<string, string>
|
||||||
|
}>;
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>;
|
||||||
|
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
getGroupLatestEssenceList(groupCode: string): Promise<unknown>;
|
||||||
|
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
shareDigest(Req: {
|
||||||
|
appId: string,
|
||||||
|
appType: number,
|
||||||
|
msgStyle: number,
|
||||||
|
recvUin: string,
|
||||||
|
sendType: number,
|
||||||
|
clientInfo: {
|
||||||
|
platform: number
|
||||||
|
},
|
||||||
|
richMsg: {
|
||||||
|
usingArk: boolean,
|
||||||
|
title: string,
|
||||||
|
summary: string,
|
||||||
|
url: string,
|
||||||
|
pictureUrl: string,
|
||||||
|
brief: string
|
||||||
|
}
|
||||||
|
}): Promise<unknown>;
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
isEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
queryCachedEssenceMsg(Req: { groupCode: string, msgRandom: number, msgSeq: number }): Promise<unknown>;
|
||||||
|
//26702(其实更早 但是我不知道)
|
||||||
|
fetchGroupEssenceList(Req: { groupCode: string, pageStart: number, pageLimit: number }, Arg: unknown): Promise<unknown>;
|
||||||
|
//26702
|
||||||
|
getAllMemberList(groupCode: string, forceFetch: boolean): Promise<{
|
||||||
|
errCode: number,
|
||||||
|
errMsg: string,
|
||||||
|
result: {
|
||||||
|
ids: Array<{
|
||||||
|
uid: string,
|
||||||
|
index: number//0
|
||||||
|
}>,
|
||||||
|
infos: {},
|
||||||
|
finish: true,
|
||||||
|
hasRobot: false
|
||||||
|
}
|
||||||
|
}>;
|
||||||
|
|
||||||
setHeader(uid: string, path: string): unknown;
|
setHeader(uid: string, path: string): unknown;
|
||||||
|
|
||||||
addKernelGroupListener(listener: NodeIKernelGroupListener): number;
|
addKernelGroupListener(listener: NodeIKernelGroupListener): number;
|
||||||
@@ -17,7 +99,7 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
createMemberListScene(groupCode: string, scene: string): string;
|
createMemberListScene(groupCode: string, scene: string): string;
|
||||||
|
|
||||||
destroyMemberListScene(): void;
|
destroyMemberListScene(SceneId:string): void;
|
||||||
//About Arg (a) name: lastId 根据手Q来看为object {index:?(number),uid:string}
|
//About Arg (a) name: lastId 根据手Q来看为object {index:?(number),uid:string}
|
||||||
getNextMemberList(sceneId: string, a: undefined, num: number): Promise<{
|
getNextMemberList(sceneId: string, a: undefined, num: number): Promise<{
|
||||||
errCode: number, errMsg: string,
|
errCode: number, errMsg: string,
|
||||||
@@ -28,9 +110,9 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
monitorMemberList(): unknown;
|
monitorMemberList(): unknown;
|
||||||
|
|
||||||
searchMember(uid: string): unknown;
|
searchMember(sceneId: string, keywords: string[]): unknown;
|
||||||
|
|
||||||
getMemberInfo(uid: string): unknown;
|
getMemberInfo(group_id: string, uids: string[], forceFetch: boolean): Promise<GeneralCallResult>;
|
||||||
//getMemberInfo [ '56729xxxx', [ 'u_4Nj08cwW5Hxxxxx' ], true ]
|
//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>;
|
||||||
@@ -39,7 +121,7 @@ export interface NodeIKernelGroupService {
|
|||||||
|
|
||||||
modifyMemberCardName(groupCode: string, uid: string, cardName: string): void;
|
modifyMemberCardName(groupCode: string, uid: string, cardName: string): void;
|
||||||
|
|
||||||
getTransferableMemberInfo(uid: string): unknown;
|
getTransferableMemberInfo(groupCode: string): unknown;//获取整个群的
|
||||||
|
|
||||||
transferGroup(uid: string): void;
|
transferGroup(uid: string): void;
|
||||||
|
|
||||||
|
@@ -2,7 +2,20 @@ import { ElementType, MessageElement, Peer, RawMessage, SendMessageElement } fro
|
|||||||
import { NodeIKernelMsgListener } from '@/core/listeners/NodeIKernelMsgListener';
|
import { NodeIKernelMsgListener } from '@/core/listeners/NodeIKernelMsgListener';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
|
||||||
|
export interface QueryMsgsParams {
|
||||||
|
chatInfo: Peer,
|
||||||
|
filterMsgType: [],
|
||||||
|
filterSendersUid: string[],
|
||||||
|
filterMsgFromTime: string,
|
||||||
|
filterMsgToTime: string,
|
||||||
|
pageLimit: number,
|
||||||
|
isReverseOrder: boolean,
|
||||||
|
isIncludeCurrent: boolean
|
||||||
|
}
|
||||||
export interface NodeIKernelMsgService {
|
export interface NodeIKernelMsgService {
|
||||||
|
|
||||||
|
generateMsgUniqueId(chatType: number, time: string): string;
|
||||||
|
|
||||||
addKernelMsgListener(nodeIKernelMsgListener: NodeIKernelMsgListener): number;
|
addKernelMsgListener(nodeIKernelMsgListener: NodeIKernelMsgListener): number;
|
||||||
|
|
||||||
sendMsg(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>): Promise<GeneralCallResult>;
|
sendMsg(msgId: string, peer: Peer, msgElements: SendMessageElement[], map: Map<any, any>): Promise<GeneralCallResult>;
|
||||||
@@ -178,14 +191,14 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
getSingleMsg(Peer: Peer, msgSeq: string): Promise<GeneralCallResult & { msgList: RawMessage[] }>;
|
getSingleMsg(Peer: Peer, msgSeq: string): Promise<GeneralCallResult & { msgList: RawMessage[] }>;
|
||||||
|
|
||||||
getSourceOfReplyMsg(...args: unknown[]): unknown;
|
getSourceOfReplyMsg(peer: Peer, MsgId: string, SourceSeq: string): unknown;
|
||||||
|
|
||||||
getSourceOfReplyMsgV2(...args: unknown[]): unknown;
|
getSourceOfReplyMsgV2(peer: Peer, RootMsgId: string, ReplyMsgId: string): unknown;
|
||||||
|
|
||||||
getMsgByClientSeqAndTime(...args: unknown[]): unknown;
|
getMsgByClientSeqAndTime(peer: Peer, clientSeq: string, time: string): unknown;
|
||||||
|
|
||||||
getSourceOfReplyMsgByClientSeqAndTime(...args: unknown[]): unknown;
|
|
||||||
|
|
||||||
|
getSourceOfReplyMsgByClientSeqAndTime(peer: Peer, clientSeq: string, time: string): unknown;
|
||||||
|
//cnt clientSeq?并不是吧
|
||||||
getMsgsByTypeFilter(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilter: { type: number, subtype: Array<number> }): unknown;
|
getMsgsByTypeFilter(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilter: { type: number, subtype: Array<number> }): unknown;
|
||||||
|
|
||||||
getMsgsByTypeFilters(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilters: Array<{ type: number, subtype: Array<number> }>): unknown;
|
getMsgsByTypeFilters(peer: Peer, msgId: string, cnt: unknown, queryOrder: boolean, typeFilters: Array<{ type: number, subtype: Array<number> }>): unknown;
|
||||||
@@ -214,19 +227,7 @@ export interface NodeIKernelMsgService {
|
|||||||
* @param param.isIncludeCurrent 是否包含当前页码。
|
* @param param.isIncludeCurrent 是否包含当前页码。
|
||||||
* @returns 返回一个Promise,解析为查询结果的未知类型对象。
|
* @returns 返回一个Promise,解析为查询结果的未知类型对象。
|
||||||
*/
|
*/
|
||||||
queryMsgsWithFilterVer2(MsgId: string, MsgTime: string, param: {
|
queryMsgsWithFilterVer2(MsgId: string, MsgTime: string, param: QueryMsgsParams): Promise<unknown>;
|
||||||
chatInfo: {
|
|
||||||
chatType: number,
|
|
||||||
peerUid: string
|
|
||||||
},
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: Array<string>,
|
|
||||||
filterMsgFromTime: string,
|
|
||||||
filterMsgToTime: string,
|
|
||||||
pageLimit: number,
|
|
||||||
isReverseOrder: boolean,
|
|
||||||
isIncludeCurrent: boolean
|
|
||||||
}): Promise<unknown>;
|
|
||||||
|
|
||||||
// this.chatType = i2;
|
// this.chatType = i2;
|
||||||
// this.peerUid = str;
|
// this.peerUid = str;
|
||||||
@@ -243,19 +244,7 @@ export interface NodeIKernelMsgService {
|
|||||||
// this.isReverseOrder = z;
|
// this.isReverseOrder = z;
|
||||||
// this.isIncludeCurrent = z2;
|
// this.isIncludeCurrent = z2;
|
||||||
//queryMsgsWithFilterEx(0L, 0L, 0L, new QueryMsgsParams(new ChatInfo(2, str), new ArrayList(), new ArrayList(), 0L, 0L, 250, false, true))
|
//queryMsgsWithFilterEx(0L, 0L, 0L, new QueryMsgsParams(new ChatInfo(2, str), new ArrayList(), new ArrayList(), 0L, 0L, 250, false, true))
|
||||||
queryMsgsWithFilterEx(msgId: string, msgTime: string, megSeq: string, param: {
|
queryMsgsWithFilterEx(msgId: string, msgTime: string, megSeq: string, param: QueryMsgsParams): Promise<GeneralCallResult & {
|
||||||
chatInfo: {
|
|
||||||
chatType: number,
|
|
||||||
peerUid: string
|
|
||||||
},
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: string[],
|
|
||||||
filterMsgFromTime: string,
|
|
||||||
filterMsgToTime: string,
|
|
||||||
pageLimit: number,
|
|
||||||
isReverseOrder: boolean,
|
|
||||||
isIncludeCurrent: boolean
|
|
||||||
}): Promise<GeneralCallResult & {
|
|
||||||
msgList: RawMessage[]
|
msgList: RawMessage[]
|
||||||
}>;
|
}>;
|
||||||
//queryMsgsWithFilterEx(this.$msgId, this.$msgTime, this.$msgSeq, this.$param)
|
//queryMsgsWithFilterEx(this.$msgId, this.$msgTime, this.$msgSeq, this.$param)
|
||||||
@@ -263,39 +252,15 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
setMsgRichInfoFlag(...args: unknown[]): unknown;
|
setMsgRichInfoFlag(...args: unknown[]): unknown;
|
||||||
|
|
||||||
queryPicOrVideoMsgs(msgId: string, msgTime: string, megSeq: string, param: {
|
queryPicOrVideoMsgs(msgId: string, msgTime: string, megSeq: string, param: QueryMsgsParams): Promise<unknown>;
|
||||||
chatInfo: {
|
|
||||||
chatType: number,
|
|
||||||
peerUid: string
|
|
||||||
},
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: [],
|
|
||||||
filterMsgFromTime: string,
|
|
||||||
filterMsgToTime: string,
|
|
||||||
pageLimit: number,
|
|
||||||
isReverseOrder: boolean,
|
|
||||||
isIncludeCurrent: boolean
|
|
||||||
}): Promise<unknown>;
|
|
||||||
|
|
||||||
queryPicOrVideoMsgsDesktop(...args: unknown[]): unknown;
|
queryPicOrVideoMsgsDesktop(...args: unknown[]): unknown;
|
||||||
|
|
||||||
queryEmoticonMsgs(...args: unknown[]): unknown;
|
queryEmoticonMsgs(msgId: string, msgTime: string, msgSeq: string, Params: QueryMsgsParams): Promise<unknown>;
|
||||||
|
|
||||||
queryTroopEmoticonMsgs(...args: unknown[]): unknown;
|
queryTroopEmoticonMsgs(msgId: string, msgTime: string, msgSeq: string, Params: QueryMsgsParams): Promise<unknown>;
|
||||||
|
|
||||||
queryMsgsAndAbstractsWithFilter(msgId: string, msgTime: string, megSeq: string, param: {
|
queryMsgsAndAbstractsWithFilter(msgId: string, msgTime: string, megSeq: string, param: QueryMsgsParams): unknown;
|
||||||
chatInfo: {
|
|
||||||
chatType: number,
|
|
||||||
peerUid: string
|
|
||||||
},
|
|
||||||
filterMsgType: [],
|
|
||||||
filterSendersUid: [],
|
|
||||||
filterMsgFromTime: string,
|
|
||||||
filterMsgToTime: string,
|
|
||||||
pageLimit: number,
|
|
||||||
isReverseOrder: boolean,
|
|
||||||
isIncludeCurrent: boolean
|
|
||||||
}): unknown;
|
|
||||||
|
|
||||||
setFocusOnGuild(...args: unknown[]): unknown;
|
setFocusOnGuild(...args: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -534,7 +499,7 @@ export interface NodeIKernelMsgService {
|
|||||||
|
|
||||||
queryCalendar(...args: unknown[]): unknown;
|
queryCalendar(...args: unknown[]): unknown;
|
||||||
|
|
||||||
queryFirstMsgSeq(...args: unknown[]): unknown;
|
queryFirstMsgSeq(peer: Peer, ...args: unknown[]): unknown;
|
||||||
|
|
||||||
queryRoamCalendar(...args: unknown[]): unknown;
|
queryRoamCalendar(...args: unknown[]): unknown;
|
||||||
|
|
||||||
@@ -628,6 +593,8 @@ export interface NodeIKernelMsgService {
|
|||||||
// this.gameSession = tempChatGameSession;
|
// this.gameSession = tempChatGameSession;
|
||||||
prepareTempChat(args: unknown): unknown;//主动临时消息 不做
|
prepareTempChat(args: unknown): unknown;//主动临时消息 不做
|
||||||
|
|
||||||
|
sendSsoCmdReqByContend(cmd: string, param: string): Promise<unknown>;
|
||||||
|
|
||||||
//chattype,uid->Promise<any>
|
//chattype,uid->Promise<any>
|
||||||
getTempChatInfo(ChatType: number, Uid: string): unknown;
|
getTempChatInfo(ChatType: number, Uid: string): unknown;
|
||||||
|
|
||||||
|
@@ -1,10 +1,36 @@
|
|||||||
import { AnyCnameRecord } from 'node:dns';
|
import { AnyCnameRecord } from 'node:dns';
|
||||||
import { BizKey, ModifyProfileParams, UserDetailInfoByUin } from '../entities';
|
import { BaseInfo, BizKey, CoreInfo, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin } from '../entities';
|
||||||
import { NodeIKernelProfileListener } from '../listeners';
|
import { NodeIKernelProfileListener } from '../listeners';
|
||||||
import { GeneralCallResult } from '@/core/services/common';
|
import { GeneralCallResult } from '@/core/services/common';
|
||||||
|
export enum UserDetailSource {
|
||||||
|
KDB,
|
||||||
|
KSERVER
|
||||||
|
}
|
||||||
|
export enum ProfileBizType {
|
||||||
|
KALL,
|
||||||
|
KBASEEXTEND,
|
||||||
|
KVAS,
|
||||||
|
KQZONE,
|
||||||
|
KOTHER
|
||||||
|
}
|
||||||
export interface NodeIKernelProfileService {
|
export interface NodeIKernelProfileService {
|
||||||
|
|
||||||
|
getUidByUin(callfrom: string, uin: Array<string>): Promise<Map<string,string>>;//uin->uid
|
||||||
|
|
||||||
|
getUinByUid(callfrom: string, uid: Array<string>): Promise<Map<string,string>>;
|
||||||
|
// {
|
||||||
|
// coreInfo: CoreInfo,
|
||||||
|
// baseInfo: BaseInfo,
|
||||||
|
// status: null,
|
||||||
|
// vasInfo: null,
|
||||||
|
// relationFlags: null,
|
||||||
|
// otherFlags: null,
|
||||||
|
// intimate: null
|
||||||
|
// }
|
||||||
|
getCoreAndBaseInfo(callfrom: string, uids: string[]): Promise<Map<string, SimpleInfo>>;
|
||||||
|
|
||||||
|
fetchUserDetailInfo(trace: string, uids: string[], arg2: number, arg3: number[]): Promise<unknown>;
|
||||||
|
|
||||||
addKernelProfileListener(listener: NodeIKernelProfileListener): number;
|
addKernelProfileListener(listener: NodeIKernelProfileListener): number;
|
||||||
|
|
||||||
removeKernelProfileListener(listenerId: number): void;
|
removeKernelProfileListener(listenerId: number): void;
|
||||||
|
@@ -21,7 +21,7 @@ export interface NodeIKernelRobotService {
|
|||||||
|
|
||||||
removeKernelRobotListener(ListenerId: number): unknown;
|
removeKernelRobotListener(ListenerId: number): unknown;
|
||||||
|
|
||||||
getAllRobotFriendsFromCache(): unknown;
|
getAllRobotFriendsFromCache(): Promise<unknown>;
|
||||||
|
|
||||||
fetchAllRobots(arg1: unknown, arg2: unknown): unknown;
|
fetchAllRobots(arg1: unknown, arg2: unknown): unknown;
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
export interface NodeIKernelUixConvertService {
|
export interface NodeIKernelUixConvertService {
|
||||||
getUin(uid: string[]): Promise<{ uidInfo: Map<string, string> }>;
|
getUin(uid: string[]): Promise<{ uinInfo: Map<string, string> }>;
|
||||||
|
|
||||||
getUid(uin: string[]): Promise<{ uinInfo: Map<string, string> }>;
|
getUid(uin: string[]): Promise<{ uidInfo: Map<string, string> }>;
|
||||||
}
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
import { appid, qqPkgInfo, qqVersionConfigInfo } from '@/common/utils/QQBasicInfo';
|
import { getFullQQVesion, QQVersionAppid } from '@/common/utils/QQBasicInfo';
|
||||||
import { hostname, systemName, systemVersion } from '@/common/utils/system';
|
import { hostname, systemName, systemVersion } from '@/common/utils/system';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
@@ -34,42 +34,42 @@ export interface WrapperSessionInitConfig {
|
|||||||
account_path: string // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
account_path: string // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
||||||
}
|
}
|
||||||
clientVer: string // 9.9.8-22355
|
clientVer: string // 9.9.8-22355
|
||||||
a2: '',
|
a2: string,
|
||||||
d2: '',
|
d2: string,
|
||||||
d2Key: '',
|
d2Key: string,
|
||||||
machineId: '',
|
machineId: string,
|
||||||
platform: 3, // 3是Windows?
|
platform: PlatformType, // 3是Windows?
|
||||||
platVer: string, // 系统版本号, 应该可以固定
|
platVer: string, // 系统版本号, 应该可以固定
|
||||||
appid: string,
|
appid: string,
|
||||||
rdeliveryConfig: {
|
rdeliveryConfig: {
|
||||||
appKey: '',
|
appKey: string,
|
||||||
systemId: 0,
|
systemId: number,
|
||||||
appId: '',
|
appId: string,
|
||||||
logicEnvironment: '',
|
logicEnvironment: string,
|
||||||
platform: 3,
|
platform: PlatformType,
|
||||||
language: '',
|
language: string,
|
||||||
sdkVersion: '',
|
sdkVersion: string,
|
||||||
userId: '',
|
userId: string,
|
||||||
appVersion: '',
|
appVersion: string,
|
||||||
osVersion: '',
|
osVersion: string,
|
||||||
bundleId: '',
|
bundleId: string,
|
||||||
serverUrl: '',
|
serverUrl: string,
|
||||||
fixedAfterHitKeys: ['']
|
fixedAfterHitKeys: string[]
|
||||||
}
|
}
|
||||||
'defaultFileDownloadPath': string, // 这个可以通过环境变量获取?
|
defaultFileDownloadPath: string, // 这个可以通过环境变量获取?
|
||||||
'deviceInfo': {
|
deviceInfo: {
|
||||||
'guid': string,
|
guid: string,
|
||||||
'buildVer': string,
|
buildVer: string,
|
||||||
'localId': 2052,
|
localId: number,
|
||||||
'devName': string,
|
devName: string,
|
||||||
'devType': string,
|
devType: string,
|
||||||
'vendorName': '',
|
vendorName: string,
|
||||||
'osVer': string,
|
osVer: string,
|
||||||
'vendorOsName': string,
|
vendorOsName: string,
|
||||||
'setMute': false,
|
setMute: boolean,
|
||||||
'vendorType': 0
|
vendorType: VendorType
|
||||||
},
|
},
|
||||||
'deviceConfig': '{"appearance":{"isSplitViewMode":true},"msg":{}}'
|
deviceConfig: '{"appearance":{"isSplitViewMode":true},"msg":{}}'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sessionConfig: WrapperSessionInitConfig | any = {};
|
export const sessionConfig: WrapperSessionInitConfig | any = {};
|
||||||
@@ -87,20 +87,20 @@ export async function genSessionConfig(selfUin: string, selfUid: string, account
|
|||||||
desktopPathConfig: {
|
desktopPathConfig: {
|
||||||
account_path // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
account_path // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
||||||
},
|
},
|
||||||
clientVer: qqVersionConfigInfo.curVersion, // 9.9.8-22355
|
clientVer: getFullQQVesion(), // 9.9.8-22355
|
||||||
a2: '',
|
a2: '',
|
||||||
d2: '',
|
d2: '',
|
||||||
d2Key: '',
|
d2Key: '',
|
||||||
machineId: '',
|
machineId: '',
|
||||||
platform: 3, // 3是Windows?
|
platform: PlatformType.KWINDOWS, // 3是Windows?
|
||||||
platVer: systemVersion, // 系统版本号, 应该可以固定
|
platVer: systemVersion, // 系统版本号, 应该可以固定
|
||||||
appid: appid,
|
appid: QQVersionAppid,
|
||||||
rdeliveryConfig: {
|
rdeliveryConfig: {
|
||||||
appKey: '',
|
appKey: '',
|
||||||
systemId: 0,
|
systemId: 0,
|
||||||
appId: '',
|
appId: '',
|
||||||
logicEnvironment: '',
|
logicEnvironment: '',
|
||||||
platform: 3,
|
platform: PlatformType.KWINDOWS,
|
||||||
language: '',
|
language: '',
|
||||||
sdkVersion: '',
|
sdkVersion: '',
|
||||||
userId: '',
|
userId: '',
|
||||||
@@ -110,22 +110,21 @@ export async function genSessionConfig(selfUin: string, selfUid: string, account
|
|||||||
serverUrl: '',
|
serverUrl: '',
|
||||||
fixedAfterHitKeys: ['']
|
fixedAfterHitKeys: ['']
|
||||||
},
|
},
|
||||||
'defaultFileDownloadPath': downloadPath,
|
defaultFileDownloadPath: downloadPath,
|
||||||
'deviceInfo': {
|
deviceInfo: {
|
||||||
guid,
|
guid,
|
||||||
'buildVer': qqPkgInfo.version,
|
buildVer: getFullQQVesion(),
|
||||||
'localId': 2052,
|
localId: 2052,
|
||||||
'devName': hostname,
|
devName: hostname,
|
||||||
'devType': systemName,
|
devType: systemName,
|
||||||
'vendorName': '',
|
vendorName: '',
|
||||||
'osVer': systemVersion,
|
osVer: systemVersion,
|
||||||
'vendorOsName': systemName,
|
vendorOsName: systemName,
|
||||||
'setMute': false,
|
setMute: false,
|
||||||
'vendorType': 0
|
vendorType: VendorType.KNOSETONIOS
|
||||||
},
|
},
|
||||||
'deviceConfig': '{"appearance":{"isSplitViewMode":true},"msg":{}}'
|
deviceConfig: '{"appearance":{"isSplitViewMode":true},"msg":{}}'
|
||||||
};
|
};
|
||||||
Object.assign(sessionConfig, config);
|
Object.assign(sessionConfig, config);
|
||||||
// log(sessionConfig);
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,6 @@ import {
|
|||||||
NodeIKernelRichMediaService,
|
NodeIKernelRichMediaService,
|
||||||
NodeIKernelAvatarService,
|
NodeIKernelAvatarService,
|
||||||
} from './services';
|
} from './services';
|
||||||
import { qqVersionConfigInfo } from '@/common/utils/QQBasicInfo';
|
|
||||||
import { NodeIKernelStorageCleanService } from './services/NodeIKernelStorageCleanService';
|
import { NodeIKernelStorageCleanService } from './services/NodeIKernelStorageCleanService';
|
||||||
import { NodeIKernelRobotService } from './services/NodeIKernelRobotService';
|
import { NodeIKernelRobotService } from './services/NodeIKernelRobotService';
|
||||||
import { dirname } from "node:path"
|
import { dirname } from "node:path"
|
||||||
@@ -42,6 +41,8 @@ import { NodeIKernelCollectionService } from './services/NodeIKernelCollectionSe
|
|||||||
import { NodeIKernelRecentContactService } from './services/NodeIKernelRecentContactService';
|
import { NodeIKernelRecentContactService } from './services/NodeIKernelRecentContactService';
|
||||||
import { NodeIKernelMSFService } from './services/NodeIKernelMSFService';
|
import { NodeIKernelMSFService } from './services/NodeIKernelMSFService';
|
||||||
import { NodeIkernelTestPerformanceService } from './services/NodeIkernelTestPerformanceService';
|
import { NodeIkernelTestPerformanceService } from './services/NodeIkernelTestPerformanceService';
|
||||||
|
import { NodeIKernelECDHService } from './services/NodeIKernelECDHService';
|
||||||
|
import { getFullQQVesion } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
@@ -157,6 +158,10 @@ export interface NodeIQQNTWrapperSession {
|
|||||||
|
|
||||||
startNT(): void;
|
startNT(): void;
|
||||||
|
|
||||||
|
getBdhUploadService(): unknown;
|
||||||
|
|
||||||
|
getECDHService(): NodeIKernelECDHService;
|
||||||
|
|
||||||
getMsgService(): NodeIKernelMsgService;
|
getMsgService(): NodeIKernelMsgService;
|
||||||
|
|
||||||
getProfileService(): NodeIKernelProfileService;
|
getProfileService(): NodeIKernelProfileService;
|
||||||
@@ -287,7 +292,7 @@ export interface WrapperNodeApi {
|
|||||||
|
|
||||||
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
||||||
if (!fs.existsSync(wrapperNodePath)) {
|
if (!fs.existsSync(wrapperNodePath)) {
|
||||||
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${qqVersionConfigInfo.curVersion}/wrapper.node`);
|
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${getFullQQVesion()}/wrapper.node`);
|
||||||
}
|
}
|
||||||
const nativemodule: any = { exports: {} };
|
const nativemodule: any = { exports: {} };
|
||||||
process.dlopen(nativemodule, wrapperNodePath);
|
process.dlopen(nativemodule, wrapperNodePath);
|
||||||
|
@@ -92,9 +92,9 @@ napCatCore.getQuickLoginList().then((res) => {
|
|||||||
|
|
||||||
WebUiDataRuntime.setQQQuickLoginCall(async (uin: string) => {
|
WebUiDataRuntime.setQQQuickLoginCall(async (uin: string) => {
|
||||||
const QuickLogin: Promise<{ result: boolean, message: string }> = new Promise((resolve, reject) => {
|
const QuickLogin: Promise<{ result: boolean, message: string }> = new Promise((resolve, reject) => {
|
||||||
if (quickLoginQQ) {
|
if (uin) {
|
||||||
log('正在快速登录 ', quickLoginQQ);
|
log('正在快速登录 ', uin);
|
||||||
napCatCore.quickLogin(quickLoginQQ).then(res => {
|
napCatCore.quickLogin(uin).then(res => {
|
||||||
if (res.loginErrorInfo.errMsg) {
|
if (res.loginErrorInfo.errMsg) {
|
||||||
resolve({ result: false, message: res.loginErrorInfo.errMsg });
|
resolve({ result: false, message: res.loginErrorInfo.errMsg });
|
||||||
}
|
}
|
||||||
|
@@ -1,12 +1,19 @@
|
|||||||
import { rawFriends } from '@/core/data';
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { BuddyCategoryType } from '@/core/entities/';
|
import { BuddyCategoryType } from '@/core/entities/';
|
||||||
|
import { NTQQFriendApi } from '@/core';
|
||||||
|
import { OB11Constructor } from '@/onebot11/constructor';
|
||||||
|
|
||||||
export class GetFriendWithCategory extends BaseAction<void, Array<BuddyCategoryType>> {
|
export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||||
actionName = ActionName.GetFriendsWithCategory;
|
actionName = ActionName.GetFriendsWithCategory;
|
||||||
|
|
||||||
protected async _handle(payload: void) {
|
protected async _handle(payload: void) {
|
||||||
return rawFriends;
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
//全新逻辑
|
||||||
|
return OB11Constructor.friendsV2(await NTQQFriendApi.getBuddyV2ExWithCate(true));
|
||||||
|
} else {
|
||||||
|
throw new Error('this ntqq version not support, must be 26702 or later');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
src/onebot11/action/extends/TestApi01.ts
Normal file
32
src/onebot11/action/extends/TestApi01.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName, BaseCheckResult } from '../types';
|
||||||
|
import * as fs from 'node:fs';
|
||||||
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
|
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||||
|
import { napCatCore, NTQQGroupApi } from '@/core';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
// import { log } from "../../../common/utils";
|
||||||
|
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
cmd: { type: 'string' },
|
||||||
|
param: { type: 'string' }
|
||||||
|
},
|
||||||
|
required: ['cmd', 'param'],
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
export default class TestApi01 extends BaseAction<Payload, any> {
|
||||||
|
actionName = ActionName.TestApi01;
|
||||||
|
// 用不着复杂检测
|
||||||
|
protected async check(payload: Payload): Promise<BaseCheckResult> {
|
||||||
|
return {
|
||||||
|
valid: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
protected async _handle(payload: Payload): Promise<any> {
|
||||||
|
return await napCatCore.session.getMsgService().sendSsoCmdReqByContend(payload.cmd, payload.param);
|
||||||
|
}
|
||||||
|
}
|
@@ -50,17 +50,17 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
try {
|
try {
|
||||||
UuidData = UUIDConverter.decode(payload.file);
|
UuidData = UUIDConverter.decode(payload.file);
|
||||||
if (UuidData) {
|
if (UuidData) {
|
||||||
let peerUin = UuidData.high;
|
const peerUin = UuidData.high;
|
||||||
let msgId = UuidData.low;
|
const msgId = UuidData.low;
|
||||||
let isGroup = await getGroup(peerUin);
|
const isGroup = await getGroup(peerUin);
|
||||||
let peer: Peer | undefined;
|
let peer: Peer | undefined;
|
||||||
//识别Peer
|
//识别Peer
|
||||||
if (isGroup) {
|
if (isGroup) {
|
||||||
peer = { chatType: ChatType.group, peerUid: peerUin };
|
peer = { chatType: ChatType.group, peerUid: peerUin };
|
||||||
}
|
}
|
||||||
let PeerUid = await NTQQUserApi.getUidByUin(peerUin);
|
const PeerUid = await NTQQUserApi.getUidByUin(peerUin);
|
||||||
if (PeerUid) {
|
if (PeerUid) {
|
||||||
let isBuddy = await NTQQFriendApi.isBuddy(PeerUid);
|
const isBuddy = await NTQQFriendApi.isBuddy(PeerUid);
|
||||||
if (isBuddy) {
|
if (isBuddy) {
|
||||||
peer = { chatType: ChatType.friend, peerUid: PeerUid };
|
peer = { chatType: ChatType.friend, peerUid: PeerUid };
|
||||||
} else {
|
} else {
|
||||||
@@ -70,18 +70,18 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
|||||||
if (!peer) {
|
if (!peer) {
|
||||||
throw new Error('chattype not support');
|
throw new Error('chattype not support');
|
||||||
}
|
}
|
||||||
let msgList = await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]);
|
const msgList = await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]);
|
||||||
if (msgList.msgList.length == 0) {
|
if (msgList.msgList.length == 0) {
|
||||||
throw new Error('msg not found');
|
throw new Error('msg not found');
|
||||||
}
|
}
|
||||||
let msg = msgList.msgList[0];
|
const msg = msgList.msgList[0];
|
||||||
let findEle = msg.elements.find(e => e.elementType == ElementType.VIDEO || e.elementType == ElementType.FILE || e.elementType == ElementType.PTT);
|
const findEle = msg.elements.find(e => e.elementType == ElementType.VIDEO || e.elementType == ElementType.FILE || e.elementType == ElementType.PTT);
|
||||||
if (!findEle) {
|
if (!findEle) {
|
||||||
throw new Error('element not found');
|
throw new Error('element not found');
|
||||||
}
|
}
|
||||||
let downloadPath = await NTQQFileApi.downloadMedia(msgId, msg.chatType, msg.peerUid, findEle.elementId, '', '');
|
const downloadPath = await NTQQFileApi.downloadMedia(msgId, msg.chatType, msg.peerUid, findEle.elementId, '', '');
|
||||||
let fileSize = findEle?.videoElement?.fileSize || findEle?.fileElement?.fileSize || findEle?.pttElement?.fileSize || '0';
|
const fileSize = findEle?.videoElement?.fileSize || findEle?.fileElement?.fileSize || findEle?.pttElement?.fileSize || '0';
|
||||||
let fileName = findEle?.videoElement?.fileName || findEle?.fileElement?.fileName || findEle?.pttElement?.fileName || '';
|
const fileName = findEle?.videoElement?.fileName || findEle?.fileElement?.fileName || findEle?.pttElement?.fileName || '';
|
||||||
const res: GetFileResponse = {
|
const res: GetFileResponse = {
|
||||||
file: downloadPath,
|
file: downloadPath,
|
||||||
url: downloadPath,
|
url: downloadPath,
|
||||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
|||||||
import { OB11Message, OB11User } from '../../types';
|
import { OB11Message, OB11User } from '../../types';
|
||||||
import { getGroup, groups } from '@/core/data';
|
import { getGroup, groups } from '@/core/data';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { ChatType } from '@/core/entities';
|
import { ChatType, RawMessage } from '@/core/entities';
|
||||||
import { NTQQMsgApi } from '@/core/apis/msg';
|
import { NTQQMsgApi } from '@/core/apis/msg';
|
||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
@@ -36,13 +36,13 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
|||||||
chatType: ChatType.group,
|
chatType: ChatType.group,
|
||||||
peerUid: group.groupCode
|
peerUid: group.groupCode
|
||||||
};
|
};
|
||||||
|
let msgList: RawMessage[];
|
||||||
if (!payload.message_seq) {
|
if (!payload.message_seq) {
|
||||||
const latestMsgId = (await NTQQMsgApi.getLastestMsgByUids(peer)).msgList[0].msgId;
|
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, count)).msgList;
|
||||||
targetMsgShortId = await MessageUnique.createMsg(peer, latestMsgId || '0');
|
} else {
|
||||||
}
|
|
||||||
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(targetMsgShortId ?? (payload.message_seq ?? 0)))?.MsgId || '0';
|
const startMsgId = (await MessageUnique.getMsgIdAndPeerByShortId(targetMsgShortId ?? (payload.message_seq ?? 0)))?.MsgId || '0';
|
||||||
const historyResult = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, count));
|
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, count)).msgList;
|
||||||
const msgList = historyResult.msgList;
|
}
|
||||||
await Promise.all(msgList.map(async msg => {
|
await Promise.all(msgList.map(async msg => {
|
||||||
msg.id = await MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
msg.id = await MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||||
}));
|
}));
|
||||||
|
@@ -5,6 +5,7 @@ import { ActionName } from '../types';
|
|||||||
import { NTQQUserApi } from '@/core/apis/user';
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
import { calcQQLevel } from '@/common/utils/qqlevel';
|
import { calcQQLevel } from '@/common/utils/qqlevel';
|
||||||
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
@@ -20,6 +21,7 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
actionName = ActionName.GoCQHTTP_GetStrangerInfo;
|
||||||
|
|
||||||
protected async _handle(payload: Payload): Promise<OB11User> {
|
protected async _handle(payload: Payload): Promise<OB11User> {
|
||||||
|
if (!requireMinNTQQBuild('26702')) {
|
||||||
const user_id = payload.user_id.toString();
|
const user_id = payload.user_id.toString();
|
||||||
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
|
const extendData = await NTQQUserApi.getUserDetailInfoByUin(user_id);
|
||||||
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
||||||
@@ -39,5 +41,26 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<Payload, OB11Use
|
|||||||
}
|
}
|
||||||
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
||||||
return OB11Constructor.stranger(data);
|
return OB11Constructor.stranger(data);
|
||||||
|
} else {
|
||||||
|
const user_id = payload.user_id.toString();
|
||||||
|
const extendData = await NTQQUserApi.getUserDetailInfoByUinV2(user_id);
|
||||||
|
//console.log(extendData);
|
||||||
|
const uid = (await NTQQUserApi.getUidByUin(user_id))!;
|
||||||
|
if (!uid || uid.indexOf('*') != -1) {
|
||||||
|
const ret = {
|
||||||
|
...extendData,
|
||||||
|
user_id: parseInt(extendData.detail.uin) || 0,
|
||||||
|
nickname: extendData.detail.simpleInfo.coreInfo.nick,
|
||||||
|
sex: OB11UserSex.unknown,
|
||||||
|
age: 0,
|
||||||
|
level: extendData.detail.commonExt.qqLevel && calcQQLevel(extendData.detail.commonExt.qqLevel) || 0,
|
||||||
|
login_days: 0,
|
||||||
|
uid: ''
|
||||||
|
};
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
const data = { ...extendData, ...(await NTQQUserApi.getUserDetailInfo(uid)) };
|
||||||
|
return OB11Constructor.stranger(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,10 +2,8 @@ import { OB11Group } from '../../types';
|
|||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { groups } from '@/core/data';
|
|
||||||
import { NTQQGroupApi } from '@/core/apis';
|
import { NTQQGroupApi } from '@/core/apis';
|
||||||
import { Group } from '@/core/entities';
|
import { Group } from '@/core/entities';
|
||||||
import { log } from '@/common/utils/log';
|
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
// no_cache get时传字符串
|
// no_cache get时传字符串
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
@@ -21,11 +19,7 @@ class GetGroupList extends BaseAction<Payload, OB11Group[]> {
|
|||||||
actionName = ActionName.GetGroupList;
|
actionName = ActionName.GetGroupList;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
let groupList: Group[] = Array.from(groups.values());
|
let groupList: Group[] = await NTQQGroupApi.getGroups(payload?.no_cache === true || payload.no_cache === 'true');
|
||||||
if (groupList.length === 0 || payload?.no_cache === true || payload.no_cache === 'true') {
|
|
||||||
groupList = await NTQQGroupApi.getGroups(true);
|
|
||||||
// log('get groups', groups);
|
|
||||||
}
|
|
||||||
return OB11Constructor.groups(groupList);
|
return OB11Constructor.groups(groupList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import { OB11GroupMember } from '../../types';
|
import { OB11GroupMember } from '../../types';
|
||||||
import { getGroup, getGroupMember, groupMembers, selfInfo } from '@/core/data';
|
|
||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
@@ -8,8 +7,7 @@ import { logDebug } from '@/common/utils/log';
|
|||||||
import { WebApi } from '@/core/apis/webapi';
|
import { WebApi } from '@/core/apis/webapi';
|
||||||
import { NTQQGroupApi } from '@/core';
|
import { NTQQGroupApi } from '@/core';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { selfInfo } from '@/core/data';
|
||||||
// no_cache get时传字符串
|
|
||||||
const SchemaData = {
|
const SchemaData = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@@ -26,17 +24,12 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
actionName = ActionName.GetGroupMemberInfo;
|
actionName = ActionName.GetGroupMemberInfo;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
const group = await getGroup(payload.group_id.toString());
|
const isNocache = payload.no_cache == true || payload.no_cache === 'true';
|
||||||
const role = (await getGroupMember(payload.group_id, selfInfo.uin))?.role;
|
let uid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||||
const isPrivilege = role === 3 || role === 4;
|
if (!uid) {
|
||||||
if (!group) {
|
throw (`Uin2Uid Error ${payload.user_id}不存在`);
|
||||||
throw (`群(${payload.group_id})不存在`);
|
|
||||||
}
|
}
|
||||||
if (payload.no_cache == true || payload.no_cache === 'true') {
|
let member = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), uid, isNocache);
|
||||||
groupMembers.set(group.groupCode, await NTQQGroupApi.getGroupMembers(payload.group_id.toString()));
|
|
||||||
}
|
|
||||||
const member = await getGroupMember(payload.group_id.toString(), payload.user_id.toString());
|
|
||||||
//早返回
|
|
||||||
if (!member) {
|
if (!member) {
|
||||||
throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
||||||
}
|
}
|
||||||
@@ -48,6 +41,11 @@ class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
|||||||
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
||||||
}
|
}
|
||||||
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
||||||
|
let SelfInfoInGroup = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), selfInfo.uid, isNocache);
|
||||||
|
let isPrivilege = false;
|
||||||
|
if (SelfInfoInGroup) {
|
||||||
|
isPrivilege = SelfInfoInGroup.role === 3 || SelfInfoInGroup.role === 4;
|
||||||
|
}
|
||||||
if (isPrivilege) {
|
if (isPrivilege) {
|
||||||
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||||
|
84
src/onebot11/action/group/GetGroupMemberInfoOld.ts
Normal file
84
src/onebot11/action/group/GetGroupMemberInfoOld.ts
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
import { OB11GroupMember } from '../../types';
|
||||||
|
import { getGroup, getGroupMember, groupMembers, selfInfo } from '@/core/data';
|
||||||
|
import { OB11Constructor } from '../../constructor';
|
||||||
|
import BaseAction from '../BaseAction';
|
||||||
|
import { ActionName } from '../types';
|
||||||
|
import { NTQQUserApi } from '@/core/apis/user';
|
||||||
|
import { logDebug } from '@/common/utils/log';
|
||||||
|
import { WebApi } from '@/core/apis/webapi';
|
||||||
|
import { NTQQGroupApi } from '@/core';
|
||||||
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
|
// no_cache get时传字符串
|
||||||
|
const SchemaData = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
group_id: { type: ['number', 'string'] },
|
||||||
|
user_id: { type: ['number', 'string'] },
|
||||||
|
no_cache: { type: ['boolean', 'string'] },
|
||||||
|
},
|
||||||
|
required: ['group_id', 'user_id']
|
||||||
|
} as const satisfies JSONSchema;
|
||||||
|
|
||||||
|
type Payload = FromSchema<typeof SchemaData>;
|
||||||
|
|
||||||
|
class GetGroupMemberInfo extends BaseAction<Payload, OB11GroupMember> {
|
||||||
|
actionName = ActionName.GetGroupMemberInfo;
|
||||||
|
PayloadSchema = SchemaData;
|
||||||
|
protected async _handle(payload: Payload) {
|
||||||
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
let V2Data = await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), payload.user_id.toString(), payload.no_cache == true || payload.no_cache === 'true');
|
||||||
|
if (V2Data) {
|
||||||
|
return OB11Constructor.groupMember(payload.group_id.toString(), V2Data);
|
||||||
|
} else {
|
||||||
|
throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const group = await getGroup(payload.group_id.toString());
|
||||||
|
const role = (await getGroupMember(payload.group_id, selfInfo.uin))?.role;
|
||||||
|
const isPrivilege = role === 3 || role === 4;
|
||||||
|
if (!group) {
|
||||||
|
throw (`群(${payload.group_id})不存在`);
|
||||||
|
}
|
||||||
|
if (payload.no_cache == true || payload.no_cache === 'true') {
|
||||||
|
groupMembers.set(group.groupCode, await NTQQGroupApi.getGroupMembers(payload.group_id.toString()));
|
||||||
|
}
|
||||||
|
const member = await getGroupMember(payload.group_id.toString(), payload.user_id.toString());
|
||||||
|
//早返回
|
||||||
|
if (!member) {
|
||||||
|
throw (`群(${payload.group_id})成员${payload.user_id}不存在`);
|
||||||
|
}
|
||||||
|
//console.log('GetGroupMemberInfo', JSON.stringify(await NTQQGroupApi.getGroupMemberV2(payload.group_id.toString(), member.uid, true), null, 4));
|
||||||
|
try {
|
||||||
|
const info = (await NTQQUserApi.getUserDetailInfo(member.uid));
|
||||||
|
logDebug('群成员详细信息结果', info);
|
||||||
|
Object.assign(member, info);
|
||||||
|
} catch (e) {
|
||||||
|
logDebug('获取群成员详细信息失败, 只能返回基础信息', e);
|
||||||
|
}
|
||||||
|
const retMember = OB11Constructor.groupMember(payload.group_id.toString(), member);
|
||||||
|
if (isPrivilege) {
|
||||||
|
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
|
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||||
|
if (webGroupMembers[i]?.uin && webGroupMembers[i].uin === retMember.user_id) {
|
||||||
|
retMember.join_time = webGroupMembers[i]?.join_time;
|
||||||
|
retMember.last_sent_time = webGroupMembers[i]?.last_speak_time;
|
||||||
|
retMember.qage = webGroupMembers[i]?.qage;
|
||||||
|
retMember.level = webGroupMembers[i]?.lv.level.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const LastestMsgList = await NTQQGroupApi.getLastestMsg(payload.group_id.toString(), [payload.user_id.toString()]);
|
||||||
|
if (LastestMsgList?.msgList?.length && LastestMsgList?.msgList?.length > 0) {
|
||||||
|
const last_send_time = LastestMsgList.msgList[0].msgTime;
|
||||||
|
if (last_send_time && last_send_time != '0' && last_send_time != '') {
|
||||||
|
retMember.last_sent_time = parseInt(last_send_time);
|
||||||
|
retMember.join_time = Math.round(Date.now() / 1000);//兜底数据 防止群管乱杀
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retMember;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default GetGroupMemberInfo;
|
@@ -1,4 +1,4 @@
|
|||||||
import { getGroup, getGroupMember, groupMembers, selfInfo } from '@/core/data';
|
import { selfInfo } from '@/core/data';
|
||||||
import { OB11GroupMember } from '../../types';
|
import { OB11GroupMember } from '../../types';
|
||||||
import { OB11Constructor } from '../../constructor';
|
import { OB11Constructor } from '../../constructor';
|
||||||
import BaseAction from '../BaseAction';
|
import BaseAction from '../BaseAction';
|
||||||
@@ -22,20 +22,16 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
actionName = ActionName.GetGroupMemberList;
|
actionName = ActionName.GetGroupMemberList;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
const role = (await getGroupMember(payload.group_id, selfInfo.uin))?.role;
|
const isNocache = payload.no_cache == true || payload.no_cache === 'true';
|
||||||
|
|
||||||
const group = await getGroup(payload.group_id.toString());
|
const GroupList = await NTQQGroupApi.getGroups(isNocache);
|
||||||
|
const group = GroupList.find(item => item.groupCode == payload.group_id);
|
||||||
if (!group) {
|
if (!group) {
|
||||||
throw (`群${payload.group_id}不存在`);
|
throw (`群${payload.group_id}不存在`);
|
||||||
}
|
}
|
||||||
|
let groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||||
// 从Data里面获取
|
let _groupMembers = Array.from(groupMembers.values())
|
||||||
let _groupMembers: OB11GroupMember[] = OB11Constructor.groupMembers(group);
|
.map(item => { return OB11Constructor.groupMember(group.groupCode, item); });
|
||||||
if (payload.no_cache == true || payload.no_cache === 'true') {
|
|
||||||
// webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());'
|
|
||||||
const _groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
|
||||||
groupMembers.set(group.groupCode, _groupMembers);
|
|
||||||
}
|
|
||||||
|
|
||||||
const MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
|
const MemberMap: Map<number, OB11GroupMember> = new Map<number, OB11GroupMember>();
|
||||||
// 转为Map 方便索引
|
// 转为Map 方便索引
|
||||||
@@ -47,7 +43,9 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
MemberMap.set(_groupMembers[i].user_id, _groupMembers[i]);
|
MemberMap.set(_groupMembers[i].user_id, _groupMembers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const isPrivilege = role === 3 || role === 4;
|
const selfRole = groupMembers.get(selfInfo.uid)?.role;
|
||||||
|
const isPrivilege = selfRole === 3 || selfRole === 4;
|
||||||
|
|
||||||
if (isPrivilege) {
|
if (isPrivilege) {
|
||||||
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
const webGroupMembers = await WebApi.getGroupMembers(payload.group_id.toString());
|
||||||
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
for (let i = 0, len = webGroupMembers.length; i < len; i++) {
|
||||||
@@ -64,6 +62,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (isNocache) {
|
||||||
const DateMap = await NTQQGroupApi.getGroupMemberLastestSendTimeCache(payload.group_id.toString());//开始从本地拉取
|
const DateMap = await NTQQGroupApi.getGroupMemberLastestSendTimeCache(payload.group_id.toString());//开始从本地拉取
|
||||||
for (const DateUin of DateMap.keys()) {
|
for (const DateUin of DateMap.keys()) {
|
||||||
const MemberData = MemberMap.get(parseInt(DateUin));
|
const MemberData = MemberMap.get(parseInt(DateUin));
|
||||||
@@ -72,6 +71,12 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
|||||||
//join_time 有基础数据兜底
|
//join_time 有基础数据兜底
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
_groupMembers.forEach(item => {
|
||||||
|
item.last_sent_time = date;
|
||||||
|
item.join_time = date;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// 还原索引到Array 一同返回
|
// 还原索引到Array 一同返回
|
||||||
|
|
||||||
|
@@ -77,6 +77,7 @@ import { GetProfileLike } from './extends/GetProfileLike';
|
|||||||
import SetGroupHeader from './extends/SetGroupHeader';
|
import SetGroupHeader from './extends/SetGroupHeader';
|
||||||
import { FetchCustomFace } from './extends/FetchCustomFace';
|
import { FetchCustomFace } from './extends/FetchCustomFace';
|
||||||
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
import GoCQHTTPUploadPrivateFile from './go-cqhttp/UploadPrivareFile';
|
||||||
|
import TestApi01 from './extends/TestApi01';
|
||||||
|
|
||||||
export const actionHandlers = [
|
export const actionHandlers = [
|
||||||
new RebootNormal(),
|
new RebootNormal(),
|
||||||
@@ -160,9 +161,9 @@ export const actionHandlers = [
|
|||||||
new GetProfileLike(),
|
new GetProfileLike(),
|
||||||
new SetGroupHeader(),
|
new SetGroupHeader(),
|
||||||
new FetchCustomFace(),
|
new FetchCustomFace(),
|
||||||
new GoCQHTTPUploadPrivateFile()
|
new GoCQHTTPUploadPrivateFile(),
|
||||||
|
new TestApi01()
|
||||||
];
|
];
|
||||||
|
|
||||||
function initActionMap() {
|
function initActionMap() {
|
||||||
const actionMap = new Map<string, BaseAction<any, any>>();
|
const actionMap = new Map<string, BaseAction<any, any>>();
|
||||||
for (const action of actionHandlers) {
|
for (const action of actionHandlers) {
|
||||||
|
@@ -36,7 +36,7 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
|||||||
const msg = await NTQQMsgApi.getMsgsByMsgId(
|
const msg = await NTQQMsgApi.getMsgsByMsgId(
|
||||||
peer,
|
peer,
|
||||||
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
[msgIdWithPeer?.MsgId || payload.message_id.toString()]);
|
||||||
let retMsg = await OB11Constructor.message(msg.msgList[0]);
|
const retMsg = await OB11Constructor.message(msg.msgList[0]);
|
||||||
try {
|
try {
|
||||||
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!;
|
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!;
|
||||||
retMsg.message_seq = retMsg.message_id;
|
retMsg.message_seq = retMsg.message_id;
|
||||||
|
@@ -12,25 +12,22 @@ import {
|
|||||||
SignMusicWrapper
|
SignMusicWrapper
|
||||||
} from '@/core';
|
} from '@/core';
|
||||||
import { getGroupMember } from '@/core/data';
|
import { getGroupMember } from '@/core/data';
|
||||||
import { logDebug, logError, logWarn } from '@/common/utils/log';
|
import { logError, logWarn } from '@/common/utils/log';
|
||||||
import { uri2local } from '@/common/utils/file';
|
import { uri2local } from '@/common/utils/file';
|
||||||
import { ob11Config } from '@/onebot11/config';
|
import { ob11Config } from '@/onebot11/config';
|
||||||
import { RequestUtil } from '@/common/utils/request';
|
import { RequestUtil } from '@/common/utils/request';
|
||||||
import fs from 'node:fs';
|
|
||||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||||
|
|
||||||
export type MessageContext = {
|
export type MessageContext = {
|
||||||
group?: Group,
|
group?: Group,
|
||||||
deleteAfterSentFiles: string[],
|
deleteAfterSentFiles: string[],
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleOb11FileLikeMessage(
|
async function handleOb11FileLikeMessage(
|
||||||
{ data: { file, name: payloadFileName } }: OB11MessageFileBase,
|
{ data: inputdata }: OB11MessageFileBase,
|
||||||
{ deleteAfterSentFiles }: MessageContext
|
{ deleteAfterSentFiles }: MessageContext
|
||||||
) {
|
) {
|
||||||
const uri = file;
|
//有的奇怪的框架将url作为参数 而不是file 此时优先url
|
||||||
|
const { path, isLocal, fileName, errMsg } = (await uri2local(inputdata?.url || inputdata.file));
|
||||||
const { path, isLocal, fileName, errMsg } = (await uri2local(uri));
|
|
||||||
|
|
||||||
if (errMsg) {
|
if (errMsg) {
|
||||||
logError('文件下载失败', errMsg);
|
logError('文件下载失败', errMsg);
|
||||||
@@ -41,7 +38,7 @@ async function handleOb11FileLikeMessage(
|
|||||||
deleteAfterSentFiles.push(path);
|
deleteAfterSentFiles.push(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return { path, fileName: payloadFileName || fileName };
|
return { path, fileName: inputdata.name || fileName };
|
||||||
}
|
}
|
||||||
|
|
||||||
const _handlers: {
|
const _handlers: {
|
||||||
|
@@ -10,6 +10,7 @@ import { ActionName, BaseCheckResult } from '@/onebot11/action/types';
|
|||||||
import { getGroup } from '@/core/data';
|
import { getGroup } from '@/core/data';
|
||||||
import { ChatType, ElementType, Group, NTQQFileApi, NTQQFriendApi, NTQQMsgApi, NTQQUserApi, Peer, SendMessageElement, } from '@/core';
|
import { ChatType, ElementType, Group, NTQQFileApi, NTQQFriendApi, NTQQMsgApi, NTQQUserApi, Peer, SendMessageElement, } from '@/core';
|
||||||
import fs from 'node:fs';
|
import fs from 'node:fs';
|
||||||
|
import fsPromise from 'node:fs/promises';
|
||||||
import { logDebug, logError } from '@/common/utils/log';
|
import { logDebug, logError } from '@/common/utils/log';
|
||||||
import { decodeCQCode } from '@/onebot11/cqcode';
|
import { decodeCQCode } from '@/onebot11/cqcode';
|
||||||
import createSendElements from './create-send-elements';
|
import createSendElements from './create-send-elements';
|
||||||
@@ -71,14 +72,7 @@ export async function sendMsg(peer: Peer, sendElements: SendMessageElement[], de
|
|||||||
logDebug('发送消息id获取失败', e);
|
logDebug('发送消息id获取失败', e);
|
||||||
returnMsg!.id = 0;
|
returnMsg!.id = 0;
|
||||||
}
|
}
|
||||||
|
deleteAfterSentFiles.map((f) => { fsPromise.unlink(f).then().catch(e => logError('发送消息删除文件失败', e)); });
|
||||||
deleteAfterSentFiles.map((f) => {
|
|
||||||
try {
|
|
||||||
fs.unlinkSync(f);
|
|
||||||
} catch (e) {
|
|
||||||
logError('发送消息删除文件失败', e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return returnMsg;
|
return returnMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +128,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
return { valid: false, message: `群${payload.group_id}不存在` };
|
return { valid: false, message: `群${payload.group_id}不存在` };
|
||||||
}
|
}
|
||||||
if (payload.user_id && payload.message_type !== 'group') {
|
if (payload.user_id && payload.message_type !== 'group') {
|
||||||
const uid = await NTQQUserApi.getUidByUin(payload.user_id);
|
const uid = await NTQQUserApi.getUidByUin(payload.user_id.toString());
|
||||||
const isBuddy = await NTQQFriendApi.isBuddy(uid!);
|
const isBuddy = await NTQQFriendApi.isBuddy(uid!);
|
||||||
// 此处有问题
|
// 此处有问题
|
||||||
if (!isBuddy) {
|
if (!isBuddy) {
|
||||||
|
@@ -101,5 +101,6 @@ export enum ActionName {
|
|||||||
GetProfileLike = 'get_profile_like',
|
GetProfileLike = 'get_profile_like',
|
||||||
SetGroupHeader = 'set_group_head',
|
SetGroupHeader = 'set_group_head',
|
||||||
FetchCustomFace = 'fetch_custom_face',
|
FetchCustomFace = 'fetch_custom_face',
|
||||||
GOCQHTTP_UploadPrivateFile = 'upload_private_file'
|
GOCQHTTP_UploadPrivateFile = 'upload_private_file',
|
||||||
|
TestApi01 = 'test_api_01'
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@ import BaseAction from '../BaseAction';
|
|||||||
import { ActionName } from '../types';
|
import { ActionName } from '../types';
|
||||||
import { NTQQFriendApi } from '@/core';
|
import { NTQQFriendApi } from '@/core';
|
||||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||||
|
import { requireMinNTQQBuild } from '@/common/utils/QQBasicInfo';
|
||||||
|
|
||||||
|
|
||||||
// no_cache get时传字符串
|
// no_cache get时传字符串
|
||||||
@@ -20,6 +21,10 @@ export default class GetFriendList extends BaseAction<Payload, OB11User[]> {
|
|||||||
actionName = ActionName.GetFriendList;
|
actionName = ActionName.GetFriendList;
|
||||||
PayloadSchema = SchemaData;
|
PayloadSchema = SchemaData;
|
||||||
protected async _handle(payload: Payload) {
|
protected async _handle(payload: Payload) {
|
||||||
|
if (requireMinNTQQBuild('26702')) {
|
||||||
|
//全新逻辑
|
||||||
|
return OB11Constructor.friendsV2(await NTQQFriendApi.getBuddyV2(payload?.no_cache === true || payload?.no_cache === 'true'));
|
||||||
|
}
|
||||||
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
if (friends.size === 0 || payload?.no_cache === true || payload?.no_cache === 'true') {
|
||||||
const _friends = await NTQQFriendApi.getFriends(true);
|
const _friends = await NTQQFriendApi.getFriends(true);
|
||||||
// log('强制刷新好友列表,结果: ', _friends)
|
// log('强制刷新好友列表,结果: ', _friends)
|
||||||
|
@@ -14,6 +14,7 @@ import {
|
|||||||
ChatType,
|
ChatType,
|
||||||
FaceIndex,
|
FaceIndex,
|
||||||
Friend,
|
Friend,
|
||||||
|
FriendV2,
|
||||||
GrayTipElementSubType,
|
GrayTipElementSubType,
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
@@ -22,6 +23,7 @@ import {
|
|||||||
RawMessage,
|
RawMessage,
|
||||||
SelfInfo,
|
SelfInfo,
|
||||||
Sex,
|
Sex,
|
||||||
|
SimpleInfo,
|
||||||
TipGroupElementType,
|
TipGroupElementType,
|
||||||
User,
|
User,
|
||||||
VideoElement
|
VideoElement
|
||||||
@@ -44,6 +46,7 @@ import { deleteGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap }
|
|||||||
import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
||||||
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
||||||
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
|
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
|
||||||
|
import { OB11FriendAddNoticeEvent } from './event/notice/OB11FriendAddNoticeEvent';
|
||||||
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
|
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
|
||||||
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent';
|
import { OB11GroupEssenceEvent } from './event/notice/OB11GroupEssenceEvent';
|
||||||
import { MessageUnique } from '@/common/utils/MessageUnique';
|
import { MessageUnique } from '@/common/utils/MessageUnique';
|
||||||
@@ -89,8 +92,9 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
else if (msg.chatType == ChatType.friend) {
|
else if (msg.chatType == ChatType.friend) {
|
||||||
resMsg.sub_type = 'friend';
|
resMsg.sub_type = 'friend';
|
||||||
const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
resMsg.sender.nickname = (await NTQQUserApi.getUserDetailInfo(msg.senderUid)).nick;
|
||||||
resMsg.sender.nickname = user.info.nick;
|
//const user = await NTQQUserApi.getUserDetailInfoByUin(msg.senderUin!);
|
||||||
|
//resMsg.sender.nickname = user.info.nick;
|
||||||
}
|
}
|
||||||
else if (msg.chatType == ChatType.temp) {
|
else if (msg.chatType == ChatType.temp) {
|
||||||
resMsg.sub_type = 'group';
|
resMsg.sub_type = 'group';
|
||||||
@@ -100,33 +104,40 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const element of msg.elements) {
|
for (const element of msg.elements) {
|
||||||
const message_data: OB11MessageData | any = {
|
let message_data: OB11MessageData = {
|
||||||
data: {},
|
data: {} as any,
|
||||||
type: 'unknown'
|
type: 'unknown' as any
|
||||||
};
|
};
|
||||||
if (element.textElement && element.textElement?.atType !== AtType.notAt) {
|
if (element.textElement && element.textElement?.atType !== AtType.notAt) {
|
||||||
message_data['type'] = OB11MessageDataType.at;
|
let qq: `${number}` | 'all';
|
||||||
|
let name: string | undefined;
|
||||||
if (element.textElement.atType == AtType.atAll) {
|
if (element.textElement.atType == AtType.atAll) {
|
||||||
// message_data["data"]["mention"] = "all"
|
qq = 'all';
|
||||||
message_data['data']['qq'] = 'all';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const atUid = element.textElement.atNtUid;
|
const { atNtUid, content } = element.textElement;
|
||||||
let atQQ = element.textElement.atUid;
|
let atQQ = element.textElement.atUid;
|
||||||
if (!atQQ || atQQ === '0') {
|
if (!atQQ || atQQ === '0') {
|
||||||
const atMember = await getGroupMember(msg.peerUin, atUid);
|
const atMember = await getGroupMember(msg.peerUin, atNtUid);
|
||||||
if (atMember) {
|
if (atMember) {
|
||||||
atQQ = atMember.uin;
|
atQQ = atMember.uin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (atQQ) {
|
if (atQQ) {
|
||||||
// message_data["data"]["mention"] = atQQ
|
qq = atQQ as `${number}`;
|
||||||
message_data['data']['qq'] = atQQ;
|
name = content.replace('@', '');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
message_data = {
|
||||||
|
type: OB11MessageDataType.at,
|
||||||
|
data: {
|
||||||
|
qq: qq!,
|
||||||
|
name
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else if (element.textElement) {
|
else if (element.textElement) {
|
||||||
message_data['type'] = 'text';
|
message_data['type'] = OB11MessageDataType.text;
|
||||||
|
|
||||||
let text = element.textElement.content;
|
let text = element.textElement.content;
|
||||||
if (!text.trim()) {
|
if (!text.trim()) {
|
||||||
@@ -139,7 +150,7 @@ export class OB11Constructor {
|
|||||||
message_data['data']['text'] = text;
|
message_data['data']['text'] = text;
|
||||||
}
|
}
|
||||||
else if (element.replyElement) {
|
else if (element.replyElement) {
|
||||||
message_data['type'] = 'reply';
|
message_data['type'] = OB11MessageDataType.reply;
|
||||||
//log("收到回复消息", element.replyElement);
|
//log("收到回复消息", element.replyElement);
|
||||||
try {
|
try {
|
||||||
//做这么多都是因为NC速度太快 可能nt还没有写入数据库
|
//做这么多都是因为NC速度太快 可能nt还没有写入数据库
|
||||||
@@ -162,17 +173,18 @@ export class OB11Constructor {
|
|||||||
message_data['data']['id'] = MessageUnique.createMsg({ peerUid: msg.peerUid, guildId: '', chatType: msg.chatType }, replyMsg.msgId)?.toString();
|
message_data['data']['id'] = MessageUnique.createMsg({ peerUid: msg.peerUid, guildId: '', chatType: msg.chatType }, replyMsg.msgId)?.toString();
|
||||||
//log("找到回复消息", message_data['data']['id'], replyMsg.msgList[0].msgId)
|
//log("找到回复消息", message_data['data']['id'], replyMsg.msgList[0].msgId)
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
message_data['type'] = "unknown";
|
message_data['type'] = 'unknown' as any;
|
||||||
message_data['data'] = undefined;
|
message_data['data'] = undefined;
|
||||||
logError('获取不到引用的消息', e.stack, element.replyElement.replayMsgSeq);
|
logError('获取不到引用的消息', e.stack, element.replyElement.replayMsgSeq);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (element.picElement) {
|
else if (element.picElement) {
|
||||||
message_data['type'] = 'image';
|
message_data['type'] = OB11MessageDataType.image;
|
||||||
// message_data["data"]["file"] = element.picElement.sourcePath
|
// message_data["data"]["file"] = element.picElement.sourcePath
|
||||||
message_data['data']['file'] = element.picElement.fileName;
|
message_data['data']['file'] = element.picElement.fileName;
|
||||||
message_data['data']['subType'] = element.picElement.picSubType;
|
message_data['data']['subType'] = element.picElement.picSubType;
|
||||||
|
message_data['data']['file_id'] = UUIDConverter.encode(msg.peerUin, msg.msgId);
|
||||||
// message_data["data"]["path"] = element.picElement.sourcePath
|
// message_data["data"]["path"] = element.picElement.sourcePath
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -317,7 +329,7 @@ export class OB11Constructor {
|
|||||||
message_data['type'] = OB11MessageDataType.forward;
|
message_data['type'] = OB11MessageDataType.forward;
|
||||||
message_data['data']['id'] = msg.msgId;
|
message_data['data']['id'] = msg.msgId;
|
||||||
}
|
}
|
||||||
if (message_data.type !== 'unknown' && message_data.data) {
|
if ((message_data.type as string) !== 'unknown' && message_data.data) {
|
||||||
const cqCode = encodeCQCode(message_data);
|
const cqCode = encodeCQCode(message_data);
|
||||||
|
|
||||||
if (messagePostFormat === 'string') {
|
if (messagePostFormat === 'string') {
|
||||||
@@ -353,6 +365,12 @@ export class OB11Constructor {
|
|||||||
}
|
}
|
||||||
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
||||||
}
|
}
|
||||||
|
if (element.grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER) {
|
||||||
|
//好友添加成功事件
|
||||||
|
if (element.grayTipElement.xmlElement.templId === '10229' && msg.peerUin !== '') {
|
||||||
|
return new OB11FriendAddNoticeEvent(parseInt(msg.peerUin));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -537,7 +555,24 @@ export class OB11Constructor {
|
|||||||
nickname: selfInfo.nick,
|
nickname: selfInfo.nick,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
static friendsV2(friends: FriendV2[]): OB11User[] {
|
||||||
|
const data: OB11User[] = [];
|
||||||
|
friends.forEach(friend => {
|
||||||
|
const sexValue = this.sex(friend.baseInfo.sex!);
|
||||||
|
data.push({
|
||||||
|
...friend.baseInfo,
|
||||||
|
...friend.coreInfo,
|
||||||
|
user_id: parseInt(friend.coreInfo.uin),
|
||||||
|
nickname: friend.coreInfo.nick,
|
||||||
|
remark: friend.coreInfo.nick,
|
||||||
|
sex: sexValue,
|
||||||
|
level: 0,
|
||||||
|
categroyName: friend.categroyName,
|
||||||
|
categoryId: friend.categoryId
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return data;
|
||||||
|
}
|
||||||
static friends(friends: Friend[]): OB11User[] {
|
static friends(friends: Friend[]): OB11User[] {
|
||||||
const data: OB11User[] = [];
|
const data: OB11User[] = [];
|
||||||
friends.forEach(friend => {
|
friends.forEach(friend => {
|
||||||
|
@@ -66,16 +66,16 @@ export function encodeCQCode(data: OB11MessageData) {
|
|||||||
|
|
||||||
let result = '[CQ:' + data.type;
|
let result = '[CQ:' + data.type;
|
||||||
for (const name in data.data) {
|
for (const name in data.data) {
|
||||||
let value = data.data[name];
|
const value = data.data[name];
|
||||||
try {
|
if (value === undefined) {
|
||||||
// Check if the value can be converted to a string
|
|
||||||
value = value.toString();
|
|
||||||
} catch (error) {
|
|
||||||
// If it can't be converted, skip this name-value pair
|
|
||||||
// console.warn(`Skipping problematic name-value pair. Name: ${name}, Value: ${value}`);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
result += `,${name}=${CQCodeEscape(value)}`;
|
try {
|
||||||
|
const text = value.toString();
|
||||||
|
result += `,${name}=${CQCodeEscape(text)}`;
|
||||||
|
} catch (error) {
|
||||||
|
// If it can't be converted, skip this name-value pair
|
||||||
|
}
|
||||||
}
|
}
|
||||||
result += ']';
|
result += ']';
|
||||||
return result;
|
return result;
|
||||||
|
11
src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts
Normal file
11
src/onebot11/event/notice/OB11FriendAddNoticeEvent.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||||
|
|
||||||
|
export class OB11FriendAddNoticeEvent extends OB11BaseNoticeEvent {
|
||||||
|
notice_type = 'friend_add';
|
||||||
|
user_id: number;
|
||||||
|
|
||||||
|
public constructor(user_Id: number) {
|
||||||
|
super();
|
||||||
|
this.user_id = user_Id;
|
||||||
|
}
|
||||||
|
}
|
@@ -22,7 +22,7 @@ import { ob11ReverseWebsockets } from '@/onebot11/server/ws/ReverseWebsocket';
|
|||||||
import { getGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/core/data';
|
import { getGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap } from '@/core/data';
|
||||||
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
import { BuddyListener, GroupListener, NodeIKernelBuddyListener } from '@/core/listeners';
|
||||||
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
import { OB11FriendRequestEvent } from '@/onebot11/event/request/OB11FriendRequest';
|
||||||
import { NTQQGroupApi, NTQQUserApi } from '@/core/apis';
|
import { NTQQGroupApi, NTQQUserApi, WebApi } from '@/core/apis';
|
||||||
import { log, logDebug, logError, setLogSelfInfo } from '@/common/utils/log';
|
import { log, logDebug, logError, setLogSelfInfo } from '@/common/utils/log';
|
||||||
import { OB11GroupRequestEvent } from '@/onebot11/event/request/OB11GroupRequest';
|
import { OB11GroupRequestEvent } from '@/onebot11/event/request/OB11GroupRequest';
|
||||||
import { OB11GroupAdminNoticeEvent } from '@/onebot11/event/notice/OB11GroupAdminNoticeEvent';
|
import { OB11GroupAdminNoticeEvent } from '@/onebot11/event/notice/OB11GroupAdminNoticeEvent';
|
||||||
@@ -209,6 +209,7 @@ export class NapCatOnebot11 {
|
|||||||
// 临时会话更新 tempGroupCodeMap uid -> source/GroupCode
|
// 临时会话更新 tempGroupCodeMap uid -> source/GroupCode
|
||||||
};
|
};
|
||||||
msgListener.onRecvMsg = async (msg) => {
|
msgListener.onRecvMsg = async (msg) => {
|
||||||
|
|
||||||
//console.log('ob11 onRecvMsg', JSON.stringify(msg, null, 2));
|
//console.log('ob11 onRecvMsg', JSON.stringify(msg, null, 2));
|
||||||
// logDebug('收到消息', msg);
|
// logDebug('收到消息', msg);
|
||||||
for (const m of msg) {
|
for (const m of msg) {
|
||||||
@@ -242,10 +243,8 @@ export class NapCatOnebot11 {
|
|||||||
this.postRecallMsg(msgList).then().catch(logError);
|
this.postRecallMsg(msgList).then().catch(logError);
|
||||||
for (const msg of msgList.filter(e => e.senderUin == selfInfo.uin)) {
|
for (const msg of msgList.filter(e => e.senderUin == selfInfo.uin)) {
|
||||||
// console.log(msg);
|
// console.log(msg);
|
||||||
if (msg.sendStatus !== 2) {
|
if (msg.sendStatus == 2) {
|
||||||
//完成后再post
|
//完成后再post
|
||||||
return;
|
|
||||||
}
|
|
||||||
OB11Constructor.message(msg).then((_msg) => {
|
OB11Constructor.message(msg).then((_msg) => {
|
||||||
_msg.target_id = parseInt(msg.peerUin);
|
_msg.target_id = parseInt(msg.peerUin);
|
||||||
if (ob11Config.reportSelfMessage) {
|
if (ob11Config.reportSelfMessage) {
|
||||||
@@ -256,6 +255,8 @@ export class NapCatOnebot11 {
|
|||||||
}
|
}
|
||||||
}).catch(logError);
|
}).catch(logError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
msgListener.onAddSendMsg = (msg) => {
|
msgListener.onAddSendMsg = (msg) => {
|
||||||
|
|
||||||
@@ -285,7 +286,7 @@ export class NapCatOnebot11 {
|
|||||||
// }
|
// }
|
||||||
groupListener.onGroupNotifiesUpdated = async (doubt, notifies) => {
|
groupListener.onGroupNotifiesUpdated = async (doubt, notifies) => {
|
||||||
//console.log('ob11 onGroupNotifiesUpdated', notifies[0]);
|
//console.log('ob11 onGroupNotifiesUpdated', notifies[0]);
|
||||||
if (![GroupNotifyTypes.INVITE_ME, GroupNotifyTypes.ADMIN_SET, GroupNotifyTypes.ADMIN_UNSET, GroupNotifyTypes.ADMIN_UNSET_OTHER].includes(notifies[0].type)) {
|
if (![GroupNotifyTypes.ADMIN_SET, GroupNotifyTypes.ADMIN_UNSET, GroupNotifyTypes.ADMIN_UNSET_OTHER].includes(notifies[0].type)) {
|
||||||
this.postGroupNotifies(notifies).then().catch(e => logError('postGroupNotifies error: ', e));
|
this.postGroupNotifies(notifies).then().catch(e => logError('postGroupNotifies error: ', e));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -10,8 +10,8 @@ import { postOB11Event } from '@/onebot11/server/postOB11Event';
|
|||||||
class OB11HTTPServer extends HttpServerBase {
|
class OB11HTTPServer extends HttpServerBase {
|
||||||
name = 'OneBot V11 server';
|
name = 'OneBot V11 server';
|
||||||
|
|
||||||
handleFailed(res: Response, payload: any, e: any) {
|
handleFailed(res: Response, payload: any, e: Error) {
|
||||||
res.send(OB11Response.error(e.stack.toString(), 200));
|
res.send(OB11Response.error(e?.stack?.toString() || e.message || "Error Handle", 200));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected listen(port: number, host: string) {
|
protected listen(port: number, host: string) {
|
||||||
|
@@ -7,6 +7,8 @@ export interface OB11User {
|
|||||||
age?: number;
|
age?: number;
|
||||||
qid?: string;
|
qid?: string;
|
||||||
login_days?: number;
|
login_days?: number;
|
||||||
|
categroyName?:string;
|
||||||
|
categoryId?:number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum OB11UserSex {
|
export enum OB11UserSex {
|
||||||
|
@@ -114,6 +114,7 @@ export interface OB11MessageAt {
|
|||||||
type: OB11MessageDataType.at
|
type: OB11MessageDataType.at
|
||||||
data: {
|
data: {
|
||||||
qq: `${number}` | 'all'
|
qq: `${number}` | 'all'
|
||||||
|
name?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,13 +178,20 @@ export interface OB11MessageMarkdown {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface OB11MessageForward {
|
||||||
|
type: OB11MessageDataType.forward
|
||||||
|
data: {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export type OB11MessageData =
|
export type OB11MessageData =
|
||||||
OB11MessageText |
|
OB11MessageText |
|
||||||
OB11MessageFace | OB11MessageMFace |
|
OB11MessageFace | OB11MessageMFace |
|
||||||
OB11MessageAt | OB11MessageReply |
|
OB11MessageAt | OB11MessageReply |
|
||||||
OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo |
|
OB11MessageImage | OB11MessageRecord | OB11MessageFile | OB11MessageVideo |
|
||||||
OB11MessageNode | OB11MessageIdMusic | OB11MessageCustomMusic | OB11MessageJson |
|
OB11MessageNode | OB11MessageIdMusic | OB11MessageCustomMusic | OB11MessageJson |
|
||||||
OB11MessageDice | OB11MessageRPS | OB11MessageMarkdown
|
OB11MessageDice | OB11MessageRPS | OB11MessageMarkdown | OB11MessageForward
|
||||||
|
|
||||||
export interface OB11PostSendMsg {
|
export interface OB11PostSendMsg {
|
||||||
message_type?: 'private' | 'group'
|
message_type?: 'private' | 'group'
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const version = '1.7.3';
|
export const version = '1.7.7';
|
||||||
|
@@ -29,7 +29,7 @@ async function onSettingWindowCreated(view: Element) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
undefined,
|
undefined,
|
||||||
SettingButton('V1.7.3', 'napcat-update-button', 'secondary')
|
SettingButton('V1.7.7', 'napcat-update-button', 'secondary')
|
||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
@@ -163,7 +163,7 @@ async function onSettingWindowCreated(view) {
|
|||||||
SettingItem(
|
SettingItem(
|
||||||
'<span id="napcat-update-title">Napcat</span>',
|
'<span id="napcat-update-title">Napcat</span>',
|
||||||
void 0,
|
void 0,
|
||||||
SettingButton("V1.7.3", "napcat-update-button", "secondary")
|
SettingButton("V1.7.7", "napcat-update-button", "secondary")
|
||||||
)
|
)
|
||||||
]),
|
]),
|
||||||
SettingList([
|
SettingList([
|
||||||
|
Reference in New Issue
Block a user