#!/usr/bin/env python3 """ 🏠 Домовой Бот — Telegram-бот для чата многоквартирного дома ВЕРСИЯ: v4.1 — VOICE-REBORN ДАТА ФИКСАЦИИ: 21 апреля 2026 г. СТАТУС: ✅ ОБНОВЛЕН НОВОЕ В v4.1: - ✅ Распознавание голосовых сообщений и видеокружков (Whisper Small) - ✅ Логирование распознанного текста в БД """ import logging import asyncio import sys import os from pathlib import Path # Добавляем путь к проекту BASE_DIR = Path(__file__).resolve().parent sys.path.insert(0, str(BASE_DIR)) from aiogram import Bot, Dispatcher from aiogram.client.default import DefaultBotProperties from aiogram.enums import ParseMode from aiogram.filters import Command from aiogram.types import Message from aiogram.client.session.aiohttp import AiohttpSession from aiogram.fsm.storage.memory import MemoryStorage from config import ( BOT_TOKEN, ADMIN_USER_ID, ADMIN_CHAT_ID, get_proxy_url, USE_PROXY, PROXY_TYPE, PROXY_HOST, PROXY_PORT ) from database.db import init_db from handlers import ( admin_router, users_router, verification_router, chat_monitor_router, security_router, apartments_router, antimat_router, phones_router, polls_router, antispam_router, ratelimit_router, schedule_router, ads_router, payments_router, multicount_router, topics_router, toxicity_router, profile_history_router, achievements_router, thanks_router, events_router, initiative_group_router ) from handlers.voice import voice_router from handlers.mutual_aid import router as mutual_aid_router from services.scheduler import Scheduler from services.web_server import WebServerService # Настройка логирования logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', handlers=[ logging.FileHandler('logs/bot.log', encoding='utf-8'), logging.StreamHandler() ] ) logger = logging.getLogger(__name__) async def on_startup(bot: Bot): await init_db() scheduler = Scheduler(bot) scheduler.start() try: await bot.send_message( ADMIN_USER_ID, '✅ LKM37 CORE v4.1 VOICE-REBORN АКТИВИРОВАН\n\n' 'Модуль распознавания речи (Whisper Small) запущен.\n' 'Шли мне голосовухи — я их теперь "читаю"!', parse_mode=ParseMode.HTML ) except Exception as e: logger.error(f'Ошибка уведомления админа: {e}') async def main(): from bot_instance import get_bot bot = get_bot() dp = Dispatcher(storage=MemoryStorage()) # Регистрация роутеров routers = [ admin_router, users_router, verification_router, chat_monitor_router, security_router, apartments_router, antimat_router, phones_router, polls_router, antispam_router, ratelimit_router, schedule_router, ads_router, payments_router, multicount_router, topics_router, toxicity_router, profile_history_router, achievements_router, thanks_router, events_router, initiative_group_router, mutual_aid_router, voice_router # Добавляем голосовой роутер ] for r in routers: dp.include_router(r) from handlers.smart_broadcast import router as smart_broadcast_router from handlers.digest import router as digest_router dp.include_router(smart_broadcast_router) dp.include_router(digest_router) dp.startup.register(on_startup) logger.info('🤖 Ожидание команд субъектов...') await dp.start_polling(bot) if __name__ == '__main__': try: asyncio.run(main()) except KeyboardInterrupt: logger.info('🛑 Остановка пользователем.') except Exception as e: logger.error(f'Критическая ошибка: {e}', exc_info=True)