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

@@ -4,6 +4,7 @@ import { MatchingService } from '../services/matchingService';
import { ChatService } from '../services/chatService';
import { Profile } from '../models/Profile';
import { MessageHandlers } from './messageHandlers';
import { NotificationHandlers } from './notificationHandlers';
import { ProfileEditController } from '../controllers/profileEditController';
import { EnhancedChatHandlers } from './enhancedChatHandlers';
import { VipController } from '../controllers/vipController';
@@ -23,6 +24,7 @@ export class CallbackHandlers {
private vipController: VipController;
private vipService: VipService;
private translationController: TranslationController;
private notificationHandlers?: NotificationHandlers;
private likeBackHandler: LikeBackHandler;
constructor(bot: TelegramBot, messageHandlers: MessageHandlers) {
@@ -36,6 +38,12 @@ export class CallbackHandlers {
this.vipController = new VipController(bot);
this.vipService = new VipService();
this.translationController = new TranslationController();
// Создаем экземпляр NotificationHandlers
try {
this.notificationHandlers = new NotificationHandlers(bot);
} catch (error) {
console.error('Failed to initialize NotificationHandlers:', error);
}
this.likeBackHandler = new LikeBackHandler(bot);
}
@@ -272,6 +280,41 @@ export class CallbackHandlers {
await this.handleSettings(chatId, telegramId);
}
// Настройки уведомлений
else if (data === 'notifications') {
if (this.notificationHandlers) {
const userId = await this.profileService.getUserIdByTelegramId(telegramId);
if (!userId) {
await this.bot.answerCallbackQuery(query.id, { text: '❌ Вы не зарегистрированы.' });
return;
}
const settings = await this.notificationHandlers.getNotificationService().getNotificationSettings(userId);
await this.notificationHandlers.sendNotificationSettings(chatId, settings);
} else {
await this.handleNotificationSettings(chatId, telegramId);
}
}
// Обработка переключения настроек уведомлений
else if (data.startsWith('notif_toggle:') ||
data === 'notif_time' ||
data.startsWith('notif_time_set:') ||
data === 'notif_dnd' ||
data.startsWith('notif_dnd_set:') ||
data === 'notif_dnd_time' ||
data.startsWith('notif_dnd_time_set:') ||
data === 'notif_dnd_time_custom') {
// Делегируем обработку в NotificationHandlers, если он доступен
if (this.notificationHandlers) {
// Эти коллбэки уже обрабатываются в NotificationHandlers, поэтому здесь ничего не делаем
// NotificationHandlers уже зарегистрировал свои обработчики в register()
} else {
await this.bot.answerCallbackQuery(query.id, {
text: 'Функция настройки уведомлений недоступна.',
show_alert: true
});
}
}
else {
await this.bot.answerCallbackQuery(query.id, {
text: 'Функция в разработке!',
@@ -870,13 +913,7 @@ export class CallbackHandlers {
);
}
// Настройки уведомлений
async handleNotificationSettings(chatId: number, telegramId: string): Promise<void> {
await this.bot.sendMessage(
chatId,
'🔔 Настройки уведомлений будут доступны в следующем обновлении!'
);
}
// Настройки уведомлений - реализация перенесена в расширенную версию
// Как это работает
async handleHowItWorks(chatId: number): Promise<void> {
@@ -1578,7 +1615,7 @@ export class CallbackHandlers {
try {
// Проверяем VIP статус пользователя
const user = await this.profileService.getUserByTelegramId(telegramId);
if (!user || !user.isPremium) {
if (!user || !user.premium) { // Изменено с isPremium на premium, чтобы соответствовать названию колонки в базе данных
const keyboard = {
inline_keyboard: [
[
@@ -2240,4 +2277,27 @@ export class CallbackHandlers {
await this.bot.sendMessage(chatId, t('translation.error'));
}
}
async handleNotificationSettings(chatId: number, telegramId: string): Promise<void> {
try {
if (this.notificationHandlers) {
const userId = await this.profileService.getUserIdByTelegramId(telegramId);
if (!userId) {
await this.bot.sendMessage(chatId, '❌ Вы не зарегистрированы. Используйте команду /start для регистрации.');
return;
}
// Вызываем метод из notificationHandlers для получения настроек и отображения меню
const settings = await this.notificationHandlers.getNotificationService().getNotificationSettings(userId);
await this.notificationHandlers.sendNotificationSettings(chatId, settings);
} else {
// Если NotificationHandlers недоступен, показываем сообщение об ошибке
await this.bot.sendMessage(chatId, '⚙️ Настройки уведомлений временно недоступны. Попробуйте позже.');
await this.handleSettings(chatId, telegramId);
}
} catch (error) {
console.error('Notification settings error:', error);
await this.bot.sendMessage(chatId, '❌ Произошла ошибка при загрузке настроек уведомлений. Попробуйте позже.');
}
}
}