feat: add lightweight matrix-triad-node.sh for minimal node deployments

Bash script for triad nodes without full Node.js workspace.
Usage: matrix-triad-node.sh <tm1|tm2|tm3> <send|join|sync> [args]

Uses raw curl + Python JSON — no node_modules needed.
Also: ignore heretek-openclaw-src/ (npm-publish artifact directory).
This commit is contained in:
TM-1 Matrix Sync
2026-03-24 16:04:48 -04:00
parent bf9e5784b0
commit 0a06867a34
2 changed files with 69 additions and 0 deletions
+1
View File
@@ -158,3 +158,4 @@ matrix-dendrite/config/matrix_key.pem
matrix-dendrite/config/tls.crt
matrix-dendrite/config/tls.key
matrix-data/
heretek-openclaw-src/
+68
View File
@@ -0,0 +1,68 @@
#!/bin/bash
# Lightweight Matrix triad node client
# Usage: ./matrix-triad-node.sh <tmN> <command>
# Commands: send <room> <message>, join <room>, sync
set -euo pipefail
TM="${1:-}"
CMD="${2:-}"
SERVER="http://192.168.31.99:8008"
TOKEN_FILE="/home/openclaw/.openclaw/.secure/matrix/${TM}.token"
usage() {
echo "Usage: $0 <tm1|tm2|tm3> <send|join|sync> [args...]"
exit 1
}
[[ -z "$TM" || -z "$CMD" ]] && usage
[[ ! -f "$TOKEN_FILE" ]] && { echo "Token not found: $TOKEN_FILE"; exit 1; }
TOKEN=$(cat "$TOKEN_FILE")
AUTH="Authorization: Bearer $TOKEN"
CONTENT_TYPE="Content-Type: application/json"
send_msg() {
local room="$3"; local msg="$4"
local txn_id="mtx_${TM}_$(date +%s)"
local resp
resp=$(curl -s -X PUT -H "$AUTH" -H "$CONTENT_TYPE" \
-d "{\"msgtype\":\"m.text\",\"body\":\"$msg\"}" \
"${SERVER}/_matrix/client/v3/rooms/${room}/send/m.room.message/${txn_id}")
echo "$resp" | python3 -c "import sys,json; d=json.load(sys.stdin); print('Sent:', d.get('event_id','?'))" 2>/dev/null || echo "Sent (no event_id in response)"
}
join_room() {
local room="$3"
local resp
resp=$(curl -s -X POST -H "$AUTH" -H "$CONTENT_TYPE" \
-d '{}' \
"${SERVER}/_matrix/client/v3/join/${room}")
echo "$resp" | python3 -c "import sys,json; d=json.load(sys.stdin); print('Joined:', d.get('room_id','?'))" 2>/dev/null || echo "Joined (no room_id in response)"
}
sync_msgs() {
local since="${3:-}"
local url="${SERVER}/_matrix/client/v3/sync?timeout=5000"
[[ -n "$since" ]] && url="${url}&since=${since}"
curl -s -H "$AUTH" "$url" | python3 -c "
import sys,json
d=json.load(sys.stdin)
next_tok = d.get('next_batch','')
rooms = d.get('rooms',{}).get('join',{})
for rid,data in rooms.items():
for ev in data.get('timeline',{}).get('events',[]):
if ev.get('type')=='m.room.message':
body=ev.get('content',{}).get('body','')
sender=ev.get('sender','').split(':')[0].replace('@','')
if sender != '${TM}':
print(f'{sender}: {body}')
print('NEXT:', next_tok)
"
}
case "$CMD" in
send) send_msg "$@" ;;
join) join_room "$@" ;;
sync) sync_msgs "$@" ;;
*) usage ;;
esac