alpha-test
This commit is contained in:
88
scripts/checkCallbackHandlers.js
Normal file
88
scripts/checkCallbackHandlers.js
Normal file
@@ -0,0 +1,88 @@
|
||||
// Скрипт для анализа и отладки проблем с обработчиками коллбэков
|
||||
require('dotenv').config();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
function analyzeCallbackHandlers() {
|
||||
const filePath = path.join(__dirname, '..', 'src', 'handlers', 'callbackHandlers.ts');
|
||||
const content = fs.readFileSync(filePath, 'utf-8');
|
||||
|
||||
// Проверяем наличие реализаций методов
|
||||
const methodsToCheck = [
|
||||
'handleCreateProfile',
|
||||
'handleGenderSelection',
|
||||
'handleViewMyProfile',
|
||||
'handleEditProfile',
|
||||
'handleManagePhotos',
|
||||
'handleStartBrowsing',
|
||||
'handleSettings'
|
||||
];
|
||||
|
||||
const issues = [];
|
||||
let debugInfo = [];
|
||||
|
||||
methodsToCheck.forEach(method => {
|
||||
debugInfo.push(`Проверяем метод: ${method}`);
|
||||
|
||||
// Проверяем наличие полной реализации метода (не только сигнатуры)
|
||||
const methodSignatureRegex = new RegExp(`async\\s+${method}\\s*\\([^)]*\\)\\s*:\\s*Promise<void>\\s*{`, 'g');
|
||||
const hasSignature = methodSignatureRegex.test(content);
|
||||
|
||||
const methodBodyRegex = new RegExp(`async\\s+${method}\\s*\\([^)]*\\)\\s*:\\s*Promise<void>\\s*{[\\s\\S]+?}`, 'g');
|
||||
const methodMatch = content.match(methodBodyRegex);
|
||||
|
||||
debugInfo.push(` Сигнатура найдена: ${hasSignature}`);
|
||||
debugInfo.push(` Реализация найдена: ${methodMatch !== null}`);
|
||||
|
||||
if (methodMatch) {
|
||||
const methodContent = methodMatch[0];
|
||||
debugInfo.push(` Длина метода: ${methodContent.length} символов`);
|
||||
|
||||
// Проверяем, содержит ли метод только заглушку
|
||||
const isStub = methodContent.includes('// Заглушка метода') ||
|
||||
(!methodContent.includes('await') && methodContent.split('\n').length <= 3);
|
||||
|
||||
if (isStub) {
|
||||
issues.push(`❌ Метод ${method} содержит только заглушку, нет реальной реализации`);
|
||||
} else {
|
||||
debugInfo.push(` Метод ${method} имеет полную реализацию`);
|
||||
}
|
||||
} else if (hasSignature) {
|
||||
issues.push(`❌ Метод ${method} имеет только сигнатуру, но нет реализации`);
|
||||
} else {
|
||||
issues.push(`❌ Метод ${method} не найден в файле`);
|
||||
}
|
||||
});
|
||||
|
||||
// Проверяем регистрацию обработчиков для NotificationHandlers
|
||||
const notificationHandlersRegex = /this\.notificationHandlers\s*=\s*new\s+NotificationHandlers\(bot\);/g;
|
||||
const hasNotificationHandlers = notificationHandlersRegex.test(content);
|
||||
debugInfo.push(`NotificationHandlers инициализирован: ${hasNotificationHandlers}`);
|
||||
|
||||
// Проверяем обработку коллбэка notifications
|
||||
const notificationsCallbackRegex = /if\s*\(data\s*===\s*['"]notifications['"].*?\)/g;
|
||||
const hasNotificationsCallback = notificationsCallbackRegex.test(content);
|
||||
debugInfo.push(`Обработчик для callback 'notifications' найден: ${hasNotificationsCallback}`);
|
||||
|
||||
// Выводим результаты
|
||||
console.log('\n=== Анализ CallbackHandlers.ts ===\n');
|
||||
if (issues.length > 0) {
|
||||
console.log('НАЙДЕНЫ ПРОБЛЕМЫ:');
|
||||
issues.forEach(issue => console.log(issue));
|
||||
console.log('\nРЕКОМЕНДАЦИИ:');
|
||||
console.log('1. Восстановите оригинальные реализации методов вместо заглушек');
|
||||
console.log('2. Убедитесь, что методы содержат необходимую бизнес-логику');
|
||||
console.log('3. Проверьте, что все коллбэки правильно обрабатываются');
|
||||
} else {
|
||||
console.log('✅ Проблем не обнаружено');
|
||||
}
|
||||
|
||||
console.log('\n=== Отладочная информация ===\n');
|
||||
debugInfo.forEach(info => console.log(info));
|
||||
|
||||
// Проверяем количество методов в файле
|
||||
const asyncMethodsCount = (content.match(/async\s+handle[A-Za-z]+\s*\(/g) || []).length;
|
||||
console.log(`\nВсего async методов в файле: ${asyncMethodsCount}`);
|
||||
}
|
||||
|
||||
analyzeCallbackHandlers();
|
||||
Reference in New Issue
Block a user