mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
88 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
e0efe635c7 | ||
![]() |
1a06841de0 | ||
![]() |
3987e0ee0b | ||
![]() |
9f53bea02f | ||
![]() |
737709f9e7 | ||
![]() |
39477aa6a0 | ||
![]() |
f097050b56 | ||
![]() |
f14726ed1a | ||
![]() |
e1e4d038d9 | ||
![]() |
d2db4cf887 | ||
![]() |
2f3ece9ca3 | ||
![]() |
9f82007116 | ||
![]() |
f79198a472 | ||
![]() |
ce3d35d7ec | ||
![]() |
f4d40f0466 | ||
![]() |
a2fa085d5f | ||
![]() |
a598266a6e | ||
![]() |
f5fe33cee7 | ||
![]() |
200c7226ef | ||
![]() |
53475a6a0e | ||
![]() |
b4ec1ad6c0 | ||
![]() |
ef511a729d | ||
![]() |
275c4ce226 | ||
![]() |
45f9c029c8 | ||
![]() |
db5e4ad5d9 | ||
![]() |
f05d0a9727 | ||
![]() |
04593e9d9a | ||
![]() |
b1ecf13f8e | ||
![]() |
e91e054f20 | ||
![]() |
130ff7517e | ||
![]() |
c7042d9684 | ||
![]() |
5752e45dd1 | ||
![]() |
1a034ecb53 | ||
![]() |
025da8fb76 | ||
![]() |
2027da1db5 | ||
![]() |
7732f28ca8 | ||
![]() |
7f9da8cc2d | ||
![]() |
c6342b80a7 | ||
![]() |
f99c82de4b | ||
![]() |
56fa57ea02 | ||
![]() |
cc85985d08 | ||
![]() |
bd1751903e | ||
![]() |
03a298a70f | ||
![]() |
2722ca2b0e | ||
![]() |
179c4b800e | ||
![]() |
6bdf14223d | ||
![]() |
1b8252aa4f | ||
![]() |
8219889154 | ||
![]() |
df4ac5dcce | ||
![]() |
738eaf9de9 | ||
![]() |
c483ccbbbc | ||
![]() |
0d65f846ae | ||
![]() |
f47e75c423 | ||
![]() |
c008e58fb8 | ||
![]() |
26e0f17bc5 | ||
![]() |
6543f28bdb | ||
![]() |
a86851b338 | ||
![]() |
3a03e455c6 | ||
![]() |
3d39fd1580 | ||
![]() |
601b0add26 | ||
![]() |
4f974cc913 | ||
![]() |
f691320453 | ||
![]() |
be39fc3a21 | ||
![]() |
d2fafaf33a | ||
![]() |
27ae331352 | ||
![]() |
3f2dcfbacc | ||
![]() |
8565aee8b6 | ||
![]() |
f983add599 | ||
![]() |
030192afeb | ||
![]() |
c8b6a158f1 | ||
![]() |
e71f7849a7 | ||
![]() |
b64d1ff4ff | ||
![]() |
5a0028be26 | ||
![]() |
926d7deb43 | ||
![]() |
6384b50bae | ||
![]() |
9feb0f4b53 | ||
![]() |
43ec1b7cfd | ||
![]() |
05b7a59f8d | ||
![]() |
17e680f7af | ||
![]() |
035d256d4e | ||
![]() |
8939adf886 | ||
![]() |
027ffbffa6 | ||
![]() |
3cca06712b | ||
![]() |
2b9359dbf4 | ||
![]() |
c0f5d3bd2e | ||
![]() |
2a2d5382e1 | ||
![]() |
2e4986024c | ||
![]() |
8a9c605dae |
@@ -4,7 +4,7 @@ module.exports = {
|
||||
'es2021': true,
|
||||
'node': true
|
||||
},
|
||||
'ignorePatterns': ['src/proto/'],
|
||||
'ignorePatterns': ['src/core/proto/'],
|
||||
'extends': [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended'
|
||||
|
@@ -4,7 +4,7 @@
|
||||
"name": "NapCatQQ",
|
||||
"slug": "NapCat.Framework",
|
||||
"description": "高性能的 OneBot 11 协议实现",
|
||||
"version": "2.2.13",
|
||||
"version": "2.2.26",
|
||||
"icon": "./logo.png",
|
||||
"authors": [
|
||||
{
|
||||
|
@@ -2,7 +2,7 @@
|
||||
"name": "napcat",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"version": "2.2.13",
|
||||
"version": "2.2.26",
|
||||
"scripts": {
|
||||
"build:framework": "vite build --mode framework",
|
||||
"build:shell": "vite build --mode shell",
|
||||
@@ -27,8 +27,8 @@
|
||||
"@types/node": "^22.0.1",
|
||||
"@types/qrcode-terminal": "^0.12.2",
|
||||
"@types/ws": "^8.5.12",
|
||||
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
||||
"@typescript-eslint/parser": "^7.4.0",
|
||||
"@typescript-eslint/eslint-plugin": "^8.3.0",
|
||||
"@typescript-eslint/parser": "^8.3.0",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-import-resolver-typescript": "^3.6.1",
|
||||
"eslint-plugin-import": "^2.29.1",
|
||||
|
2
script/KillQQ.bat
Normal file
2
script/KillQQ.bat
Normal file
@@ -0,0 +1,2 @@
|
||||
@echo off
|
||||
taskkill /f /im QQ.exe
|
@@ -1,4 +1,4 @@
|
||||
import type { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper/wrapper';
|
||||
import type { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper';
|
||||
import EventEmitter from 'node:events';
|
||||
|
||||
export type ListenerClassBase = Record<string, string>;
|
||||
@@ -10,7 +10,7 @@ export interface ListenerIBase {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export class NTEventChannel extends EventEmitter {
|
||||
export class NTEventWrapperV2 extends EventEmitter {
|
||||
private wrapperApi: WrapperNodeApi;
|
||||
private wrapperSession: NodeIQQNTWrapperSession;
|
||||
private listenerRefStorage = new Map<string, ListenerIBase>();
|
@@ -1,4 +1,4 @@
|
||||
import { NodeIQQNTWrapperSession } from '@/core/wrapper/wrapper';
|
||||
import { NodeIQQNTWrapperSession } from '@/core/wrapper';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { ListenerNamingMapping, ServiceNamingMapping } from '@/core';
|
||||
|
||||
@@ -11,7 +11,7 @@ interface InternalMapKey {
|
||||
|
||||
export type ListenerClassBase = Record<string, string>;
|
||||
|
||||
export class LegacyNTEventWrapper {
|
||||
export class NTEventWrapper {
|
||||
private WrapperSession: NodeIQQNTWrapperSession | undefined; //WrapperSession
|
||||
private listenerManager: Map<string, ListenerClassBase> = new Map<string, ListenerClassBase>(); //ListenerName-Unique -> Listener实例
|
||||
private EventTask = new Map<string, Map<string, Map<string, InternalMapKey>>>(); //tasks ListenerMainName -> ListenerSubName-> uuid -> {timeout,createtime,func}
|
@@ -1,7 +1,7 @@
|
||||
import path from 'node:path';
|
||||
import fs from 'fs';
|
||||
import os from 'node:os';
|
||||
import { QQLevel } from '@/core';
|
||||
import { Peer, QQLevel } from '@/core';
|
||||
|
||||
export async function solveProblem<T extends (...arg: any[]) => any>(func: T, ...args: Parameters<T>): Promise<ReturnType<T> | undefined> {
|
||||
return new Promise<ReturnType<T> | undefined>((resolve) => {
|
||||
@@ -23,29 +23,48 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//下面这个类是用于将uid+msgid合并的类
|
||||
export class UUIDConverter {
|
||||
static encode(highStr: string, lowStr: string): string {
|
||||
const high = BigInt(highStr);
|
||||
const low = BigInt(lowStr);
|
||||
const highHex = high.toString(16).padStart(16, '0');
|
||||
const lowHex = low.toString(16).padStart(16, '0');
|
||||
const combinedHex = highHex + lowHex;
|
||||
return `${combinedHex.substring(0, 8)}-${combinedHex.substring(8, 12)}-${combinedHex.substring(
|
||||
12,
|
||||
16,
|
||||
)}-${combinedHex.substring(16, 20)}-${combinedHex.substring(20)}`;
|
||||
export class FileNapCatOneBotUUID {
|
||||
static encodeModelId(peer: Peer, modelId: string): string {
|
||||
return `NapCatOneBot-ModeldFile-${peer.chatType}-${peer.peerUid}-${modelId}`;
|
||||
}
|
||||
|
||||
static decode(uuid: string): { high: string; low: string } {
|
||||
const hex = uuid.replace(/-/g, '');
|
||||
const high = BigInt('0x' + hex.substring(0, 16));
|
||||
const low = BigInt('0x' + hex.substring(16));
|
||||
return { high: high.toString(), low: low.toString() };
|
||||
static decodeModelId(uuid: string): undefined | {
|
||||
peer: Peer,
|
||||
modelId: string
|
||||
} {
|
||||
if (!uuid.startsWith('NapCatOneBot-ModeldFile-')) return undefined;
|
||||
const data = uuid.split('-');
|
||||
if (data.length !== 5) return undefined;
|
||||
const [, , chatType, peerUid, modelId] = data;
|
||||
return {
|
||||
peer: {
|
||||
chatType: chatType as any,
|
||||
peerUid: peerUid
|
||||
},
|
||||
modelId,
|
||||
};
|
||||
}
|
||||
static encode(peer: Peer, msgId: string, elementId: string): string {
|
||||
return `NapCatOneBot-MsgFile-${peer.chatType}-${peer.peerUid}-${msgId}-${elementId}`;
|
||||
}
|
||||
static decode(uuid: string): undefined | {
|
||||
peer: Peer,
|
||||
msgId: string,
|
||||
elementId: string
|
||||
} {
|
||||
if (!uuid.startsWith('NapCatOneBot-MsgFile-')) return undefined;
|
||||
const data = uuid.split('-');
|
||||
if (data.length !== 6) return undefined;
|
||||
const [, , chatType, peerUid, msgId, elementId] = data;
|
||||
return {
|
||||
peer: {
|
||||
chatType: chatType as any,
|
||||
peerUid: peerUid
|
||||
},
|
||||
msgId,
|
||||
elementId,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function sleep(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
import log4js, { Configuration } from 'log4js';
|
||||
import { truncateString } from '@/common/utils/helper';
|
||||
import { truncateString } from '@/common/helper';
|
||||
import path from 'node:path';
|
||||
import chalk from 'chalk';
|
||||
import { AtType, ChatType, ElementType, MessageElement, RawMessage, SelfInfo } from '@/core';
|
@@ -91,7 +91,7 @@ class MessageUniqueWrapper {
|
||||
return ret.map((t) => t?.MsgId).filter((t) => t !== undefined);
|
||||
}
|
||||
|
||||
createMsg(peer: Peer, msgId: string) {
|
||||
createUniqueMsgId(peer: Peer, msgId: string) {
|
||||
const key = `${msgId}|${peer.chatType}|${peer.peerUid}`;
|
||||
const hash = crypto.createHash('md5').update(key).digest();
|
||||
//设置第一个bit为0 保证shortId为正数
|
@@ -2,8 +2,6 @@ import path, { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import fs from 'fs';
|
||||
|
||||
export const napcat_version = '2.2.13';
|
||||
|
||||
export class NapCatPathWrapper {
|
||||
binaryPath: string;
|
||||
logsPath: string;
|
@@ -1,6 +1,6 @@
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { systemPlatform } from '@/common/utils/system';
|
||||
import { systemPlatform } from '@/common/system';
|
||||
import { getDefaultQQVersionConfigInfo, getQQVersionConfigPath } from './helper';
|
||||
import AppidTable from '@/core/external/appid.json';
|
||||
import { LogWrapper } from './log';
|
||||
@@ -60,20 +60,17 @@ export class QQBasicInfoWrapper {
|
||||
|
||||
getAppidV2(): { appid: string; qua: string } {
|
||||
const appidTbale = AppidTable as unknown as QQAppidTableType;
|
||||
try {
|
||||
const fullVersion = this.getFullQQVesion();
|
||||
if (!fullVersion) throw new Error('QQ版本获取失败');
|
||||
const fullVersion = this.getFullQQVesion();
|
||||
if (fullVersion) {
|
||||
const data = appidTbale[fullVersion];
|
||||
if (data) {
|
||||
return data;
|
||||
}
|
||||
} catch (e) {
|
||||
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
||||
}
|
||||
// 以下是兜底措施
|
||||
this.context.logger.log(
|
||||
`[QQ版本兼容性检测] ${this.getFullQQVesion()} 版本兼容性不佳,可能会导致一些功能无法正常使用`,
|
||||
);
|
||||
|
||||
// else
|
||||
this.context.logger.log(`[QQ版本兼容性检测] 获取Appid异常 请检测NapCat/QQNT是否正常`);
|
||||
this.context.logger.log(`[QQ版本兼容性检测] ${fullVersion} 版本兼容性不佳,可能会导致一些功能无法正常使用`,);
|
||||
return { appid: systemPlatform === 'linux' ? '537240795' : '537240709', qua: this.getQUAInternal() };
|
||||
}
|
||||
}
|
1
src/common/version.ts
Normal file
1
src/common/version.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const napCatVersion = '2.2.26';
|
@@ -17,18 +17,17 @@ import {
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import fsPromises from 'fs/promises';
|
||||
import { InstanceContext, NapCatCore } from '@/core';
|
||||
import { InstanceContext, NapCatCore, SearchResultItem } from '@/core';
|
||||
import * as fileType from 'file-type';
|
||||
import imageSize from 'image-size';
|
||||
import { ISizeCalculationResult } from 'image-size/dist/types/interface';
|
||||
import { NodeIKernelSearchService } from '../services/NodeIKernelSearchService';
|
||||
import { RkeyManager } from '../helper/rkey';
|
||||
import { calculateFileMD5, isGIF } from '@/common/utils/file';
|
||||
import { calculateFileMD5, isGIF } from '@/common/file';
|
||||
import pathLib from 'node:path';
|
||||
import { defaultVideoThumbB64, getVideoInfo } from '@/common/utils/video';
|
||||
import { defaultVideoThumbB64, getVideoInfo } from '@/common/video';
|
||||
import ffmpeg from 'fluent-ffmpeg';
|
||||
import fsnormal from 'node:fs';
|
||||
import { encodeSilk } from '@/common/utils/audio';
|
||||
import { encodeSilk } from '@/common/audio';
|
||||
|
||||
|
||||
export class NTQQFileApi {
|
||||
@@ -303,7 +302,18 @@ export class NTQQFileApi {
|
||||
async downloadMediaByUuid() {
|
||||
//napCatCore.session.getRichMediaService().downloadFileForFileUuid();
|
||||
}
|
||||
|
||||
async downloadFileForModelId(peer: Peer, modelId: string, timeout = 1000 * 60 * 2) {
|
||||
const [, fileTransNotifyInfo] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelRichMediaService/downloadFileForModelId',
|
||||
'NodeIKernelMsgListener/onRichMediaDownloadComplete',
|
||||
[peer, [modelId]],
|
||||
() => true,
|
||||
(arg) => arg?.commonFileInfo?.fileModelId === modelId,
|
||||
1,
|
||||
timeout,
|
||||
);
|
||||
return fileTransNotifyInfo.filePath;
|
||||
}
|
||||
async downloadMedia(msgId: string, chatType: ChatType, peerUid: string, elementId: string, thumbPath: string, sourcePath: string, timeout = 1000 * 60 * 2, force: boolean = false) {
|
||||
//logDebug('receive downloadMedia task', msgId, chatType, peerUid, elementId, thumbPath, sourcePath, timeout, force);
|
||||
// 用于下载收到的消息中的图片等
|
||||
@@ -343,20 +353,15 @@ export class NTQQFileApi {
|
||||
chatType: chatType,
|
||||
peerUid: peerUid,
|
||||
}, [msgId]);
|
||||
if (msg.msgList.length === 0) {
|
||||
return fileTransNotifyInfo.filePath;
|
||||
const mixElement = msg.msgList.find((msg) => msg.msgId === msgId)?.elements.find((e) => e.elementId === elementId);
|
||||
const mixElementInner = mixElement?.videoElement ?? mixElement?.fileElement ?? mixElement?.pttElement ?? mixElement?.picElement;
|
||||
let realPath = mixElementInner?.filePath;
|
||||
if (!realPath) {
|
||||
const picThumbPath: Map<number, string> = (mixElementInner as any)?.picThumbPath;
|
||||
const picThumbPathList = Array.from(picThumbPath.values());
|
||||
if (picThumbPathList.length > 0) realPath = picThumbPathList[0];
|
||||
}
|
||||
//获取原始消息
|
||||
const FileElements = msg?.msgList[0]?.elements?.find(e => e.elementId === elementId);
|
||||
if (!FileElements) {
|
||||
//失败则就乱来 Todo
|
||||
return fileTransNotifyInfo.filePath;
|
||||
}
|
||||
//从原始消息获取文件路径
|
||||
return FileElements?.fileElement?.filePath ??
|
||||
FileElements?.pttElement?.filePath ??
|
||||
FileElements?.videoElement?.filePath ??
|
||||
FileElements?.picElement?.sourcePath;
|
||||
return realPath;
|
||||
}
|
||||
|
||||
async getImageSize(filePath: string): Promise<ISizeCalculationResult | undefined> {
|
||||
@@ -430,17 +435,36 @@ export class NTQQFileApi {
|
||||
});
|
||||
}
|
||||
|
||||
async searchfile(keys: string[]) {
|
||||
const Event = this.core.eventWrapper.createEventFunction('NodeIKernelSearchService/searchFileWithKeywords');
|
||||
const id = await Event!(keys, 12);
|
||||
const Listener = this.core.eventWrapper.registerListen(
|
||||
'NodeIKernelSearchListener/onSearchFileKeywordsResult',
|
||||
1,
|
||||
20000,
|
||||
(params) => id !== '' && params.searchId == id,
|
||||
async searchForFile(keys: string[]): Promise<SearchResultItem | undefined> {
|
||||
const [, searchResult] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelFileAssistantService/searchFile',
|
||||
'NodeIKernelFileAssistantListener/onFileSearch',
|
||||
[
|
||||
keys,
|
||||
{
|
||||
resultType: 2,
|
||||
pageLimit: 1,
|
||||
}
|
||||
]
|
||||
);
|
||||
const [ret] = (await Listener);
|
||||
return ret;
|
||||
return searchResult.resultItems[0];
|
||||
}
|
||||
|
||||
async downloadFileById(
|
||||
fileId: string,
|
||||
fileSize: number = 1024576,
|
||||
estimatedTime: number = (fileSize * 1000 / 1024576) + 5000,
|
||||
) {
|
||||
const [, ret] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelFileAssistantService/downloadFile',
|
||||
'NodeIKernelFileAssistantListener/onFileStatusChanged',
|
||||
[[fileId]],
|
||||
ret => ret.result === 0,
|
||||
status => status.fileStatus === 2 && status.fileProgress === '0',
|
||||
1,
|
||||
estimatedTime, // estimate 1MB/s
|
||||
);
|
||||
return ret.filePath!;
|
||||
}
|
||||
|
||||
async getImageUrl(element: PicElement) {
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { FriendV2 } from '@/core/entities';
|
||||
import { BuddyListReqType, InstanceContext, NapCatCore, NodeIKernelProfileService } from '@/core';
|
||||
import { LimitedHashTable } from '@/common/utils/message-unique';
|
||||
import { BuddyListReqType, InstanceContext, NapCatCore } from '@/core';
|
||||
import { LimitedHashTable } from '@/common/message-unique';
|
||||
|
||||
export class NTQQFriendApi {
|
||||
context: InstanceContext;
|
||||
|
@@ -2,6 +2,7 @@ import {
|
||||
ChatType,
|
||||
GeneralCallResult,
|
||||
Group,
|
||||
GroupInfoSource,
|
||||
GroupMember,
|
||||
GroupMemberRole,
|
||||
GroupRequestOperateTypes,
|
||||
@@ -9,9 +10,9 @@ import {
|
||||
KickMemberV2Req,
|
||||
MemberExtSourceType,
|
||||
NapCatCore,
|
||||
NodeIKernelGroupService,
|
||||
} from '@/core';
|
||||
import { isNumeric, runAllWithTimeout, sleep } from '@/common/utils/helper';
|
||||
import { isNumeric, runAllWithTimeout } from '@/common/helper';
|
||||
import { LimitedHashTable } from '@/common/message-unique';
|
||||
|
||||
export class NTQQGroupApi {
|
||||
context: InstanceContext;
|
||||
@@ -19,25 +20,32 @@ export class NTQQGroupApi {
|
||||
groupCache: Map<string, Group> = new Map<string, Group>();
|
||||
groupMemberCache: Map<string, Map<string, GroupMember>> = new Map<string, Map<string, GroupMember>>();
|
||||
groups: Group[] = [];
|
||||
essenceLRU = new LimitedHashTable<number, string>(1000);
|
||||
|
||||
constructor(context: InstanceContext, core: NapCatCore) {
|
||||
this.context = context;
|
||||
this.core = core;
|
||||
sleep(1000).then(() => {
|
||||
this.initCache().then().catch(context.logger.logError);
|
||||
});
|
||||
this.initCache().then().catch(context.logger.logError);
|
||||
}
|
||||
|
||||
async initCache() {
|
||||
this.groups = await this.getGroups();
|
||||
for (const group of this.groups) {
|
||||
this.groupCache.set(group.groupCode, group);
|
||||
const data = await this.getGroupMembers(group.groupCode, 3000);
|
||||
this.groupMemberCache.set(group.groupCode, data);
|
||||
}
|
||||
this.context.logger.logDebug(`加载${this.groups.length}个群组缓存完成`);
|
||||
}
|
||||
|
||||
async fetchGroupEssenceList(groupCode: string) {
|
||||
const pskey = (await this.core.apis.UserApi.getPSkey(['qun.qq.com'])).domainPskeyMap.get('qun.qq.com')!;
|
||||
return this.context.session.getGroupService().fetchGroupEssenceList({
|
||||
groupCode: groupCode,
|
||||
pageStart: 0,
|
||||
pageLimit: 300
|
||||
}, pskey);
|
||||
}
|
||||
async clearGroupNotifiesUnreadCount(unk: boolean) {
|
||||
return this.context.session.getGroupService().clearGroupNotifiesUnreadCount(unk);
|
||||
}
|
||||
async setGroupAvatar(gc: string, filePath: string) {
|
||||
return this.context.session.getGroupService().setHeader(gc, filePath);
|
||||
}
|
||||
@@ -175,7 +183,7 @@ export class NTQQGroupApi {
|
||||
let members = this.groupMemberCache.get(groupCodeStr);
|
||||
if (!members) {
|
||||
try {
|
||||
members = await this.getGroupMembers(groupCodeStr);
|
||||
members = await this.getGroupMembersV2(groupCodeStr);
|
||||
// 更新群成员列表
|
||||
this.groupMemberCache.set(groupCodeStr, members);
|
||||
} catch (e) {
|
||||
@@ -196,7 +204,7 @@ export class NTQQGroupApi {
|
||||
|
||||
let member = getMember();
|
||||
if (!member) {
|
||||
members = await this.getGroupMembers(groupCodeStr);
|
||||
members = await this.getGroupMembersV2(groupCodeStr);
|
||||
member = getMember();
|
||||
}
|
||||
return member;
|
||||
@@ -275,7 +283,15 @@ export class NTQQGroupApi {
|
||||
//应该是直接返回不需要Listener的 未经测试 需测试再发布
|
||||
return this.context.session.getGroupService().quitGroupV2(param);
|
||||
}
|
||||
|
||||
async removeGroupEssenceBySeq(GroupCode: string, msgRandom: string, msgSeq: string) {
|
||||
const param = {
|
||||
groupCode: GroupCode,
|
||||
msgRandom: parseInt(msgRandom),
|
||||
msgSeq: parseInt(msgSeq),
|
||||
};
|
||||
// GetMsgByShoretID(ShoretID); -> MsgService.getMsgs(Peer,MsgId,1,false); -> 组出参数
|
||||
return this.context.session.getGroupService().removeGroupEssence(param);
|
||||
}
|
||||
async removeGroupEssence(GroupCode: string, msgId: string) {
|
||||
// 代码没测过
|
||||
// 需要 ob11msgid->msgId + (peer) -> msgSeq + msgRandom
|
||||
@@ -293,12 +309,12 @@ export class NTQQGroupApi {
|
||||
return this.context.session.getGroupService().removeGroupEssence(param);
|
||||
}
|
||||
|
||||
async getSingleScreenNotifies(num: number) {
|
||||
async getSingleScreenNotifies(doubt: boolean, num: number) {
|
||||
const [, , , notifies] = await this.core.eventWrapper.callNormalEventV2(
|
||||
'NodeIKernelGroupService/getSingleScreenNotifies',
|
||||
'NodeIKernelGroupListener/onGroupSingleScreenNotifies',
|
||||
[
|
||||
false,
|
||||
doubt,
|
||||
'',
|
||||
num,
|
||||
],
|
||||
@@ -307,7 +323,6 @@ export class NTQQGroupApi {
|
||||
}
|
||||
|
||||
async getGroupMemberV2(GroupCode: string, uid: string, forced = false) {
|
||||
type EventType = NodeIKernelGroupService['getMemberInfo'];
|
||||
const Listener = this.core.eventWrapper.registerListen(
|
||||
'NodeIKernelGroupListener/onMemberInfoChange',
|
||||
1,
|
||||
@@ -330,6 +345,38 @@ export class NTQQGroupApi {
|
||||
return member;
|
||||
}
|
||||
|
||||
async getGroupMembersV2(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||
const groupService = this.context.session.getGroupService();
|
||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||
const listener = this.core.eventWrapper.registerListen(
|
||||
'NodeIKernelGroupListener/onMemberListChange',
|
||||
1,
|
||||
500,
|
||||
(params) => params.sceneId === sceneId,
|
||||
);
|
||||
try {
|
||||
const [membersFromFunc, membersFromListener] = await Promise.allSettled([
|
||||
groupService.getNextMemberList(sceneId, undefined, num),
|
||||
listener,
|
||||
]);
|
||||
if (membersFromFunc.status === 'fulfilled' && membersFromListener.status === 'fulfilled') {
|
||||
return new Map([
|
||||
...membersFromFunc.value.result.infos,
|
||||
...membersFromListener.value[0].infos
|
||||
]);
|
||||
}
|
||||
if (membersFromFunc.status === 'fulfilled') {
|
||||
return membersFromFunc.value.result.infos;
|
||||
}
|
||||
if (membersFromListener.status === 'fulfilled') {
|
||||
return membersFromListener.value[0].infos;
|
||||
}
|
||||
throw new Error('获取群成员列表失败');
|
||||
} finally {
|
||||
groupService.destroyMemberListScene(sceneId);
|
||||
}
|
||||
}
|
||||
|
||||
async getGroupMembers(groupQQ: string, num = 3000): Promise<Map<string, GroupMember>> {
|
||||
const groupService = this.context.session.getGroupService();
|
||||
const sceneId = groupService.createMemberListScene(groupQQ, 'groupMemberList_MainWindow');
|
||||
|
@@ -3,6 +3,10 @@ import { InstanceContext, NapCatCore } from '@/core';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
export class NTQQMsgApi {
|
||||
// nt_qq//global//nt_data//Emoji//emoji-resource//sysface_res/apng/ 下可以看到所有QQ表情预览
|
||||
// nt_qq\global\nt_data\Emoji\emoji-resource\face_config.json 里面有所有表情的id, 自带表情id是QSid, 标准emoji表情id是QCid
|
||||
// 其实以官方文档为准是最好的,https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#EmojiType
|
||||
|
||||
context: InstanceContext;
|
||||
core: NapCatCore;
|
||||
|
||||
@@ -10,7 +14,12 @@ export class NTQQMsgApi {
|
||||
this.context = context;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
async getAioFirstViewLatestMsgs(peer: Peer, MsgCount: number) {
|
||||
return this.context.session.getMsgService().getAioFirstViewLatestMsgs(peer, MsgCount);
|
||||
}
|
||||
async getLatestDbMsgs(peer: Peer, MsgCount: number) {
|
||||
return this.context.session.getMsgService().getLatestDbMsgs(peer, MsgCount);
|
||||
}
|
||||
async FetchLongMsg(peer: Peer, msgId: string) {
|
||||
return this.context.session.getMsgService().fetchLongMsg(peer, msgId);
|
||||
}
|
||||
@@ -191,7 +200,7 @@ export class NTQQMsgApi {
|
||||
msgElements,
|
||||
new Map(),
|
||||
],
|
||||
() => true,
|
||||
(ret) => ret.result === 0,
|
||||
msgRecords => {
|
||||
for (const msgRecord of msgRecords) {
|
||||
if (msgRecord.guildId === msgId && msgRecord.sendStatus === SendStatusType.KSEND_STATUS_SUCCESS) {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { RequestUtil } from '@/common/utils/request';
|
||||
import { RequestUtil } from '@/common/request';
|
||||
import { MiniAppLuaJsonType } from '@/core';
|
||||
import { InstanceContext, NapCatCore } from '..';
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { GeneralCallResult, InstanceContext, NapCatCore } from '@/core';
|
||||
import { InstanceContext, NapCatCore } from '@/core';
|
||||
|
||||
export class NTQQSystemApi {
|
||||
context: InstanceContext;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import type { ModifyProfileParams, User, UserDetailInfoByUinV2 } from '@/core/entities';
|
||||
import { RequestUtil } from '@/common/utils/request';
|
||||
import type { ModifyProfileParams, User } from '@/core/entities';
|
||||
import { RequestUtil } from '@/common/request';
|
||||
import { ProfileBizType, UserDetailSource } from '@/core/services';
|
||||
import { InstanceContext, NapCatCore } from '..';
|
||||
import { solveAsyncProblem } from '@/common/utils/helper';
|
||||
import { solveAsyncProblem } from '@/common/helper';
|
||||
|
||||
export class NTQQUserApi {
|
||||
context: InstanceContext;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { RequestUtil } from '@/common/utils/request';
|
||||
import { RequestUtil } from '@/common/request';
|
||||
import {
|
||||
GroupEssenceMsgRet,
|
||||
InstanceContext,
|
||||
@@ -27,27 +27,40 @@ export class NTQQWebApi {
|
||||
msg_random: msgRandom,
|
||||
target_group_code: targetGroupCode,
|
||||
}).toString()
|
||||
}`;
|
||||
}`;
|
||||
try {
|
||||
return RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
async getGroupEssenceMsgAll(GroupCode: string) {
|
||||
let ret: GroupEssenceMsgRet[] = [];
|
||||
for (let i = 0; i < 4; i++) {
|
||||
let data = await this.getGroupEssenceMsg(GroupCode, i, 50);
|
||||
if (!data) break;
|
||||
if (data.data.is_end) {
|
||||
ret.push(data);
|
||||
break;
|
||||
}
|
||||
ret.push(data);
|
||||
|
||||
async getGroupEssenceMsg(GroupCode: string, page_start: string) {
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
async getGroupEssenceMsg(GroupCode: string, page_start: number = 0, page_limit: number = 50) {
|
||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||
const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?${new URLSearchParams({
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
page_start: page_start.toString(),
|
||||
page_limit: page_limit.toString(),
|
||||
group_code: GroupCode,
|
||||
page_start,
|
||||
page_limit: '20',
|
||||
}).toString()
|
||||
}`;
|
||||
}`;
|
||||
let ret;
|
||||
try {
|
||||
ret = await RequestUtil.HttpGetJson<GroupEssenceMsgRet>
|
||||
(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
@@ -63,14 +76,14 @@ export class NTQQWebApi {
|
||||
const cookieObject = await this.core.apis.UserApi.getCookies('qun.qq.com');
|
||||
const retList: Promise<WebApiGroupMemberRet>[] = [];
|
||||
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>
|
||||
(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||
st: '0',
|
||||
end: '40',
|
||||
sort: '1',
|
||||
gc: GroupCode,
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
}).toString()
|
||||
}`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||
st: '0',
|
||||
end: '40',
|
||||
sort: '1',
|
||||
gc: GroupCode,
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
}).toString()
|
||||
}`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) {
|
||||
return [];
|
||||
} else {
|
||||
@@ -83,14 +96,14 @@ export class NTQQWebApi {
|
||||
//遍历批量请求
|
||||
for (let i = 2; i <= PageNum; i++) {
|
||||
const ret = RequestUtil.HttpGetJson<WebApiGroupMemberRet>
|
||||
(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||
st: ((i - 1) * 40).toString(),
|
||||
end: (i * 40).toString(),
|
||||
sort: '1',
|
||||
gc: GroupCode,
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
}).toString()
|
||||
}`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
(`https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?${new URLSearchParams({
|
||||
st: ((i - 1) * 40).toString(),
|
||||
end: (i * 40).toString(),
|
||||
sort: '1',
|
||||
gc: GroupCode,
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
}).toString()
|
||||
}`, 'POST', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
retList.push(ret);
|
||||
}
|
||||
//批量等待
|
||||
@@ -123,15 +136,15 @@ export class NTQQWebApi {
|
||||
let ret: any = undefined;
|
||||
try {
|
||||
ret = await RequestUtil.HttpGetJson<any>
|
||||
(`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice${new URLSearchParams({
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
qid: GroupCode,
|
||||
text: Content,
|
||||
pinned: '0',
|
||||
type: '1',
|
||||
settings: '{"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}',
|
||||
}).toString()
|
||||
}`, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
(`https://web.qun.qq.com/cgi-bin/announce/add_qun_notice${new URLSearchParams({
|
||||
bkn: this.getBknFromCookie(cookieObject),
|
||||
qid: GroupCode,
|
||||
text: Content,
|
||||
pinned: '0',
|
||||
type: '1',
|
||||
settings: '{"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}',
|
||||
}).toString()
|
||||
}`, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
return ret;
|
||||
} catch (e) {
|
||||
return undefined;
|
||||
@@ -162,7 +175,7 @@ export class NTQQWebApi {
|
||||
gc: Internal_groupCode,
|
||||
type: Internal_type.toString(),
|
||||
}).toString()
|
||||
}`;
|
||||
}`;
|
||||
let resJson;
|
||||
try {
|
||||
const res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': this.cookieToString(cookieObject) });
|
||||
@@ -184,11 +197,8 @@ export class NTQQWebApi {
|
||||
const HonorInfo: any = { group_id: groupCode };
|
||||
|
||||
if (getType === WebHonorType.TALKATIVE || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
const RetInternal = await getDataInternal(groupCode, 1);
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取龙王信息失败');
|
||||
}
|
||||
const RetInternal = await getDataInternal(groupCode, 1);
|
||||
if (RetInternal) {
|
||||
HonorInfo.current_talkative = {
|
||||
user_id: RetInternal[0]?.uin,
|
||||
avatar: RetInternal[0]?.avatar,
|
||||
@@ -206,16 +216,13 @@ export class NTQQWebApi {
|
||||
nickname: talkative_ele?.name,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.context.logger.logDebug(e);
|
||||
} else {
|
||||
this.context.logger.logError('获取龙王信息失败');
|
||||
}
|
||||
}
|
||||
if (getType === WebHonorType.PERFORMER || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
const RetInternal = await getDataInternal(groupCode, 2);
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取群聊之火失败');
|
||||
}
|
||||
const RetInternal = await getDataInternal(groupCode, 2);
|
||||
if (RetInternal) {
|
||||
HonorInfo.performer_list = [];
|
||||
for (const performer_ele of RetInternal) {
|
||||
HonorInfo.performer_list.push({
|
||||
@@ -225,16 +232,13 @@ export class NTQQWebApi {
|
||||
description: performer_ele?.desc,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.context.logger.logDebug(e);
|
||||
} else {
|
||||
this.context.logger.logError('获取群聊之火失败');
|
||||
}
|
||||
}
|
||||
if (getType === WebHonorType.PERFORMER || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
const RetInternal = await getDataInternal(groupCode, 3);
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取群聊炽焰失败');
|
||||
}
|
||||
const RetInternal = await getDataInternal(groupCode, 3);
|
||||
if (RetInternal) {
|
||||
HonorInfo.legend_list = [];
|
||||
for (const legend_ele of RetInternal) {
|
||||
HonorInfo.legend_list.push({
|
||||
@@ -244,16 +248,13 @@ export class NTQQWebApi {
|
||||
desc: legend_ele?.description,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.context.logger.logDebug('获取群聊炽焰失败', e);
|
||||
} else {
|
||||
this.context.logger.logError('获取群聊炽焰失败');
|
||||
}
|
||||
}
|
||||
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||
try {
|
||||
const RetInternal = await getDataInternal(groupCode, 6);
|
||||
if (!RetInternal) {
|
||||
throw new Error('获取快乐源泉失败');
|
||||
}
|
||||
const RetInternal = await getDataInternal(groupCode, 6);
|
||||
if (RetInternal) {
|
||||
HonorInfo.emotion_list = [];
|
||||
for (const emotion_ele of RetInternal) {
|
||||
HonorInfo.emotion_list.push({
|
||||
@@ -263,11 +264,11 @@ export class NTQQWebApi {
|
||||
desc: emotion_ele.description,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
this.context.logger.logDebug('获取快乐源泉失败', e);
|
||||
} else {
|
||||
this.context.logger.logError('获取快乐源泉失败');
|
||||
}
|
||||
}
|
||||
//冒尖小春笋好像已经被tx扬了
|
||||
// 冒尖小春笋好像已经被tx扬了 R.I.P.
|
||||
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||
HonorInfo.strong_newbie_list = [];
|
||||
}
|
||||
|
206
src/core/core.ts
206
src/core/core.ts
@@ -1,206 +0,0 @@
|
||||
import { NodeQQNTWrapperUtil, StableNTApiWrapper, WrapperNodeApi } from '@/core/wrapper';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { InstanceContext } from './wrapper';
|
||||
import { proxiedListenerOf } from '@/common/utils/proxy-handler';
|
||||
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from './listeners';
|
||||
import { DataSource, GroupMember, SelfInfo } from './entities';
|
||||
import { LegacyNTEventWrapper } from '@/common/framework/event-legacy';
|
||||
import { NTQQFileApi, NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from './apis';
|
||||
import os from 'node:os';
|
||||
import { NTQQCollectionApi } from './apis/collection';
|
||||
import { NapCatConfigLoader } from './helper/config';
|
||||
import { LogLevel } from '@/common/utils/log';
|
||||
|
||||
export enum NapCatCoreWorkingEnv {
|
||||
Unknown = 0,
|
||||
Shell = 1,
|
||||
Framework = 2,
|
||||
}
|
||||
|
||||
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
||||
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
||||
if (!fs.existsSync(wrapperNodePath)) {
|
||||
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${QQVersion}/wrapper.node`);
|
||||
}
|
||||
const nativemodule: any = { exports: {} };
|
||||
process.dlopen(nativemodule, wrapperNodePath);
|
||||
return nativemodule.exports;
|
||||
}
|
||||
|
||||
export class NapCatCore {
|
||||
readonly context: InstanceContext;
|
||||
readonly apis: StableNTApiWrapper;
|
||||
readonly eventWrapper: LegacyNTEventWrapper;
|
||||
// readonly eventChannel: NTEventChannel;
|
||||
NapCatDataPath: string;
|
||||
NapCatTempPath: string;
|
||||
// runtime info, not readonly
|
||||
selfInfo: SelfInfo;
|
||||
util: NodeQQNTWrapperUtil;
|
||||
configLoader: NapCatConfigLoader;
|
||||
|
||||
// 通过构造器递过去的 runtime info 应该尽量少
|
||||
constructor(context: InstanceContext, selfInfo: SelfInfo) {
|
||||
this.selfInfo = selfInfo;
|
||||
this.context = context;
|
||||
this.util = this.context.wrapper.NodeQQNTWrapperUtil;
|
||||
this.eventWrapper = new LegacyNTEventWrapper(context.session);
|
||||
this.apis = {
|
||||
FileApi: new NTQQFileApi(this.context, this),
|
||||
SystemApi: new NTQQSystemApi(this.context, this),
|
||||
CollectionApi: new NTQQCollectionApi(this.context, this),
|
||||
WebApi: new NTQQWebApi(this.context, this),
|
||||
FriendApi: new NTQQFriendApi(this.context, this),
|
||||
MsgApi: new NTQQMsgApi(this.context, this),
|
||||
UserApi: new NTQQUserApi(this.context, this),
|
||||
GroupApi: new NTQQGroupApi(this.context, this),
|
||||
};
|
||||
this.configLoader = new NapCatConfigLoader(this, this.context.pathWrapper.configPath);
|
||||
this.NapCatDataPath = path.join(this.dataPath, 'NapCat');
|
||||
fs.mkdirSync(this.NapCatDataPath, { recursive: true });
|
||||
this.NapCatTempPath = path.join(this.NapCatDataPath, 'temp');
|
||||
// 创建临时目录
|
||||
if (!fs.existsSync(this.NapCatTempPath)) {
|
||||
fs.mkdirSync(this.NapCatTempPath, { recursive: true });
|
||||
}
|
||||
this.initNapCatCoreListeners().then().catch(this.context.logger.logError);
|
||||
|
||||
this.context.logger.setFileLogEnabled(
|
||||
this.configLoader.configData.fileLog,
|
||||
);
|
||||
this.context.logger.setConsoleLogEnabled(
|
||||
this.configLoader.configData.consoleLog,
|
||||
);
|
||||
this.context.logger.setFileAndConsoleLogLevel(
|
||||
this.configLoader.configData.fileLogLevel as LogLevel,
|
||||
this.configLoader.configData.consoleLogLevel as LogLevel,
|
||||
);
|
||||
}
|
||||
|
||||
get dataPath(): string {
|
||||
let result = this.context.wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
||||
if (!result) {
|
||||
result = path.resolve(os.homedir(), './.config/QQ');
|
||||
fs.mkdirSync(result, { recursive: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Renamed from 'InitDataListener'
|
||||
async initNapCatCoreListeners() {
|
||||
const msgListener = new NodeIKernelMsgListener();
|
||||
msgListener.onRecvMsg = (msgs) => {
|
||||
msgs.forEach(msg => this.context.logger.logMessage(msg, this.selfInfo));
|
||||
};
|
||||
msgListener.onAddSendMsg = (msg) => {
|
||||
this.context.logger.logMessage(msg, this.selfInfo);
|
||||
};
|
||||
//await sleep(2500);
|
||||
this.context.session.getMsgService().addKernelMsgListener(
|
||||
proxiedListenerOf(msgListener, this.context.logger) as any,
|
||||
);
|
||||
|
||||
const profileListener = new NodeIKernelProfileListener();
|
||||
profileListener.onProfileDetailInfoChanged = (profile) => {
|
||||
if (profile.uid === this.selfInfo.uid) {
|
||||
Object.assign(this.selfInfo, profile);
|
||||
}
|
||||
};
|
||||
profileListener.onSelfStatusChanged = (/* Info: SelfStatusInfo */) => {
|
||||
// if (Info.status == 20) {
|
||||
// log("账号状态变更为离线")
|
||||
// }
|
||||
};
|
||||
this.context.session.getProfileService().addKernelProfileListener(
|
||||
proxiedListenerOf(profileListener, this.context.logger),
|
||||
);
|
||||
|
||||
// 群相关
|
||||
const groupListener = new NodeIKernelGroupListener();
|
||||
groupListener.onGroupListUpdate = (updateType, groupList) => {
|
||||
// console.log("onGroupListUpdate", updateType, groupList)
|
||||
groupList.map(g => {
|
||||
const existGroup = this.apis.GroupApi.groupCache.get(g.groupCode);
|
||||
//群成员数量变化 应该刷新缓存
|
||||
if (existGroup && g.memberCount === existGroup.memberCount) {
|
||||
Object.assign(existGroup, g);
|
||||
} else {
|
||||
this.apis.GroupApi.groupCache.set(g.groupCode, g);
|
||||
// 获取群成员
|
||||
}
|
||||
const sceneId = this.context.session.getGroupService().createMemberListScene(g.groupCode, 'groupMemberList_MainWindow');
|
||||
this.context.session.getGroupService().getNextMemberList(sceneId!, undefined, 3000).then( /* r => {
|
||||
// console.log(`get group ${g.groupCode} members`, r);
|
||||
// r.result.infos.forEach(member => {
|
||||
// });
|
||||
// groupMembers.set(g.groupCode, r.result.infos);
|
||||
} */);
|
||||
});
|
||||
};
|
||||
groupListener.onMemberListChange = (arg) => {
|
||||
// todo: 应该加一个内部自己维护的成员变动callback,用于判断成员变化通知
|
||||
const groupCode = arg.sceneId.split('_')[0];
|
||||
if (this.apis.GroupApi.groupMemberCache.has(groupCode)) {
|
||||
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode)!;
|
||||
arg.infos.forEach((member, uid) => {
|
||||
//console.log('onMemberListChange', member);
|
||||
const existMember = existMembers.get(uid);
|
||||
if (existMember) {
|
||||
Object.assign(existMember, member);
|
||||
} else {
|
||||
existMembers!.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
if (member.isDelete) {
|
||||
existMembers.delete(uid);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.apis.GroupApi.groupMemberCache.set(groupCode, arg.infos);
|
||||
}
|
||||
// console.log('onMemberListChange', groupCode, arg);
|
||||
};
|
||||
groupListener.onMemberInfoChange = (groupCode, dataSource, members) => {
|
||||
//console.log('onMemberInfoChange', groupCode, changeType, members);
|
||||
if (dataSource === DataSource.LOCAL && members.get(this.selfInfo.uid)?.isDelete) {
|
||||
// 自身退群或者被踢退群 5s用于Api操作 之后不再出现
|
||||
setTimeout(() => {
|
||||
this.apis.GroupApi.groupCache.delete(groupCode);
|
||||
}, 5000);
|
||||
|
||||
}
|
||||
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode);
|
||||
if (existMembers) {
|
||||
members.forEach((member, uid) => {
|
||||
const existMember = existMembers.get(uid);
|
||||
if (existMember) {
|
||||
// 检查管理变动
|
||||
member.isChangeRole = this.checkAdminEvent(groupCode, member, existMember);
|
||||
// 更新成员信息
|
||||
Object.assign(existMember, member);
|
||||
} else {
|
||||
existMembers.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
if (member.isDelete) {
|
||||
existMembers.delete(uid);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.apis.GroupApi.groupMemberCache.set(groupCode, members);
|
||||
}
|
||||
};
|
||||
this.context.session.getGroupService().addKernelGroupListener(
|
||||
proxiedListenerOf(groupListener, this.context.logger) as any,
|
||||
);
|
||||
}
|
||||
|
||||
checkAdminEvent(groupCode: string, memberNew: GroupMember, memberOld: GroupMember | undefined): boolean {
|
||||
if (memberNew.role !== memberOld?.role) {
|
||||
this.context.logger.logDebug(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -593,6 +593,7 @@ export const IMAGE_HTTP_HOST_NT = 'https://multimedia.nt.qq.com.cn';
|
||||
|
||||
export interface PicElement {
|
||||
md5HexStr?: string;
|
||||
filePath?: string;
|
||||
fileSize: number | string;//number
|
||||
picWidth: number;
|
||||
picHeight: number;
|
||||
|
@@ -1,11 +1,9 @@
|
||||
import { ConfigBase } from '@/common/utils/config-base';
|
||||
import { ConfigBase } from '@/common/config-base';
|
||||
import napCatDefaultConfig from '@/core/external/napcat.json';
|
||||
import { NapCatCore } from '@/core';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export type NapCatConfig = typeof napCatDefaultConfig;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
||||
export class NapCatConfigLoader extends ConfigBase<NapCatConfig> {
|
||||
constructor(core: NapCatCore, configPath: string) {
|
||||
super('napcat', core, configPath);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { LogWrapper } from '@/common/utils/log';
|
||||
import { RequestUtil } from '@/common/utils/request';
|
||||
import { LogWrapper } from '@/common/log';
|
||||
import { RequestUtil } from '@/common/request';
|
||||
|
||||
interface ServerRkeyData {
|
||||
group_rkey: string;
|
||||
|
@@ -1,5 +1,299 @@
|
||||
export * from './core';
|
||||
import {
|
||||
NTQQFileApi,
|
||||
NTQQFriendApi,
|
||||
NTQQGroupApi,
|
||||
NTQQMsgApi,
|
||||
NTQQSystemApi,
|
||||
NTQQUserApi,
|
||||
NTQQWebApi,
|
||||
} from '@/core/apis';
|
||||
import { NTQQCollectionApi } from '@/core/apis/collection';
|
||||
import {
|
||||
NodeIQQNTWrapperSession,
|
||||
NodeQQNTWrapperUtil,
|
||||
PlatformType,
|
||||
VendorType,
|
||||
WrapperNodeApi,
|
||||
WrapperSessionInitConfig,
|
||||
} from '@/core/wrapper';
|
||||
import { LogLevel, LogWrapper } from '@/common/log';
|
||||
import { NodeIKernelLoginService } from '@/core/services';
|
||||
import { QQBasicInfoWrapper } from '@/common/qq-basic-info';
|
||||
import { NapCatPathWrapper } from '@/common/path';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { getMachineId, hostname, systemName, systemVersion } from '@/common/system';
|
||||
import { NTEventWrapper } from '@/common/event';
|
||||
import { DataSource, GroupMember, SelfInfo } from '@/core/entities';
|
||||
import { NapCatConfigLoader } from '@/core/helper/config';
|
||||
import os from 'node:os';
|
||||
import { NodeIKernelGroupListener, NodeIKernelMsgListener, NodeIKernelProfileListener } from '@/core/listeners';
|
||||
import { proxiedListenerOf } from '@/common/proxy-handler';
|
||||
|
||||
export * from './wrapper';
|
||||
export * from './entities';
|
||||
export * from './services';
|
||||
export * from './listeners';
|
||||
|
||||
export enum NapCatCoreWorkingEnv {
|
||||
Unknown = 0,
|
||||
Shell = 1,
|
||||
Framework = 2,
|
||||
}
|
||||
|
||||
export function loadQQWrapper(QQVersion: string): WrapperNodeApi {
|
||||
let wrapperNodePath = path.resolve(path.dirname(process.execPath), './resources/app/wrapper.node');
|
||||
if (!fs.existsSync(wrapperNodePath)) {
|
||||
wrapperNodePath = path.join(path.dirname(process.execPath), `resources/app/versions/${QQVersion}/wrapper.node`);
|
||||
}
|
||||
const nativemodule: any = { exports: {} };
|
||||
process.dlopen(nativemodule, wrapperNodePath);
|
||||
return nativemodule.exports;
|
||||
}
|
||||
|
||||
export class NapCatCore {
|
||||
readonly context: InstanceContext;
|
||||
readonly apis: StableNTApiWrapper;
|
||||
readonly eventWrapper: NTEventWrapper;
|
||||
// readonly eventChannel: NTEventChannel;
|
||||
NapCatDataPath: string;
|
||||
NapCatTempPath: string;
|
||||
// runtime info, not readonly
|
||||
selfInfo: SelfInfo;
|
||||
util: NodeQQNTWrapperUtil;
|
||||
configLoader: NapCatConfigLoader;
|
||||
|
||||
// 通过构造器递过去的 runtime info 应该尽量少
|
||||
constructor(context: InstanceContext, selfInfo: SelfInfo) {
|
||||
this.selfInfo = selfInfo;
|
||||
this.context = context;
|
||||
this.util = this.context.wrapper.NodeQQNTWrapperUtil;
|
||||
this.eventWrapper = new NTEventWrapper(context.session);
|
||||
this.apis = {
|
||||
FileApi: new NTQQFileApi(this.context, this),
|
||||
SystemApi: new NTQQSystemApi(this.context, this),
|
||||
CollectionApi: new NTQQCollectionApi(this.context, this),
|
||||
WebApi: new NTQQWebApi(this.context, this),
|
||||
FriendApi: new NTQQFriendApi(this.context, this),
|
||||
MsgApi: new NTQQMsgApi(this.context, this),
|
||||
UserApi: new NTQQUserApi(this.context, this),
|
||||
GroupApi: new NTQQGroupApi(this.context, this),
|
||||
};
|
||||
this.configLoader = new NapCatConfigLoader(this, this.context.pathWrapper.configPath);
|
||||
this.NapCatDataPath = path.join(this.dataPath, 'NapCat');
|
||||
fs.mkdirSync(this.NapCatDataPath, { recursive: true });
|
||||
this.NapCatTempPath = path.join(this.NapCatDataPath, 'temp');
|
||||
// 创建临时目录
|
||||
if (!fs.existsSync(this.NapCatTempPath)) {
|
||||
fs.mkdirSync(this.NapCatTempPath, { recursive: true });
|
||||
}
|
||||
this.initNapCatCoreListeners().then().catch(this.context.logger.logError);
|
||||
|
||||
this.context.logger.setFileLogEnabled(
|
||||
this.configLoader.configData.fileLog,
|
||||
);
|
||||
this.context.logger.setConsoleLogEnabled(
|
||||
this.configLoader.configData.consoleLog,
|
||||
);
|
||||
this.context.logger.setFileAndConsoleLogLevel(
|
||||
this.configLoader.configData.fileLogLevel as LogLevel,
|
||||
this.configLoader.configData.consoleLogLevel as LogLevel,
|
||||
);
|
||||
}
|
||||
|
||||
get dataPath(): string {
|
||||
let result = this.context.wrapper.NodeQQNTWrapperUtil.getNTUserDataInfoConfig();
|
||||
if (!result) {
|
||||
result = path.resolve(os.homedir(), './.config/QQ');
|
||||
fs.mkdirSync(result, { recursive: true });
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Renamed from 'InitDataListener'
|
||||
async initNapCatCoreListeners() {
|
||||
const msgListener = new NodeIKernelMsgListener();
|
||||
msgListener.onRecvMsg = (msgs) => {
|
||||
msgs.forEach(msg => this.context.logger.logMessage(msg, this.selfInfo));
|
||||
};
|
||||
msgListener.onAddSendMsg = (msg) => {
|
||||
this.context.logger.logMessage(msg, this.selfInfo);
|
||||
};
|
||||
//await sleep(2500);
|
||||
this.context.session.getMsgService().addKernelMsgListener(
|
||||
proxiedListenerOf(msgListener, this.context.logger) as any,
|
||||
);
|
||||
|
||||
const profileListener = new NodeIKernelProfileListener();
|
||||
profileListener.onProfileDetailInfoChanged = (profile) => {
|
||||
if (profile.uid === this.selfInfo.uid) {
|
||||
Object.assign(this.selfInfo, profile);
|
||||
}
|
||||
};
|
||||
profileListener.onSelfStatusChanged = (/* Info: SelfStatusInfo */) => {
|
||||
// if (Info.status == 20) {
|
||||
// log("账号状态变更为离线")
|
||||
// }
|
||||
};
|
||||
this.context.session.getProfileService().addKernelProfileListener(
|
||||
proxiedListenerOf(profileListener, this.context.logger),
|
||||
);
|
||||
|
||||
// 群相关
|
||||
const groupListener = new NodeIKernelGroupListener();
|
||||
groupListener.onGroupListUpdate = (updateType, groupList) => {
|
||||
// console.log("onGroupListUpdate", updateType, groupList)
|
||||
groupList.map(g => {
|
||||
const existGroup = this.apis.GroupApi.groupCache.get(g.groupCode);
|
||||
//群成员数量变化 应该刷新缓存
|
||||
if (existGroup && g.memberCount === existGroup.memberCount) {
|
||||
Object.assign(existGroup, g);
|
||||
} else {
|
||||
this.apis.GroupApi.groupCache.set(g.groupCode, g);
|
||||
// 获取群成员
|
||||
}
|
||||
const sceneId = this.context.session.getGroupService().createMemberListScene(g.groupCode, 'groupMemberList_MainWindow');
|
||||
this.context.session.getGroupService().getNextMemberList(sceneId, undefined, 3000).then( /* r => {
|
||||
// console.log(`get group ${g.groupCode} members`, r);
|
||||
// r.result.infos.forEach(member => {
|
||||
// });
|
||||
// groupMembers.set(g.groupCode, r.result.infos);
|
||||
} */);
|
||||
this.context.session.getGroupService().destroyMemberListScene(sceneId);
|
||||
});
|
||||
};
|
||||
groupListener.onMemberListChange = (arg) => {
|
||||
// todo: 应该加一个内部自己维护的成员变动callback,用于判断成员变化通知
|
||||
const groupCode = arg.sceneId.split('_')[0];
|
||||
if (this.apis.GroupApi.groupMemberCache.has(groupCode)) {
|
||||
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode)!;
|
||||
arg.infos.forEach((member, uid) => {
|
||||
//console.log('onMemberListChange', member);
|
||||
const existMember = existMembers.get(uid);
|
||||
if (existMember) {
|
||||
Object.assign(existMember, member);
|
||||
} else {
|
||||
existMembers!.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
if (member.isDelete) {
|
||||
existMembers.delete(uid);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.apis.GroupApi.groupMemberCache.set(groupCode, arg.infos);
|
||||
}
|
||||
};
|
||||
groupListener.onMemberInfoChange = (groupCode, dataSource, members) => {
|
||||
if (dataSource === DataSource.LOCAL && members.get(this.selfInfo.uid)?.isDelete) {
|
||||
// 自身退群或者被踢退群 5s用于Api操作 之后不再出现
|
||||
setTimeout(() => {
|
||||
this.apis.GroupApi.groupCache.delete(groupCode);
|
||||
}, 5000);
|
||||
|
||||
}
|
||||
const existMembers = this.apis.GroupApi.groupMemberCache.get(groupCode);
|
||||
if (existMembers) {
|
||||
members.forEach((member, uid) => {
|
||||
const existMember = existMembers.get(uid);
|
||||
if (existMember) {
|
||||
// 检查管理变动
|
||||
member.isChangeRole = this.checkAdminEvent(groupCode, member, existMember);
|
||||
// 更新成员信息
|
||||
Object.assign(existMember, member);
|
||||
} else {
|
||||
existMembers.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
if (member.isDelete) {
|
||||
existMembers.delete(uid);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.apis.GroupApi.groupMemberCache.set(groupCode, members);
|
||||
}
|
||||
};
|
||||
this.context.session.getGroupService().addKernelGroupListener(
|
||||
proxiedListenerOf(groupListener, this.context.logger) as any,
|
||||
);
|
||||
}
|
||||
|
||||
checkAdminEvent(groupCode: string, memberNew: GroupMember, memberOld: GroupMember | undefined): boolean {
|
||||
if (memberNew.role !== memberOld?.role) {
|
||||
this.context.logger.logDebug(`群 ${groupCode} ${memberNew.nick} 角色变更为 ${memberNew.role === 3 ? '管理员' : '群员'}`);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export async function genSessionConfig(QQVersionAppid: string, QQVersion: string, selfUin: string, selfUid: string, account_path: string): Promise<WrapperSessionInitConfig> {
|
||||
const downloadPath = path.join(account_path, 'NapCat', 'temp');
|
||||
fs.mkdirSync(downloadPath, { recursive: true });
|
||||
const guid: string = await getMachineId();//26702 支持JS获取guid值 在LoginService中获取 TODO mlikiow a
|
||||
return {
|
||||
selfUin,
|
||||
selfUid,
|
||||
desktopPathConfig: {
|
||||
account_path, // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
||||
},
|
||||
clientVer: QQVersion, // 9.9.8-22355
|
||||
a2: '',
|
||||
d2: '',
|
||||
d2Key: '',
|
||||
machineId: '',
|
||||
platform: PlatformType.KWINDOWS, // 3是Windows?
|
||||
platVer: systemVersion, // 系统版本号, 应该可以固定
|
||||
appid: QQVersionAppid,
|
||||
rdeliveryConfig: {
|
||||
appKey: '',
|
||||
systemId: 0,
|
||||
appId: '',
|
||||
logicEnvironment: '',
|
||||
platform: PlatformType.KWINDOWS,
|
||||
language: '',
|
||||
sdkVersion: '',
|
||||
userId: '',
|
||||
appVersion: '',
|
||||
osVersion: '',
|
||||
bundleId: '',
|
||||
serverUrl: '',
|
||||
fixedAfterHitKeys: [''],
|
||||
},
|
||||
defaultFileDownloadPath: downloadPath,
|
||||
deviceInfo: {
|
||||
guid,
|
||||
buildVer: QQVersion,
|
||||
localId: 2052,
|
||||
devName: hostname,
|
||||
devType: systemName,
|
||||
vendorName: '',
|
||||
osVer: systemVersion,
|
||||
vendorOsName: systemName,
|
||||
setMute: false,
|
||||
vendorType: VendorType.KNOSETONIOS,
|
||||
},
|
||||
deviceConfig: '{"appearance":{"isSplitViewMode":true},"msg":{}}',
|
||||
};
|
||||
}
|
||||
|
||||
export interface InstanceContext {
|
||||
readonly workingEnv: NapCatCoreWorkingEnv;
|
||||
readonly wrapper: WrapperNodeApi;
|
||||
readonly session: NodeIQQNTWrapperSession;
|
||||
readonly logger: LogWrapper;
|
||||
readonly loginService: NodeIKernelLoginService;
|
||||
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
||||
readonly pathWrapper: NapCatPathWrapper;
|
||||
}
|
||||
|
||||
export interface StableNTApiWrapper {
|
||||
FileApi: NTQQFileApi,
|
||||
SystemApi: NTQQSystemApi,
|
||||
CollectionApi: NTQQCollectionApi,
|
||||
WebApi: NTQQWebApi,
|
||||
FriendApi: NTQQFriendApi,
|
||||
MsgApi: NTQQMsgApi,
|
||||
UserApi: NTQQUserApi,
|
||||
GroupApi: NTQQGroupApi
|
||||
}
|
||||
|
@@ -1,5 +1,13 @@
|
||||
export class NodeIKernelFileAssistantListener {
|
||||
onFileStatusChanged(...args: unknown[]) {
|
||||
onFileStatusChanged(fileStatus: {
|
||||
id: string,
|
||||
fileStatus: number,
|
||||
fileProgress: `${number}`,
|
||||
fileSize: `${number}`,
|
||||
fileSpeed: number,
|
||||
thumbPath: string | null,
|
||||
filePath: string | null,
|
||||
}) {
|
||||
}
|
||||
|
||||
onSessionListChanged(...args: unknown[]) {
|
||||
@@ -11,6 +19,42 @@ export class NodeIKernelFileAssistantListener {
|
||||
onFileListChanged(...args: unknown[]) {
|
||||
}
|
||||
|
||||
onFileSearch(...args: unknown[]) {
|
||||
onFileSearch(searchResult: SearchResultWrapper) {
|
||||
}
|
||||
}
|
||||
|
||||
export type SearchResultWrapper = {
|
||||
searchId: number,
|
||||
resultType: number,
|
||||
hasMore: boolean,
|
||||
resultItems: SearchResultItem[],
|
||||
};
|
||||
|
||||
export type SearchResultItem = {
|
||||
id: string,
|
||||
fileName: string,
|
||||
fileNameHits: string[],
|
||||
fileStatus: number,
|
||||
fileSize: string,
|
||||
isSend: boolean,
|
||||
source: number,
|
||||
fileTime: string,
|
||||
expTime: string,
|
||||
session: {
|
||||
context: null,
|
||||
uid: string,
|
||||
nick: string,
|
||||
remark: string,
|
||||
memberCard: string,
|
||||
groupCode: string,
|
||||
groupName: string,
|
||||
groupRemark: string,
|
||||
count: number,
|
||||
},
|
||||
thumbPath: string,
|
||||
filePath: string,
|
||||
msgId: string,
|
||||
chatType: number,
|
||||
peerUid: string,
|
||||
fileType: number,
|
||||
};
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { DataSource, Group, GroupListUpdateType, GroupMember, GroupNotify } from '@/core/entities';
|
||||
|
||||
export class NodeIKernelGroupListener {
|
||||
onGroupListInited(listEmpty: boolean): void { }
|
||||
// 发现于Win 9.9.9 23159
|
||||
onGroupMemberLevelInfoChange(...args: unknown[]): void {
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import { ChatType, RawMessage } from '@/core/entities';
|
||||
import { CommonFileInfo } from '@/core';
|
||||
|
||||
export interface OnRichMediaDownloadCompleteParams {
|
||||
fileModelId: string,
|
||||
@@ -15,7 +16,7 @@ export interface OnRichMediaDownloadCompleteParams {
|
||||
totalSize: string,
|
||||
trasferStatus: number,
|
||||
step: number,
|
||||
commonFileInfo: unknown | null,
|
||||
commonFileInfo?: CommonFileInfo,
|
||||
fileSrvErrCode: string,
|
||||
clientMsg: string,
|
||||
businessId: number,
|
||||
|
@@ -19,10 +19,10 @@ import type {
|
||||
NodeIKernelMsgListener,
|
||||
NodeIKernelProfileListener,
|
||||
NodeIKernelRobotListener,
|
||||
NodeIKernelSearchListener_Polyfill,
|
||||
NodeIKernelSessionListener,
|
||||
NodeIKernelStorageCleanListener,
|
||||
NodeIKernelTicketListener,
|
||||
NodeIKernelSearchListener_Polyfill,
|
||||
} from '.';
|
||||
|
||||
export type ListenerNamingMapping = {
|
||||
|
31
src/core/proto/EmojiLikeToOthers.proto
Normal file
31
src/core/proto/EmojiLikeToOthers.proto
Normal file
@@ -0,0 +1,31 @@
|
||||
syntax = 'proto3';
|
||||
package SysMessage;
|
||||
|
||||
message EmojiLikeToOthersWrapper1 {
|
||||
EmojiLikeToOthersWrapper2 wrapper = 1;
|
||||
}
|
||||
|
||||
message EmojiLikeToOthersWrapper2 {
|
||||
EmojiLikeToOthersWrapper3 body = 1;
|
||||
}
|
||||
|
||||
message EmojiLikeToOthersWrapper3 {
|
||||
EmojiLikeToOthersMsgSpec msgSpec = 2;
|
||||
EmojiLikeToOthersAttributes attributes = 3;
|
||||
}
|
||||
|
||||
message EmojiLikeToOthersMsgSpec {
|
||||
uint32 msgSeq = 1;
|
||||
}
|
||||
|
||||
message EmojiLikeToOthersAttributes {
|
||||
enum Operation {
|
||||
FALLBACK = 0;
|
||||
LIKE = 1;
|
||||
UNLIKE = 2;
|
||||
}
|
||||
|
||||
string emojiId = 1;
|
||||
string senderUid = 4;
|
||||
Operation operation = 5;
|
||||
}
|
341
src/core/proto/EmojiLikeToOthers.ts
Normal file
341
src/core/proto/EmojiLikeToOthers.ts
Normal file
@@ -0,0 +1,341 @@
|
||||
// @generated by protobuf-ts 2.9.4
|
||||
// @generated from protobuf file "EmojiLikeToOthers.proto" (package "SysMessage", syntax proto3)
|
||||
// tslint:disable
|
||||
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
||||
import { WireType } from "@protobuf-ts/runtime";
|
||||
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
||||
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
||||
import type { PartialMessage } from "@protobuf-ts/runtime";
|
||||
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
||||
import { MessageType } from "@protobuf-ts/runtime";
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.EmojiLikeToOthersWrapper1
|
||||
*/
|
||||
export interface EmojiLikeToOthersWrapper1 {
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.EmojiLikeToOthersWrapper2 wrapper = 1;
|
||||
*/
|
||||
wrapper?: EmojiLikeToOthersWrapper2;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.EmojiLikeToOthersWrapper2
|
||||
*/
|
||||
export interface EmojiLikeToOthersWrapper2 {
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.EmojiLikeToOthersWrapper3 body = 1;
|
||||
*/
|
||||
body?: EmojiLikeToOthersWrapper3;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.EmojiLikeToOthersWrapper3
|
||||
*/
|
||||
export interface EmojiLikeToOthersWrapper3 {
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.EmojiLikeToOthersMsgSpec msgSpec = 2;
|
||||
*/
|
||||
msgSpec?: EmojiLikeToOthersMsgSpec;
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.EmojiLikeToOthersAttributes attributes = 3;
|
||||
*/
|
||||
attributes?: EmojiLikeToOthersAttributes;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.EmojiLikeToOthersMsgSpec
|
||||
*/
|
||||
export interface EmojiLikeToOthersMsgSpec {
|
||||
/**
|
||||
* @generated from protobuf field: uint32 msgSeq = 1;
|
||||
*/
|
||||
msgSeq: number;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.EmojiLikeToOthersAttributes
|
||||
*/
|
||||
export interface EmojiLikeToOthersAttributes {
|
||||
/**
|
||||
* @generated from protobuf field: string emojiId = 1;
|
||||
*/
|
||||
emojiId: string;
|
||||
/**
|
||||
* @generated from protobuf field: string senderUid = 4;
|
||||
*/
|
||||
senderUid: string;
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.EmojiLikeToOthersAttributes.Operation operation = 5;
|
||||
*/
|
||||
operation: EmojiLikeToOthersAttributes_Operation;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf enum SysMessage.EmojiLikeToOthersAttributes.Operation
|
||||
*/
|
||||
export enum EmojiLikeToOthersAttributes_Operation {
|
||||
/**
|
||||
* @generated from protobuf enum value: FALLBACK = 0;
|
||||
*/
|
||||
FALLBACK = 0,
|
||||
/**
|
||||
* @generated from protobuf enum value: LIKE = 1;
|
||||
*/
|
||||
LIKE = 1,
|
||||
/**
|
||||
* @generated from protobuf enum value: UNLIKE = 2;
|
||||
*/
|
||||
UNLIKE = 2
|
||||
}
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class EmojiLikeToOthersWrapper1$Type extends MessageType<EmojiLikeToOthersWrapper1> {
|
||||
constructor() {
|
||||
super("SysMessage.EmojiLikeToOthersWrapper1", [
|
||||
{ no: 1, name: "wrapper", kind: "message", T: () => EmojiLikeToOthersWrapper2 }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<EmojiLikeToOthersWrapper1>): EmojiLikeToOthersWrapper1 {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<EmojiLikeToOthersWrapper1>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersWrapper1): EmojiLikeToOthersWrapper1 {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* SysMessage.EmojiLikeToOthersWrapper2 wrapper */ 1:
|
||||
message.wrapper = EmojiLikeToOthersWrapper2.internalBinaryRead(reader, reader.uint32(), options, message.wrapper);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: EmojiLikeToOthersWrapper1, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* SysMessage.EmojiLikeToOthersWrapper2 wrapper = 1; */
|
||||
if (message.wrapper)
|
||||
EmojiLikeToOthersWrapper2.internalBinaryWrite(message.wrapper, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersWrapper1
|
||||
*/
|
||||
export const EmojiLikeToOthersWrapper1 = new EmojiLikeToOthersWrapper1$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class EmojiLikeToOthersWrapper2$Type extends MessageType<EmojiLikeToOthersWrapper2> {
|
||||
constructor() {
|
||||
super("SysMessage.EmojiLikeToOthersWrapper2", [
|
||||
{ no: 1, name: "body", kind: "message", T: () => EmojiLikeToOthersWrapper3 }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<EmojiLikeToOthersWrapper2>): EmojiLikeToOthersWrapper2 {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<EmojiLikeToOthersWrapper2>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersWrapper2): EmojiLikeToOthersWrapper2 {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* SysMessage.EmojiLikeToOthersWrapper3 body */ 1:
|
||||
message.body = EmojiLikeToOthersWrapper3.internalBinaryRead(reader, reader.uint32(), options, message.body);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: EmojiLikeToOthersWrapper2, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* SysMessage.EmojiLikeToOthersWrapper3 body = 1; */
|
||||
if (message.body)
|
||||
EmojiLikeToOthersWrapper3.internalBinaryWrite(message.body, writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersWrapper2
|
||||
*/
|
||||
export const EmojiLikeToOthersWrapper2 = new EmojiLikeToOthersWrapper2$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class EmojiLikeToOthersWrapper3$Type extends MessageType<EmojiLikeToOthersWrapper3> {
|
||||
constructor() {
|
||||
super("SysMessage.EmojiLikeToOthersWrapper3", [
|
||||
{ no: 2, name: "msgSpec", kind: "message", T: () => EmojiLikeToOthersMsgSpec },
|
||||
{ no: 3, name: "attributes", kind: "message", T: () => EmojiLikeToOthersAttributes }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<EmojiLikeToOthersWrapper3>): EmojiLikeToOthersWrapper3 {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<EmojiLikeToOthersWrapper3>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersWrapper3): EmojiLikeToOthersWrapper3 {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* SysMessage.EmojiLikeToOthersMsgSpec msgSpec */ 2:
|
||||
message.msgSpec = EmojiLikeToOthersMsgSpec.internalBinaryRead(reader, reader.uint32(), options, message.msgSpec);
|
||||
break;
|
||||
case /* SysMessage.EmojiLikeToOthersAttributes attributes */ 3:
|
||||
message.attributes = EmojiLikeToOthersAttributes.internalBinaryRead(reader, reader.uint32(), options, message.attributes);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: EmojiLikeToOthersWrapper3, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* SysMessage.EmojiLikeToOthersMsgSpec msgSpec = 2; */
|
||||
if (message.msgSpec)
|
||||
EmojiLikeToOthersMsgSpec.internalBinaryWrite(message.msgSpec, writer.tag(2, WireType.LengthDelimited).fork(), options).join();
|
||||
/* SysMessage.EmojiLikeToOthersAttributes attributes = 3; */
|
||||
if (message.attributes)
|
||||
EmojiLikeToOthersAttributes.internalBinaryWrite(message.attributes, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersWrapper3
|
||||
*/
|
||||
export const EmojiLikeToOthersWrapper3 = new EmojiLikeToOthersWrapper3$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class EmojiLikeToOthersMsgSpec$Type extends MessageType<EmojiLikeToOthersMsgSpec> {
|
||||
constructor() {
|
||||
super("SysMessage.EmojiLikeToOthersMsgSpec", [
|
||||
{ no: 1, name: "msgSeq", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<EmojiLikeToOthersMsgSpec>): EmojiLikeToOthersMsgSpec {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.msgSeq = 0;
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<EmojiLikeToOthersMsgSpec>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersMsgSpec): EmojiLikeToOthersMsgSpec {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* uint32 msgSeq */ 1:
|
||||
message.msgSeq = reader.uint32();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: EmojiLikeToOthersMsgSpec, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* uint32 msgSeq = 1; */
|
||||
if (message.msgSeq !== 0)
|
||||
writer.tag(1, WireType.Varint).uint32(message.msgSeq);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersMsgSpec
|
||||
*/
|
||||
export const EmojiLikeToOthersMsgSpec = new EmojiLikeToOthersMsgSpec$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class EmojiLikeToOthersAttributes$Type extends MessageType<EmojiLikeToOthersAttributes> {
|
||||
constructor() {
|
||||
super("SysMessage.EmojiLikeToOthersAttributes", [
|
||||
{ no: 1, name: "emojiId", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 4, name: "senderUid", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 5, name: "operation", kind: "enum", T: () => ["SysMessage.EmojiLikeToOthersAttributes.Operation", EmojiLikeToOthersAttributes_Operation] }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<EmojiLikeToOthersAttributes>): EmojiLikeToOthersAttributes {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.emojiId = "";
|
||||
message.senderUid = "";
|
||||
message.operation = 0;
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<EmojiLikeToOthersAttributes>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: EmojiLikeToOthersAttributes): EmojiLikeToOthersAttributes {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* string emojiId */ 1:
|
||||
message.emojiId = reader.string();
|
||||
break;
|
||||
case /* string senderUid */ 4:
|
||||
message.senderUid = reader.string();
|
||||
break;
|
||||
case /* SysMessage.EmojiLikeToOthersAttributes.Operation operation */ 5:
|
||||
message.operation = reader.int32();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: EmojiLikeToOthersAttributes, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* string emojiId = 1; */
|
||||
if (message.emojiId !== "")
|
||||
writer.tag(1, WireType.LengthDelimited).string(message.emojiId);
|
||||
/* string senderUid = 4; */
|
||||
if (message.senderUid !== "")
|
||||
writer.tag(4, WireType.LengthDelimited).string(message.senderUid);
|
||||
/* SysMessage.EmojiLikeToOthersAttributes.Operation operation = 5; */
|
||||
if (message.operation !== 0)
|
||||
writer.tag(5, WireType.Varint).int32(message.operation);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.EmojiLikeToOthersAttributes
|
||||
*/
|
||||
export const EmojiLikeToOthersAttributes = new EmojiLikeToOthersAttributes$Type();
|
9
src/core/proto/GreyTipWrapper.proto
Normal file
9
src/core/proto/GreyTipWrapper.proto
Normal file
@@ -0,0 +1,9 @@
|
||||
syntax = 'proto3';
|
||||
package SysMessage;
|
||||
|
||||
message GreyTipWrapper {
|
||||
uint32 subTypeId = 1;
|
||||
uint32 groupCode = 4;
|
||||
uint32 subTypeIdMinusOne = 13;
|
||||
bytes rest = 44;
|
||||
}
|
104
src/core/proto/GreyTipWrapper.ts
Normal file
104
src/core/proto/GreyTipWrapper.ts
Normal file
@@ -0,0 +1,104 @@
|
||||
// @generated by protobuf-ts 2.9.4
|
||||
// @generated from protobuf file "GreyTipWrapper.proto" (package "SysMessage", syntax proto3)
|
||||
// tslint:disable
|
||||
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
||||
import { WireType } from "@protobuf-ts/runtime";
|
||||
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
||||
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
||||
import type { PartialMessage } from "@protobuf-ts/runtime";
|
||||
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
||||
import { MessageType } from "@protobuf-ts/runtime";
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.GreyTipWrapper
|
||||
*/
|
||||
export interface GreyTipWrapper {
|
||||
/**
|
||||
* @generated from protobuf field: uint32 subTypeId = 1;
|
||||
*/
|
||||
subTypeId: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 groupCode = 4;
|
||||
*/
|
||||
groupCode: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 subTypeIdMinusOne = 13;
|
||||
*/
|
||||
subTypeIdMinusOne: number;
|
||||
/**
|
||||
* @generated from protobuf field: bytes rest = 44;
|
||||
*/
|
||||
rest: Uint8Array;
|
||||
}
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class GreyTipWrapper$Type extends MessageType<GreyTipWrapper> {
|
||||
constructor() {
|
||||
super("SysMessage.GreyTipWrapper", [
|
||||
{ no: 1, name: "subTypeId", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 4, name: "groupCode", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 13, name: "subTypeIdMinusOne", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 44, name: "rest", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<GreyTipWrapper>): GreyTipWrapper {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.subTypeId = 0;
|
||||
message.groupCode = 0;
|
||||
message.subTypeIdMinusOne = 0;
|
||||
message.rest = new Uint8Array(0);
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<GreyTipWrapper>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GreyTipWrapper): GreyTipWrapper {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* uint32 subTypeId */ 1:
|
||||
message.subTypeId = reader.uint32();
|
||||
break;
|
||||
case /* uint32 groupCode */ 4:
|
||||
message.groupCode = reader.uint32();
|
||||
break;
|
||||
case /* uint32 subTypeIdMinusOne */ 13:
|
||||
message.subTypeIdMinusOne = reader.uint32();
|
||||
break;
|
||||
case /* bytes rest */ 44:
|
||||
message.rest = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: GreyTipWrapper, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* uint32 subTypeId = 1; */
|
||||
if (message.subTypeId !== 0)
|
||||
writer.tag(1, WireType.Varint).uint32(message.subTypeId);
|
||||
/* uint32 groupCode = 4; */
|
||||
if (message.groupCode !== 0)
|
||||
writer.tag(4, WireType.Varint).uint32(message.groupCode);
|
||||
/* uint32 subTypeIdMinusOne = 13; */
|
||||
if (message.subTypeIdMinusOne !== 0)
|
||||
writer.tag(13, WireType.Varint).uint32(message.subTypeIdMinusOne);
|
||||
/* bytes rest = 44; */
|
||||
if (message.rest.length)
|
||||
writer.tag(44, WireType.LengthDelimited).bytes(message.rest);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.GreyTipWrapper
|
||||
*/
|
||||
export const GreyTipWrapper = new GreyTipWrapper$Type();
|
36
src/core/proto/SysMessage.proto
Normal file
36
src/core/proto/SysMessage.proto
Normal file
@@ -0,0 +1,36 @@
|
||||
syntax = 'proto3';
|
||||
package SysMessage;
|
||||
|
||||
message SysMessage {
|
||||
repeated SysMessageHeader header = 1;
|
||||
repeated SysMessageMsgSpec msgSpec = 2;
|
||||
SysMessageBodyWrapper bodyWrapper = 3;
|
||||
}
|
||||
|
||||
message SysMessageHeader {
|
||||
uint32 PeerNumber = 1;
|
||||
string PeerString = 2;
|
||||
uint32 Uin = 5;
|
||||
optional string Uid = 6;
|
||||
}
|
||||
|
||||
message SysMessageMsgSpec {
|
||||
uint32 msgType = 1;
|
||||
uint32 subType = 2;
|
||||
uint32 subSubType = 3;
|
||||
uint32 msgSeq = 5;
|
||||
uint32 time = 6;
|
||||
uint64 msgId = 12;
|
||||
uint32 other = 13;
|
||||
}
|
||||
|
||||
message SysMessageBodyWrapper {
|
||||
bytes wrappedBody = 2;
|
||||
// Find the first [08], or ignore the first 7 bytes?
|
||||
// And it becomes another ProtoBuf message.
|
||||
}
|
||||
|
||||
message KeyValuePair {
|
||||
string key = 1;
|
||||
string value = 2;
|
||||
}
|
435
src/core/proto/SysMessage.ts
Normal file
435
src/core/proto/SysMessage.ts
Normal file
@@ -0,0 +1,435 @@
|
||||
// @generated by protobuf-ts 2.9.4
|
||||
// @generated from protobuf file "SysMessage.proto" (package "SysMessage", syntax proto3)
|
||||
// tslint:disable
|
||||
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
||||
import { WireType } from "@protobuf-ts/runtime";
|
||||
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
||||
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
||||
import type { PartialMessage } from "@protobuf-ts/runtime";
|
||||
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
||||
import { MessageType } from "@protobuf-ts/runtime";
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.SysMessage
|
||||
*/
|
||||
export interface SysMessage {
|
||||
/**
|
||||
* @generated from protobuf field: repeated SysMessage.SysMessageHeader header = 1;
|
||||
*/
|
||||
header: SysMessageHeader[];
|
||||
/**
|
||||
* @generated from protobuf field: repeated SysMessage.SysMessageMsgSpec msgSpec = 2;
|
||||
*/
|
||||
msgSpec: SysMessageMsgSpec[];
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.SysMessageBodyWrapper bodyWrapper = 3;
|
||||
*/
|
||||
bodyWrapper?: SysMessageBodyWrapper;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.SysMessageHeader
|
||||
*/
|
||||
export interface SysMessageHeader {
|
||||
/**
|
||||
* @generated from protobuf field: uint32 PeerNumber = 1 [json_name = "PeerNumber"];
|
||||
*/
|
||||
peerNumber: number;
|
||||
/**
|
||||
* @generated from protobuf field: string PeerString = 2 [json_name = "PeerString"];
|
||||
*/
|
||||
peerString: string;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 Uin = 5 [json_name = "Uin"];
|
||||
*/
|
||||
uin: number;
|
||||
/**
|
||||
* @generated from protobuf field: optional string Uid = 6 [json_name = "Uid"];
|
||||
*/
|
||||
uid?: string;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.SysMessageMsgSpec
|
||||
*/
|
||||
export interface SysMessageMsgSpec {
|
||||
/**
|
||||
* @generated from protobuf field: uint32 msgType = 1;
|
||||
*/
|
||||
msgType: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 subType = 2;
|
||||
*/
|
||||
subType: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 subSubType = 3;
|
||||
*/
|
||||
subSubType: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 msgSeq = 5;
|
||||
*/
|
||||
msgSeq: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 time = 6;
|
||||
*/
|
||||
time: number;
|
||||
/**
|
||||
* @generated from protobuf field: uint64 msgId = 12;
|
||||
*/
|
||||
msgId: bigint;
|
||||
/**
|
||||
* @generated from protobuf field: uint32 other = 13;
|
||||
*/
|
||||
other: number;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.SysMessageBodyWrapper
|
||||
*/
|
||||
export interface SysMessageBodyWrapper {
|
||||
/**
|
||||
* @generated from protobuf field: bytes wrappedBody = 2;
|
||||
*/
|
||||
wrappedBody: Uint8Array; // Find the first [08], or ignore the first 7 bytes?
|
||||
// And it becomes another ProtoBuf message.
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.KeyValuePair
|
||||
*/
|
||||
export interface KeyValuePair {
|
||||
/**
|
||||
* @generated from protobuf field: string key = 1;
|
||||
*/
|
||||
key: string;
|
||||
/**
|
||||
* @generated from protobuf field: string value = 2;
|
||||
*/
|
||||
value: string;
|
||||
}
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class SysMessage$Type extends MessageType<SysMessage> {
|
||||
constructor() {
|
||||
super("SysMessage.SysMessage", [
|
||||
{ no: 1, name: "header", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => SysMessageHeader },
|
||||
{ no: 2, name: "msgSpec", kind: "message", repeat: 1 /*RepeatType.PACKED*/, T: () => SysMessageMsgSpec },
|
||||
{ no: 3, name: "bodyWrapper", kind: "message", T: () => SysMessageBodyWrapper }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<SysMessage>): SysMessage {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.header = [];
|
||||
message.msgSpec = [];
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<SysMessage>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessage): SysMessage {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* repeated SysMessage.SysMessageHeader header */ 1:
|
||||
message.header.push(SysMessageHeader.internalBinaryRead(reader, reader.uint32(), options));
|
||||
break;
|
||||
case /* repeated SysMessage.SysMessageMsgSpec msgSpec */ 2:
|
||||
message.msgSpec.push(SysMessageMsgSpec.internalBinaryRead(reader, reader.uint32(), options));
|
||||
break;
|
||||
case /* SysMessage.SysMessageBodyWrapper bodyWrapper */ 3:
|
||||
message.bodyWrapper = SysMessageBodyWrapper.internalBinaryRead(reader, reader.uint32(), options, message.bodyWrapper);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: SysMessage, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* repeated SysMessage.SysMessageHeader header = 1; */
|
||||
for (let i = 0; i < message.header.length; i++)
|
||||
SysMessageHeader.internalBinaryWrite(message.header[i], writer.tag(1, WireType.LengthDelimited).fork(), options).join();
|
||||
/* repeated SysMessage.SysMessageMsgSpec msgSpec = 2; */
|
||||
for (let i = 0; i < message.msgSpec.length; i++)
|
||||
SysMessageMsgSpec.internalBinaryWrite(message.msgSpec[i], writer.tag(2, WireType.LengthDelimited).fork(), options).join();
|
||||
/* SysMessage.SysMessageBodyWrapper bodyWrapper = 3; */
|
||||
if (message.bodyWrapper)
|
||||
SysMessageBodyWrapper.internalBinaryWrite(message.bodyWrapper, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.SysMessage
|
||||
*/
|
||||
export const SysMessage = new SysMessage$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class SysMessageHeader$Type extends MessageType<SysMessageHeader> {
|
||||
constructor() {
|
||||
super("SysMessage.SysMessageHeader", [
|
||||
{ no: 1, name: "PeerNumber", kind: "scalar", jsonName: "PeerNumber", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 2, name: "PeerString", kind: "scalar", jsonName: "PeerString", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 5, name: "Uin", kind: "scalar", jsonName: "Uin", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 6, name: "Uid", kind: "scalar", jsonName: "Uid", opt: true, T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<SysMessageHeader>): SysMessageHeader {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.peerNumber = 0;
|
||||
message.peerString = "";
|
||||
message.uin = 0;
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<SysMessageHeader>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessageHeader): SysMessageHeader {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* uint32 PeerNumber = 1 [json_name = "PeerNumber"];*/ 1:
|
||||
message.peerNumber = reader.uint32();
|
||||
break;
|
||||
case /* string PeerString = 2 [json_name = "PeerString"];*/ 2:
|
||||
message.peerString = reader.string();
|
||||
break;
|
||||
case /* uint32 Uin = 5 [json_name = "Uin"];*/ 5:
|
||||
message.uin = reader.uint32();
|
||||
break;
|
||||
case /* optional string Uid = 6 [json_name = "Uid"];*/ 6:
|
||||
message.uid = reader.string();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: SysMessageHeader, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* uint32 PeerNumber = 1 [json_name = "PeerNumber"]; */
|
||||
if (message.peerNumber !== 0)
|
||||
writer.tag(1, WireType.Varint).uint32(message.peerNumber);
|
||||
/* string PeerString = 2 [json_name = "PeerString"]; */
|
||||
if (message.peerString !== "")
|
||||
writer.tag(2, WireType.LengthDelimited).string(message.peerString);
|
||||
/* uint32 Uin = 5 [json_name = "Uin"]; */
|
||||
if (message.uin !== 0)
|
||||
writer.tag(5, WireType.Varint).uint32(message.uin);
|
||||
/* optional string Uid = 6 [json_name = "Uid"]; */
|
||||
if (message.uid !== undefined)
|
||||
writer.tag(6, WireType.LengthDelimited).string(message.uid);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.SysMessageHeader
|
||||
*/
|
||||
export const SysMessageHeader = new SysMessageHeader$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class SysMessageMsgSpec$Type extends MessageType<SysMessageMsgSpec> {
|
||||
constructor() {
|
||||
super("SysMessage.SysMessageMsgSpec", [
|
||||
{ no: 1, name: "msgType", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 2, name: "subType", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 3, name: "subSubType", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 5, name: "msgSeq", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 6, name: "time", kind: "scalar", T: 13 /*ScalarType.UINT32*/ },
|
||||
{ no: 12, name: "msgId", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ },
|
||||
{ no: 13, name: "other", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<SysMessageMsgSpec>): SysMessageMsgSpec {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.msgType = 0;
|
||||
message.subType = 0;
|
||||
message.subSubType = 0;
|
||||
message.msgSeq = 0;
|
||||
message.time = 0;
|
||||
message.msgId = 0n;
|
||||
message.other = 0;
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<SysMessageMsgSpec>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessageMsgSpec): SysMessageMsgSpec {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* uint32 msgType */ 1:
|
||||
message.msgType = reader.uint32();
|
||||
break;
|
||||
case /* uint32 subType */ 2:
|
||||
message.subType = reader.uint32();
|
||||
break;
|
||||
case /* uint32 subSubType */ 3:
|
||||
message.subSubType = reader.uint32();
|
||||
break;
|
||||
case /* uint32 msgSeq */ 5:
|
||||
message.msgSeq = reader.uint32();
|
||||
break;
|
||||
case /* uint32 time */ 6:
|
||||
message.time = reader.uint32();
|
||||
break;
|
||||
case /* uint64 msgId */ 12:
|
||||
message.msgId = reader.uint64().toBigInt();
|
||||
break;
|
||||
case /* uint32 other */ 13:
|
||||
message.other = reader.uint32();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: SysMessageMsgSpec, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* uint32 msgType = 1; */
|
||||
if (message.msgType !== 0)
|
||||
writer.tag(1, WireType.Varint).uint32(message.msgType);
|
||||
/* uint32 subType = 2; */
|
||||
if (message.subType !== 0)
|
||||
writer.tag(2, WireType.Varint).uint32(message.subType);
|
||||
/* uint32 subSubType = 3; */
|
||||
if (message.subSubType !== 0)
|
||||
writer.tag(3, WireType.Varint).uint32(message.subSubType);
|
||||
/* uint32 msgSeq = 5; */
|
||||
if (message.msgSeq !== 0)
|
||||
writer.tag(5, WireType.Varint).uint32(message.msgSeq);
|
||||
/* uint32 time = 6; */
|
||||
if (message.time !== 0)
|
||||
writer.tag(6, WireType.Varint).uint32(message.time);
|
||||
/* uint64 msgId = 12; */
|
||||
if (message.msgId !== 0n)
|
||||
writer.tag(12, WireType.Varint).uint64(message.msgId);
|
||||
/* uint32 other = 13; */
|
||||
if (message.other !== 0)
|
||||
writer.tag(13, WireType.Varint).uint32(message.other);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.SysMessageMsgSpec
|
||||
*/
|
||||
export const SysMessageMsgSpec = new SysMessageMsgSpec$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class SysMessageBodyWrapper$Type extends MessageType<SysMessageBodyWrapper> {
|
||||
constructor() {
|
||||
super("SysMessage.SysMessageBodyWrapper", [
|
||||
{ no: 2, name: "wrappedBody", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<SysMessageBodyWrapper>): SysMessageBodyWrapper {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.wrappedBody = new Uint8Array(0);
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<SysMessageBodyWrapper>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: SysMessageBodyWrapper): SysMessageBodyWrapper {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* bytes wrappedBody */ 2:
|
||||
message.wrappedBody = reader.bytes();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: SysMessageBodyWrapper, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* bytes wrappedBody = 2; */
|
||||
if (message.wrappedBody.length)
|
||||
writer.tag(2, WireType.LengthDelimited).bytes(message.wrappedBody);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.SysMessageBodyWrapper
|
||||
*/
|
||||
export const SysMessageBodyWrapper = new SysMessageBodyWrapper$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class KeyValuePair$Type extends MessageType<KeyValuePair> {
|
||||
constructor() {
|
||||
super("SysMessage.KeyValuePair", [
|
||||
{ no: 1, name: "key", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 2, name: "value", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<KeyValuePair>): KeyValuePair {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.key = "";
|
||||
message.value = "";
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<KeyValuePair>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: KeyValuePair): KeyValuePair {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* string key */ 1:
|
||||
message.key = reader.string();
|
||||
break;
|
||||
case /* string value */ 2:
|
||||
message.value = reader.string();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: KeyValuePair, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* string key = 1; */
|
||||
if (message.key !== "")
|
||||
writer.tag(1, WireType.LengthDelimited).string(message.key);
|
||||
/* string value = 2; */
|
||||
if (message.value !== "")
|
||||
writer.tag(2, WireType.LengthDelimited).string(message.value);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.KeyValuePair
|
||||
*/
|
||||
export const KeyValuePair = new KeyValuePair$Type();
|
@@ -1,5 +1,7 @@
|
||||
import { NodeIKernelFileAssistantListener } from '@/core';
|
||||
|
||||
export interface NodeIKernelFileAssistantService {
|
||||
addKernelFileAssistantListener(arg1: unknown[]): unknown;
|
||||
addKernelFileAssistantListener(listener: NodeIKernelFileAssistantListener): unknown;
|
||||
|
||||
removeKernelFileAssistantListener(arg1: unknown[]): unknown;
|
||||
|
||||
@@ -9,7 +11,7 @@ export interface NodeIKernelFileAssistantService {
|
||||
|
||||
getFileSessionList(): unknown;
|
||||
|
||||
searchFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||
searchFile(keywords: string[], params: { resultType: number, pageLimit: number }): unknown;
|
||||
|
||||
resetSearchFileSortType(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||
|
||||
@@ -17,7 +19,7 @@ export interface NodeIKernelFileAssistantService {
|
||||
|
||||
cancelSearchFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||
|
||||
downloadFile(arg1: unknown[]): unknown;
|
||||
downloadFile(fileIds: string[]): { result: number, errMsg: string };
|
||||
|
||||
forwardFile(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||
|
||||
@@ -32,4 +34,4 @@ export interface NodeIKernelFileAssistantService {
|
||||
saveAsWithRename(arg1: unknown, arg2: unknown, arg3: unknown): unknown;
|
||||
|
||||
isNull(): boolean;
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ import { NodeIKernelGroupListener } from '@/core/listeners/NodeIKernelGroupListe
|
||||
import {
|
||||
GroupExt0xEF0InfoFilter,
|
||||
GroupExtParam,
|
||||
GroupInfoSource,
|
||||
GroupMember,
|
||||
GroupMemberRole,
|
||||
GroupNotifyMsgType,
|
||||
@@ -13,9 +14,9 @@ import { GeneralCallResult } from '@/core/services/common';
|
||||
//高版本的接口不应该随意使用 使用应该严格进行pr审核 同时部分ipc中未出现的接口不要过于依赖 应该做好数据兜底
|
||||
|
||||
export interface NodeIKernelGroupService {
|
||||
//getGroupExt0xEF0Info(this.$enableGroupCodes, this.$bannedGroupCodes, this.$filter, this.$forceFetch
|
||||
getGroupExt0xEF0Info(enableGroupCodes: string[], bannedGroupCodes: string[], filter: GroupExt0xEF0InfoFilter, forceFetch: boolean):
|
||||
Promise<GeneralCallResult & { result: { groupExtInfos: Map<string, any> }}>;
|
||||
Promise<GeneralCallResult & { result: { groupExtInfos: Map<string, any> } }>;
|
||||
|
||||
kickMemberV2(param: KickMemberV2Req): Promise<GeneralCallResult>;
|
||||
|
||||
quitGroupV2(param: { groupCode: string; needDeleteLocalMsg: boolean; }): Promise<GeneralCallResult>;
|
||||
@@ -39,11 +40,11 @@ export interface NodeIKernelGroupService {
|
||||
realSpecialTitleFlag: number
|
||||
}): Promise<unknown>;
|
||||
|
||||
//26702
|
||||
getGroupMemberLevelInfo(groupCode: string): Promise<unknown>;
|
||||
|
||||
//26702
|
||||
getGroupHonorList(groupCodes: Array<string>): unknown;
|
||||
getGroupInfoForJoinGroup(groupCode: string, needPrivilegeFlag: boolean, serviceType: number): Promise<unknown>;
|
||||
|
||||
getGroupHonorList(req: { groupCodes: Array<string> }): Promise<unknown>;
|
||||
|
||||
getUinByUids(uins: string[]): Promise<{
|
||||
errCode: number,
|
||||
@@ -57,13 +58,10 @@ export interface NodeIKernelGroupService {
|
||||
uids: Map<string, string>
|
||||
}>;
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
checkGroupMemberCache(arrayList: Array<string>): Promise<unknown>;
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
getGroupLatestEssenceList(groupCode: string): Promise<unknown>;
|
||||
|
||||
//26702(其实更早 但是我不知道)
|
||||
shareDigest(Req: {
|
||||
appId: string,
|
||||
appType: number,
|
||||
@@ -83,20 +81,17 @@ export interface NodeIKernelGroupService {
|
||||
}
|
||||
}): 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,
|
||||
@@ -135,8 +130,6 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
getMemberInfo(group_id: string, uids: string[], forceFetch: boolean): Promise<GeneralCallResult>;
|
||||
|
||||
//getMemberInfo [ '56729xxxx', [ 'u_4Nj08cwW5Hxxxxx' ], true ]
|
||||
|
||||
kickMember(groupCode: string, memberUids: string[], refuseForever: boolean, kickReason: string): Promise<void>;
|
||||
|
||||
modifyMemberRole(groupCode: string, uid: string, role: GroupMemberRole): void;
|
||||
@@ -151,7 +144,7 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
getGroupExtList(force: boolean): Promise<GeneralCallResult>;
|
||||
|
||||
getGroupDetailInfo(groupCode: string): unknown;
|
||||
getGroupDetailInfo(groupCode: string, groupInfoSource: GroupInfoSource): Promise<unknown>;
|
||||
|
||||
getMemberExtInfo(param: GroupExtParam): Promise<unknown>;//req
|
||||
|
||||
@@ -189,14 +182,13 @@ export interface NodeIKernelGroupService {
|
||||
|
||||
destroyGroup(groupCode: string): void;
|
||||
|
||||
//获取单屏群通知列表
|
||||
getSingleScreenNotifies(force: boolean, start_seq: string, num: number): Promise<GeneralCallResult>;
|
||||
getSingleScreenNotifies(doubted: boolean, start_seq: string, num: number): Promise<GeneralCallResult>;
|
||||
|
||||
clearGroupNotifies(groupCode: string): void;
|
||||
|
||||
getGroupNotifiesUnreadCount(unknown: boolean): Promise<GeneralCallResult>;
|
||||
|
||||
clearGroupNotifiesUnreadCount(groupCode: string): void;
|
||||
clearGroupNotifiesUnreadCount(unknown: boolean): void;
|
||||
|
||||
operateSysNotify(
|
||||
doubt: boolean,
|
||||
|
@@ -167,11 +167,17 @@ export interface NodeIKernelMsgService {
|
||||
|
||||
getAllOnlineFileMsgs(...args: unknown[]): unknown;
|
||||
|
||||
getLatestDbMsgs(peer: Peer, cnt: number): Promise<unknown>;
|
||||
getLatestDbMsgs(peer: Peer, cnt: number): Promise<GeneralCallResult & {
|
||||
msgList: RawMessage[]
|
||||
}>;
|
||||
|
||||
getLastMessageList(peer: Peer[]): Promise<unknown>;
|
||||
getLastMessageList(peer: Peer[]): Promise<GeneralCallResult & {
|
||||
msgList: RawMessage[]
|
||||
}>;
|
||||
|
||||
getAioFirstViewLatestMsgs(peer: Peer, num: number): unknown;
|
||||
getAioFirstViewLatestMsgs(peer: Peer, num: number): Promise<GeneralCallResult & {
|
||||
msgList: RawMessage[]
|
||||
}>;
|
||||
|
||||
getMsgs(peer: Peer, msgId: string, count: unknown, queryOrder: boolean): Promise<unknown>;
|
||||
|
||||
@@ -512,11 +518,11 @@ export interface NodeIKernelMsgService {
|
||||
result: number,
|
||||
errMsg: string,
|
||||
emojiLikesList:
|
||||
Array<{
|
||||
tinyId: string,
|
||||
nickName: string,
|
||||
headUrl: string
|
||||
}>,
|
||||
Array<{
|
||||
tinyId: string,
|
||||
nickName: string,
|
||||
headUrl: string
|
||||
}>,
|
||||
cookie: string,
|
||||
isLastPage: boolean,
|
||||
isFirstPage: boolean
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import { AnyCnameRecord } from 'node:dns';
|
||||
import { BizKey, ModifyProfileParams, SimpleInfo, UserDetailInfoByUin, UserDetailInfoByUinV2 } from '@/core';
|
||||
import { NodeIKernelProfileListener } from '@/core';
|
||||
import { BizKey, ModifyProfileParams, NodeIKernelProfileListener, SimpleInfo, UserDetailInfoByUinV2 } from '@/core';
|
||||
import { GeneralCallResult } from '@/core/services/common';
|
||||
|
||||
export enum UserDetailSource {
|
||||
|
@@ -155,7 +155,7 @@ export interface NodeIKernelRichMediaService {
|
||||
}): unknown;
|
||||
|
||||
//arg3为“”
|
||||
downloadFileForModelId(peer: Peer, ModelId: string[], arg3: string): unknown;
|
||||
downloadFileForModelId(peer: Peer, ModelId: string[]): Promise<unknown>;
|
||||
|
||||
//第三个参数 Array<Type>
|
||||
// this.fileId = "";
|
||||
|
@@ -20,6 +20,7 @@ export * from './NodeIKernelCollectionService';
|
||||
import type {
|
||||
NodeIKernelAvatarService,
|
||||
NodeIKernelBuddyService,
|
||||
NodeIKernelCollectionService,
|
||||
NodeIKernelDbToolsService,
|
||||
NodeIKernelFileAssistantService,
|
||||
NodeIKernelGroupService,
|
||||
@@ -30,11 +31,10 @@ import type {
|
||||
NodeIKernelProfileService,
|
||||
NodeIKernelRichMediaService,
|
||||
NodeIKernelRobotService,
|
||||
NodeIKernelSearchService,
|
||||
NodeIKernelStorageCleanService,
|
||||
NodeIKernelTicketService,
|
||||
NodeIKernelTipOffService,
|
||||
NodeIKernelSearchService,
|
||||
NodeIKernelCollectionService,
|
||||
} from '.';
|
||||
|
||||
export type ServiceNamingMapping = {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { NodeIDependsAdapter, NodeIDispatcherAdapter, NodeIGlobalAdapter } from '../adapters';
|
||||
import { NodeIKernelSessionListener } from '@/core';
|
||||
import { NodeIDependsAdapter, NodeIDispatcherAdapter, NodeIGlobalAdapter } from './adapters';
|
||||
import {
|
||||
NodeIKernelAvatarService,
|
||||
NodeIKernelBuddyService,
|
||||
@@ -9,23 +8,24 @@ import {
|
||||
NodeIKernelProfileLikeService,
|
||||
NodeIKernelProfileService,
|
||||
NodeIKernelRichMediaService,
|
||||
NodeIKernelRobotService,
|
||||
NodeIKernelSessionListener,
|
||||
NodeIKernelStorageCleanService,
|
||||
NodeIKernelTicketService,
|
||||
NodeIKernelTipOffService,
|
||||
} from '@/core';
|
||||
import { NodeIKernelStorageCleanService } from '@/core';
|
||||
import { NodeIKernelRobotService } from '@/core';
|
||||
import { NodeIKernelNodeMiscService } from '../services/NodeIKernelNodeMiscService';
|
||||
import { NodeIKernelUixConvertService } from '../services/NodeIKernelUixConvertService';
|
||||
import { NodeIKernelMsgBackupService } from '../services/NodeIKernelMsgBackupService';
|
||||
import { NodeIKernelAlbumService } from '../services/NodeIKernelAlbumService';
|
||||
import { NodeIKernelTianShuService } from '../services/NodeIKernelTianShuService';
|
||||
import { NodeIKernelUnitedConfigService } from '../services/NodeIKernelUnitedConfigService';
|
||||
import { NodeIKernelSearchService } from '../services/NodeIKernelSearchService';
|
||||
import { NodeIKernelCollectionService } from '../services/NodeIKernelCollectionService';
|
||||
import { NodeIKernelRecentContactService } from '../services/NodeIKernelRecentContactService';
|
||||
import { NodeIKernelMSFService } from '../services/NodeIKernelMSFService';
|
||||
import { NodeIkernelTestPerformanceService } from '../services/NodeIkernelTestPerformanceService';
|
||||
import { NodeIKernelECDHService } from '../services/NodeIKernelECDHService';
|
||||
} from '@/core/index';
|
||||
import { NodeIKernelNodeMiscService } from './services/NodeIKernelNodeMiscService';
|
||||
import { NodeIKernelUixConvertService } from './services/NodeIKernelUixConvertService';
|
||||
import { NodeIKernelMsgBackupService } from './services/NodeIKernelMsgBackupService';
|
||||
import { NodeIKernelAlbumService } from './services/NodeIKernelAlbumService';
|
||||
import { NodeIKernelTianShuService } from './services/NodeIKernelTianShuService';
|
||||
import { NodeIKernelUnitedConfigService } from './services/NodeIKernelUnitedConfigService';
|
||||
import { NodeIKernelSearchService } from './services/NodeIKernelSearchService';
|
||||
import { NodeIKernelCollectionService } from './services/NodeIKernelCollectionService';
|
||||
import { NodeIKernelRecentContactService } from './services/NodeIKernelRecentContactService';
|
||||
import { NodeIKernelMSFService } from './services/NodeIKernelMSFService';
|
||||
import { NodeIkernelTestPerformanceService } from './services/NodeIkernelTestPerformanceService';
|
||||
import { NodeIKernelECDHService } from './services/NodeIKernelECDHService';
|
||||
|
||||
export interface NodeQQNTWrapperUtil {
|
||||
get(): unknown;
|
@@ -1,27 +0,0 @@
|
||||
import { LogWrapper } from '@/common/utils/log';
|
||||
import { QQBasicInfoWrapper } from '@/common/utils/qq-basic-info';
|
||||
import { NapCatCoreWorkingEnv, NodeIKernelLoginService, NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core';
|
||||
import { NTQQFileApi, NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQSystemApi, NTQQUserApi, NTQQWebApi } from '../apis';
|
||||
import { NTQQCollectionApi } from '../apis/collection';
|
||||
import { NapCatPathWrapper } from '@/common/framework/napcat';
|
||||
|
||||
export interface InstanceContext {
|
||||
readonly workingEnv: NapCatCoreWorkingEnv;
|
||||
readonly wrapper: WrapperNodeApi;
|
||||
readonly session: NodeIQQNTWrapperSession;
|
||||
readonly logger: LogWrapper;
|
||||
readonly loginService: NodeIKernelLoginService;
|
||||
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
||||
readonly pathWrapper: NapCatPathWrapper;
|
||||
}
|
||||
|
||||
export interface StableNTApiWrapper {
|
||||
FileApi: NTQQFileApi,
|
||||
SystemApi: NTQQSystemApi,
|
||||
CollectionApi: NTQQCollectionApi,
|
||||
WebApi: NTQQWebApi,
|
||||
FriendApi: NTQQFriendApi,
|
||||
MsgApi: NTQQMsgApi,
|
||||
UserApi: NTQQUserApi,
|
||||
GroupApi: NTQQGroupApi
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import { PlatformType, VendorType, WrapperSessionInitConfig } from './wrapper';
|
||||
import { getMachineId, hostname, systemName, systemVersion } from '@/common/utils/system';
|
||||
|
||||
export async function genSessionConfig(QQVersionAppid: string, QQVersion: string, selfUin: string, selfUid: string, account_path: string): Promise<WrapperSessionInitConfig> {
|
||||
const downloadPath = path.join(account_path, 'NapCat', 'temp');
|
||||
fs.mkdirSync(downloadPath, { recursive: true });
|
||||
const guid: string = await getMachineId();//26702 支持JS获取guid值 在LoginService中获取 TODO mlikiow a
|
||||
const config: WrapperSessionInitConfig = {
|
||||
selfUin,
|
||||
selfUid,
|
||||
desktopPathConfig: {
|
||||
account_path, // 可以通过NodeQQNTWrapperUtil().getNTUserDataInfoConfig()获取
|
||||
},
|
||||
clientVer: QQVersion, // 9.9.8-22355
|
||||
a2: '',
|
||||
d2: '',
|
||||
d2Key: '',
|
||||
machineId: '',
|
||||
platform: PlatformType.KWINDOWS, // 3是Windows?
|
||||
platVer: systemVersion, // 系统版本号, 应该可以固定
|
||||
appid: QQVersionAppid,
|
||||
rdeliveryConfig: {
|
||||
appKey: '',
|
||||
systemId: 0,
|
||||
appId: '',
|
||||
logicEnvironment: '',
|
||||
platform: PlatformType.KWINDOWS,
|
||||
language: '',
|
||||
sdkVersion: '',
|
||||
userId: '',
|
||||
appVersion: '',
|
||||
osVersion: '',
|
||||
bundleId: '',
|
||||
serverUrl: '',
|
||||
fixedAfterHitKeys: [''],
|
||||
},
|
||||
defaultFileDownloadPath: downloadPath,
|
||||
deviceInfo: {
|
||||
guid,
|
||||
buildVer: QQVersion,
|
||||
localId: 2052,
|
||||
devName: hostname,
|
||||
devType: systemName,
|
||||
vendorName: '',
|
||||
osVer: systemVersion,
|
||||
vendorOsName: systemName,
|
||||
setMute: false,
|
||||
vendorType: VendorType.KNOSETONIOS,
|
||||
},
|
||||
deviceConfig: '{"appearance":{"isSplitViewMode":true},"msg":{}}',
|
||||
};
|
||||
return config;
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
export * from './wrapper';
|
||||
export * from './helper';
|
||||
export * from './context';
|
@@ -1,13 +1,13 @@
|
||||
import { NapCatPathWrapper } from '@/common/framework/napcat';
|
||||
import { LogWrapper } from '@/common/utils/log';
|
||||
import { proxiedListenerOf } from '@/common/utils/proxy-handler';
|
||||
import { QQBasicInfoWrapper } from '@/common/utils/qq-basic-info';
|
||||
import { loadQQWrapper, NapCatCore, NapCatCoreWorkingEnv } from '@/core/core';
|
||||
import { NapCatPathWrapper } from '@/common/path';
|
||||
import { LogWrapper } from '@/common/log';
|
||||
import { proxiedListenerOf } from '@/common/proxy-handler';
|
||||
import { QQBasicInfoWrapper } from '@/common/qq-basic-info';
|
||||
import { loadQQWrapper, NapCatCore, NapCatCoreWorkingEnv } from '@/core';
|
||||
import { InstanceContext } from '@/core';
|
||||
import { SelfInfo } from '@/core/entities';
|
||||
import { NodeIKernelLoginListener } from '@/core/listeners';
|
||||
import { NodeIKernelLoginService } from '@/core/services';
|
||||
import { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper/wrapper';
|
||||
import { NodeIQQNTWrapperSession, WrapperNodeApi } from '@/core/wrapper';
|
||||
import { InitWebUi, WebUiConfig } from '@/webui';
|
||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||
|
||||
|
4
src/nekodoge/Readme.md
Normal file
4
src/nekodoge/Readme.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# nekodoge
|
||||
此协议为替代QQ平台 OnebotV11长期不可靠问题
|
||||
|
||||
# 规划路线
|
0
src/nekodoge/api/index.ts
Normal file
0
src/nekodoge/api/index.ts
Normal file
0
src/nekodoge/event/index.ts
Normal file
0
src/nekodoge/event/index.ts
Normal file
0
src/nekodoge/helper/index.ts
Normal file
0
src/nekodoge/helper/index.ts
Normal file
0
src/nekodoge/index.ts
Normal file
0
src/nekodoge/index.ts
Normal file
18
src/nekodoge/network/socket.ts
Normal file
18
src/nekodoge/network/socket.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { createServer } from 'node:net';
|
||||
export class NewAdapterNetwork {
|
||||
constructor(public host: number, public port: number) { }
|
||||
async open() {
|
||||
const server = createServer((socket) => {
|
||||
socket.on('data', (data) => {
|
||||
|
||||
});
|
||||
socket.on('end', () => {
|
||||
|
||||
});
|
||||
socket.on('connect', () => {
|
||||
|
||||
})
|
||||
});
|
||||
server.listen(this.port, this.host);
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
import { OB11Return } from '../types';
|
||||
|
||||
import { isNull } from '../../common/utils/helper';
|
||||
import { isNull } from '../../common/helper';
|
||||
|
||||
export class OB11Response {
|
||||
static res<T>(data: T, status: string, retcode: number, message: string = ''): OB11Return<T> {
|
||||
|
@@ -2,7 +2,7 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
|
24
src/onebot/action/extends/GetGroupInfoEx.ts
Normal file
24
src/onebot/action/extends/GetGroupInfoEx.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
},
|
||||
required: ['group_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupInfoEx extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GetGroupInfoEx;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const groupInfoEx = (await NTQQGroupApi.getGroupExtFE0Info([payload.group_id.toString()])).result.groupExtInfos.get(payload.group_id.toString());
|
||||
return groupInfoEx;
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
import fs from 'fs';
|
||||
|
||||
const SchemaData = {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName, BaseCheckResult } from '../types';
|
||||
import * as fs from 'node:fs';
|
||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
|
||||
interface Payload {
|
||||
file: string;
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import fs from 'fs/promises';
|
||||
import { UUIDConverter } from '@/common/utils/helper';
|
||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, ElementType, FileElement, Peer, RawMessage, VideoElement } from '@/core/entities';
|
||||
import { ChatType, Peer, RawMessage } from '@/core/entities';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
export interface GetFilePayload {
|
||||
@@ -29,167 +29,81 @@ export class GetFileBase extends BaseAction<GetFilePayload, GetFileResponse> {
|
||||
payloadSchema: any = GetFileBase_PayloadSchema;
|
||||
|
||||
async _handle(payload: GetFilePayload): Promise<GetFileResponse> {
|
||||
const NTQQFriendApi = this.core.apis.FriendApi;
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const NTQQFileApi = this.core.apis.FileApi;
|
||||
let UuidData: {
|
||||
high: string;
|
||||
low: string;
|
||||
} | undefined;
|
||||
try {
|
||||
UuidData = UUIDConverter.decode(payload.file);
|
||||
if (UuidData) {
|
||||
const peerUin = UuidData.high;
|
||||
const msgId = UuidData.low;
|
||||
const isGroup: boolean = !!(await NTQQGroupApi.getGroups(false)).find(e => e.groupCode == peerUin);
|
||||
let peer: Peer | undefined;
|
||||
//识别Peer
|
||||
if (isGroup) {
|
||||
peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: peerUin };
|
||||
}
|
||||
const PeerUid = await NTQQUserApi.getUidByUinV2(peerUin);
|
||||
if (PeerUid) {
|
||||
const isBuddy = await NTQQFriendApi.isBuddy(PeerUid);
|
||||
if (isBuddy) {
|
||||
peer = { chatType: ChatType.KCHATTYPEC2C, peerUid: PeerUid };
|
||||
} else {
|
||||
peer = { chatType: ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: PeerUid };
|
||||
}
|
||||
}
|
||||
if (!peer) {
|
||||
throw new Error('chattype not support');
|
||||
}
|
||||
const msgList = await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]);
|
||||
if (msgList.msgList.length == 0) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
const msg = msgList.msgList[0];
|
||||
const findEle = msg.elements.find(e => e.elementType == ElementType.VIDEO || e.elementType == ElementType.FILE || e.elementType == ElementType.PTT);
|
||||
if (!findEle) {
|
||||
throw new Error('element not found');
|
||||
}
|
||||
const downloadPath = await NTQQFileApi.downloadMedia(msgId, msg.chatType, msg.peerUid, findEle.elementId, '', '');
|
||||
const fileSize = findEle?.videoElement?.fileSize || findEle?.fileElement?.fileSize || findEle?.pttElement?.fileSize || '0';
|
||||
const fileName = findEle?.videoElement?.fileName || findEle?.fileElement?.fileName || findEle?.pttElement?.fileName || '';
|
||||
const res: GetFileResponse = {
|
||||
file: downloadPath,
|
||||
url: downloadPath,
|
||||
file_size: fileSize,
|
||||
file_name: fileName,
|
||||
};
|
||||
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
||||
try {
|
||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||
} catch (e) {
|
||||
throw new Error('文件下载失败. ' + e);
|
||||
}
|
||||
}
|
||||
//不手动删除?文件持久化了
|
||||
return res;
|
||||
}
|
||||
} catch {
|
||||
this.core.context.logger.logDebug('GetFileBase Mode - 1 Error');
|
||||
}
|
||||
|
||||
const NTSearchNameResult = (await NTQQFileApi.searchfile([payload.file])).resultItems;
|
||||
if (NTSearchNameResult.length !== 0) {
|
||||
const MsgId = NTSearchNameResult[0].msgId;
|
||||
let peer: Peer | undefined = undefined;
|
||||
if (NTSearchNameResult[0].chatType == ChatType.KCHATTYPEGROUP) {
|
||||
peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: NTSearchNameResult[0].groupChatInfo[0].groupCode };
|
||||
}
|
||||
if (!peer) {
|
||||
throw new Error('chattype not support');
|
||||
}
|
||||
const msgList: RawMessage[] = (await NTQQMsgApi.getMsgsByMsgId(peer, [MsgId]))?.msgList;
|
||||
if (!msgList || msgList.length == 0) {
|
||||
throw new Error('msg not found');
|
||||
}
|
||||
const msg = msgList[0];
|
||||
const file = msg.elements.filter(e => e.elementType == NTSearchNameResult[0].elemType);
|
||||
if (file.length == 0) {
|
||||
throw new Error('file not found');
|
||||
}
|
||||
const downloadPath = await NTQQFileApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid, file[0].elementId, '', '');
|
||||
const contextMsgFile = FileNapCatOneBotUUID.decode(payload.file);
|
||||
//接收消息标记模式
|
||||
if (contextMsgFile) {
|
||||
const { peer, msgId, elementId } = contextMsgFile;
|
||||
const downloadPath = await NTQQFileApi.downloadMedia(msgId, peer.chatType, peer.peerUid, elementId, '', '');
|
||||
const mixElement = (await NTQQMsgApi.getMsgsByMsgId(peer, [msgId]))?.msgList
|
||||
.find(msg => msg.msgId === msgId)?.elements.find(e => e.elementId === elementId);
|
||||
const mixElementInner = mixElement?.videoElement ?? mixElement?.fileElement ?? mixElement?.pttElement ?? mixElement?.picElement;
|
||||
if (!mixElementInner) throw new Error('element not found');
|
||||
const fileSize = mixElementInner.fileSize?.toString() ?? '';
|
||||
const fileName = mixElementInner.fileName ?? '';
|
||||
|
||||
const res: GetFileResponse = {
|
||||
file: downloadPath,
|
||||
url: downloadPath,
|
||||
file_size: NTSearchNameResult[0].fileSize.toString(),
|
||||
file_name: NTSearchNameResult[0].fileName,
|
||||
file_size: fileSize,
|
||||
file_name: fileName,
|
||||
};
|
||||
if (true/*enableLocalFile2Url*/ && downloadPath) {
|
||||
|
||||
if (this.obContext.configLoader.configData.enableLocalFile2Url && downloadPath) {
|
||||
try {
|
||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||
} catch (e) {
|
||||
throw new Error('文件下载失败. ' + e);
|
||||
}
|
||||
}
|
||||
//不手动删除?文件持久化了
|
||||
return res;
|
||||
}
|
||||
|
||||
//群文件模式
|
||||
const contextModelIdFile = FileNapCatOneBotUUID.decodeModelId(payload.file);
|
||||
if (contextModelIdFile) {
|
||||
const { peer, modelId } = contextModelIdFile;
|
||||
const downloadPath = await NTQQFileApi.downloadFileForModelId(peer, modelId);
|
||||
const res: GetFileResponse = {
|
||||
file: downloadPath,
|
||||
url: downloadPath,
|
||||
file_size: '',
|
||||
file_name: '',
|
||||
};
|
||||
|
||||
if (this.obContext.configLoader.configData.enableLocalFile2Url && downloadPath) {
|
||||
try {
|
||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||
} catch (e) {
|
||||
throw new Error('文件下载失败. ' + e);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
//搜索名字模式
|
||||
const searchResult = (await NTQQFileApi.searchForFile([payload.file]));
|
||||
if (searchResult) {
|
||||
const downloadPath = await NTQQFileApi.downloadFileById(searchResult.id, parseInt(searchResult.fileSize));
|
||||
const res: GetFileResponse = {
|
||||
file: downloadPath,
|
||||
url: downloadPath,
|
||||
file_size: searchResult.fileSize.toString(),
|
||||
file_name: searchResult.fileName,
|
||||
};
|
||||
if (this.obContext.configLoader.configData.enableLocalFile2Url && downloadPath) {
|
||||
try {
|
||||
res.base64 = await fs.readFile(downloadPath, 'base64');
|
||||
} catch (e) {
|
||||
throw new Error('文件下载失败. ' + e);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
throw new Error('file not found');
|
||||
// let cache = await dbUtil.getFileCacheByName(payload.file);
|
||||
// if (!cache) {
|
||||
// cache = await dbUtil.getFileCacheByUuid(payload.file);
|
||||
// }
|
||||
// if (!cache) {
|
||||
// throw new Error('file not found');
|
||||
// }
|
||||
// const { enableLocalFile2Url } = ob11Config;
|
||||
// try {
|
||||
// await fs.access(cache.path, fs.constants.F_OK);
|
||||
// } catch (e) {
|
||||
// logDebug('local file not found, start download...');
|
||||
// // if (cache.url) {
|
||||
// // const downloadResult = await uri2local(cache.url);
|
||||
// // if (downloadResult.success) {
|
||||
// // cache.path = downloadResult.path;
|
||||
// // dbUtil.updateFileCache(cache).then();
|
||||
// // } else {
|
||||
// // throw new Error('file download failed. ' + downloadResult.errMsg);
|
||||
// // }
|
||||
// // } else {
|
||||
// // // 没有url的可能是私聊文件或者群文件,需要自己下载
|
||||
// // log('需要调用 NTQQ 下载文件api');
|
||||
// let peer = MessageUnique.getPeerByMsgId(cache.msgId);
|
||||
// let msg = await NTQQMsgApi.getMsgsByMsgId(peer?.Peer!,cache.msgId);
|
||||
// // log('文件 msg', msg);
|
||||
// if (msg) {
|
||||
// // 构建下载函数
|
||||
// const downloadPath = await NTQQFileApi.downloadMedia(msg.msgId, msg.chatType, msg.peerUid,
|
||||
// cache.elementId, '', '');
|
||||
// // await sleep(1000);
|
||||
|
||||
// // log('download result', downloadPath);
|
||||
// let peer = MessageUnique.getPeerByMsgId(cache.msgId);
|
||||
// msg = await NTQQMsgApi.getMsgsByMsgId(peer?.Peer!,cache.msgId);
|
||||
// // log('下载完成后的msg', msg);
|
||||
// cache.path = downloadPath!;
|
||||
// dbUtil.updateFileCache(cache).then();
|
||||
// // log('下载完成后的msg', msg);
|
||||
// // }
|
||||
// }
|
||||
|
||||
// }
|
||||
// // log('file found', cache);
|
||||
// const res: GetFileResponse = {
|
||||
// file: cache.path,
|
||||
// url: cache.url,
|
||||
// file_size: cache.size.toString(),
|
||||
// file_name: cache.name
|
||||
// };
|
||||
// if (enableLocalFile2Url) {
|
||||
// if (!cache.url) {
|
||||
// try {
|
||||
// res.base64 = await fs.readFile(cache.path, 'base64');
|
||||
// } catch (e) {
|
||||
// throw new Error('文件下载失败. ' + e);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//return res;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,13 +1,15 @@
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FileNapCatOneBotUUID } from '@/common/helper';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['string', 'number'] },
|
||||
start_index: { type: 'number' },
|
||||
file_count: { type: 'number' },
|
||||
start_index: { type: ['string', 'number'] },
|
||||
file_count: { type: ['string', 'number'] },
|
||||
folder_id: { type: ['string', 'number'] },
|
||||
},
|
||||
required: ['group_id', 'start_index', 'file_count'],
|
||||
} as const satisfies JSONSchema;
|
||||
@@ -20,15 +22,29 @@ export class GetGroupFileList extends BaseAction<Payload, { FileList: Array<any>
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQMsgApi = this.core.apis.MsgApi;
|
||||
let param = {};
|
||||
if (payload.folder_id) {
|
||||
param = {
|
||||
folderId: payload.folder_id.toString(),
|
||||
};
|
||||
}
|
||||
const ret = await NTQQMsgApi.getGroupFileList(payload.group_id.toString(), {
|
||||
sortType: 1,
|
||||
fileCount: payload.file_count,
|
||||
startIndex: payload.start_index,
|
||||
fileCount: +payload.file_count,
|
||||
startIndex: +payload.start_index,
|
||||
sortOrder: 2,
|
||||
showOnlinedocFolder: 0,
|
||||
...param
|
||||
}).catch((e) => {
|
||||
return [];
|
||||
});
|
||||
ret.forEach((e) => {
|
||||
let fileModelId = e?.fileInfo?.fileModelId;
|
||||
if (fileModelId) {
|
||||
e.fileModelId = fileModelId;
|
||||
}
|
||||
e.fileId = FileNapCatOneBotUUID.encodeModelId({ chatType: 2, peerUid: payload.group_id.toString() }, fileModelId);
|
||||
});
|
||||
return { FileList: ret };
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import fs from 'fs';
|
||||
import { join as joinPath } from 'node:path';
|
||||
import { calculateFileMD5, httpDownload } from '@/common/utils/file';
|
||||
import { calculateFileMD5, httpDownload } from '@/common/file';
|
||||
import { randomUUID } from 'crypto';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
||||
import { OB11ForwardMessage } from '@/onebot';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@@ -38,7 +38,7 @@ export class GoCQHTTPGetForwardMsgAction extends BaseAction<Payload, any> {
|
||||
const resMsg = await this.obContext.apis.MsgApi
|
||||
.parseMessage(msg);
|
||||
if (!resMsg) return;
|
||||
resMsg.message_id = MessageUnique.createMsg({
|
||||
resMsg.message_id = MessageUnique.createUniqueMsgId({
|
||||
guildId: '',
|
||||
chatType: msg.chatType,
|
||||
peerUid: msg.peerUid,
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11Message } from '@/onebot';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, RawMessage } from '@/core/entities';
|
||||
import { ChatType } from '@/core/entities';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
interface Response {
|
||||
messages: OB11Message[];
|
||||
@@ -13,7 +13,7 @@ const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
user_id: { type: ['number', 'string'] },
|
||||
message_seq: { type: 'number' },
|
||||
message_seq: { type: ['number', 'string'] },
|
||||
count: { type: ['number', 'string'] },
|
||||
reverseOrder: { type: ['boolean', 'string'] },
|
||||
},
|
||||
@@ -37,21 +37,19 @@ export default class GetFriendMsgHistory extends BaseAction<Payload, Response> {
|
||||
if (!uid) throw `记录${payload.user_id}不存在`;
|
||||
const friend = await NTQQFriendApi.isBuddy(uid);
|
||||
const peer = { chatType: friend ? ChatType.KCHATTYPEC2C : ChatType.KCHATTYPETEMPC2CFROMGROUP, peerUid: uid };
|
||||
|
||||
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||
//拉取消息
|
||||
let msgList: RawMessage[];
|
||||
if (!payload.message_seq || payload.message_seq == 0) {
|
||||
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, MsgCount)).msgList;
|
||||
} else {
|
||||
const startMsgId = MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq)?.MsgId;
|
||||
if (!startMsgId) throw `消息${payload.message_seq}不存在`;
|
||||
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList;
|
||||
}
|
||||
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||
const msgList = hasMessageSeq ?
|
||||
(await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList : (await NTQQMsgApi.getAioFirstViewLatestMsgs(peer, MsgCount)).msgList;
|
||||
if (msgList.length === 0) throw `消息${payload.message_seq}不存在`;
|
||||
//翻转消息
|
||||
if (isReverseOrder) msgList.reverse();
|
||||
//转换序号
|
||||
await Promise.all(msgList.map(async msg => {
|
||||
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
}));
|
||||
//转换消息
|
||||
//烘焙消息
|
||||
const ob11MsgList = (await Promise.all(
|
||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
||||
).filter(msg => msg !== undefined);
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11Message } from '@/onebot';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, Peer, RawMessage } from '@/core/entities';
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
interface Response {
|
||||
messages: OB11Message[];
|
||||
@@ -13,7 +13,7 @@ const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
message_seq: { type: 'number' },
|
||||
message_seq: { type: ['number', 'string'] },
|
||||
count: { type: ['number', 'string'] },
|
||||
reverseOrder: { type: ['boolean', 'string'] },
|
||||
},
|
||||
@@ -32,21 +32,19 @@ export default class GoCQHTTPGetGroupMsgHistory extends BaseAction<Payload, Resp
|
||||
const isReverseOrder = typeof payload.reverseOrder === 'string' ? payload.reverseOrder === 'true' : !!payload.reverseOrder;
|
||||
const MsgCount = +(payload.count ?? 20);
|
||||
const peer: Peer = { chatType: ChatType.KCHATTYPEGROUP, peerUid: payload.group_id.toString() };
|
||||
const hasMessageSeq = !payload.message_seq ? !!payload.message_seq : !(payload.message_seq?.toString() === '' || payload.message_seq?.toString() === '0');
|
||||
//拉取消息
|
||||
let msgList: RawMessage[];
|
||||
if (!payload.message_seq || payload.message_seq == 0) {
|
||||
msgList = (await NTQQMsgApi.getLastestMsgByUids(peer, MsgCount)).msgList;
|
||||
} else {
|
||||
const startMsgId = MessageUnique.getMsgIdAndPeerByShortId(payload.message_seq)?.MsgId;
|
||||
if (!startMsgId) throw `消息${payload.message_seq}不存在`;
|
||||
msgList = (await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList;
|
||||
}
|
||||
const startMsgId = hasMessageSeq ? (MessageUnique.getMsgIdAndPeerByShortId(+payload.message_seq!)?.MsgId ?? payload.message_seq!.toString()) : '0';
|
||||
const msgList = hasMessageSeq ?
|
||||
(await NTQQMsgApi.getMsgHistory(peer, startMsgId, MsgCount)).msgList : (await NTQQMsgApi.getAioFirstViewLatestMsgs(peer, MsgCount)).msgList;
|
||||
if (msgList.length === 0) throw `消息${payload.message_seq}不存在`;
|
||||
//翻转消息
|
||||
if (isReverseOrder) msgList.reverse();
|
||||
//转换序号
|
||||
await Promise.all(msgList.map(async msg => {
|
||||
msg.id = MessageUnique.createMsg({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
msg.id = MessageUnique.createUniqueMsgId({ guildId: '', chatType: msg.chatType, peerUid: msg.peerUid }, msg.msgId);
|
||||
}));
|
||||
|
||||
//转换消息
|
||||
//烘焙消息
|
||||
const ob11MsgList = (await Promise.all(
|
||||
msgList.map(msg => this.obContext.apis.MsgApi.parseMessage(msg)))
|
||||
).filter(msg => msg !== undefined);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { JSONSchema } from 'json-schema-to-ts';
|
||||
import { sleep } from '@/common/utils/helper';
|
||||
import { sleep } from '@/common/helper';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { OB11User, OB11UserSex } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { calcQQLevel } from '@/common/utils/helper';
|
||||
import { calcQQLevel } from '@/common/helper';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -13,7 +13,7 @@ export class GoCQHTTPHandleQuickAction extends BaseAction<Payload, null> {
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
this.obContext.apis.QuickActionApi
|
||||
.handleQuickOperation(payload.context, payload.operation)
|
||||
.catch(this.core.context.logger.logError);
|
||||
.catch(this.core.context.logger.logError.bind(this.core.context.logger));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { unlink } from 'node:fs';
|
||||
@@ -11,7 +11,7 @@ const SchemaData = {
|
||||
content: { type: 'string' },
|
||||
image: { type: 'string' },
|
||||
pinned: { type: ['number', 'string'] },
|
||||
confirmRequired: { type: ['number', 'string'] },
|
||||
confirm_required: { type: ['number', 'string'] },
|
||||
},
|
||||
required: ['group_id', 'content'],
|
||||
} as const satisfies JSONSchema;
|
||||
@@ -27,7 +27,6 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||
if (payload.image) {
|
||||
//公告图逻辑
|
||||
const {
|
||||
errMsg,
|
||||
path,
|
||||
isLocal,
|
||||
success,
|
||||
@@ -49,12 +48,12 @@ export class SendGroupNotice extends BaseAction<Payload, null> {
|
||||
}
|
||||
UploadImage = ImageUploadResult.picInfo;
|
||||
}
|
||||
let Notice_Pinned = +(payload.pinned ?? 0);
|
||||
let Notice_confirmRequired = +(payload.confirmRequired ?? 0);
|
||||
const PublishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, Notice_Pinned, Notice_confirmRequired);
|
||||
const noticePinned = +(payload.pinned ?? 0);
|
||||
const noticeConfirmRequired = +(payload.confirm_required ?? 0);
|
||||
const publishGroupBulletinResult = await NTQQGroupApi.publishGroupBulletin(payload.group_id.toString(), payload.content, UploadImage, noticePinned, noticeConfirmRequired);
|
||||
|
||||
if (PublishGroupBulletinResult.result != 0) {
|
||||
throw `设置群公告失败,错误信息:${PublishGroupBulletinResult.errMsg}`;
|
||||
if (publishGroupBulletinResult.result != 0) {
|
||||
throw `设置群公告失败,错误信息:${publishGroupBulletinResult.errMsg}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName, BaseCheckResult } from '../types';
|
||||
import * as fs from 'node:fs';
|
||||
import { checkFileReceived, uri2local } from '@/common/utils/file';
|
||||
import { checkFileReceived, uri2local } from '@/common/file';
|
||||
|
||||
interface Payload {
|
||||
file: string,
|
||||
@@ -53,6 +53,5 @@ export default class SetGroupPortrait extends BaseAction<Payload, any> {
|
||||
}
|
||||
throw `头像${payload.file}设置失败,无法获取头像,文件可能不存在`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType } from '@/core/entities';
|
||||
import fs from 'fs';
|
||||
import { uri2local } from '@/common/utils/file';
|
||||
import { uri2local } from '@/common/file';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { ChatType, Peer, SendFileElement } from '@/core/entities';
|
||||
import fs from 'fs';
|
||||
import { uri2local } from '@/common/utils/file';
|
||||
import { uri2local } from '@/common/file';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
@@ -20,7 +20,13 @@ export default class DelEssenceMsg extends BaseAction<Payload, any> {
|
||||
async _handle(payload: Payload): Promise<any> {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const msg = MessageUnique.getMsgIdAndPeerByShortId(+payload.message_id);
|
||||
if (!msg) throw new Error('msg not found');
|
||||
const NTQQWebApi = this.core.apis.WebApi;
|
||||
if (!msg) {
|
||||
const data = NTQQGroupApi.essenceLRU.getValue(+payload.message_id);
|
||||
if(!data) throw new Error('消息不存在');
|
||||
const { msg_seq, msg_random, group_id } = JSON.parse(data) as { msg_seq: string, msg_random: string, group_id: string };
|
||||
return await NTQQGroupApi.removeGroupEssenceBySeq(group_id, msg_seq, msg_random);
|
||||
}
|
||||
return await NTQQGroupApi.removeGroupEssence(
|
||||
msg.Peer.peerUid,
|
||||
msg.MsgId,
|
||||
|
@@ -1,29 +1,99 @@
|
||||
import { GroupEssenceMsgRet } from '@/core';
|
||||
import { ChatType, Peer } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import crypto from 'crypto';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
pages: { type: ['number', 'string'] },
|
||||
group_id: { type: ['number', 'string'] }
|
||||
},
|
||||
required: ['group_id'],
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupEssence extends BaseAction<Payload, GroupEssenceMsgRet> {
|
||||
export class GetGroupEssence extends BaseAction<Payload, any> {
|
||||
actionName = ActionName.GoCQHTTP_GetEssenceMsg;
|
||||
payloadSchema = SchemaData;
|
||||
|
||||
private async msgSeqToMsgId(peer: Peer, msgSeq: string, msgRandom: string) {
|
||||
const replyMsgList = (await this.core.apis.MsgApi.getMsgsBySeqAndCount(peer, msgSeq, 1, true, true)).msgList.find((msg) => msg.msgSeq === msgSeq && msg.msgRandom === msgRandom);
|
||||
if (!replyMsgList) {
|
||||
return undefined;
|
||||
}
|
||||
return {
|
||||
id: MessageUnique.createUniqueMsgId(peer, replyMsgList.msgId),
|
||||
msg: replyMsgList
|
||||
};
|
||||
}
|
||||
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQWebApi = this.core.apis.WebApi;
|
||||
const ret = await NTQQWebApi.getGroupEssenceMsg(payload.group_id.toString(), (+(payload.pages ?? 0)).toString());
|
||||
if (!ret) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const msglist = (await NTQQWebApi.getGroupEssenceMsgAll(payload.group_id.toString())).flatMap((e) => e.data.msg_list);
|
||||
if (!msglist) {
|
||||
throw new Error('获取失败');
|
||||
}
|
||||
return ret;
|
||||
return await Promise.all(msglist.map(async (msg) => {
|
||||
const msgOriginData = await this.msgSeqToMsgId({
|
||||
chatType: ChatType.KCHATTYPEGROUP,
|
||||
peerUid: payload.group_id.toString(),
|
||||
}, msg.msg_seq.toString(), msg.msg_random.toString());
|
||||
if (msgOriginData) {
|
||||
const { id: message_id, msg: rawMessage } = msgOriginData;
|
||||
return {
|
||||
msg_seq: msg.msg_seq,
|
||||
msg_random: msg.msg_random,
|
||||
sender_id: +msg.sender_uin,
|
||||
sender_nick: msg.sender_nick,
|
||||
operator_id: +msg.add_digest_uin,
|
||||
operator_nick: msg.add_digest_nick,
|
||||
message_id: message_id,
|
||||
operator_time: msg.add_digest_time,
|
||||
content: (await this.obContext.apis.MsgApi.parseMessage(rawMessage, 'array'))?.message
|
||||
};
|
||||
}
|
||||
const msgTempData = JSON.stringify({
|
||||
msg_seq: msg.msg_seq.toString(),
|
||||
msg_random: msg.msg_random.toString(),
|
||||
group_id: payload.group_id.toString(),
|
||||
});
|
||||
const hash = crypto.createHash('md5').update(msgTempData).digest();
|
||||
//设置第一个bit为0 保证shortId为正数
|
||||
hash[0] &= 0x7f;
|
||||
const shortId = hash.readInt32BE(0);
|
||||
NTQQGroupApi.essenceLRU.set(shortId, msgTempData);
|
||||
return {
|
||||
msg_seq: msg.msg_seq,
|
||||
msg_random: msg.msg_random,
|
||||
sender_id: +msg.sender_uin,
|
||||
sender_nick: msg.sender_nick,
|
||||
operator_id: +msg.add_digest_uin,
|
||||
operator_nick: msg.add_digest_nick,
|
||||
message_id: shortId,
|
||||
operator_time: msg.add_digest_time,
|
||||
content: msg.msg_content.map((msg) => {
|
||||
if (msg.msg_type === 1) {
|
||||
return {
|
||||
type: 'text',
|
||||
data: {
|
||||
text: msg?.text
|
||||
}
|
||||
};
|
||||
} else if (msg.msg_type === 3) {
|
||||
return {
|
||||
type: 'image',
|
||||
data: {
|
||||
url: msg?.image_url,
|
||||
}
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}).filter(e => e !== undefined),
|
||||
};
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
39
src/onebot/action/group/GetGroupIgnoredNotifies.ts
Normal file
39
src/onebot/action/group/GetGroupIgnoredNotifies.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { GroupNotifyMsgStatus } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
},
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupIgnoredNotifies extends BaseAction<void, any> {
|
||||
actionName = ActionName.GetGroupIgnoredNotifies;
|
||||
|
||||
async _handle(payload: void) {
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const ignoredNotifies = await NTQQGroupApi.getSingleScreenNotifies(true, 10);
|
||||
const retData: any = {
|
||||
join_requests: await Promise.all(
|
||||
ignoredNotifies
|
||||
.filter(notify => notify.type === 7)
|
||||
.map(async SSNotify => ({
|
||||
request_id: SSNotify.seq,
|
||||
requester_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid),
|
||||
requester_nick: SSNotify.user1?.nickName,
|
||||
group_id: SSNotify.group?.groupCode,
|
||||
group_name: SSNotify.group?.groupName,
|
||||
checked: SSNotify.status !== GroupNotifyMsgStatus.KUNHANDLE,
|
||||
actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
|
||||
}))),
|
||||
};
|
||||
|
||||
return retData;
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
import { OB11Group } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { OB11Group } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { Group } from '@/core/entities';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { OB11GroupMember } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { OB11GroupMember } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
@@ -22,7 +22,7 @@ class GetGroupMemberList extends BaseAction<Payload, OB11GroupMember[]> {
|
||||
async _handle(payload: Payload) {
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
const NTQQWebApi = this.core.apis.WebApi;
|
||||
const groupMembers = await NTQQGroupApi.getGroupMembers(payload.group_id.toString());
|
||||
const groupMembers = await NTQQGroupApi.getGroupMembersV2(payload.group_id.toString());
|
||||
const groupMembersArr = Array.from(groupMembers.values());
|
||||
|
||||
let _groupMembers = groupMembersArr.map(item => {
|
||||
|
@@ -1,50 +0,0 @@
|
||||
import { GroupNotifyMsgStatus } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
},
|
||||
} as const satisfies JSONSchema;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export class GetGroupSystemMsg extends BaseAction<void, any> {
|
||||
actionName = ActionName.GetGroupSystemMsg;
|
||||
|
||||
async _handle(payload: void) {
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
const NTQQGroupApi = this.core.apis.GroupApi;
|
||||
// 默认10条 该api未完整实现 包括响应数据规范化 类型规范化
|
||||
const SingleScreenNotifies = await NTQQGroupApi.getSingleScreenNotifies(10);
|
||||
const retData: any = { InvitedRequest: [], join_requests: [] };
|
||||
for (const SSNotify of SingleScreenNotifies) {
|
||||
if (SSNotify.type == 1) {
|
||||
retData.InvitedRequest.push({
|
||||
request_id: SSNotify.seq,
|
||||
invitor_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid),
|
||||
invitor_nick: SSNotify.user1?.nickName,
|
||||
group_id: SSNotify.group?.groupCode,
|
||||
group_name: SSNotify.group?.groupName,
|
||||
checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true,
|
||||
actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
|
||||
});
|
||||
} else if (SSNotify.type == 7) {
|
||||
retData.join_requests.push({
|
||||
request_id: SSNotify.seq,
|
||||
requester_uin: await NTQQUserApi.getUinByUidV2(SSNotify.user1?.uid),
|
||||
requester_nick: SSNotify.user1?.nickName,
|
||||
group_id: SSNotify.group?.groupCode,
|
||||
group_name: SSNotify.group?.groupName,
|
||||
checked: SSNotify.status === GroupNotifyMsgStatus.KUNHANDLE ? false : true,
|
||||
actor: await NTQQUserApi.getUinByUidV2(SSNotify.user2?.uid) || 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return retData;
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -52,7 +52,7 @@ import { GetFriendWithCategory } from './extends/GetFriendWithCategory';
|
||||
import { SendGroupNotice } from './go-cqhttp/SendGroupNotice';
|
||||
import { GetGroupHonorInfo } from './go-cqhttp/GetGroupHonorInfo';
|
||||
import { GoCQHTTPHandleQuickAction } from './go-cqhttp/QuickAction';
|
||||
import { GetGroupSystemMsg } from './group/GetGroupSystemMsg';
|
||||
import { GetGroupIgnoredNotifies } from './group/GetGroupIgnoredNotifies';
|
||||
import { GetOnlineClient } from './go-cqhttp/GetOnlineClient';
|
||||
import { IOCRImage, OCRImage } from './extends/OCRImage';
|
||||
import { GetGroupFileCount } from './file/GetGroupFileCount';
|
||||
@@ -81,11 +81,13 @@ import SetModelShow from './go-cqhttp/SetModelShow';
|
||||
import { SetInputStatus } from './extends/SetInputStatus';
|
||||
import { GetCSRF } from './system/GetCSRF';
|
||||
import { DelGroupNotice } from './group/DelGroupNotice';
|
||||
import { GetGroupInfoEx } from './extends/GetGroupInfoEx';
|
||||
|
||||
export type ActionMap = Map<string, BaseAction<any, any>>;
|
||||
|
||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore): ActionMap {
|
||||
const actionHandlers = [
|
||||
new GetGroupInfoEx(obContext, core),
|
||||
new FetchEmojiLike(obContext, core),
|
||||
new GetFile(obContext, core),
|
||||
new SetQQProfile(obContext, core),
|
||||
@@ -157,7 +159,7 @@ export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCo
|
||||
new GoCQHTTPGetForwardMsgAction(obContext, core),
|
||||
new GetFriendMsgHistory(obContext, core),
|
||||
new GoCQHTTPHandleQuickAction(obContext, core),
|
||||
new GetGroupSystemMsg(obContext, core),
|
||||
new GetGroupIgnoredNotifies(obContext, core),
|
||||
new DelEssenceMsg(obContext, core),
|
||||
new SetEssenceMsg(obContext, core),
|
||||
new GetRecentContact(obContext, core),
|
||||
|
@@ -1,8 +1,7 @@
|
||||
import { ActionName } from '../types';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { NodeIKernelMsgListener } from '@/core';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -2,7 +2,7 @@ import BaseAction from '../BaseAction';
|
||||
import { ChatType, Peer } from '@/core/entities';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -2,7 +2,7 @@ import { OB11Message } from '@/onebot';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
|
||||
export type ReturnDataType = OB11Message
|
||||
@@ -39,7 +39,7 @@ class GetMsg extends BaseAction<Payload, OB11Message> {
|
||||
const retMsg = await this.obContext.apis.MsgApi.parseMessage(msg.msgList[0], 'array');
|
||||
if (!retMsg) throw Error('消息为空');
|
||||
try {
|
||||
retMsg.message_id = MessageUnique.createMsg(peer, msg.msgList[0].msgId)!;
|
||||
retMsg.message_id = MessageUnique.createUniqueMsgId(peer, msg.msgList[0].msgId)!;
|
||||
retMsg.message_seq = retMsg.message_id;
|
||||
retMsg.real_id = retMsg.message_id;
|
||||
} catch (e) {
|
||||
|
@@ -6,8 +6,8 @@ import {
|
||||
OB11PostSendMsg,
|
||||
} from '@/onebot/types';
|
||||
import { ActionName, BaseCheckResult } from '@/onebot/action/types';
|
||||
import { decodeCQCode } from '@/onebot/helper/cqcode';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { decodeCQCode } from '@/onebot/cqcode';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
import { ChatType, ElementType, NapCatCore, Peer, RawMessage, SendMessageElement } from '@/core';
|
||||
import BaseAction from '../BaseAction';
|
||||
|
||||
@@ -30,7 +30,7 @@ export function normalize(message: OB11MessageMixType, autoEscape = false): OB11
|
||||
) : Array.isArray(message) ? message : [message];
|
||||
}
|
||||
|
||||
async function createContext(core: NapCatCore, payload: OB11PostSendMsg, contextMode: ContextMode): Promise<Peer> {
|
||||
export async function createContext(core: NapCatCore, payload: OB11PostSendMsg, contextMode: ContextMode): Promise<Peer> {
|
||||
// This function determines the type of message by the existence of user_id / group_id,
|
||||
// not message_type.
|
||||
// This redundant design of Ob11 here should be blamed.
|
||||
@@ -98,11 +98,6 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
||||
};
|
||||
}
|
||||
if (payload.user_id && payload.message_type !== 'group') {
|
||||
// const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
// const isBuddy = await NTQQFriendApi.isBuddy(uid!);
|
||||
// if (!isBuddy) { }
|
||||
}
|
||||
return { valid: true };
|
||||
}
|
||||
|
||||
@@ -119,7 +114,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (getSpecialMsgNum(payload, OB11MessageDataType.node)) {
|
||||
const returnMsg = await this.handleForwardedNodes(peer, messages as OB11MessageNode[]);
|
||||
if (returnMsg) {
|
||||
const msgShortId = MessageUnique.createMsg({
|
||||
const msgShortId = MessageUnique.createUniqueMsgId({
|
||||
guildId: '',
|
||||
peerUid: peer.peerUid,
|
||||
chatType: peer.chatType,
|
||||
@@ -175,7 +170,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
const nodeMsg = await this.handleForwardedNodes(selfPeer, OB11Data.filter(e => e.type === OB11MessageDataType.node));
|
||||
if (nodeMsg) {
|
||||
nodeMsgIds.push(nodeMsg.msgId);
|
||||
MessageUnique.createMsg(selfPeer, nodeMsg.msgId);
|
||||
MessageUnique.createUniqueMsgId(selfPeer, nodeMsg.msgId);
|
||||
}
|
||||
//完成子卡片生成跳过后续
|
||||
continue;
|
||||
@@ -193,7 +188,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
(await Promise.allSettled(MsgNodeList)).map((result) => {
|
||||
if (result.status === 'fulfilled' && result.value) {
|
||||
nodeMsgIds.push(result.value.msgId);
|
||||
MessageUnique.createMsg(selfPeer, result.value.msgId);
|
||||
MessageUnique.createUniqueMsgId(selfPeer, result.value.msgId);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { ActionName } from '../types';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { MessageUnique } from '@/common/utils/message-unique';
|
||||
import { MessageUnique } from '@/common/message-unique';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { OB11User } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { napcat_version } from '@/common/framework/napcat';
|
||||
|
||||
import { napCatVersion } from '@/common/version';
|
||||
|
||||
export default class GetVersionInfo extends BaseAction<any, any> {
|
||||
actionName = ActionName.GetVersionInfo;
|
||||
@@ -9,7 +10,7 @@ export default class GetVersionInfo extends BaseAction<any, any> {
|
||||
return {
|
||||
app_name: 'NapCat.Onebot',
|
||||
protocol_version: 'v11',
|
||||
app_version: napcat_version,
|
||||
app_version: napCatVersion,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -87,7 +87,7 @@ export enum ActionName {
|
||||
GoCQHTTP_GetGroupMsgHistory = 'get_group_msg_history',
|
||||
GoCQHTTP_GetForwardMsg = 'get_forward_msg',
|
||||
GetFriendMsgHistory = 'get_friend_msg_history',
|
||||
GetGroupSystemMsg = 'get_group_system_msg',
|
||||
GetGroupIgnoredNotifies = 'get_group_ignored_notifies',
|
||||
GetOnlineClient = 'get_online_clients',
|
||||
OCRImage = 'ocr_image',
|
||||
IOCRImage = '.ocr_image',
|
||||
@@ -110,4 +110,5 @@ export enum ActionName {
|
||||
SetInputStatus = 'set_input_status',
|
||||
GetCSRF = 'get_csrf_token',
|
||||
DelGroupNotice = '_del_group_notice',
|
||||
GetGroupInfoEx = "get_group_info_ex"
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { OB11User } from '@/onebot';
|
||||
import { OB11Entities } from '@/onebot/helper/entities';
|
||||
import { OB11Entities } from '@/onebot/entities';
|
||||
import BaseAction from '../BaseAction';
|
||||
import { ActionName } from '../types';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
@@ -20,16 +20,12 @@ export default class SendLike extends BaseAction<Payload, null> {
|
||||
async _handle(payload: Payload): Promise<null> {
|
||||
const NTQQUserApi = this.core.apis.UserApi;
|
||||
//logDebug('点赞参数', payload);
|
||||
try {
|
||||
const qq = payload.user_id.toString();
|
||||
const uid: string = await NTQQUserApi.getUidByUinV2(qq) || '';
|
||||
const result = await NTQQUserApi.like(uid, parseInt(payload.times?.toString()) || 1);
|
||||
//logDebug('点赞结果', result);
|
||||
if (result.result !== 0) {
|
||||
throw Error(result.errMsg);
|
||||
}
|
||||
} catch (e) {
|
||||
throw `点赞失败 ${e}`;
|
||||
const qq = payload.user_id.toString();
|
||||
const uid: string = await NTQQUserApi.getUidByUinV2(qq) || '';
|
||||
const result = await NTQQUserApi.like(uid, parseInt(payload.times?.toString()) || 1);
|
||||
//logDebug('点赞结果', result);
|
||||
if (result.result !== 0) {
|
||||
throw `点赞失败 ${result.errMsg}`;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user