Бот для капчи в чатах
Roman Sergienko
8 hours ago 0b66bae39759a5553d8ce46131dca3026325097b
Fix RP action upload response handling
2 files modified
18 ■■■■■ changed files
web/templates/rp.html 16 ●●●●● patch | view | raw | blame | history
web/views.py 2 ●●●●● patch | view | raw | blame | history
web/templates/rp.html
@@ -61,7 +61,13 @@
            method: 'POST',
            body: formData
        });
        const result = await response.json();
        const body = await response.text();
        let result;
        try {
            result = JSON.parse(body);
        } catch (err) {
            throw new Error(`Сервер вернул не JSON (HTTP ${response.status}): ${body.slice(0, 240)}`);
        }
        
        msgEl.classList.remove('hidden');
        if (result.ok) {
@@ -93,7 +99,13 @@
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: new URLSearchParams({action_id: actionId, chat_id: chatId})
            });
            const result = await response.json();
            const body = await response.text();
            let result;
            try {
                result = JSON.parse(body);
            } catch (err) {
                throw new Error(`Сервер вернул не JSON (HTTP ${response.status}): ${body.slice(0, 240)}`);
            }
            
            if (result.ok) {
                btn.closest('.flex').remove();
web/views.py
@@ -656,7 +656,7 @@
                    file_path = gif_dir / file_name
                    
                    # Сохраняем файл
                    content = await file.read()
                    content = file.file.read()
                    with open(file_path, "wb") as f:
                        f.write(content)