communication: switch atlasbot to MAS login
This commit is contained in:
parent
be2c2ba33e
commit
bfd1c5dd49
@ -9,6 +9,7 @@ data:
|
||||
from urllib import request, parse, error
|
||||
|
||||
BASE = os.environ.get("MATRIX_BASE", "http://othrys-synapse-matrix-synapse:8008")
|
||||
AUTH_BASE = os.environ.get("AUTH_BASE", "http://matrix-authentication-service:8080")
|
||||
USER = os.environ["BOT_USER"]
|
||||
PASSWORD = os.environ["BOT_PASS"]
|
||||
ROOM_ALIAS = "#othrys:live.bstein.dev"
|
||||
@ -16,8 +17,8 @@ data:
|
||||
MODEL = os.environ.get("OLLAMA_MODEL", "qwen2.5-coder:7b-instruct-q4_0")
|
||||
API_KEY = os.environ.get("CHAT_API_KEY", "")
|
||||
|
||||
def req(method: str, path: str, token: str | None = None, body=None, timeout=60):
|
||||
url = BASE + path
|
||||
def req(method: str, path: str, token: str | None = None, body=None, timeout=60, base: str | None = None):
|
||||
url = (base or BASE) + path
|
||||
data = None
|
||||
headers = {}
|
||||
if body is not None:
|
||||
@ -36,7 +37,7 @@ data:
|
||||
"identifier": {"type": "m.id.user", "user": USER},
|
||||
"password": PASSWORD,
|
||||
}
|
||||
res = req("POST", "/_matrix/client/v3/login", body=payload)
|
||||
res = req("POST", "/_matrix/client/v3/login", body=payload, base=AUTH_BASE)
|
||||
return res["access_token"]
|
||||
|
||||
def resolve_alias(token: str, alias: str) -> str:
|
||||
|
||||
@ -28,13 +28,15 @@ spec:
|
||||
env:
|
||||
- name: MATRIX_BASE
|
||||
value: http://othrys-synapse-matrix-synapse:8008
|
||||
- name: AUTH_BASE
|
||||
value: http://matrix-authentication-service:8080
|
||||
- name: BOT_USER
|
||||
value: atlasbot
|
||||
value: atlas
|
||||
- name: BOT_PASS
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: atlasbot-credentials-runtime
|
||||
key: bot-password
|
||||
name: atlasbot-mas-credentials-runtime
|
||||
key: password
|
||||
- name: CHAT_API_KEY
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user