From 0f1f34c52a4e8e6defcc086d219ef1ce0d7afbb2 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Thu, 1 Jan 2026 12:50:26 -0300 Subject: [PATCH] communication(atlasbot): reduce spam and use atlasbot user --- services/communication/atlasbot-configmap.yaml | 12 ++++++------ services/communication/atlasbot-deployment.yaml | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/services/communication/atlasbot-configmap.yaml b/services/communication/atlasbot-configmap.yaml index a15352d..b897683 100644 --- a/services/communication/atlasbot-configmap.yaml +++ b/services/communication/atlasbot-configmap.yaml @@ -53,7 +53,6 @@ data: req("POST", path, token, body={"msgtype": "m.text", "body": text}) history = collections.defaultdict(list) # room_id -> list of str (short transcript) - greeted = set() def ollama_reply(room_id: str, prompt: str) -> str: try: @@ -74,6 +73,11 @@ data: def sync_loop(token: str, room_id: str): since = None + try: + res = req("GET", "/_matrix/client/v3/sync?timeout=0", token, timeout=10) + since = res.get("next_batch") + except Exception: + pass while True: params = {"timeout": 30000} if since: @@ -90,15 +94,11 @@ data: for rid, data in res.get("rooms", {}).get("invite", {}).items(): try: join_room(token, rid) - send_msg(token, rid, "Atlas online.") except Exception: pass # messages for rid, data in res.get("rooms", {}).get("join", {}).items(): - if rid not in greeted and room_id and rid == room_id: - greeted.add(rid) - send_msg(token, rid, "Atlas online.") timeline = data.get("timeline", {}).get("events", []) for ev in timeline: if ev.get("type") != "m.room.message": @@ -113,7 +113,7 @@ data: # Only respond if bot is mentioned or in a DM joined_count = data.get("summary", {}).get("m.joined_member_count") is_dm = joined_count is not None and joined_count <= 2 - mentioned = f"@{USER}" in body or "atlas" in body.lower() + mentioned = f"@{USER}" in body history[rid].append(f"{sender}: {body}") if is_dm or mentioned: reply = ollama_reply(rid, body) diff --git a/services/communication/atlasbot-deployment.yaml b/services/communication/atlasbot-deployment.yaml index 5834435..a0b3f05 100644 --- a/services/communication/atlasbot-deployment.yaml +++ b/services/communication/atlasbot-deployment.yaml @@ -29,14 +29,14 @@ spec: - name: MATRIX_BASE value: http://othrys-synapse-matrix-synapse:8008 - name: AUTH_BASE - value: http://matrix-authentication-service:8080 + value: http://othrys-synapse-matrix-synapse:8008 - name: BOT_USER - value: atlas + value: atlasbot - name: BOT_PASS valueFrom: secretKeyRef: - name: atlasbot-mas-credentials-runtime - key: password + name: atlasbot-credentials-runtime + key: bot-password - name: CHAT_API_KEY valueFrom: secretKeyRef: