fix(onebot): resolve voice transcription for signed message IDs

Allow voice transcription results to complete for messages with negative IDs while preserving existing message identities and account isolation.

Report unmatched transcription results accurately and document the signed message ID contract.

Fixes #554
This commit is contained in:
DrSmoothl committed 2026-10-20 13:27:40 +08:00
1 parent 79522d949f
commit 76846f40b1
10 files changed
+153 -18

No files matched your search

@@ -5,8 +5,12 @@ interface Pending {
const pending = new Map<string, Pending>();
export function pttTransKey(selfUin: number, msgId: number): string {
return selfUin + ':' + msgId;
export function pttTransKey(selfUin: number, msgId: number | bigint): string {
if (typeof msgId === 'number' && !Number.isSafeInteger(msgId)) {
throw new RangeError('PTT message id must be a safe integer or bigint');
}
return selfUin + ':' + BigInt.asIntN(64, BigInt(msgId));
}
/** Register before triggering; only this request may settle its own response or timeout. */
@@ -53,6 +57,13 @@ export function requestPttTransText(
}
/** QQ push results identify the account and message, not an individual trigger request. */
export function deliverPttTransText(key: string, text: string): void {
pending.get(key)?.resolve(text);
export function deliverPttTransText(key: string, text: string): boolean {
const waiter = pending.get(key);
if (!waiter) {
return false;
}
waiter.resolve(text);
return true;
}