1
0
Fork 0

add mx-set-status

This commit is contained in:
tastytea 2024-04-04 13:27:58 +02:00
parent 53b6532e5d
commit 7c615772f0
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
#!/usr/bin/env zsh
# set matrix status message to ${1}
# cfg file: server\nuser ID\token
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
local -a cfg
while IFS=\n read -r line; do
cfg+=${line}
done < ${XDG_CONFIG_HOME:-~/.config}/mx-set-status.cfg
local host=${cfg[1]}
local user=${cfg[2]}
local token=${cfg[3]}
local mxstatus="be gay, do crime! :3"
[[ -v 1 ]] && mxstatus=${1}
local response=$(curl --silent \
--header "Authorization: Bearer ${token}" \
"https://${host}/_matrix/client/v3/presence/${user}/status")
local presence=$(jq --raw-output .presence <<<${response})
curl --silent -X PUT \
--header "Authorization: Bearer ${token}" \
--json '{"presence": "'${presence}'", "status_msg": "'${mxstatus}'"}' \
"https://${host}/_matrix/client/v3/presence/${user}/status" > /dev/null