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.callback_handler import callback_router from voice_bot.handlers.voice_handler import voice_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_routers(voice_router, callback_router) await bot.delete_webhook(drop_pending_updates=True) await dp.start_polling(bot, skip_updates=True)