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:
Dorian
2026-03-09 19:02:35 +00:00
co-authored by Claude Opus 4.6
parent 95ed80335a
commit 68e292183a
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -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)