summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bash/api.sh18
1 files changed, 17 insertions, 1 deletions
diff --git a/bash/api.sh b/bash/api.sh
index a365671..0757a60 100644
--- a/bash/api.sh
+++ b/bash/api.sh
@@ -3,7 +3,10 @@ CURL='curl -g -s'
req() { # req <method> <url> "$@"
local _out=$(mktemp)
- ${CURL} "-X$1" -o "$_out" "$2"
+ local method="$1"
+ local url="$2"
+ shift 2
+ ${CURL} "-X$method" -o "$_out" "$url" "$@"
echo "$_out"
}
@@ -36,6 +39,11 @@ matrix_login_password() {
fi
}
+# to sync events, call matrix_sync and the the next_batch
+# then continue calling it with `since=$NEXT_BATCH`
+#
+# to get the full state of all joined rooms, use `full_state=true`
+
matrix_sync() {
local _out=$(mktemp)
local _url="$SERVER_URL/_matrix/client/r0/sync?access_token=$TOKEN"
@@ -101,3 +109,11 @@ matrix_get_room_message() {
local _out="$(req GET "$_url")"
jq . "$_out"
}
+
+# 6.4.3 PUT /_matrix/client/r0/rooms/{roomId}/send/{eventType}/{txnId}
+
+matrix_send() { # args: roomid, eventType(m.room.message), txn, msg
+ local _url="$SERVER_URL/_matrix/client/r0/rooms/$1/send/$2/$3?access_token=$TOKEN"
+ local _out="$(req PUT "$_url" -d "$4")"
+ jq . "$_out"
+}