settings application
.env db params+global settings in admin model ECVI plugin module
This commit is contained in:
@@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand
|
||||
from telegram.ext import Application
|
||||
from bot.utils.bot_setup import setup_bot
|
||||
from scheduler.tasks import load_tasks_to_scheduler
|
||||
|
||||
from settings.models import TelegramSettings
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Запуск Telegram бота и планировщика"
|
||||
@@ -32,12 +32,13 @@ class Command(BaseCommand):
|
||||
return
|
||||
|
||||
# Настройка Telegram бота
|
||||
bot_token = os.getenv("TELEGRAM_BOT_TOKEN")
|
||||
# bot_token = os.getenv("TELEGRAM_BOT_TOKEN")
|
||||
bot_token = TelegramSettings.objects.first().bot_token
|
||||
|
||||
if not bot_token:
|
||||
raise ValueError("Токен бота не найден в переменных окружения.")
|
||||
application = Application.builder().token(bot_token).build()
|
||||
setup_bot(application)
|
||||
|
||||
# Основная асинхронная функция
|
||||
async def main():
|
||||
await application.initialize()
|
||||
|
||||
Reference in New Issue
Block a user