feat: 统一并标准化eslint

This commit is contained in:
时瑾 2025-11-03 12:39:26 +08:00
parent d5b8f886d6
commit 2889a9f8db
No known key found for this signature in database
GPG Key ID: 023F70A1B8F8C196
55 changed files with 3935 additions and 3441 deletions

View File

@ -15,7 +15,7 @@ charset = utf-8
# 4 space indentation
[*.{cjs,mjs,js,jsx,ts,tsx,css,scss,sass,html,json}]
indent_style = space
indent_size = 4
indent_size = 2
[*.bat]
charset = latin1

View File

@ -1,10 +0,0 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": true,
"singleQuote": true,
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 120,
"endOfLine": "auto"
}

28
.vscode/settings.json vendored
View File

@ -3,15 +3,35 @@
"explorer.fileNesting.expand": false,
"explorer.fileNesting.patterns": {
".env.universal": ".env.*",
"tsconfig.json": "tsconfig.*.json, env.d.ts, vite.config.ts",
"vite.config.ts": "vite*.ts",
"README.md": "CODE_OF_CONDUCT.md, RELEASES.md, CONTRIBUTING.md, CHANGELOG.md, SECURITY.md",
"tsconfig.json": "tsconfig.*.json, env.d.ts",
"package.json": "package-lock.json, eslint*, .prettier*, .editorconfig, manifest.json, logo.png, .gitignore, LICENSE"
},
"css.customData": [
".vscode/tailwindcss.json"
],
"editor.formatOnPaste": false,
"editor.formatOnSave": false,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnType": false,
"editor.formatOnPaste": true,
"editor.formatOnSaveMode": "file",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "never"
"source.fixAll.eslint": "always"
},
"files.autoSave": "onFocusChange",
"javascript.preferences.quoteStyle": "single",
"typescript.preferences.quoteStyle": "single",
"javascript.format.semicolons": "insert",
"typescript.format.semicolons": "insert",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceAfterConstructor": true,
"javascript.format.insertSpaceAfterConstructor": true,
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.preferences.importModuleSpecifierEnding": "minimal",
"javascript.preferences.importModuleSpecifier": "non-relative",
"javascript.preferences.importModuleSpecifierEnding": "minimal",
"typescript.disableAutomaticTypeAcquisition": true,
}

View File

@ -1,32 +1,43 @@
import eslint from '@eslint/js';
import tsEslintPlugin from '@typescript-eslint/eslint-plugin';
import tsEslintParser from '@typescript-eslint/parser';
import globals from "globals";
import neostandard from 'neostandard';
const customTsFlatConfig = [
{
name: 'typescript-eslint/base',
languageOptions: {
parser: tsEslintParser,
sourceType: 'module',
globals: {
...globals.browser,
...globals.node,
NodeJS: 'readonly', // 添加 NodeJS 全局变量
},
},
files: ['**/*.{ts,tsx}'],
rules: {
...tsEslintPlugin.configs.recommended.rules,
'quotes': ['error', 'single'], // 使用单引号
'semi': ['error', 'always'], // 强制使用分号
'indent': ['error', 4], // 使用 4 空格缩进
},
plugins: {
'@typescript-eslint': tsEslintPlugin,
},
ignores: ['src/webui/**'], // 忽略 src/webui/ 目录所有文件
},
/** 尾随逗号 */
const commaDangle = val => {
if (val?.rules?.['@stylistic/comma-dangle']?.[0] === 'warn') {
const rule = val?.rules?.['@stylistic/comma-dangle']?.[1];
Object.keys(rule).forEach(key => {
rule[key] = 'always-multiline';
});
val.rules['@stylistic/comma-dangle'][1] = rule;
}
/** 三元表达式 */
if (val?.rules?.['@stylistic/indent']) {
val.rules['@stylistic/indent'][2] = {
...val.rules?.['@stylistic/indent']?.[2],
flatTernaryExpressions: true,
offsetTernaryExpressions: false,
};
}
/** 支持下划线 - 禁用 camelcase 规则 */
if (val?.rules?.camelcase) {
val.rules.camelcase = 'off';
}
return val;
};
/** 忽略的文件 */
const ignores = [
'node_modules',
'**/dist/**',
'launcher',
];
export default [eslint.configs.recommended, ...customTsFlatConfig];
const options = neostandard({
ts: true,
ignores,
semi: true, // 强制使用分号
}).map(commaDangle);
export default options;

View File

@ -1,7 +0,0 @@
dist
*.md
*.html
yarn.lock
package-lock.json
node_modules
pnpm-lock.yaml

View File

@ -1,23 +0,0 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"semi": false,
"trailingComma": "none",
"bracketSpacing": true,
"importOrder": [
"<THIRD_PARTY_MODULES>",
"^@/const/(.*)$",
"^@/store/(.*)$",
"^@/components/(.*)$",
"^@/contexts/(.*)$",
"^@/hooks/(.*)$",
"^@/utils/(.*)$",
"^@/(.*)$",
"^[./]"
],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"plugins": ["@trivago/prettier-plugin-sort-imports"]
}

View File

@ -1,91 +0,0 @@
import eslint_js from '@eslint/js'
import tsEslintPlugin from '@typescript-eslint/eslint-plugin'
import tsEslintParser from '@typescript-eslint/parser'
import eslintConfigPrettier from 'eslint-config-prettier'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
import reactPlugin from 'eslint-plugin-react'
import reactHooksPlugin from 'eslint-plugin-react-hooks'
import globals from 'globals'
const customTsFlatConfig = [
{
name: 'typescript-eslint/base',
languageOptions: {
parser: tsEslintParser,
sourceType: 'module'
},
files: ['**/*.{js,jsx,mjs,cjs,ts,tsx}'],
rules: {
...tsEslintPlugin.configs.recommended.rules
},
plugins: {
'@typescript-eslint': tsEslintPlugin
}
}
]
export default [
eslint_js.configs.recommended,
eslintPluginPrettierRecommended,
...customTsFlatConfig,
{
name: 'global config',
languageOptions: {
globals: {
...globals.es2022,
...globals.browser,
...globals.node
},
parserOptions: {
warnOnUnsupportedTypeScriptVersion: false
}
},
rules: {
'prettier/prettier': 'error',
'no-unused-vars': 'off',
'no-undef': 'off',
//关闭不能再promise中使用ansyc
'no-async-promise-executor': 'off',
//关闭不能再常量中使用??
'no-constant-binary-expression': 'off',
'@typescript-eslint/ban-types': 'off',
'@typescript-eslint/no-unused-vars': 'off',
//禁止失去精度的字面数字
'@typescript-eslint/no-loss-of-precision': 'off',
//禁止使用any
'@typescript-eslint/no-explicit-any': 'error'
}
},
{
ignores: ['**/node_modules', '**/dist', '**/output']
},
{
name: 'react-eslint',
files: ['src/*.{js,jsx,mjs,cjs,ts,tsx}'],
plugins: {
react: reactPlugin,
'react-hooks': reactHooksPlugin
},
languageOptions: {
...reactPlugin.configs.recommended.languageOptions
},
rules: {
...reactPlugin.configs.recommended.rules,
'react/react-in-jsx-scope': 'off'
},
settings: {
react: {
// 需要显示安装 react
version: 'detect'
}
}
},
{
languageOptions: { globals: { ...globals.browser, ...globals.node } }
},
eslintConfigPrettier
]

