add mx-set-status
This commit is contained in:
parent
53b6532e5d
commit
7c615772f0
26
.config/zsh/functions/mx-set-status
Executable file
26
.config/zsh/functions/mx-set-status
Executable 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
|
Loading…
Reference in New Issue
Block a user