diff --git a/zen/gchange_MONITOR.sh b/zen/gchange_MONITOR.sh index c8aaa62..88926e2 100755 --- a/zen/gchange_MONITOR.sh +++ b/zen/gchange_MONITOR.sh @@ -7,6 +7,8 @@ # Extract last ads # Thank you @kimamila for cesium & gchange # ES backend http://www.elasticsearchtutorial.com/spatial-search-tutorial.html +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ipfsnodeid=$(ipfs id -f='\n') [[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh @@ -14,9 +16,9 @@ g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) CESIUM="https://g1.data.le-sou.org" -curl -sk ${CESIUM}/user/profile/${g1pub} -o /tmp/profile.json -LON=$(cat /tmp/profile.json | jq '._source.geoPoint.lon') -LAT=$(cat /tmp/profile.json | jq '._source.geoPoint.lat') +curl -sk ${CESIUM}/user/profile/${g1pub} -o ~/.zen/cache/cesium_profile.json +LON=$(cat ~/.zen/cache/cesium_profile.json | jq '._source.geoPoint.lon') +LAT=$(cat ~/.zen/cache/cesium_profile.json | jq '._source.geoPoint.lat') RAD="$1" [[ ! $RAD ]] && RAD="10km" @@ -47,24 +49,48 @@ TIMESTAMP=$(date -u +"%s") TOTAL=$(cat /tmp/gchange.json | jq .hits.total) echo 'tail -f ~/.zen/cache/gchange.txt' echo '# #GCHANGE-Market' > ~/.zen/cache/gchange.txt -echo "> A $RAD de la [position](https://demo.cesium.app/#/app/wot/map) de mon [portefeuille](https://demo.cesium.app/#/app/wot/$g1pub/)" >> ~/.zen/cache/gchange.txt +echo "Le profil géolocalisé de ce [portefeuille](https://demo.cesium.app/#/app/wot/$g1pub/)" >> ~/.zen/cache/gchange.txt +echo "reçoit les annonces [situées dans un rayon de $RAD](https://www.openstreetmap.org/#map=10/$LAT/$LON) " >> ~/.zen/cache/gchange.txt chunk=0 +fullcount=0 + +DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh) +DUNITERURL="https://$DUNITERNODE" +LASTDU=$(curl -s ${DUNITERURL}/blockchain/with/ud | jq '.result.blocks[]' | tail -n 1); +[[ $LASTDU != "" ]] && LASTDU=$(curl -s ${DUNITERURL}/blockchain/block/${LASTDU} | jq '.dividend') +echo "DU = $LASTDU G1" + for gID in $(cat /tmp/gchange.json | jq -r .hits.hits[]._id); do - [[ -f ~/.zen/ipfs_swarm/gchange/$gID.json ]] && INSWARM="true" + NEW="" - [[ ! -f ~/.zen/cache/gchange/$gID.json ]] && NEW="true" \ + + #[[ ! -f ~/.zen/cache/gchange/$gID.json ]] && + NEW="true" \ && curl -s --create-dirs -o ~/.zen/cache/gchange/$gID.json -s https://data.gchange.fr/market/record/$gID?_source=category,title,description,issuer,time,creationTime,location,address,city,price,unit,currency,thumbnail._content_type,thumbnail._content,picturesCount,type,stock,fees,feesCurrency,geoPoint \ && sleep $((1 + RANDOM % 3)) + type=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.type) + # [[ $type == "need" ]] && continue creationTime=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.creationTime) title=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.title) + currency=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.currency) price=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.price) - [[ $price == null ]] && price="A débattre" || price=$(bc -l <<< "scale=2; $price / 100") - - categoryname=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.category.name) - [[ $NEW == "true" ]] && echo "- [$title](https://data.gchange.fr/market/record/$gID/_share) PRIX $price ($currency)" >> ~/.zen/cache/gchange.txt && chunk=$((chunk+1)) + categoryname=$(cat ~/.zen/cache/gchange/$gID.json | jq -r ._source.category.name) + + [[ $price == null ]] && price="0" + [[ $currency == "g1" ]] && love=$(bc -l <<< "scale=2; $price / $LASTDU * 100") || love="?.??" + love="$love LOVE" + price=$(bc -l <<< "scale=2; $price / 100") + + fullcount=$((fullcount+1)) && echo "DEBUG : $fullcount - $type - $price $currency - $title " + [[ $price == "0" ]] && love="OFFERT !?" && price="A débattre " + + + [[ $NEW == "true" ]] \ + && echo "- [$title](https://data.gchange.fr/market/record/$gID/_share) :heart: $love" >> ~/.zen/cache/gchange.txt \ + && chunk=$((chunk+1)) && echo $chunk done echo "$chunk nouvelles annonces ($TOTAL)" >> ~/.zen/cache/gchange.txt diff --git a/zen/tools/make_G1SSB_secret.sh b/zen/tools/make_G1SSB_secret.sh index 91f4bb2..1ffaa58 100755 --- a/zen/tools/make_G1SSB_secret.sh +++ b/zen/tools/make_G1SSB_secret.sh @@ -53,6 +53,25 @@ fi cd ~/.zen/astroport +# Install nvm +echo ' + __ _ + ____ ____ ____/ /__ (_)____ + / __ \/ __ \/ __ / _ \ / / ___/ + / / / / /_/ / /_/ / __/ / (__ ) +/_/ /_/\____/\__,_/\___/ __/ /____/ + /___/ + + +' +if [[ ! $(which nvm) ]]; then + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash + source ~/.bashrc + export NVM_DIR="$HOME/.nvm" + nvm install --lts +fi + + # INSTALL Silkaj, CLI for Duniter echo '************************************************************** __ ___