Added getopts and -s option to curl
This commit is contained in:
parent
90fb158618
commit
14a7466c1c
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"
|
||||
if [ "$manualAuth" = "true" ];
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ ClearCache () {
|
|||
}
|
||||
|
||||
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"
|
||||
|
||||
[ -z "$1" ] && usage
|
||||
[ "$1" = "-c" ] && ClearCache
|
||||
[ "$1" = "-h" ] && help
|
||||
[ "$1" = "-V" ] && version
|
||||
#[ "$1" = "-c" ] && ClearCache
|
||||
#[ "$1" = "-h" ] && help
|
||||
#[ "$1" = "-V" ] && version
|
||||
|
||||
while getopts :chV opt
|
||||
do
|
||||
case $opt in
|
||||
c) ClearCache ;;
|
||||
h) help ;;
|
||||
V) version ;;
|
||||
esac
|
||||
done
|
||||
|
||||
###############################
|
||||
#### Configuration loading ####
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue