fix: claude加入首条消息检测应对claude不说话的情况

This commit is contained in:
ikechan8370 2023-04-16 13:48:35 +08:00
parent a68055c11d
commit 1e5010e9f1

View file

@ -1,6 +1,6 @@
import { Config } from '../config.js'
import slack from '@slack/bolt'
import delay from "delay";
import delay from 'delay'
let proxy
if (Config.proxy) {
try {
@ -38,6 +38,7 @@ export class SlackClaudeClient {
})
let ts = sendResponse.ts
let response = '_Typing…_'
let tryTimes = 0
while (response.trim().endsWith('_Typing…_')) {
let replies = await this.app.client.conversations.history({
token: this.config.slackUserToken,
@ -55,6 +56,10 @@ export class SlackClaudeClient {
}
}
await delay(500)
if (tryTimes > 10 && response === '_Typing…_') {
// 过了5秒还没任何回复就重新发一下试试
return await this.sendMessage(prompt)
}
}
return response
}