Patch getting membre key with jq
This commit is contained in:
parent
d5f9d2711b
commit
cac412fa07
|
@ -4,16 +4,11 @@ node="http://192.168.9.54:45000"
|
|||
|
||||
pubkey() {
|
||||
url="$node/wot/members"
|
||||
# if [[ "$@" =~ "brocket" ]]; then
|
||||
# [[ $4 ]] && username=$4 || username=$1
|
||||
# else
|
||||
# [[ $3 ]] && username=$3 || username=$1
|
||||
# fi
|
||||
args=$(echo $@ | tr ' ' '\n' | grep -v 'biz' | tr '\n' ' ')
|
||||
[ $(echo $args | wc -w) -ge 3 ] && username=$(echo $args | awk '{ print $3 }') || username=$1
|
||||
username=$(echo $username | tr -d '@')
|
||||
local pubkey=$(curl -m 5 -s $url | grep -w -i -B 1 $username | grep "pubkey" | awk -F '"' '{ print $4 }')
|
||||
# TODO: local pubkey=$(curl -m 5 -s $url | jq -r --arg username "$username" '.results[] | select(.uid=="$username") | .pubkey')
|
||||
# old way: local pubkey=$(curl -m 5 -s $url | grep -wiB 1 $username | grep "pubkey" | awk -F '"' '{ print $4 }')
|
||||
local pubkey=$(curl -m 5 -s $url | jq -r --arg username "$username" '.results[] | select(.uid==$username) | .pubkey')
|
||||
[[ $pubkey ]] && echo "@$username Ta clé publique Ğ1 est: $pubkey" || echo "@$username n'est pas pseudo membre de la Ḡ1"
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue