mx-set-status: preserve non-default status message
This commit is contained in:
parent
5334da6ce1
commit
35e1e95a3e
@ -13,12 +13,21 @@ 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})
|
||||
local status_msg=$(jq --raw-output .status_msg <<<${response})
|
||||
|
||||
if [[ -v 1 ]]; then
|
||||
mxstatus=${1}
|
||||
else
|
||||
# preserve status message that is not empty or beginning with “np: ”
|
||||
if [[ ${#status_msg} != 0 ]] && [[ ${status_msg[1,4]} != "np: " ]]; then
|
||||
mxstatus=${status_msg}
|
||||
fi
|
||||
fi
|
||||
|
||||
curl --silent -X PUT \
|
||||
--header "Authorization: Bearer ${token}" \
|
||||
|
Loading…
x
Reference in New Issue
Block a user