Added getopts and -s option to curl
This commit is contained in:
parent
c74497105b
commit
b98624bc78
1 changed files with 14 additions and 5 deletions
19
matrix-send
Normal file → Executable file
19
matrix-send
Normal file → Executable file
|
@ -101,7 +101,7 @@ GetAccessToken () {
|
||||||
[ -z "$manualAuth" ] && printf "Getting access token...\n"
|
[ -z "$manualAuth" ] && printf "Getting access token...\n"
|
||||||
if [ "$manualAuth" = "true" ];
|
if [ "$manualAuth" = "true" ];
|
||||||
then printf ""; # printf "" basically means do nothing
|
then printf ""; # printf "" basically means do nothing
|
||||||
else token=$(curl -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$server/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......');
|
else token=$(curl -s -XPOST -d "{"'"'"type"'"'":"'"'"m.login.password"'"'", "'"'"user"'"'":"'"'"$username"'"'", "'"'"password"'"'":"'"'"$password"'"'"}" "https://$server/_matrix/client/r0/login" | grep -oE 'syt_.+_...................._......');
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ ClearCache () {
|
||||||
}
|
}
|
||||||
|
|
||||||
Send () {
|
Send () {
|
||||||
curl -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token"
|
curl -s -XPOST -d "{"'"'"msgtype"'"'":"'"'"m.text"'"'", "'"'"body"'"'":"'"'"$message"'"'"}" "https://$server/_matrix/client/r0/rooms/%21$roomid/send/m.room.message?access_token=$token"
|
||||||
}
|
}
|
||||||
|
|
||||||
########################
|
########################
|
||||||
|
@ -131,9 +131,18 @@ Send () {
|
||||||
[ -e /usr/local/bin/curl ] || [ -e /usr/bin/curl ] || error "curl not found"
|
[ -e /usr/local/bin/curl ] || [ -e /usr/bin/curl ] || error "curl not found"
|
||||||
|
|
||||||
[ -z "$1" ] && usage
|
[ -z "$1" ] && usage
|
||||||
[ "$1" = "-c" ] && ClearCache
|
#[ "$1" = "-c" ] && ClearCache
|
||||||
[ "$1" = "-h" ] && help
|
#[ "$1" = "-h" ] && help
|
||||||
[ "$1" = "-V" ] && version
|
#[ "$1" = "-V" ] && version
|
||||||
|
|
||||||
|
while getopts :chV opt
|
||||||
|
do
|
||||||
|
case $opt in
|
||||||
|
c) ClearCache ;;
|
||||||
|
h) help ;;
|
||||||
|
V) version ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
###############################
|
###############################
|
||||||
#### Configuration loading ####
|
#### Configuration loading ####
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue