- Deleted the Makefile, `README_TESTING.md`, and several deployment scripts to streamline the project. - Updated `.dockerignore` to exclude unnecessary development files. - Adjusted database schema comments for clarity. - Refactored metrics handling in middleware for improved command extraction and logging. - Enhanced command mappings for buttons and callbacks in constants for better maintainability. - Start refactor voice bot
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import os
|
|
import sys
|
|
|
|
# Ensure project root is on sys.path for module resolution when running voice bot directly
|
|
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
PROJECT_ROOT = os.path.dirname(CURRENT_DIR)
|
|
if PROJECT_ROOT not in sys.path:
|
|
sys.path.insert(0, PROJECT_ROOT)
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
from aiogram.client.default import DefaultBotProperties
|
|
from aiogram.fsm.storage.memory import MemoryStorage
|
|
from aiogram.fsm.strategy import FSMStrategy
|
|
|
|
from voice_bot.handlers import voice_router, callback_router
|
|
|
|
|
|
async def start_bot(bdf):
|
|
token = bdf.settings['Telegram']['listen_bot_token']
|
|
bot = Bot(token=token, default=DefaultBotProperties(
|
|
parse_mode='HTML',
|
|
link_preview_is_disabled=bdf.settings['Telegram']['preview_link']
|
|
))
|
|
|
|
dp = Dispatcher(storage=MemoryStorage(), fsm_strategy=FSMStrategy.GLOBAL_USER)
|
|
|
|
# Подключаем роутеры
|
|
dp.include_router(voice_router)
|
|
dp.include_router(callback_router)
|
|
|
|
await bot.delete_webhook(drop_pending_updates=True)
|
|
await dp.start_polling(bot, skip_updates=True)
|