Refactor bot and integrate services

This commit is contained in:
2026-02-07 22:10:08 +03:00
parent 492e3bd3cf
commit 588127c076
31 changed files with 1061 additions and 849 deletions

23
lock_utils.py Normal file
View File

@@ -0,0 +1,23 @@
from pathlib import Path
import time
LOCK_DIR = Path("/var/run/tg-bot")
LOCK_DIR.mkdir(parents=True, exist_ok=True)
def lock_path(name: str) -> Path:
return LOCK_DIR / f"{name}.lock"
def acquire_lock(name: str) -> bool:
p = lock_path(name)
if p.exists():
return False
p.write_text(str(time.time()))
return True
def release_lock(name: str):
p = lock_path(name)
if p.exists():
p.unlink()