Cette révision appartient à :
@@ -41,49 +41,6 @@ def log(message):
|
||||
print(f"[{time.strftime('%Y-%m-%d %H:%M:%S')}] {message}", flush=True)
|
||||
|
||||
|
||||
|
||||
def html_to_sms_text(raw_html):
|
||||
"""
|
||||
Convert HTML content to clean SMS-compatible plain text.
|
||||
- Removes HTML tags
|
||||
- Decodes HTML entities
|
||||
- Normalizes unicode
|
||||
- Removes unsupported SMS characters
|
||||
"""
|
||||
|
||||
if not raw_html:
|
||||
return ""
|
||||
|
||||
# Parse HTML
|
||||
soup = BeautifulSoup(raw_html, "html.parser")
|
||||
|
||||
# Get text only
|
||||
text = soup.get_text(separator=" ")
|
||||
|
||||
# Decode HTML entities ( & etc.)
|
||||
text = html.unescape(text)
|
||||
|
||||
# Normalize unicode (remove weird accents/combined chars)
|
||||
text = unicodedata.normalize("NFKD", text)
|
||||
|
||||
# Remove non GSM basic characters
|
||||
gsm_basic = (
|
||||
"@£$¥èéùìòÇ\nØø\rÅåΔ_ΦΓΛΩΠΨΣΘΞ"
|
||||
+ ' !"#¤%&\'()*+,-./'
|
||||
+ "0123456789:;<=>?"
|
||||
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
+ "ÄÖÑܧ¿"
|
||||
+ "abcdefghijklmnopqrstuvwxyz"
|
||||
+ "äöñüà"
|
||||
)
|
||||
|
||||
cleaned = "".join(c for c in text if c in gsm_basic)
|
||||
|
||||
# Remove multiple spaces
|
||||
cleaned = re.sub(r"\s+", " ", cleaned).strip()
|
||||
|
||||
return cleaned
|
||||
|
||||
# ============================================================
|
||||
# SUBJECT PARAMETER EXTRACTION
|
||||
# ============================================================
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur