21 lines
606 B
Python
21 lines
606 B
Python
from django.apps import AppConfig
|
|
import threading
|
|
import os
|
|
|
|
class TgbotConfig(AppConfig):
|
|
default_auto_field = "django.db.models.BigAutoField"
|
|
name = "tgbot"
|
|
|
|
def ready(self):
|
|
from .updater import tg_bot_updater_instance
|
|
if not tg_bot_updater_instance.is_run and os.environ.get("RUN_MAIN", None) == "true":
|
|
threading.Thread(
|
|
target=(tg_bot_updater_instance.run_func),
|
|
name="tg_updater_thread",
|
|
daemon=True,
|
|
).start()
|
|
tg_bot_updater_instance.is_run = True
|
|
|
|
return super().ready()
|
|
|