SnowCat 雪猫底层全源码:NapCat 4.18.28 底座 + SnowLuma 能力移植 + V8 通道适配 9.9.37
26 包 monorepo(TS 全源码): - snowcat-core: NT 内核 API 封装 + listener(含 9.9.37 六回调适配)+ Packet 发包 - snowcat-onebot: OneBot v11 全动作 + MCP Streamable HTTP 适配器 + 稳定线 - snowcat-webui-frontend/backend: 雪猫控制台(React+HeroUI) - snowcat-shell: 单文件 bundle 出口(vite inlineDynamicImports) - snowcat-native: napi2native / MoeHoo / ffmpeg / pty 运行时 - 56 项 SnowLuma 独门动作移植(qzone 全家桶/群相册/装扮/闪照/收藏) - 工具件: 解包器/启动器/便携制作器/doctor GitHub 关联已全量指向 DandanLLab/SnowCatQQ
This commit is contained in:
commit
b9655a5ab1
1048 files changed
+130851
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { describe, expect, test, vi } from 'vitest';
|
||||
import { NapProtoMsg } from 'snowcat-protobuf';
|
||||
import { OidbSvcTrpcTcpBase } from '@/snowcat-core/packet/transformer/proto/oidb/OidbBase';
|
||||
import { OidbSvcTrpcTcp0XF90 } from '@/snowcat-core/packet/transformer/proto/oidb/Oidb.0xf90';
|
||||
import SetGroupTodo from '@/snowcat-core/packet/transformer/action/SetGroupTodo';
|
||||
import CompleteGroupTodo from '@/snowcat-core/packet/transformer/action/CompleteGroupTodo';
|
||||
import CancelGroupTodo from '@/snowcat-core/packet/transformer/action/CancelGroupTodo';
|
||||
|
||||
vi.mock('@/snowcat-core/packet/transformer/base', () => ({
|
||||
PacketTransformer: class PacketTransformer {
|
||||
protected msgBuilder: unknown;
|
||||
|
||||
constructor () {
|
||||
this.msgBuilder = undefined;
|
||||
}
|
||||
},
|
||||
PacketBufBuilder: (str: Uint8Array) => Buffer.from(str),
|
||||
}));
|
||||
|
||||
const decodePacket = (data: Buffer) => {
|
||||
const base = new NapProtoMsg(OidbSvcTrpcTcpBase).decode(data);
|
||||
const body = new NapProtoMsg(OidbSvcTrpcTcp0XF90).decode(base.body);
|
||||
return { base, body };
|
||||
};
|
||||
|
||||
describe('Group todo packet builder', () => {
|
||||
test('builds OIDB 0xF90 subCommand 1 for set', () => {
|
||||
const packet = SetGroupTodo.build(123456, '789');
|
||||
const { base, body } = decodePacket(packet.data);
|
||||
|
||||
expect(packet.cmd).toBe('OidbSvcTrpcTcp.0xF90_1');
|
||||
expect(base.command).toBe(0xF90);
|
||||
expect(base.subCommand).toBe(1);
|
||||
expect(body.groupUin).toBe(123456);
|
||||
expect(body.msgSeq).toBe('789');
|
||||
});
|
||||
|
||||
test('builds OIDB 0xF90 subCommand 2 for complete', () => {
|
||||
const packet = CompleteGroupTodo.build(123456, '789');
|
||||
const { base, body } = decodePacket(packet.data);
|
||||
|
||||
expect(packet.cmd).toBe('OidbSvcTrpcTcp.0xF90_2');
|
||||
expect(base.command).toBe(0xF90);
|
||||
expect(base.subCommand).toBe(2);
|
||||
expect(body.groupUin).toBe(123456);
|
||||
expect(body.msgSeq).toBe('789');
|
||||
});
|
||||
|
||||
test('builds OIDB 0xF90 subCommand 3 for cancel', () => {
|
||||
const packet = CancelGroupTodo.build(123456, '789');
|
||||
const { base, body } = decodePacket(packet.data);
|
||||
|
||||
expect(packet.cmd).toBe('OidbSvcTrpcTcp.0xF90_3');
|
||||
expect(base.command).toBe(0xF90);
|
||||
expect(base.subCommand).toBe(3);
|
||||
expect(body.groupUin).toBe(123456);
|
||||
expect(body.msgSeq).toBe('789');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user