add timeshtamp
This commit is contained in:
parent
2639aa0157
commit
206bb9fec0
21
main.py
21
main.py
@ -70,17 +70,21 @@ def parse_date(value: str) -> date:
|
|||||||
return datetime.strptime(value, "%Y-%m-%d").date()
|
return datetime.strptime(value, "%Y-%m-%d").date()
|
||||||
|
|
||||||
|
|
||||||
|
def _log_ts() -> str:
|
||||||
|
return msk_now().strftime("%Y-%m-%d %H:%M:%S MSK")
|
||||||
|
|
||||||
|
|
||||||
def log_info(msg: str) -> None:
|
def log_info(msg: str) -> None:
|
||||||
print(f"[info] {msg}")
|
print(f"[{_log_ts()}] [info] {msg}")
|
||||||
|
|
||||||
|
|
||||||
def log_warn(msg: str) -> None:
|
def log_warn(msg: str) -> None:
|
||||||
print(f"[warn] {msg}")
|
print(f"[{_log_ts()}] [warn] {msg}")
|
||||||
|
|
||||||
|
|
||||||
def log_error(context: str, exc: Exception) -> None:
|
def log_error(context: str, exc: Exception) -> None:
|
||||||
# Не логируем str(exc), чтобы не утекали токены/URL/чувствительные детали.
|
# Не логируем str(exc), чтобы не утекали токены/URL/чувствительные детали.
|
||||||
print(f"[error] {context}: {type(exc).__name__}")
|
print(f"[{_log_ts()}] [error] {context}: {type(exc).__name__}")
|
||||||
|
|
||||||
|
|
||||||
def is_user_allowed(chat_id: int, username: str | None) -> bool:
|
def is_user_allowed(chat_id: int, username: str | None) -> bool:
|
||||||
@ -918,14 +922,21 @@ async def handle_pr_reviewed(payload: dict[str, Any]) -> None:
|
|||||||
if not repo_full_name or not pr_number:
|
if not repo_full_name or not pr_number:
|
||||||
return
|
return
|
||||||
state = (review.get("state") or "").lower()
|
state = (review.get("state") or "").lower()
|
||||||
reviewer_login = (review.get("user") or {}).get("login") or ""
|
reviewer_login = (
|
||||||
|
(review.get("user") or {}).get("login")
|
||||||
|
or (payload.get("sender") or {}).get("login")
|
||||||
|
or ""
|
||||||
|
)
|
||||||
if state == "approved":
|
if state == "approved":
|
||||||
status_text = "одобрен(апрувнут)"
|
status_text = "одобрен(апрувнут)"
|
||||||
elif state in ("request_changes", "request changes"):
|
elif state in ("request_changes", "request changes"):
|
||||||
status_text = "запрошены правки"
|
status_text = "запрошены правки"
|
||||||
else:
|
else:
|
||||||
status_text = state or "обновлён"
|
status_text = state or "обновлён"
|
||||||
msg = f"PR {repo_full_name}#{pr_number}: ревью {status_text} ({reviewer_login})."
|
if reviewer_login:
|
||||||
|
msg = f"PR {repo_full_name}#{pr_number}: ревью {status_text} ({reviewer_login})."
|
||||||
|
else:
|
||||||
|
msg = f"PR {repo_full_name}#{pr_number}: ревью {status_text}."
|
||||||
for chat_id in await get_pr_participant_chat_ids(
|
for chat_id in await get_pr_participant_chat_ids(
|
||||||
repo_full_name,
|
repo_full_name,
|
||||||
int(pr_number),
|
int(pr_number),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user