View File

@ -86,7 +86,6 @@
"zod": "^3.24.1"
},
"devDependencies": {
"@eslint/js": "^9.19.0",
"@react-types/shared": "^3.26.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.2",
"@types/crypto-js": "^4.2.2",
@ -97,20 +96,14 @@
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@types/react-window": "^1.8.8",
"@typescript-eslint/eslint-plugin": "^8.22.0",
"@typescript-eslint/parser": "^8.22.0",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "5.2.3",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.14.0",
"postcss": "^8.5.1",
"prettier": "^3.4.2",
"typescript": "^5.7.3",

View File

@ -1,69 +1,69 @@
import { useEffect, useRef, useState } from 'react'
import { useEffect, useRef, useState } from 'react';
// 全局图片缓存
const imageCache = new Map<string, HTMLImageElement>()
const imageCache = new Map<string, HTMLImageElement>();
export function usePreloadImages (urls: string[]) {
const [loadedUrls, setLoadedUrls] = useState<Record<string, boolean>>({})
const [isLoading, setIsLoading] = useState(true)
const isMounted = useRef(true)
const [loadedUrls, setLoadedUrls] = useState<Record<string, boolean>>({});
const [isLoading, setIsLoading] = useState(true);
const isMounted = useRef(true);
useEffect(() => {
isMounted.current = true
isMounted.current = true;
// 检查是否所有图片都已缓存
const allCached = urls.every((url) => imageCache.has(url))
const allCached = urls.every((url) => imageCache.has(url));
if (allCached) {
setLoadedUrls(urls.reduce((acc, url) => ({ ...acc, [url]: true }), {}))
setIsLoading(false)
return
setLoadedUrls(urls.reduce((acc, url) => ({ ...acc, [url]: true }), {}));
setIsLoading(false);
return;
}
setIsLoading(true)
const loadedImages: Record<string, boolean> = {}
let pendingCount = urls.length
setIsLoading(true);
const loadedImages: Record<string, boolean> = {};
let pendingCount = urls.length;
urls.forEach((url) => {
// 如果已经缓存,直接标记为已加载
if (imageCache.has(url)) {
loadedImages[url] = true
pendingCount--
loadedImages[url] = true;
pendingCount--;
if (pendingCount === 0) {
setLoadedUrls(loadedImages)
setIsLoading(false)
setLoadedUrls(loadedImages);
setIsLoading(false);
}
return
return;
}
const img = new Image()
const img = new Image();
img.onload = () => {
if (!isMounted.current) return
loadedImages[url] = true
imageCache.set(url, img)
pendingCount--
if (!isMounted.current) return;
loadedImages[url] = true;
imageCache.set(url, img);
pendingCount--;
if (pendingCount === 0) {
setLoadedUrls(loadedImages)
setIsLoading(false)
}
setLoadedUrls(loadedImages);
setIsLoading(false);
}
};
img.onerror = () => {
if (!isMounted.current) return
loadedImages[url] = false
pendingCount--
if (!isMounted.current) return;
loadedImages[url] = false;
pendingCount--;
if (pendingCount === 0) {
setLoadedUrls(loadedImages)
setIsLoading(false)
setLoadedUrls(loadedImages);
setIsLoading(false);
}
}
img.src = url
})
};
img.src = url;
});
return () => {
isMounted.current = false
}
}, [urls])
isMounted.current = false;
};
}, [urls]);
return { loadedUrls, isLoading }
return { loadedUrls, isLoading };
}

View File

@ -1,25 +1,25 @@
import { createElement } from 'react'
import { createElement } from 'react';
import ShowStructedMessage from '@/components/chat_input/components/show_structed_message'
import ShowStructedMessage from '@/components/chat_input/components/show_structed_message';
import { OB11Segment } from '@/types/onebot'
import { OB11Segment } from '@/types/onebot';
import useDialog from './use-dialog'
import useDialog from './use-dialog';
const useShowStructuredMessage = () => {
const dialog = useDialog()
const dialog = useDialog();
const showStructuredMessage = (messages: OB11Segment[]) => {
dialog.alert({
title: '消息内容',
size: '3xl',
content: createElement(ShowStructedMessage, {
messages: messages
})
})
}
messages,
}),
});
};
return showStructuredMessage
}
return showStructuredMessage;
};
export default useShowStructuredMessage
export default useShowStructuredMessage;

1015
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,12 @@
"dev:shell": "vite build --mode shell",
"dev:shell-analysis": "vite build --mode shell-analysis",
"dev:webui": "cd napcat.webui && npm run dev",
"lint": "eslint --fix src/**/*.{js,ts,vue}",
"lint": "npm run lint:core && npm run lint:webui",
"lint:fix": "npm run lint:fix:core && npm run lint:fix:webui",
"lint:core": "eslint src/**/*.{js,ts}",
"lint:fix:core": "eslint --fix src/**/*.{js,ts,vue}",
"lint:webui": "cd napcat.webui && eslint src/**/*.{js,ts}",
"lint:fix:webui": "cd napcat.webui && eslint --fix src/**/*.{js,ts,tsx}",
"depend": "cd dist && npm install --omit=dev",
"dev:depend": "npm i && cd napcat.webui && npm i"
},
@ -24,9 +29,6 @@
"@babel/preset-typescript": "^7.24.7",
"@babel/traverse": "^7.28.0",
"@babel/types": "^7.28.2",
"@eslint/compat": "^1.3.1",
"@eslint/eslintrc": "^3.1.0",
"@eslint/js": "^9.33.0",
"@homebridge/node-pty-prebuilt-multiarch": "^0.12.0-beta.5",
"@log4js-node/log4js-api": "^1.0.2",
"@napneko/nap-proto-core": "^0.0.4",
@ -42,8 +44,6 @@
"@types/react-color": "^3.0.13",
"@types/type-is": "^1.6.7",
"@types/ws": "^8.5.12",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.39.0",
"ajv": "^8.13.0",
"async-mutex": "^0.5.0",
"commander": "^13.0.0",
@ -51,15 +51,13 @@
"cors": "^2.8.5",
"esbuild": "0.25.8",
"eslint": "^9.14.0",
"eslint-import-resolver-typescript": "^4.4.4",
"eslint-plugin-import": "^2.32.0",
"express-rate-limit": "^7.5.0",
"fast-xml-parser": "^4.3.6",
"file-type": "^21.0.0",
"globals": "^16.0.0",
"json5": "^2.2.3",
"multer": "^2.0.1",
"napcat.protobuf": "^1.1.4",
"neostandard": "^0.12.2",
"typescript": "^5.3.3",
"typescript-eslint": "^8.35.1",
"vite": "^7.1.1",

