# bot/management/commands/runbot.py from django.core.management.base import BaseCommand from django.conf import settings from telegram.ext import ApplicationBuilder, CommandHandler, CallbackQueryHandler from bot.handlers import start, router import logging class Command(BaseCommand): help = 'Запускает Telegram бота' def handle(self, *args, **options): # Логирование для отладки logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO ) print("Starting bot...") application = ApplicationBuilder().token(settings.TELEGRAM_TOKEN).build() # Регистрация хендлеров application.add_handler(CommandHandler("start", start)) # Все callback-и идут в наш роутер application.add_handler(CallbackQueryHandler(router.handle)) application.run_polling()