Initial version of Telegram admin bot

This commit is contained in:
root
2026-02-07 21:34:24 +03:00
commit 492e3bd3cf
9 changed files with 1027 additions and 0 deletions

17
locks.py Normal file
View File

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