View File

@ -6,7 +6,7 @@ import {
PacketMsgFileElement,
PacketMsgPicElement,
PacketMsgPttElement,
PacketMsgVideoElement
PacketMsgVideoElement,
} from '@/core/packet/message/element';
import { ChatType, Peer } from '@/core';
import { calculateSha1, calculateSha1StreamBytes, computeMd5AndLengthWithLimit } from '@/core/packet/utils/crypto/hash';
@ -79,7 +79,7 @@ export class PacketHighwayContext {
this.logger.debug(`[Highway PrepareUpload] server addr add: ${int32ip2str(addr.ip)}:${addr.port}`);
this.sig.serverAddr.push({
ip: int32ip2str(addr.ip),
port: addr.port
port: addr.port,
});
this.hwClient.changeServer(int32ip2str(addr.ip), addr.port);
}
@ -151,13 +151,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: ukey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: [sha1]
}
fileSha1: [sha1],
},
});
await this.hwClient.upload(
1004,
@ -188,13 +188,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: ukey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: [sha1]
}
fileSha1: [sha1],
},
});
await this.hwClient.upload(
1003,
@ -225,13 +225,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: ukey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: await calculateSha1StreamBytes(video.filePath)
}
fileSha1: await calculateSha1StreamBytes(video.filePath),
},
});
await this.hwClient.upload(
1005,
@ -253,13 +253,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: subFile!.uKey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(subFile!.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(subFile!.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: [sha1]
}
fileSha1: [sha1],
},
});
await this.hwClient.upload(
1006,
@ -290,13 +290,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: ukey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: await calculateSha1StreamBytes(video.filePath)
}
fileSha1: await calculateSha1StreamBytes(video.filePath),
},
});
await this.hwClient.upload(
1001,
@ -318,13 +318,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: subFile!.uKey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(subFile!.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(subFile!.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: [sha1]
}
fileSha1: [sha1],
},
});
await this.hwClient.upload(
1002,
@ -354,13 +354,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: ukey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: [sha1]
}
fileSha1: [sha1],
},
});
await this.hwClient.upload(
1008,
@ -390,13 +390,13 @@ export class PacketHighwayContext {
fileUuid: index.fileUuid,
uKey: ukey,
network: {
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S)
ipv4S: oidbIpv4s2HighwayIpv4s(preRespData.upload.ipv4S),
},
msgInfoBody: preRespData.upload.msgInfo.msgInfoBody,
blockSize: BlockSize,
hash: {
fileSha1: [sha1]
}
fileSha1: [sha1],
},
});
await this.hwClient.upload(
1007,
@ -442,10 +442,10 @@ export class PacketHighwayContext {
appId: '100',
terminalType: 3,
clientVer: '1.1.1',
unknown: 4
unknown: 4,
},
fileNameInfo: {
fileName: file.fileName
fileName: file.fileName,
},
host: {
hosts: [
@ -455,9 +455,9 @@ export class PacketHighwayContext {
unknown: 1,
},
port: preRespData.upload.uploadPort,
}
]
}
},
],
},
},
unknown200: 0,
});
@ -503,10 +503,10 @@ export class PacketHighwayContext {
appId: '100',
terminalType: 3,
clientVer: '1.1.1',
unknown: 4
unknown: 4,
},
fileNameInfo: {
fileName: file.fileName
fileName: file.fileName,
},
host: {
hosts: [
@ -516,12 +516,12 @@ export class PacketHighwayContext {
unknown: 1,
},
port: preRespData.upload?.uploadPort,
}
]
}
},
],
},
},
unknown200: 1,
unknown3: 0
unknown3: 0,
});
await this.hwClient.upload(
95,

View File

@ -48,7 +48,7 @@ export class HighwayHttpUploader extends IHighwayUploader {
const options: http.RequestOptions = {
method: 'POST',
headers: {
'Connection': 'keep-alive',
Connection: 'keep-alive',
'Accept-Encoding': 'identity',
'User-Agent': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2)',
'Content-Length': frame.length.toString(),

View File

@ -17,7 +17,6 @@ class HighwayTcpUploaderTransform extends stream.Transform {
this.offset = 0;
}
// eslint-disable-next-line no-undef
override _transform (data: Buffer, _: BufferEncoding, callback: stream.TransformCallback) {
let chunkOffset = 0;
while (chunkOffset < data.length) {

View File

@ -55,7 +55,7 @@ export abstract class IHighwayUploader {
msgLoginSigHead: {
uint32LoginSigType: 8,
appId: 1600001604,
}
},
});
}

View File

@ -8,7 +8,7 @@ import { SendTextElement } from '@/core';
export class PacketMsgBuilder {
protected static failBackText = new PacketMsgTextElement(
{
textElement: { content: '[该消息类型暂不支持查看]' }
textElement: { content: '[该消息类型暂不支持查看]' },
} as SendTextElement
);
@ -29,15 +29,19 @@ export class PacketMsgBuilder {
sigMap: 0,
toUin: 0,
fromUid: '',
forward: node.groupId ? undefined : {
forward: node.groupId
? undefined
: {
friendName: node.senderName,
},
toUid: node.groupId ? undefined : selfUid,
grp: node.groupId ? {
grp: node.groupId
? {
groupUin: node.groupId,
memberName: node.senderName,
unknown5: 2
} : undefined,
unknown5: 2,
}
: undefined,
},
contentHead: {
type: node.groupId ? 82 : 9,
@ -51,15 +55,15 @@ export class PacketMsgBuilder {
field2: 0,
field3: node.groupId ? 1 : 2,
unknownBase64: avatar,
avatar: avatar
}
avatar,
},
},
body: {
richText: {
elems: msgElement
elems: msgElement,
},
msgContent,
},
msgContent: msgContent,
}
};
});
}

View File

