fix: fileId

This commit is contained in:
手瓜一十雪
2024-09-01 12:17:17 +08:00
parent 77505a6f5b
commit ae009f98c1
3 changed files with 12 additions and 7 deletions

View File

@@ -25,24 +25,26 @@ export async function solveAsyncProblem<T extends (...args: any[]) => Promise<an
}
export class FileNapCatOneBotUUID {
static encodeModelId(peer: Peer, modelId: string): string {
return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}`;
static encodeModelId(peer: Peer, modelId: string, fileId: string): string {
return `NapCatOneBot-ModelIdFile-${peer.chatType}-${peer.peerUid}-${modelId}-${fileId}`;
}
static decodeModelId(uuid: string): undefined | {
peer: Peer,
modelId: string
modelId: string,
fileId: string
} {
if (!uuid.startsWith('NapCatOneBot-ModelIdFile-')) return undefined;
const data = uuid.split('-');
if (data.length !== 5) return undefined;
const [, , chatType, peerUid, modelId] = data;
if (data.length !== 6) return undefined;
const [, , chatType, peerUid, modelId, fileId] = data;
return {
peer: {
chatType: chatType as any,
peerUid: peerUid,
},
modelId,
fileId
};
}