Spaces:
Running
Running
Baida commited on
fix(webhook): raw newline strings → \n escape (SyntaxError crash)
Browse files
backend/api/telegram_webhook.py
CHANGED
|
@@ -1057,11 +1057,8 @@ async def _cmd_coord(chat_id: int) -> None:
|
|
| 1057 |
|
| 1058 |
if not rows:
|
| 1059 |
await _tg_reply(chat_id,
|
| 1060 |
-
"🔗 <b>Agent Coord</b>
|
| 1061 |
-
|
| 1062 |
-
"
|
| 1063 |
-
"ℹ️ Nessuna sessione registrata.
|
| 1064 |
-
<i>Tutti i file sono liberi.</i>",
|
| 1065 |
keyboard=_BACK_KB)
|
| 1066 |
return
|
| 1067 |
|
|
@@ -1090,8 +1087,7 @@ async def _cmd_coord(chat_id: int) -> None:
|
|
| 1090 |
for s in stale:
|
| 1091 |
out.append(f" {html.escape(s['name'])} · {_age_str(s['age_ms'])} fa")
|
| 1092 |
|
| 1093 |
-
await _tg_reply(chat_id, "
|
| 1094 |
-
".join(out), keyboard=_BACK_KB)
|
| 1095 |
|
| 1096 |
|
| 1097 |
async def _cmd_git(chat_id: int, n: int = 5) -> None:
|
|
@@ -1143,27 +1139,23 @@ async def _cmd_git(chat_id: int, n: int = 5) -> None:
|
|
| 1143 |
except Exception:
|
| 1144 |
return "?"
|
| 1145 |
|
| 1146 |
-
lines = [f"🔀 <b>Git log — main</b> ({_gh_repo})
|
| 1147 |
-
"]
|
| 1148 |
for c in commits:
|
| 1149 |
_sha = (c.get("sha") or "")[:7]
|
| 1150 |
_commit = c.get("commit") or {}
|
| 1151 |
-
_msg_raw = (_commit.get("message") or "").split("
|
| 1152 |
-
")[0][:52]
|
| 1153 |
_msg = html.escape(_msg_raw)
|
| 1154 |
_author = html.escape((_commit.get("author") or {}).get("name", "?")[:18])
|
| 1155 |
_date = (_commit.get("committer") or {}).get("date", "")
|
| 1156 |
_when = _age(_date)
|
| 1157 |
_url = f"https://github.com/{_gh_repo}/commit/{c.get('sha','')}"
|
| 1158 |
lines.append(
|
| 1159 |
-
f"<code>{html.escape(_sha)}</code> {_msg}
|
| 1160 |
-
"
|
| 1161 |
f" <i>{_author} · {_when}</i> "
|
| 1162 |
f"<a href="{_url}">diff →</a>"
|
| 1163 |
)
|
| 1164 |
|
| 1165 |
-
await _tg_reply(chat_id, "
|
| 1166 |
-
".join(lines), keyboard=_BACK_KB)
|
| 1167 |
|
| 1168 |
async def _cmd_telemetry(chat_id: int) -> None:
|
| 1169 |
"""📡 Metriche runtime live: /api/telemetry + /debug/timing da Railway."""
|
|
|
|
| 1057 |
|
| 1058 |
if not rows:
|
| 1059 |
await _tg_reply(chat_id,
|
| 1060 |
+
"🔗 <b>Agent Coord</b>\n\n"
|
| 1061 |
+
"ℹ️ Nessuna sessione registrata.\n<i>Tutti i file sono liberi.</i>",
|
|
|
|
|
|
|
|
|
|
| 1062 |
keyboard=_BACK_KB)
|
| 1063 |
return
|
| 1064 |
|
|
|
|
| 1087 |
for s in stale:
|
| 1088 |
out.append(f" {html.escape(s['name'])} · {_age_str(s['age_ms'])} fa")
|
| 1089 |
|
| 1090 |
+
await _tg_reply(chat_id, "\n".join(out), keyboard=_BACK_KB)
|
|
|
|
| 1091 |
|
| 1092 |
|
| 1093 |
async def _cmd_git(chat_id: int, n: int = 5) -> None:
|
|
|
|
| 1139 |
except Exception:
|
| 1140 |
return "?"
|
| 1141 |
|
| 1142 |
+
lines = [f"🔀 <b>Git log — main</b> ({_gh_repo})\n"]
|
|
|
|
| 1143 |
for c in commits:
|
| 1144 |
_sha = (c.get("sha") or "")[:7]
|
| 1145 |
_commit = c.get("commit") or {}
|
| 1146 |
+
_msg_raw = (_commit.get("message") or "").split("\n")[0][:52]
|
|
|
|
| 1147 |
_msg = html.escape(_msg_raw)
|
| 1148 |
_author = html.escape((_commit.get("author") or {}).get("name", "?")[:18])
|
| 1149 |
_date = (_commit.get("committer") or {}).get("date", "")
|
| 1150 |
_when = _age(_date)
|
| 1151 |
_url = f"https://github.com/{_gh_repo}/commit/{c.get('sha','')}"
|
| 1152 |
lines.append(
|
| 1153 |
+
f"<code>{html.escape(_sha)}</code> {_msg}\n"
|
|
|
|
| 1154 |
f" <i>{_author} · {_when}</i> "
|
| 1155 |
f"<a href="{_url}">diff →</a>"
|
| 1156 |
)
|
| 1157 |
|
| 1158 |
+
await _tg_reply(chat_id, "\n".join(lines), keyboard=_BACK_KB)
|
|
|
|
| 1159 |
|
| 1160 |
async def _cmd_telemetry(chat_id: int) -> None:
|
| 1161 |
"""📡 Metriche runtime live: /api/telemetry + /debug/timing da Railway."""
|