26 lines
833 B
Python
26 lines
833 B
Python
from aiogram import Bot, Dispatcher
|
|
from config import load_cfg, load_env
|
|
from services import runtime_state
|
|
|
|
cfg = load_cfg()
|
|
|
|
TOKEN = cfg["telegram"]["token"]
|
|
admin_ids_cfg = cfg["telegram"].get("admin_ids")
|
|
if isinstance(admin_ids_cfg, list) and admin_ids_cfg:
|
|
ADMIN_IDS = [int(x) for x in admin_ids_cfg]
|
|
ADMIN_ID = ADMIN_IDS[0]
|
|
else:
|
|
ADMIN_ID = int(cfg["telegram"]["admin_id"])
|
|
ADMIN_IDS = [ADMIN_ID]
|
|
|
|
paths_cfg = cfg.get("paths", {})
|
|
runtime_state.configure(paths_cfg.get("runtime_state", "/var/server-bot/runtime.json"))
|
|
ARTIFACT_STATE = paths_cfg["artifact_state"]
|
|
RESTIC_ENV = load_env(paths_cfg.get("restic_env", "/etc/restic/restic.env"))
|
|
|
|
DISK_WARN = int(cfg.get("thresholds", {}).get("disk_warn", 80))
|
|
LOAD_WARN = float(cfg.get("thresholds", {}).get("load_warn", 2.0))
|
|
|
|
bot = Bot(TOKEN)
|
|
dp = Dispatcher()
|