From 284aea57dcaff0c7542ca5790e26c29508989e1c Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Sat, 26 Dec 2020 13:48:27 +0100 Subject: [PATCH] Support multiple command arguments --- konata.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/konata.sh b/konata.sh index 5e82911..8e904d5 100755 --- a/konata.sh +++ b/konata.sh @@ -3,7 +3,8 @@ printf "Content-Type: text/plain\n\n" input=$(cat /dev/stdin) token=1493641835:AAGR7kLksUIjcrM-PXiVEM_yxLGqLGRWKZA -cmd=($(jq -r '.message.text' <<< $input)) +cmd=$(jq -r '.message.text' <<< $input) +args=$(cut -d" " -f2- <<< $cmd) chat=$(jq -r '.message.chat.id' <<< $input) user=$(jq -r '.message.from.username' <<< $input) @@ -33,7 +34,7 @@ stat(){ } cv(){ - stats=$(curl -sL corona.lmao.ninja/v2/countries/${cmd[1]}) + stats=$(curl -sL corona.lmao.ninja/v2/countries/$args) country=$(jq -r '.country' <<< $stats) cases=$(jq -r '.todayCases' <<< $stats) sendmsg "Today's COVID-19 cases for $country: $cases. Stay safe!"