from app import create_app
from app.bot.services.mailing_service import start_mailing_service
from app.bot.telezab_bot import run_bot
import telebot
from config import TOKEN
from app.bot.handlers import register_handlers, register_callbacks

if __name__ == '__main__':
    app = create_app()
    bot = telebot.TeleBot(TOKEN, use_class_middlewares=True, parse_mode='HTML')

    register_handlers(bot, app)
    register_callbacks(bot, app)

    # Запускаем рассылку, передавая bot и app
    start_mailing_service(app, bot)

    # Запускаем самого бота
    run_bot(app, bot)
