Fix Cloudflare bot detection blocking net_alerter Matrix sends

urllib's default Python-urllib user agent is flagged by Cloudflare Bot
Fight Mode (error 1010) when m.example.org homeserver sits behind
Cloudflare. Add a browser-like User-Agent to Matrix PUT/POST requests so
Cloudflare passes the traffic through.
This commit is contained in:
Cobra
2026-04-08 20:19:24 -04:00
parent 019a96b205
commit d9c27eaf66
+5 -1
View File
@@ -103,7 +103,11 @@ def _do_send(token: str, msg: str) -> int:
req = urllib.request.Request(
url,
data=payload,
headers={"Authorization": f"Bearer {token}", "Content-Type": "application/json"},
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
},
method="POST",
)
try: