alpha-test

This commit is contained in:
2025-09-18 13:46:35 +09:00
parent 85027a7747
commit 5ea3e8c1f3
27 changed files with 5887 additions and 174 deletions

View File

@@ -0,0 +1,104 @@
/**
* Скрипт для проверки и исправления регистрации NotificationHandlers в bot.ts
*/
const fs = require('fs');
const path = require('path');
const botFilePath = path.join(__dirname, '../src/bot.ts');
// Проверка существования файла bot.ts
if (!fs.existsSync(botFilePath)) {
console.error(`❌ Файл ${botFilePath} не найден`);
process.exit(1);
}
// Чтение содержимого файла bot.ts
let botContent = fs.readFileSync(botFilePath, 'utf8');
// Проверка импорта NotificationHandlers
if (!botContent.includes('import { NotificationHandlers }')) {
console.log('Добавляем импорт NotificationHandlers в bot.ts...');
// Находим последний импорт
const importRegex = /^import.*?;/gms;
const matches = [...botContent.matchAll(importRegex)];
if (matches.length > 0) {
const lastImport = matches[matches.length - 1][0];
const lastImportIndex = botContent.lastIndexOf(lastImport) + lastImport.length;
// Добавляем импорт NotificationHandlers
botContent =
botContent.slice(0, lastImportIndex) +
'\nimport { NotificationHandlers } from \'./handlers/notificationHandlers\';\n' +
botContent.slice(lastImportIndex);
console.log('✅ Импорт NotificationHandlers добавлен');
} else {
console.error('❌ Не удалось найти место для добавления импорта');
}
}
// Проверка объявления NotificationHandlers в классе
if (!botContent.includes('private notificationHandlers')) {
console.log('Добавляем объявление notificationHandlers в класс...');
const classPropertiesRegex = /class TelegramTinderBot {([^}]+?)constructor/s;
const classPropertiesMatch = botContent.match(classPropertiesRegex);
if (classPropertiesMatch) {
const classProperties = classPropertiesMatch[1];
const updatedProperties = classProperties + ' private notificationHandlers: NotificationHandlers;\n ';
botContent = botContent.replace(classPropertiesRegex, `class TelegramTinderBot {${updatedProperties}constructor`);
console.log('✅ Объявление notificationHandlers добавлено');
} else {
console.error('❌ Не удалось найти место для добавления объявления notificationHandlers');
}
}
// Проверка создания экземпляра NotificationHandlers в конструкторе
if (!botContent.includes('this.notificationHandlers = new NotificationHandlers')) {
console.log('Добавляем инициализацию notificationHandlers в конструктор...');
const initializationRegex = /(this\.callbackHandlers = new CallbackHandlers[^;]+;)/;
const initializationMatch = botContent.match(initializationRegex);
if (initializationMatch) {
const callbackHandlersInit = initializationMatch[1];
const updatedInit = callbackHandlersInit + '\n this.notificationHandlers = new NotificationHandlers(this.bot);';
botContent = botContent.replace(initializationRegex, updatedInit);
console.log('✅ Инициализация notificationHandlers добавлена');
} else {
console.error('❌ Не удалось найти место для добавления инициализации notificationHandlers');
}
}
// Проверка регистрации notificationHandlers в методе registerHandlers
if (!botContent.includes('this.notificationHandlers.register()')) {
console.log('Добавляем регистрацию notificationHandlers...');
const registerHandlersRegex = /(private registerHandlers\(\): void {[^}]+?)}/s;
const registerHandlersMatch = botContent.match(registerHandlersRegex);
if (registerHandlersMatch) {
const registerHandlersBody = registerHandlersMatch[1];
const updatedBody = registerHandlersBody + '\n // Обработчики уведомлений\n this.notificationHandlers.register();\n }';
botContent = botContent.replace(registerHandlersRegex, updatedBody);
console.log('✅ Регистрация notificationHandlers добавлена');
} else {
console.error('❌ Не удалось найти место для добавления регистрации notificationHandlers');
}
}
// Запись обновленного содержимого в файл
fs.writeFileSync(botFilePath, botContent, 'utf8');
console.log('✅ Файл bot.ts успешно обновлен');
console.log('🔔 Перезапустите бота для применения изменений');