Upload app/services/normalizer.py with huggingface_hub
Browse files
app/services/normalizer.py
CHANGED
|
@@ -407,9 +407,15 @@ def _normalize_steps(steps: list) -> list[dict]:
|
|
| 407 |
qr = str(s.get("qr_url", s.get("qr_image", ""))).strip()
|
| 408 |
if step_num == 1 and not qr:
|
| 409 |
telegram_ref = ""
|
| 410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 411 |
telegram_ref = plain_links[0]
|
| 412 |
-
|
| 413 |
m = re.search(r"(https?://(?:t\.me|telegram\.me)/[^\s<)]+)", body, flags=re.IGNORECASE)
|
| 414 |
if m:
|
| 415 |
telegram_ref = m.group(1)
|
|
|
|
| 407 |
qr = str(s.get("qr_url", s.get("qr_image", ""))).strip()
|
| 408 |
if step_num == 1 and not qr:
|
| 409 |
telegram_ref = ""
|
| 410 |
+
# Check links array for Telegram URLs first
|
| 411 |
+
for lnk in links:
|
| 412 |
+
url_val = str(lnk.get("url", "")).lower()
|
| 413 |
+
if "t.me/" in url_val or "telegram.me/" in url_val:
|
| 414 |
+
telegram_ref = lnk["url"]
|
| 415 |
+
break
|
| 416 |
+
if not telegram_ref and plain_links:
|
| 417 |
telegram_ref = plain_links[0]
|
| 418 |
+
if not telegram_ref and isinstance(body, str):
|
| 419 |
m = re.search(r"(https?://(?:t\.me|telegram\.me)/[^\s<)]+)", body, flags=re.IGNORECASE)
|
| 420 |
if m:
|
| 421 |
telegram_ref = m.group(1)
|