fix: polling bots play practice fights as human players in browser
Polling bots have no external script running during practice mode, so the poll would time out giving empty answers. Now overrides the webhook URL to human.local so the browser UI handles challenges. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
95ed80335a
commit
68e292183a
@@ -11,7 +11,7 @@ import { runFight, runFightAsync, isInFight, getActiveFightId } from '../engine/
|
||||
import { fightEvents } from '../engine/events.js'
|
||||
import { botRateLimit } from '../middleware/rate-limit.js'
|
||||
import { getPendingChallenge, getPendingAnswers, submitHumanResponse } from '../engine/human-responses.js'
|
||||
import { getPendingPollChallenge, submitPollResponse } from '../engine/poll-responses.js'
|
||||
import { getPendingPollChallenge, submitPollResponse, isPollingBot } from '../engine/poll-responses.js'
|
||||
import { authenticateBot } from '../middleware/bot-auth.js'
|
||||
import { checkAnswer } from '../engine/answers.js'
|
||||
|
||||
@@ -310,7 +310,9 @@ fightsRouter.post('/practice/:botId', botRateLimit(10_000), async (c) => {
|
||||
|
||||
let fightId: string
|
||||
try {
|
||||
fightId = await runFightAsync(botId, opponent.id, 'free')
|
||||
// Polling bots play practice as human players (answer in browser)
|
||||
const overrides = isPollingBot(bot.webhookUrl) ? { botAWebhookUrl: 'http://human.local/' } : undefined
|
||||
fightId = await runFightAsync(botId, opponent.id, 'free', overrides)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : 'Fight failed to start'
|
||||
return c.json({ error: msg }, 400)
|
||||
|
||||
Reference in New Issue
Block a user