fix(onebot): decode user status property list (#330)

This commit is contained in:
DrSmoothl committed 2026-08-09 11:28:14 +08:00
1 parent 7eea8059cc
commit 49439370e1
5 files changed
+86 -28

No files matched your search

+11 -5
View File
@@ -104,14 +104,20 @@ export class ExtrasApi {
// ─────────────── Stranger online/ext status (0xFE1_2) ───────────────
/**
* Returns `null` on transport / decode failure rather than throwing,
* so the OneBot action can produce a clean retcode without try/catch
* gymnastics. Namespace throws on transport failure → swallow here.
* Keeps the action response user-safe while retaining the underlying
* failure in the service log for diagnosis.
*/
async getStrangerStatus(uin: number): Promise<StrangerStatus | null> {
try {
return await GetStrangerStatus.invoke(this.ctx, { uin });
} catch {
const status = await GetStrangerStatus.invoke(this.ctx, { uin });
if (!status) log.warn('user status query returned no status target=%d', uin);
return status;
} catch (error) {
log.warn(
'user status query failed target=%d: %s',
uin,
error instanceof Error ? error.message : String(error),
);
return null;
}
}