@ -14,7 +14,7 @@ import {
SendPttElement,
SendReplyElement,
SendTextElement,
SendVideoElement
SendVideoElement,
} from '@/core';
import {
IPacketMsgElement,
@ -29,7 +29,7 @@ import {
PacketMsgReplyElement,
PacketMsgTextElement,
PacketMsgVideoElement,
PacketMultiMsgElement
PacketMultiMsgElement,
} from '@/core/packet/message/element';
import { PacketMsg, PacketSendMsgElement } from '@/core/packet/message/message';
import { NapProtoDecodeStructType } from '@napneko/nap-proto-core';
@ -46,7 +46,7 @@ const SupportedElementTypes = [
ElementType.PTT,
ElementType.ARK,
ElementType.MARKDOWN,
ElementType.MULTIFORWARD
ElementType.MULTIFORWARD,
];
type SendMessageTypeElementMap = {
@ -67,7 +67,7 @@ type ElementToPacketMsgConverters = {
[K in keyof SendMessageTypeElementMap]: (
sendElement: MessageElement
) => IPacketMsgElement<SendMessageTypeElementMap[K]>;
}
};
export type rawMsgWithSendMsg = {
senderUin: number;
@ -76,7 +76,7 @@ export type rawMsgWithSendMsg = {
groupId?: number;
time: number;
msg: PacketSendMsgElement[]
}
};
// TODO: make it become adapter?
export class PacketMsgConverter {
@ -120,7 +120,7 @@ export class PacketMsgConverter {
},
[ElementType.MULTIFORWARD]: (element) => {
return new PacketMultiMsgElement(element as SendMultiForwardMsgElement);
}
},
};
rawMsgWithSendMsgToPacketMsg (msg: rawMsgWithSendMsg): PacketMsg {
@ -133,7 +133,7 @@ export class PacketMsgConverter {
msg: msg.msg.map((element) => {
if (!this.isValidElementType(element.elementType)) return null;
return this.rawToPacketMsgConverters[element.elementType](element as MessageElement);
}).filter((e) => e !== null)
}).filter((e) => e !== null),
};
}
@ -152,7 +152,7 @@ export class PacketMsgConverter {
msg: msg.elements.map((element) => {
if (!this.isValidElementType(element.elementType)) return null;
return this.rawToPacketMsgConverters[element.elementType](element);
}).filter((e) => e !== null)
}).filter((e) => e !== null),
};
}

View File

@ -31,7 +31,7 @@ import {
SendMultiForwardMsgElement,
SendTextElement,
SendVideoElement,
Peer
Peer,
} from '@/core';
import { ForwardMsgBuilder } from '@/common/forward-msg-builder';
import { PacketMsg, PacketSendMsgElement } from '@/core/packet/message/message';
@ -42,7 +42,6 @@ type ParseElementFn = (elem: NapProtoDecodeStructType<typeof Elem>) => ParseElem
// raw <-> packet
// TODO: SendStructLongMsgElement
export abstract class IPacketMsgElement<T extends PacketSendMsgElement> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected constructor (_rawElement: T) {
}
@ -76,8 +75,8 @@ export class PacketMsgTextElement extends IPacketMsgElement<SendTextElement> {
override buildElement (): NapProtoEncodeStructType<typeof Elem>[] {
return [{
text: {
str: this.text
}
str: this.text,
},
}];
}
@ -100,10 +99,8 @@ export class PacketMsgTextElement extends IPacketMsgElement<SendTextElement> {
override toPreview (): string {
return this.text;
};
}
}
export class PacketMsgAtElement extends PacketMsgTextElement {
targetUid: string;
@ -125,10 +122,11 @@ export class PacketMsgAtElement extends PacketMsgTextElement {
field5: 0,
uid: this.targetUid,
}
)
}
),
},
}];
}
static override parseElement = (elem: NapProtoDecodeStructType<typeof Elem>): ParseElementFnR => {
if (elem.text?.str && (elem.text?.attr6Buf?.length ?? 100) >= 11) {
return [{
@ -182,7 +180,7 @@ export class PacketMsgReplyElement extends IPacketMsgElement<SendReplyElement> {
elems: this.targetElems ?? [],
sourceMsg: new NapProtoMsg(PushMsgBody).encode(this.targetSourceMsg ?? {}),
toUin: BigInt(0),
}
},
}];
}
@ -193,7 +191,7 @@ export class PacketMsgReplyElement extends IPacketMsgElement<SendReplyElement> {
replyElement: {
replayMsgSeq: String(reserve.friendSeq ?? elem.srcMsg?.origSeqs?.[0] ?? 0),
replayMsgId: String(reserve.messageId ?? 0),
senderUin: String(elem?.srcMsg ?? 0)
senderUin: String(elem?.srcMsg ?? 0),
},
elementType: ElementType.UNKNOWN,
elementId: '',
@ -231,16 +229,16 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
sourceType: 1,
resultId: this.resultId,
preview: '',
randomType: 1
randomType: 1,
}),
businessType: 1
}
businessType: 1,
},
}];
} else if (this.faceId < 260) {
return [{
face: {
index: this.faceId
}
index: this.faceId,
},
}];
} else {
return [{
@ -249,10 +247,10 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
pbElem: new NapProtoMsg(QSmallFaceExtra).encode({
faceId: this.faceId,
preview: '',
preview2: ''
preview2: '',
}),
businessType: 1
}
businessType: 1,
},
}];
}
}
@ -262,7 +260,7 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
return [{
faceElement: {
faceIndex: elem.face.index,
faceType: FaceType.Normal
faceType: FaceType.Normal,
},
elementType: ElementType.UNKNOWN,
elementId: '',
@ -274,7 +272,7 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
return [{
faceElement: {
faceIndex: qface.faceId,
faceType: FaceType.Normal
faceType: FaceType.Normal,
},
elementType: ElementType.UNKNOWN,
elementId: '',
@ -287,7 +285,7 @@ export class PacketMsgFaceElement extends IPacketMsgElement<SendFaceElement> {
return [{
faceElement: {
faceIndex: qface.faceId,
faceType: FaceType.Normal
faceType: FaceType.Normal,
},
elementType: ElementType.UNKNOWN,
elementId: '',
@ -329,9 +327,9 @@ export class PacketMsgMarkFaceElement extends IPacketMsgElement<SendMarketFaceEl
imageWidth: 300,
imageHeight: 300,
pbReserve: {
field8: 1
}
}
field8: 1,
},
},
}];
}
@ -365,9 +363,11 @@ export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
this.height = element.picElement.picHeight;
this.picType = element.picElement.picType;
this.picSubType = element.picElement.picSubType ?? 0;
this.summary = element.picElement.summary === '' ? (
this.summary = element.picElement.summary === ''
? (
element.picElement.picSubType === 0 ? '[图片]' : '[动画表情]'
) : element.picElement.summary;
)
: element.picElement.summary;
}
override get valid (): boolean {
@ -381,7 +381,7 @@ export class PacketMsgPicElement extends IPacketMsgElement<SendPicElement> {
serviceType: 48,
pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo),
businessType: 10,
}
},
}];
}
@ -480,7 +480,7 @@ export class PacketMsgVideoElement extends IPacketMsgElement<SendVideoElement> {
serviceType: 48,
pbElem: new NapProtoMsg(MsgInfo).encode(this.msgInfo),
businessType: 21,
}
},
}];
}
@ -576,8 +576,8 @@ export class PacketMsgFileElement extends IPacketMsgElement<SendFileElement> {
fileHash: this.fileHash,
selfUid: this._private_send_uid,
destUid: this._private_recv_uid,
}
}
},
},
});
}
@ -596,15 +596,15 @@ export class PacketMsgFileElement extends IPacketMsgElement<SendFileElement> {
fileSha: this.fileSha1,
extInfoString: '',
fileMd5: this.fileMd5,
}
}
},
},
});
lb.writeUInt16BE(transElemVal.length);
return [{
transElem: {
elemType: 24,
elemValue: Buffer.concat([Buffer.from([0x01]), lb, transElemVal]) // TLV
}
elemValue: Buffer.concat([Buffer.from([0x01]), lb, transElemVal]), // TLV
},
}];
}
@ -626,9 +626,9 @@ export class PacketMsgLightAppElement extends IPacketMsgElement<SendArkElement>
lightAppElem: {
data: Buffer.concat([
Buffer.from([0x01]),
zlib.deflateSync(Buffer.from(this.payload, 'utf-8'))
])
}
zlib.deflateSync(Buffer.from(this.payload, 'utf-8')),
]),
},
}];
}
@ -650,10 +650,10 @@ export class PacketMsgMarkDownElement extends IPacketMsgElement<SendMarkdownElem
commonElem: {
serviceType: 45,
pbElem: new NapProtoMsg(MarkdownData).encode({
content: this.content
content: this.content,
}),
businessType: 1
}
businessType: 1,
},
}];
}
@ -677,9 +677,9 @@ export class PacketMultiMsgElement extends IPacketMsgElement<SendMultiForwardMsg
lightAppElem: {
data: Buffer.concat([
Buffer.from([0x01]),
zlib.deflateSync(Buffer.from(JSON.stringify(ForwardMsgBuilder.fromPacketMsg(this.resid, this.message)), 'utf-8'))
])
}
zlib.deflateSync(Buffer.from(JSON.stringify(ForwardMsgBuilder.fromPacketMsg(this.resid, this.message)), 'utf-8')),
]),
},
}];
}

