From 96918e66d19661d693e8b447688b739c19b8e642 Mon Sep 17 00:00:00 2001 From: fred Date: Mon, 24 Oct 2022 16:19:33 +0200 Subject: [PATCH] Rebuilt Core based on G1FRIENDS get from Gchange cache --- ASTROBOT/PLAYER.refresh.sh | 10 +-- ASTROBOT/VOEUX.create.sh | 2 +- ASTROBOT/VOEUX.refresh.sh | 124 ++++++++++--------------------------- 3 files changed, 37 insertions(+), 99 deletions(-) diff --git a/ASTROBOT/PLAYER.refresh.sh b/ASTROBOT/PLAYER.refresh.sh index 1443fa3d..296719a6 100755 --- a/ASTROBOT/PLAYER.refresh.sh +++ b/ASTROBOT/PLAYER.refresh.sh @@ -20,10 +20,15 @@ for PLAYER in $(ls ~/.zen/game/players/); do echo "##################################################################" echo ">>>>> PLAYER : $PLAYER" echo "##################################################################" + # Get PLAYER wallet amount + COINS=$($MY_PATH/../tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey balance) + echo "+++ WALLET BALANCE _ $COINS (G1) _" + echo echo " ## MANAGE GCHANGE+ & Ŋ1 EXPLORATION" ${MY_PATH}/../tools/Connect_PLAYER_To_Gchange.sh "$PLAYER" echo "##################################################################" echo "##################################################################" + echo "################### REFRESH ASTRONAUTE TW ###########################" echo "##################################################################" PSEUDO=$(cat ~/.zen/game/players/$PLAYER/.pseudo 2>/dev/null) @@ -34,11 +39,6 @@ for PLAYER in $(ls ~/.zen/game/players/); do rm -Rf ~/.zen/tmp/astro mkdir -p ~/.zen/tmp/astro - # Get PLAYER wallet amount - COINS=$($MY_PATH/../tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey balance) - echo "+++ WALLET BALANCE _ $COINS (G1) _" - echo - myIP=$(hostname -I | awk '{print $1}' | head -n 1) echo "Getting latest online TW..." diff --git a/ASTROBOT/VOEUX.create.sh b/ASTROBOT/VOEUX.create.sh index d4f6f4fe..6f89f39a 100755 --- a/ASTROBOT/VOEUX.create.sh +++ b/ASTROBOT/VOEUX.create.sh @@ -30,7 +30,7 @@ echo "$INDEX [tag[voeu]] ?" rm -f ~/.zen/tmp/voeu.json tiddlywiki --load ${INDEX} --output ~/.zen/tmp --render '.' 'voeu.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[voeu]]' -[[ ! -s ~/.zen/tmp/voeu.json ]] && echo "Aucun Tiddler avec le tag voeu..." && exit 0 +[[ ! -s ~/.zen/tmp/voeu.json ]] && echo "AUCUN VOEU - EXIT -" && exit 0 ## Tous les tiddlers comportant le tag "voeu" lancent la création d'un G1VOEU ayant le titre du Voeu comme génrateur de clef TW (pepper). for VOEU in "$(cat ~/.zen/tmp/voeu.json | jq -r '.[].title')" diff --git a/ASTROBOT/VOEUX.refresh.sh b/ASTROBOT/VOEUX.refresh.sh index 955d6b62..71bf07c2 100755 --- a/ASTROBOT/VOEUX.refresh.sh +++ b/ASTROBOT/VOEUX.refresh.sh @@ -27,7 +27,10 @@ echo "Exporting $PLAYER TW [tag[G1Voeu]]" rm -f ~/.zen/tmp/g1voeu.json tiddlywiki --load ${INDEX} --output ~/.zen/tmp --render '.' 'g1voeu.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[G1Voeu]]' +[[ ! -s ~/.zen/tmp/g1voeu.json ]] && echo "AUCUN G1VOEU - EXIT -" && exit 1 + cat ~/.zen/tmp/g1voeu.json | jq -r '.[].wish' > ~/.zen/tmp/g1wishes +echo "NB DE VOEUX : "$(cat ~/.zen/tmp/g1wishes | wc -l) echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%" @@ -38,10 +41,12 @@ do echo "===============================" echo "G1Voeu $WISH" ## Get $WISHNAME TW - WISHNAME=$(cat ~/.zen/game/world/$WISH/.pepper) - [[ ! $WISHNAME ]] && echo "ERROR - Missing WISHNAME !! CONTINUE" && continue + WISHNAME=$(cat ~/.zen/tmp/g1voeu.json | jq -r '.title | select(.wish | strings | test("'$WISH'"))') + [[ ! $WISHNAME ]] && echo "WISH sans NOM - CONTINUE -" && continue + VOEUNS=$(cat ~/.zen/tmp/g1voeu.json | jq -r '.ipns | select(.wish | strings | test("'$WISH'"))') + + mkdir -p ~/.zen/tmp/$WISHNAME/$WISH - WISHINDEX="$HOME/.zen/game/world/$WISH/index.html" ## RUN SPECIFIC G1Voeu Treatment (G1CopierYoutube.sh) if [[ -s $MY_PATH/G1$WISHNAME.sh ]]; then echo "........................ Astrobot G1$WISHNAME.sh program found !" @@ -54,110 +59,43 @@ do ## RUN TW search & copy treatment echo "*********************************" - echo "Search & Collect Ŋ1 G1$WISHNAME tids" - - ## CLEAN OLD CACHE - rm -Rf ~/.zen/tmp/work - mkdir -p ~/.zen/tmp/work - echo "VOEU : $WISHNAME : $WISH" - VOEUNS=$(ipfs key list -l | grep $WISH | cut -d ' ' -f1) - echo "http://$myIP:8080/ipns/$VOEUNS" - echo "===============================" - - YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); - LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) - echo "$LIBRA/ipns/$VOEUNS" - echo "http://$myIP:8080/ipns/$VOEUNS" - echo "Getting latest online TW..." - [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$VOEUNS > ~/.zen/tmp/work/index.html \ - || curl -m 12 -so ~/.zen/tmp/work/index.html "$LIBRA/ipns/$VOEUNS" - - if [[ ! -s ~/.zen/tmp/work/index.html ]]; then - echo "UNAVAILABLE WISH! If you want to remove $WISHNAME $VOEU" - echo "ipfs key rm $VOEU && rm -Rf ~/.zen/game/world/$VOEU" - echo "=============================================" - echo "ipfs name publish -t 72h /ipfs/$(cat ~/.zen/game/world/$VOEU/.chain)" - echo "=============================================" - ## CONTINUE - COULD WORK ON LOCAL CACHE ?? - continue - else - ################################## ## Search for [tag[G1$WISHNAME]] in all Friends TW. ## Copy tiddlers ... ################################## - echo "NEXT SEARCH Ŋ1 FRIENDS TW's FOR tag=$WISHNAME" + echo "NOW SEARCH Ŋ1 FRIENDS TW's FOR tag=$WISHNAME" + echo "*********************************" ## Search in Local World (NB! G1Voeu TW copied by Connect_PLAYER_To_Gchange.sh) - for pepperpath in $(grep -lw "$WISHNAME" ~/.zen/game/world/*/.pepper); + FINDEX=($( ls $HOME/.zen/game/players/$PLAYER/FRIENDS/*/index.html)) + + for FRIENDTW in ${FINDEX[@]}; do - G1PUB=$(echo $pepperpath | rev | cut -d '/' -f 2 | rev) - ##### EACH FRIEND SAME G1VOEU HAVE SAME PEPPER - VTWINDEX="$HOME/.zen/game/world/$G1PUB/index.html" - ##### Search Friend TW to get All Tiddlers G1Voeu tiddlers and copy to Player G1Voeu TW - tiddlywiki --load $VTWINDEX --output ~/.zen/tmp --render '.' 'astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport' - FRIENDNS=$(cat ~/.zen/tmp/astroport.json | jq -r .[].astroport) ## Value exists also in "MadeInZion" tiddler - G1FRIEND=$(cat ~/.zen/tmp/astroport.json | jq -r .[].g1pub) ## Value exists also in "MadeInZion" tiddler + rm -f ~/.zen/tmp/$WISHNAME/g1wishtiddlers.json + echo "TRY EXPORT [tag[G1$WISHNAME]] FROM $FINDEX" + tiddlywiki --load $FRIENDTW \ + --output ~/.zen/tmp/$WISHNAME --render '.' 'g1wishtiddlers.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[G1'$WISHNAME']]' + [[ ! -s ~/.zen/tmp/$WISHNAME/g1wishtiddlers.json ]] && echo "NO $WISHNAME - CONTINUE" && continue - [[ ! $FRIENDNS ]] && echo "ERROR MISSING /ipns/astroport FOR THAT WISH - CONTINUE -" && continue - [[ $FRIENDNS == $ASTRONAUTENS ]] && echo "One of My Wish !! - CONTINUE -" && continue + echo "## WISHES FOUND ;) MIAM " + ## TODO ADD EXTRA TAG ? + echo ">>> Importing ~/.zen/tmp/$WISHNAME/g1wishtiddlers.json" - FINDEX="$HOME/.zen/game/players/$PLAYER/FRIENDS/$G1FRIEND/index.html" + tiddlywiki --load $INDEX \ + --import "~/.zen/tmp/$WISHNAME/g1wishtiddlers.json" "application/json" \ + --output ~/.zen/tmp/$WISHNAME/$WISH --render "$:/core/save/all" "newindex.html" "text/plain" - echo "Expport [tag[G1$WISHNAME]] from $FINDEX" - tiddlywiki --load $FINDEX \ - --output ~/.zen/tmp --render '.' 'g1wishtiddlers.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[G1'$WISHNAME']]' - [[ ! -s ~/.zen/tmp/g1wishtiddlers.json ]] && echo "ERROR - FAILED" && continue + if [[ -s ~/.zen/tmp/$WISHNAME/$WISH/newindex.html ]]; then + echo "Updating $INDEX" + cp ~/.zen/tmp/$WISHNAME/$WISH/newindex.html $INDEX + else + echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/$WISHNAME/$WISH/newindex.html" + echo "XXXXXXXXXXXXXXXXXXXXXXX" + fi - # TODO Add Friends G1Voeu Tiddlers to my G1Voeu - ## DIRECTLY LOOP SCAN FRIENDS TW !? - ##### done - - echo "DIFFERENCE ?" - DIFF=$(diff ~/.zen/tmp/work/index.html ~/.zen/game/world/$VOEU/index.html) - - if [[ $DIFF ]]; then - echo "Upgrade TW local copy..." - cp ~/.zen/tmp/work/index.html ~/.zen/game/world/$VOEU/index.html - else - echo "No change since last Refresh" - fi - fi - - # RECORDING CHANGES - MOATS=$(date -u +"%Y%m%d%H%M%S%4N") - [[ $DIFF ]] && cp ~/.zen/game/world/$VOEU/.chain \ - ~/.zen/game/world/$VOEU/.chain.$(cat ~/.zen/game/world/$VOEU/.moats) - - # PUBLISH VOEU TW - IPUSH=$(ipfs add -Hq ~/.zen/game/world/$VOEU/index.html | tail -n 1) - ipfs name publish -t 24h --key=${VOEU} /ipfs/$IPUSH 2>/dev/null - - [[ $DIFF ]] && echo $IPUSH > ~/.zen/game/world/$VOEU/.chain; \ - echo $MOATS > ~/.zen/game/world/$VOEU/.moats - - rm -Rf ~/.zen/tmp/work - - echo "================================================" - echo "$WISHNAME : http://$myIP:8080/ipns/$VOEUNS" - echo "================================================" - echo - echo "*****************************************************" - - done < ~/.zen/tmp/g1wishes ############################################ -echo "## WORLD VOEUX LIST = " -myIP=$(hostname -I | awk '{print $1}' | head -n 1) - -for v in $(cat ~/.zen/game/players/*/voeux/*/.title); do echo $v ;done - -for VOEU in $(ls ~/.zen/game/world/); -do - echo "$VOEU" - ## TODO REFESH IPNS -done exit 0