fix(ask): prototype 拦截器替代 waterfall hook + TG 原生按钮作答
根因:dsh 0.1.5-rc.1 把 'user-questions/request' waterfall 分发到 per-fiber events 注册表,其他 fiber 的 ctx.on 监听(含本插件)永远收不到 分发(实测 root/global/agent 作用域监听全部落空)。 修复:包装 UserQuestionService.prototype.ask(类跨实例共享),无论哪个 fiber/实例发起的 ask 都能拦截到 agent+questions;TG 答案与原 ask 竞速, 保留 dual-path 语义;stop 时恢复原型,热重载不叠加。 功能(应用户要求): - 提问前显式发送预告文本消息 - 选项改用 TG 原生 inline keyboard 按钮(单选即点即答,多选带提交键) - 文本作答保留并与按钮作答合并,逐题累计、齐题自动提交 - 附带修复:Telegram API 调用加 15s 客户端超时(代理挂死会卡死通知队列) Co-authored-by: Shirobana Agent Bot <tg-bridge>
This commit is contained in:
co-authored by
Shirobana Agent Bot <tg-bridge>
parent
4039dec03c
commit
da06485d64
+8
-2
@@ -153,12 +153,17 @@ export class TelegramClient implements TelegramClientLike {
|
||||
return message.split(this.token).join('***')
|
||||
}
|
||||
|
||||
private async call<T>(method: string, body?: Record<string, unknown>): Promise<T> {
|
||||
private async call<T>(method: string, body?: Record<string, unknown>, timeoutMs = 15_000): Promise<T> {
|
||||
const url = `${this.baseUrl}/bot${this.token}/${method}`
|
||||
try {
|
||||
const init: RequestInit = {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
// Without a client-side timeout a stalled proxy connection hangs the
|
||||
// request forever — and the serialized notice queue wedges behind it,
|
||||
// silently swallowing every later tool/ask notice. TimeoutError is
|
||||
// caught below and surfaces as a normal (retryable) failure.
|
||||
signal: AbortSignal.timeout(timeoutMs),
|
||||
}
|
||||
if (body !== undefined) {
|
||||
init.body = JSON.stringify(body)
|
||||
@@ -187,7 +192,8 @@ export class TelegramClient implements TelegramClientLike {
|
||||
if (offset !== undefined) {
|
||||
body.offset = offset
|
||||
}
|
||||
return this.call<TelegramUpdate[]>('getUpdates', body)
|
||||
// Long-poll: client-side abort must outlive the server-side hold.
|
||||
return this.call<TelegramUpdate[]>('getUpdates', body, this.pollingTimeoutSec * 1000 + 10_000)
|
||||
}
|
||||
|
||||
async sendMessage(
|
||||
|
||||
Reference in New Issue
Block a user