View File

@ -1,7 +1,7 @@
import { IPacketMsgElement } from '@/core/packet/message/element';
import { SendMessageElement, SendMultiForwardMsgElement } from '@/core';
export type PacketSendMsgElement = SendMessageElement | SendMultiForwardMsgElement
export type PacketSendMsgElement = SendMessageElement | SendMultiForwardMsgElement;
export interface PacketMsg {
seq?: number;

View File

@ -11,13 +11,13 @@ class GetAiVoice extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0X929B_0Re
build (groupUin: number, voiceId: string, text: string, sessionId: number, chatType: AIVoiceChatType): OidbPacket {
const data = new NapProtoMsg(proto.OidbSvcTrpcTcp0X929B_0).encode({
groupUin: groupUin,
voiceId: voiceId,
text: text,
chatType: chatType,
groupUin,
voiceId,
text,
chatType,
session: {
sessionId: sessionId
}
sessionId,
},
});
return OidbBase.build(0x929B, 0, data);
}

View File

@ -13,7 +13,7 @@ class GetMiniAppAdaptShareInfo extends PacketTransformer<typeof proto.MiniAppAda
appId: req.sdkId,
body: {
extInfo: {
field2: Buffer.alloc(0)
field2: Buffer.alloc(0),
},
appid: req.appId,
title: req.title,
@ -34,14 +34,14 @@ class GetMiniAppAdaptShareInfo extends PacketTransformer<typeof proto.MiniAppAda
appidRich: Buffer.alloc(0),
template: {
templateId: '',
templateData: ''
templateData: '',
},
field20: '',
},
field20: ''
}
});
return {
cmd: 'LightAppSvc.mini_app_share.AdaptShareInfo',
data: PacketBufBuilder(data)
data: PacketBufBuilder(data),
};
}

View File

@ -10,8 +10,8 @@ class GetStrangerInfo extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0XFE1
build (uin: number): OidbPacket {
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0XFE1_2).encode({
uin: uin,
key: [{ key: 27372 }]
uin,
key: [{ key: 27372 }],
});
return OidbBase.build(0XFE1, 2, body);
}

View File

@ -22,7 +22,7 @@ class ImageOCR extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0xE07_0_Resp
afterCompressWeight: '',
afterCompressHeight: '',
isCut: false,
}
},
}
);
return OidbBase.build(0XEB7, 1, body, false, false);

View File

@ -11,13 +11,13 @@ class MoveGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6D6Re
build (groupUin: number, fileUUID: string, currentParentDirectory: string, targetParentDirectory: string): OidbPacket {
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6).encode({
move: {
groupUin: groupUin,
groupUin,
appId: 5,
busId: 102,
fileId: fileUUID,
parentDirectory: currentParentDirectory,
targetDirectory: targetParentDirectory,
}
},
});
return OidbBase.build(0x6D6, 5, body, true, false);
}

View File

@ -11,12 +11,12 @@ class RenameGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6D6
build (groupUin: number, fileUUID: string, currentParentDirectory: string, newName: string): OidbPacket {
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6).encode({
rename: {
groupUin: groupUin,
groupUin,
busId: 102,
fileId: fileUUID,
parentFolder: currentParentDirectory,
newFileName: newName,
}
},
});
return OidbBase.build(0x6D6, 4, body, true, false);
}

View File

@ -11,11 +11,11 @@ class DownloadGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6
build (groupUin: number, fileUUID: string): OidbPacket {
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6).encode({
download: {
groupUin: groupUin,
groupUin,
appId: 7,
busId: 102,
fileId: fileUUID
}
fileId: fileUUID,
},
});
return OidbBase.build(0x6D6, 2, body, true, false);
}

View File

@ -14,29 +14,29 @@ class DownloadGroupImage extends PacketTransformer<typeof proto.NTV2RichMediaRes
reqHead: {
common: {
requestId: 1,
command: 200
command: 200,
},
scene: {
requestType: 2,
businessType: 1,
sceneType: 2,
group: {
groupUin: group_uin
}
groupUin: group_uin,
},
},
client: {
agentType: 2,
}
},
},
download: {
node: node,
node,
download: {
video: {
busiType: 0,
sceneType: 0
}
}
}
sceneType: 0,
},
},
},
});
return OidbBase.build(0x11C4, 200, body, true, false);
}

View File

@ -14,29 +14,29 @@ class DownloadGroupVideo extends PacketTransformer<typeof proto.NTV2RichMediaRes
reqHead: {
common: {
requestId: 1,
command: 200
command: 200,
},
scene: {
requestType: 2,
businessType: 2,
sceneType: 2,
group: {
groupUin: groupUin
}
groupUin,
},
},
client: {
agentType: 2,
}
},
},
download: {
node: node,
node,
download: {
video: {
busiType: 0,
sceneType: 0
}
}
}
sceneType: 0,
},
},
},
});
return OidbBase.build(0x11EA, 200, body, true, false);
}

View File

@ -14,7 +14,7 @@ class DownloadImage extends PacketTransformer<typeof proto.NTV2RichMediaResp> {
reqHead: {
common: {
requestId: 1,
command: 200
command: 200,
},
scene: {
requestType: 2,
@ -22,22 +22,22 @@ class DownloadImage extends PacketTransformer<typeof proto.NTV2RichMediaResp> {
sceneType: 1,
c2C: {
accountType: 2,
targetUid: selfUid
targetUid: selfUid,
},
},
client: {
agentType: 2,
}
},
},
download: {
node: node,
node,
download: {
video: {
busiType: 0,
sceneType: 0
}
}
}
sceneType: 0,
},
},
},
});
return OidbBase.build(0x11C5, 200, body, true, false);
}

