Files
NapCatQQ/packages/napcat-core/packet/transformer/base.ts
T
手瓜一十雪 36aa08a8f5 Replace nap-proto-core with napcat-protobuf package
Switched all imports from '@napneko/nap-proto-core' to the new 'napcat-protobuf' package across napcat-core and related packages. Updated dependencies and references to support the new package structure, improving maintainability and workspace integration.
2025-11-14 16:19:26 +08:00

26 lines
674 B
TypeScript

import { NapProtoDecodeStructType } from 'napcat-protobuf';
import { PacketMsgBuilder } from '@/napcat-core/packet/message/builder';
export type PacketBuf = Buffer & { readonly hexNya: unique symbol; };
export const PacketBufBuilder = (str: Uint8Array): PacketBuf => {
return Buffer.from(str) as PacketBuf;
};
export interface OidbPacket {
cmd: string;
data: PacketBuf;
}
export abstract class PacketTransformer<T> {
protected msgBuilder: PacketMsgBuilder;
constructor () {
this.msgBuilder = new PacketMsgBuilder();
}
abstract build (...args: any[]): OidbPacket | Promise<OidbPacket>;
abstract parse (data: Buffer): NapProtoDecodeStructType<T>;
}