File size: 566 Bytes
594481c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from __future__ import annotations

import re


def is_ms_timestamp(ts: int) -> bool:
    # Accept any positive-ish ms timestamp; avoid strict "current time" checks.
    return isinstance(ts, int) and ts > 0


def safe_sender(sender: str) -> str:
    s = sender.strip().lower()
    if s not in {"scammer", "user"}:
        raise ValueError("invalid sender")
    return s


HOSTILE_RE = re.compile(r"\b(idiot|stupid|moron|abuse|wasting time|last warning|final warning)\b", re.I)


def seems_hostile(text: str) -> bool:
    return bool(HOSTILE_RE.search(text or ""))