View File

@ -13,10 +13,10 @@ class DownloadOfflineFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0
subCommand: 800,
field2: 0,
body: {
senderUid: senderUid,
receiverUid: receiverUid,
senderUid,
receiverUid,
fileUuid: fileUUID,
fileHash: fileHash,
fileHash,
},
field101: 3,
field102: 1,

View File

@ -16,13 +16,13 @@ class DownloadPrivateFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0
receiverUid: selfUid,
fileUuid: fileUUID,
type: 2,
fileHash: fileHash,
t2: 0
fileHash,
t2: 0,
},
field101: 3,
field102: 103,
field200: 1,
field99999: Buffer.from([0xc0, 0x85, 0x2c, 0x01])
field99999: Buffer.from([0xc0, 0x85, 0x2c, 0x01]),
});
return OidbBase.build(0xE37, 1200, body, false, false);
}

View File

@ -14,7 +14,7 @@ class DownloadVideo extends PacketTransformer<typeof proto.NTV2RichMediaResp> {
reqHead: {
common: {
requestId: 1,
command: 200
command: 200,
},
scene: {
requestType: 2,
@ -22,22 +22,22 @@ class DownloadVideo extends PacketTransformer<typeof proto.NTV2RichMediaResp> {
sceneType: 1,
c2C: {
accountType: 2,
targetUid: selfUid
targetUid: selfUid,
},
},
client: {
agentType: 2,
}
},
},
download: {
node: node,
node,
download: {
video: {
busiType: 0,
sceneType: 0
}
}
}
sceneType: 0,
},
},
},
});
return OidbBase.build(0x11E9, 200, body, true, false);
}

View File

@ -20,12 +20,12 @@ class FetchSessionKey extends PacketTransformer<typeof proto.HttpConn0x6ff_501Re
field9: 2,
field10: 9,
field11: 8,
ver: '1.0.1'
}
ver: '1.0.1',
},
});
return {
cmd: 'HttpConn.0x6ff_501',
data: PacketBufBuilder(req)
data: PacketBufBuilder(req),
};
}

View File

@ -12,7 +12,7 @@ class UploadGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6D6
build (groupUin: number, file: PacketMsgFileElement): OidbPacket {
const body = new NapProtoMsg(proto.OidbSvcTrpcTcp0x6D6).encode({
file: {
groupUin: groupUin,
groupUin,
appId: 4,
busId: 102,
entrance: 6,
@ -23,8 +23,8 @@ class UploadGroupFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0x6D6
fileMd5: file.fileMd5,
fileSha1: file.fileSha1,
fileSha3: Buffer.alloc(0),
field15: true
}
field15: true,
},
});
return OidbBase.build(0x6D6, 0, body, true, false);
}

View File

@ -16,19 +16,19 @@ class UploadGroupImage extends PacketTransformer<typeof proto.NTV2RichMediaResp>
reqHead: {
common: {
requestId: 1,
command: 100
command: 100,
},
scene: {
requestType: 2,
businessType: 1,
sceneType: 2,
group: {
groupUin: groupUin
groupUin,
},
},
client: {
agentType: 2
}
agentType: 2,
},
},
upload: {
uploadInfo: [
@ -47,10 +47,10 @@ class UploadGroupImage extends PacketTransformer<typeof proto.NTV2RichMediaResp>
width: img.width,
height: img.height,
time: 0,
original: 1
original: 1,
},
subFileType: 0,
}
},
],
tryFastUploadCompleted: true,
srvSendMsg: false,
@ -71,11 +71,11 @@ class UploadGroupImage extends PacketTransformer<typeof proto.NTV2RichMediaResp>
bytesPbReserve: Buffer.alloc(0),
bytesReserve: Buffer.alloc(0),
bytesGeneralFlags: Buffer.alloc(0),
}
},
},
clientSeq: 0,
noNeedCompatMsg: false,
}
},
}
);
return OidbBase.build(0x11C4, 100, data, true, false);

View File

@ -16,19 +16,19 @@ class UploadGroupVideo extends PacketTransformer<typeof proto.NTV2RichMediaResp>
reqHead: {
common: {
requestId: 3,
command: 100
command: 100,
},
scene: {
requestType: 2,
businessType: 2,
sceneType: 2,
group: {
groupUin: groupUin
groupUin,
},
},
client: {
agentType: 2
}
agentType: 2,
},
},
upload: {
uploadInfo: [
@ -42,14 +42,14 @@ class UploadGroupVideo extends PacketTransformer<typeof proto.NTV2RichMediaResp>
type: 2,
picFormat: 0,
videoFormat: 0,
voiceFormat: 0
voiceFormat: 0,
},
height: 0,
width: 0,
time: 0,
original: 0
original: 0,
},
subFileType: 0
subFileType: 0,
}, {
fileInfo: {
fileSize: +video.thumbSize,
@ -60,15 +60,15 @@ class UploadGroupVideo extends PacketTransformer<typeof proto.NTV2RichMediaResp>
type: 1,
picFormat: 0,
videoFormat: 0,
voiceFormat: 0
voiceFormat: 0,
},
height: video.thumbHeight,
width: video.thumbWidth,
time: 0,
original: 0
original: 0,
},
subFileType: 100,
},
subFileType: 100
}
],
tryFastUploadCompleted: true,
srvSendMsg: false,
@ -86,11 +86,11 @@ class UploadGroupVideo extends PacketTransformer<typeof proto.NTV2RichMediaResp>
bytesPbReserve: Buffer.alloc(0),
bytesReserve: Buffer.alloc(0),
bytesGeneralFlags: Buffer.alloc(0),
}
},
},
clientSeq: 0,
noNeedCompatMsg: false
}
noNeedCompatMsg: false,
},
});
return OidbBase.build(0x11EA, 100, data, true, false);
}

View File

@ -23,11 +23,11 @@ class UploadPrivateFile extends PacketTransformer<typeof proto.OidbSvcTrpcTcp0XE
sha1CheckSum: file.fileSha1,
localPath: '/',
md5CheckSum: file.fileMd5,
sha3CheckSum: Buffer.alloc(0)
sha3CheckSum: Buffer.alloc(0),
},
businessId: 3,
clientType: 1,
flagSupportMediaPlatform: 1
flagSupportMediaPlatform: 1,
});
return OidbBase.build(0xE37, 1700, body, false, false);
}

View File

