Files
trading_bot_v3/app/api/test-captcha/route.ts
mindesbunister b91d35ad60 Fix timeframe selection bug and syntax errors
- Fixed critical timeframe mapping bug where '4h' was interpreted as '4 minutes'
- Now prioritizes minute values: '4h' -> ['240', '240m', '4h', '4H']
- Added fallback mechanism to enter exact minutes (240) in custom interval input
- Fixed multiple syntax errors in tradingview-automation.ts:
  * Missing closing parentheses in console.log statements
  * Missing parentheses in writeFile and JSON.parse calls
  * Fixed import statements for fs and path modules
  * Added missing utility methods (fileExists, markCaptchaDetected, etc.)
- Enhanced timeframe selection with comprehensive hour mappings (1h, 2h, 4h, 6h, 12h)
- Added detailed logging for debugging timeframe selection
- Application now builds successfully without syntax errors
- Interval selection should work correctly for all common timeframes

Key improvements:
 4h chart selection now works correctly (240 minutes, not 4 minutes)
 All TypeScript compilation errors resolved
 Enhanced debugging output for timeframe mapping
 Robust fallback mechanisms for interval selection
 Docker integration and manual CAPTCHA handling maintained
2025-07-13 13:57:35 +02:00

45 lines
1.5 KiB
TypeScript

import { NextRequest, NextResponse } from 'next/server'
import { tradingViewAutomation } from '../../../lib/tradingview-automation'
export async function POST(req: NextRequest) {
try {
console.log('🧪 Testing manual CAPTCHA interaction...')
// Initialize browser with manual CAPTCHA support
await tradingViewAutomation.init()
// Try a login that will likely trigger CAPTCHA
const loginResult = await tradingViewAutomation.smartLogin()
return NextResponse.json({
success: loginResult,
message: loginResult ? 'Login successful!' : 'Login failed or CAPTCHA interaction required',
timestamp: new Date().toISOString()
})
} catch (error: any) {
console.error('Manual CAPTCHA test failed:', error)
return NextResponse.json({
error: error.message,
timestamp: new Date().toISOString()
}, { status: 500 })
}
}
export async function GET(req: NextRequest) {
return NextResponse.json({
message: 'Manual CAPTCHA test endpoint',
instructions: [
'1. Send a POST request to this endpoint to trigger login with manual CAPTCHA support',
'2. If CAPTCHA is detected, a browser window will appear (non-headless mode)',
'3. Manually click the "I am not a robot" checkbox',
'4. Complete any additional challenges',
'5. The automation will continue once CAPTCHA is solved'
],
environment: {
allowManualCaptcha: process.env.ALLOW_MANUAL_CAPTCHA === 'true',
display: process.env.DISPLAY
}
})
}