fix: make optional services non-blocking

This commit is contained in:
owo
2026-09-15 21:37:16 +08:00
parent f3f6a3ebaf
commit e748132541
6 changed files with 48 additions and 8 deletions
+19 -1
View File
@@ -1345,7 +1345,25 @@ export class TelegramBridge {
}
// ── ask_user_question: TG answering via dual-path race with the UI ──
userQuestions() {
return this.ctx.userQuestions;
const ctx = this.ctx;
if (typeof ctx.get === 'function') {
try {
const service = ctx.get('userQuestions');
if (service)
return service;
}
catch {
// Continue to the plain-object fallback used by tests and simple hosts.
}
}
try {
return Object.prototype.hasOwnProperty.call(ctx, 'userQuestions')
? ctx.userQuestions
: undefined;
}
catch {
return undefined;
}
}
/**
* Wrap the UI provider's ask() so Telegram gets a parallel answer path.