64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
"""Shared AwoooP operator deeplinks used by Telegram-facing services."""
|
|
|
|
from urllib.parse import quote
|
|
|
|
AWOOOP_WEB_BASE_URL = "https://awoooi.wooo.work"
|
|
|
|
|
|
def incident_runs_url(
|
|
incident_id: str,
|
|
*,
|
|
project_id: str = "awoooi",
|
|
locale: str = "zh-TW",
|
|
) -> str:
|
|
safe_project_id = quote(str(project_id or "awoooi"), safe="")
|
|
safe_incident_id = quote(str(incident_id or ""), safe="")
|
|
return (
|
|
f"{AWOOOP_WEB_BASE_URL}/{locale}/awooop/runs"
|
|
f"?project_id={safe_project_id}&incident_id={safe_incident_id}"
|
|
)
|
|
|
|
|
|
def incident_alerts_url(
|
|
incident_id: str,
|
|
*,
|
|
project_id: str = "awoooi",
|
|
locale: str = "zh-TW",
|
|
) -> str:
|
|
safe_project_id = quote(str(project_id or "awoooi"), safe="")
|
|
safe_incident_id = quote(str(incident_id or ""), safe="")
|
|
return (
|
|
f"{AWOOOP_WEB_BASE_URL}/{locale}/alerts"
|
|
f"?project_id={safe_project_id}&incident_id={safe_incident_id}"
|
|
)
|
|
|
|
|
|
def incident_truth_chain_button_row(
|
|
incident_id: str,
|
|
*,
|
|
project_id: str = "awoooi",
|
|
) -> list[dict[str, str]]:
|
|
if not incident_id:
|
|
return []
|
|
return [
|
|
{
|
|
"text": "🔎 真相鏈",
|
|
"url": incident_alerts_url(incident_id, project_id=project_id),
|
|
},
|
|
{
|
|
"text": "🧭 Runs",
|
|
"url": incident_runs_url(incident_id, project_id=project_id),
|
|
},
|
|
]
|
|
|
|
|
|
def incident_truth_chain_reply_markup(
|
|
incident_id: str,
|
|
*,
|
|
project_id: str = "awoooi",
|
|
) -> dict | None:
|
|
row = incident_truth_chain_button_row(incident_id, project_id=project_id)
|
|
if not row:
|
|
return None
|
|
return {"inline_keyboard": [row]}
|