@ -15,7 +15,7 @@ class UploadPrivateImage extends PacketTransformer<typeof proto.NTV2RichMediaRes
reqHead: {
common: {
requestId: 1,
command: 100
command: 100,
},
scene: {
requestType: 2,
@ -23,12 +23,12 @@ class UploadPrivateImage extends PacketTransformer<typeof proto.NTV2RichMediaRes
sceneType: 1,
c2C: {
accountType: 2,
targetUid: peerUin
targetUid: peerUin,
},
},
client: {
agentType: 2,
}
},
},
upload: {
uploadInfo: [
@ -47,10 +47,10 @@ class UploadPrivateImage extends PacketTransformer<typeof proto.NTV2RichMediaRes
width: img.width,
height: img.height,
time: 0,
original: 1
original: 1,
},
subFileType: 0,
}
},
],
tryFastUploadCompleted: true,
srvSendMsg: false,
@ -71,11 +71,11 @@ class UploadPrivateImage extends PacketTransformer<typeof proto.NTV2RichMediaRes
bytesPbReserve: Buffer.alloc(0),
bytesReserve: Buffer.alloc(0),
bytesGeneralFlags: Buffer.alloc(0),
}
},
},
clientSeq: 0,
noNeedCompatMsg: false,
}
},
}
);
return OidbBase.build(0x11C5, 100, data, true, false);

View File

@ -15,7 +15,7 @@ class UploadPrivatePtt extends PacketTransformer<typeof proto.NTV2RichMediaResp>
reqHead: {
common: {
requestId: 4,
command: 100
command: 100,
},
scene: {
requestType: 2,
@ -23,12 +23,12 @@ class UploadPrivatePtt extends PacketTransformer<typeof proto.NTV2RichMediaResp>
sceneType: 1,
c2C: {
accountType: 2,
targetUid: peerUin
}
targetUid: peerUin,
},
},
client: {
agentType: 2
}
agentType: 2,
},
},
upload: {
uploadInfo: [
@ -42,15 +42,15 @@ class UploadPrivatePtt extends PacketTransformer<typeof proto.NTV2RichMediaResp>
type: 3,
picFormat: 0,
videoFormat: 0,
voiceFormat: 1
voiceFormat: 1,
},
height: 0,
width: 0,
time: ptt.fileDuration,
original: 0
original: 0,
},
subFileType: 0,
},
subFileType: 0
}
],
tryFastUploadCompleted: true,
srvSendMsg: false,
@ -63,11 +63,11 @@ class UploadPrivatePtt extends PacketTransformer<typeof proto.NTV2RichMediaResp>
ptt: {
bytesReserve: Buffer.from([0x08, 0x00, 0x38, 0x00]),
bytesGeneralFlags: Buffer.from([0x9a, 0x01, 0x0b, 0xaa, 0x03, 0x08, 0x08, 0x04, 0x12, 0x04, 0x00, 0x00, 0x00, 0x00]),
}
},
},
clientSeq: 0,
noNeedCompatMsg: false
}
noNeedCompatMsg: false,
},
});
return OidbBase.build(0x126D, 100, data, true, false);
}

View File

@ -16,7 +16,7 @@ class UploadPrivateVideo extends PacketTransformer<typeof proto.NTV2RichMediaRes
reqHead: {
common: {
requestId: 3,
command: 100
command: 100,
},
scene: {
requestType: 2,
@ -24,12 +24,12 @@ class UploadPrivateVideo extends PacketTransformer<typeof proto.NTV2RichMediaRes
sceneType: 1,
c2C: {
accountType: 2,
targetUid: peerUin
}
targetUid: peerUin,
},
},
client: {
agentType: 2
}
agentType: 2,
},
},
upload: {
uploadInfo: [
@ -43,14 +43,14 @@ class UploadPrivateVideo extends PacketTransformer<typeof proto.NTV2RichMediaRes
type: 2,
picFormat: 0,
videoFormat: 0,
voiceFormat: 0
voiceFormat: 0,
},
height: 0,
width: 0,
time: 0,
original: 0
original: 0,
},
subFileType: 0
subFileType: 0,
}, {
fileInfo: {
fileSize: +video.thumbSize,
@ -61,15 +61,15 @@ class UploadPrivateVideo extends PacketTransformer<typeof proto.NTV2RichMediaRes
type: 1,
picFormat: 0,
videoFormat: 0,
voiceFormat: 0
voiceFormat: 0,
},
height: video.thumbHeight,
width: video.thumbWidth,
time: 0,
original: 0
original: 0,
},
subFileType: 100,
},
subFileType: 100
}
],
tryFastUploadCompleted: true,
srvSendMsg: false,
@ -87,11 +87,11 @@ class UploadPrivateVideo extends PacketTransformer<typeof proto.NTV2RichMediaRes
bytesPbReserve: Buffer.alloc(0),
bytesReserve: Buffer.alloc(0),
bytesGeneralFlags: Buffer.alloc(0),
}
},
},
clientSeq: 0,
noNeedCompatMsg: false
}
noNeedCompatMsg: false,
},
});
return OidbBase.build(0x11E9, 100, data, true, false);
}

View File

@ -11,21 +11,21 @@ class DownloadForwardMsg extends PacketTransformer<typeof proto.RecvLongMsgResp>
const req = new NapProtoMsg(proto.RecvLongMsgReq).encode({
info: {
uid: {
uid: uid
uid,
},
resId: resId,
acquire: true
resId,
acquire: true,
},
settings: {
field1: 2,
field2: 0,
field3: 0,
field4: 0
}
field4: 0,
},
});
return {
cmd: 'trpc.group.long_msg_interface.MsgService.SsoRecvLongMsg',
data: PacketBufBuilder(req)
data: PacketBufBuilder(req),
};
}

View File

@ -15,7 +15,7 @@ class FetchC2CMessage extends PacketTransformer<typeof proto.SsoGetC2cMsgRespons
});
return {
cmd: 'trpc.msg.register_proxy.RegisterProxy.SsoGetC2cMsg',
data: PacketBufBuilder(req)
data: PacketBufBuilder(req),
};
}

View File

@ -10,15 +10,15 @@ class FetchGroupMessage extends PacketTransformer<typeof proto.SsoGetGroupMsgRes
build (groupUin: number, startSeq: number, endSeq: number): OidbPacket {
const req = new NapProtoMsg(proto.SsoGetGroupMsg).encode({
info: {
groupUin: groupUin,
groupUin,
startSequence: startSeq,
endSequence: endSeq
endSequence: endSeq,
},
direction: true
direction: true,
});
return {
cmd: 'trpc.msg.register_proxy.RegisterProxy.SsoGetGroupMsg',
data: PacketBufBuilder(req)
data: PacketBufBuilder(req),
};
}

View File

@ -16,9 +16,9 @@ class UploadForwardMsg extends PacketTransformer<typeof proto.SendLongMsgResp> {
action: [{
actionCommand: 'MultiMsg',
actionData: {
msgBody: msgBody
}
}]
msgBody,
},
}],
}
);
const payload = zlib.gzipSync(Buffer.from(longMsgResultData));
@ -29,17 +29,17 @@ class UploadForwardMsg extends PacketTransformer<typeof proto.SendLongMsgResp> {
uid: {
uid: groupUin === 0 ? selfUid : groupUin.toString(),
},
groupUin: groupUin,
payload: payload
groupUin,
payload,
},
settings: {
field1: 4, field2: 1, field3: 7, field4: 0
}
field1: 4, field2: 1, field3: 7, field4: 0,
},
}
);
return {
cmd: 'trpc.group.long_msg_interface.MsgService.SsoSendLongMsg',
data: PacketBufBuilder(req)
data: PacketBufBuilder(req),
};
}

View File

@ -2,91 +2,91 @@ import { ProtoField, ScalarType } from '@napneko/nap-proto-core';
import { PushMsgBody } from '@/core/packet/transformer/proto';
export const LongMsgResult = {
action: ProtoField(2, () => LongMsgAction, false, true)
action: ProtoField(2, () => LongMsgAction, false, true),
};
export const LongMsgAction = {
actionCommand: ProtoField(1, ScalarType.STRING),
actionData: ProtoField(2, () => LongMsgContent)
actionData: ProtoField(2, () => LongMsgContent),
};
export const LongMsgContent = {
msgBody: ProtoField(1, () => PushMsgBody, false, true)
msgBody: ProtoField(1, () => PushMsgBody, false, true),
};
export const RecvLongMsgReq = {
info: ProtoField(1, () => RecvLongMsgInfo, true),
settings: ProtoField(15, () => LongMsgSettings, true)
settings: ProtoField(15, () => LongMsgSettings, true),
};
export const RecvLongMsgInfo = {
uid: ProtoField(1, () => LongMsgUid, true),
resId: ProtoField(2, ScalarType.STRING, true),
acquire: ProtoField(3, ScalarType.BOOL)
acquire: ProtoField(3, ScalarType.BOOL),
};
export const LongMsgUid = {
uid: ProtoField(2, ScalarType.STRING, true)
uid: ProtoField(2, ScalarType.STRING, true),
};
export const LongMsgSettings = {
field1: ProtoField(1, ScalarType.UINT32),
field2: ProtoField(2, ScalarType.UINT32),
field3: ProtoField(3, ScalarType.UINT32),
field4: ProtoField(4, ScalarType.UINT32)
field4: ProtoField(4, ScalarType.UINT32),
};
export const RecvLongMsgResp = {
result: ProtoField(1, () => RecvLongMsgResult),
settings: ProtoField(15, () => LongMsgSettings)
settings: ProtoField(15, () => LongMsgSettings),
};
export const RecvLongMsgResult = {
resId: ProtoField(3, ScalarType.STRING),
payload: ProtoField(4, ScalarType.BYTES)
payload: ProtoField(4, ScalarType.BYTES),
};
export const SendLongMsgReq = {
info: ProtoField(2, () => SendLongMsgInfo),
settings: ProtoField(15, () => LongMsgSettings)
settings: ProtoField(15, () => LongMsgSettings),
};
export const SendLongMsgInfo = {
type: ProtoField(1, ScalarType.UINT32),
uid: ProtoField(2, () => LongMsgUid, true),
groupUin: ProtoField(3, ScalarType.UINT32, true),
payload: ProtoField(4, ScalarType.BYTES, true)
payload: ProtoField(4, ScalarType.BYTES, true),
};
export const SendLongMsgResp = {
result: ProtoField(2, () => SendLongMsgResult),
settings: ProtoField(15, () => LongMsgSettings)
settings: ProtoField(15, () => LongMsgSettings),
};
export const SendLongMsgResult = {
resId: ProtoField(3, ScalarType.STRING)
resId: ProtoField(3, ScalarType.STRING),
};
export const SsoGetGroupMsg = {
info: ProtoField(1, () => SsoGetGroupMsgInfo),
direction: ProtoField(2, ScalarType.BOOL)
direction: ProtoField(2, ScalarType.BOOL),
};
export const SsoGetGroupMsgInfo = {
groupUin: ProtoField(1, ScalarType.UINT32),
startSequence: ProtoField(2, ScalarType.UINT32),
endSequence: ProtoField(3, ScalarType.UINT32)
endSequence: ProtoField(3, ScalarType.UINT32),
};
export const SsoGetGroupMsgResponse = {
body: ProtoField(3, () => SsoGetGroupMsgResponseBody)
body: ProtoField(3, () => SsoGetGroupMsgResponseBody),
};
export const SsoGetGroupMsgResponseBody = {
groupUin: ProtoField(3, ScalarType.UINT32),
startSequence: ProtoField(4, ScalarType.UINT32),
endSequence: ProtoField(5, ScalarType.UINT32),
messages: ProtoField(6, () => PushMsgBody, false, true)
messages: ProtoField(6, () => PushMsgBody, false, true),
};
export const SsoGetRoamMsg = {
@ -94,23 +94,23 @@ export const SsoGetRoamMsg = {
time: ProtoField(2, ScalarType.UINT32),
random: ProtoField(3, ScalarType.UINT32),
count: ProtoField(4, ScalarType.UINT32),
direction: ProtoField(5, ScalarType.BOOL)
direction: ProtoField(5, ScalarType.BOOL),
};
export const SsoGetRoamMsgResponse = {
friendUid: ProtoField(3, ScalarType.STRING),
timestamp: ProtoField(5, ScalarType.UINT32),
random: ProtoField(6, ScalarType.UINT32),
messages: ProtoField(7, () => PushMsgBody, false, true)
messages: ProtoField(7, () => PushMsgBody, false, true),
};
export const SsoGetC2cMsg = {
friendUid: ProtoField(2, ScalarType.STRING, true),
startSequence: ProtoField(3, ScalarType.UINT32),
endSequence: ProtoField(4, ScalarType.UINT32)
endSequence: ProtoField(4, ScalarType.UINT32),
};
export const SsoGetC2cMsgResponse = {
friendUid: ProtoField(4, ScalarType.STRING),
messages: ProtoField(7, () => PushMsgBody, false, true)
messages: ProtoField(7, () => PushMsgBody, false, true),
};

View File

@ -116,7 +116,7 @@ export const MarketFace = {
};
export const MarketFacePbRes = {
field8: ProtoField(8, ScalarType.INT32)
field8: ProtoField(8, ScalarType.INT32),
};
export const CustomFace = {
@ -356,5 +356,5 @@ export const QSmallFaceExtra = {
};
export const MarkdownData = {
content: ProtoField(1, ScalarType.STRING)
content: ProtoField(1, ScalarType.STRING),
};

View File

@ -7,7 +7,7 @@ import {
ResponseForward,
ResponseGrp, RichText,
Trans0X211,
WPATmp
WPATmp,
} from '@/core/packet/transformer/proto';
export const ContentHead = {
@ -136,4 +136,3 @@ export const RoutingHead = {
wpaTmp: ProtoField(6, () => WPATmp, true),
trans0X211: ProtoField(15, () => Trans0X211, true),
};