diff --git a/20h12.process.sh b/20h12.process.sh index 468b2d90..6c62b193 100755 --- a/20h12.process.sh +++ b/20h12.process.sh @@ -18,7 +18,7 @@ git pull ## SOON /ipns/ Address !!! # Refresh ~/.zen/game/world/G1VOEU -~/.zen/Astroport.ONE/ASTROBOT/VOEUX.refresh.sh +# NOW RUN FROM PLAYER.refresh.sh !! ~/.zen/Astroport.ONE/ASTROBOT/VOEUX.refresh.sh # Refresh ~/.zen/game/players/PLAYER ~/.zen/Astroport.ONE/ASTROBOT/PLAYER.refresh.sh diff --git a/ASTROBOT/G1Voeu.sh b/ASTROBOT/G1Voeu.sh index 2ddc637d..1bd8c302 100755 --- a/ASTROBOT/G1Voeu.sh +++ b/ASTROBOT/G1Voeu.sh @@ -9,12 +9,12 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" ################################################################################ # Create G1VOEU TW for PLAYER -# TITRE => G1TITRE => PEPPER -## PARAM : "TITRE DU VOEU" "PLAYER" +# Mon Titre => G1MonTitre => PEPPER +## PARAM : "TITRE DU VOEU" "PLAYER" "INDEX" ################################################################################ TITRE="$1" PLAYER="$2" -INDEX="$3" ## When called from VOEUX.create.sh (Not provided in CLI start.sh ) +INDEX="$3" [[ $PLAYER == "" ]] && PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) [[ $PLAYER == "" ]] && echo "Second paramètre PLAYER manquant" && exit 1 @@ -23,7 +23,8 @@ PSEUDO=$(cat ~/.zen/game/players/$PLAYER/.pseudo 2>/dev/null) [[ $G1PUB == "" ]] && echo "Troisième paramètre G1PUB manquant" && exit 1 [[ ! $INDEX ]] && echo "MISSING ASTRONAUTE TW index.html" && exit 1 -echo "Working on $INDEX" # FROM VOEUX.create.sh + +echo "Working on $INDEX" ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1) [[ $ASTRONAUTENS == "" ]] && echo "ASTRONAUTE manquant" && exit 1 @@ -86,7 +87,7 @@ echo cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/world/$WISHKEY/index.html # TODO : CREATE ONE TEMPLATE / REMOVE USELESS TID - # PERSONNALISATION + # PERSONNALISATION "MadeInZion" sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/world/$WISHKEY/index.html sed -i "s~_PSEUDO_~${PSEUDO}~g" ~/.zen/game/world/$WISHKEY/index.html sed -i "s~_PLAYER_~${PLAYER}~g" ~/.zen/game/world/$WISHKEY/index.html @@ -115,7 +116,9 @@ echo --import ~/.zen/Astroport.ONE/templates/data/local.gw.json "application/json" \ --deletetiddlers '"Dessin de Moa"' \ --output ~/.zen/tmp --render "$:/core/save/all" "newindex.html" "text/plain" + [[ -s ~/.zen/tmp/newindex.html ]] && cp ~/.zen/tmp/newindex.html ~/.zen/game/world/$WISHKEY/index.html + [[ ! -s ~/.zen/tmp/newindex.html ]] && echo "ERROR ~/.zen/tmp/newindex.html MISSING" && exit 1 ## EXTEND ipfs daemon accreditation ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://'$myIP':8080", "http://127.0.0.1:8080", "http://astroport:8080", "http://astroport.com:8080", "https://astroport.com", "https://qo-op.com", "http://qo-op.com:8080", "https://tube.copylaradio.com", "http://'$(hostname)'.local:8080" ]' @@ -178,8 +181,9 @@ convert -gravity northwest -pointsize 50 -fill black -draw "text 30,300 \"$PEPPE { "title": "'${PEPPER}'", "type": "'text/vnd.tiddlywiki'", - "ipns": "'/ipns/$VOEUNS'", - "ipfs": "'/ipfs/$IVOEUPLAY'", + "astronautens": "'$ASTRONAUTENS'", + "ipns": "'$VOEUNS'", + "wish": "'$WISHKEY'", "text": "'$TEXT'", "tags": "'G1Voeu G1${PEPPER}'" } diff --git a/ASTROBOT/PLAYER.refresh.sh b/ASTROBOT/PLAYER.refresh.sh index 2ee107ab..e8001844 100755 --- a/ASTROBOT/PLAYER.refresh.sh +++ b/ASTROBOT/PLAYER.refresh.sh @@ -1,7 +1,7 @@ #!/bin/bash ################################################################################ # Author: Fred (support@qo-op.com) -# Version: 0.1 +# Version: 0.2 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ################################################################################ MY_PATH="`dirname \"$0\"`" # relative @@ -28,8 +28,8 @@ for PLAYER in $(ls ~/.zen/game/players/); do mkdir -p ~/.zen/tmp/astro # Get PLAYER wallet amount - BAL=$($MY_PATH/../tools/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey balance) - echo "+++ WALLET BALANCE _ $BAL (G1) _" + 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) @@ -45,35 +45,39 @@ for PLAYER in $(ls ~/.zen/game/players/); do ## PLAYER TW IS ONLINE ? if [ ! -s ~/.zen/tmp/astro/index.html ]; then + echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" echo "ERROR_PLAYERTW_TIMEOUT : /ipns/$ASTRONAUTENS" echo "------------------------------------------------" echo "MANUAL PROCEDURE NEEDED" echo "------------------------------------------------" echo "TW=$(ipfs add -Hq ~/.zen/game/players/$PLAYER/ipfs/moa/index.html | tail -n 1)" echo "ipfs name publish -t 72h --key=$PLAYER /ipfs/\$TW" + echo "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" continue else - ## CHECK IF myIP IS LAST GATEWAY + ############################################################# + ## CHECK IF myIP IS ACTUAL OFFICIAL GATEWAY tiddlywiki --load ~/.zen/tmp/astro/index.html --output ~/.zen/tmp --render '.' 'miz.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion' OLDIP=$(cat ~/.zen/tmp/miz.json | jq -r .[].secret) - - # FIRST TW MANAGER + # FIRST TIME PLAYER TW USING GATEWAY [[ $OLDIP == "_SECRET_" ]] && sed -i "s~_SECRET_~${myIP}~g" ~/.zen/tmp/astro/index.html && OLDIP=$myIP - # ALREADY MANAGED TW + # AM I MANAGING TW [[ $OLDIP != $myIP ]] && echo "ASTRONAUTE GATEWAY IS http://$OLDIP:8080/ipns/$ASTRONAUTENS - BYPASSING -" && continue + ############################################################# - + # VOEUX.create.sh ############################################################## ## SPECIAL TAG "voeu" => Creation G1Voeu (G1Titre) makes AstroBot TW G1Processing ############################################################## $MY_PATH/VOEUX.create.sh ~/.zen/tmp/astro/index.html $PLAYER + + # VOEUX.refresh.sh ############################################################## - ## RUN ASTROBOT SUBPROCESS (SEARCH FOR SPECIFIC OR RUN STANDARD Ŋ1 SYNC) + ## RUN ASTROBOT G1Voeux SUBPROCESS (SPECIFIC AND STANDARD Ŋ1 SYNC) ############################################################## - ## TAG="tube" tiddler => Dowload youtube video links (playlist accepted) ## WISHKEY=PLAYER or G1PUB ! - $MY_PATH/G1CopierYoutube.sh ~/.zen/tmp/astro/index.html $PLAYER + $MY_PATH/VOEUX.refresh.sh ~/.zen/tmp/astro/index.html $PLAYER ############################################################## ## ANY CHANGES ? @@ -91,18 +95,13 @@ for PLAYER in $(ls ~/.zen/game/players/); do fi # - + ############################################################## + ## TODO : Make it G1Voeu with program contained in a tiddler using G1AstroBot ;) ## REFRESH G1BARRE for ALL G1VOEUX in PLAYER TW ############################################################## # ~/.zen/Astroport.ONE/tools/G1Barre4Player.sh $PLAYER ############################################################## -############################ -## ASTRONAUTE SIGNALING ## -[[ ! $(grep -w "$ASTRONAUTENS" ~/.zen/game/astronautes.txt ) ]] && echo "$PSEUDO:$PLAYER:$ASTRONAUTENS" >> ~/.zen/game/astronautes.txt -############################ - - MOATS=$(date -u +"%Y%m%d%H%M%S%4N") [[ $DIFF ]] && cp ~/.zen/game/players/$PLAYER/ipfs/moa/.chain \ ~/.zen/game/players/$PLAYER/ipfs/moa/.chain.$(cat ~/.zen/game/players/$PLAYER/ipfs/moa/.moats) @@ -120,12 +119,15 @@ for PLAYER in $(ls ~/.zen/game/players/); do done ################################################################# -## IPFSNODEID ROUTING +## IPFSNODEIDE ASTRONAUTES SIGNALING ## +############################ ## PUBLISHING ASTRONAUTS LIST -## EVOLVE TO P2P QOS MAP JSON +[[ ! $(grep -w "$ASTRONAUTENS" ~/.zen/game/astronautes.txt ) ]] && echo "$PSEUDO:$PLAYER:$ASTRONAUTENS" >> ~/.zen/game/astronautes.txt +############################ +## TODO EVOLVE TO P2P QOS MAPPING +cat ~/.zen/game/astronautes.txt ROUTING=$(ipfs add -q ~/.zen/game/astronautes.txt) echo "PUBLISHING Astronaute List SELF" ipfs name publish /ipfs/$ROUTING -cat ~/.zen/game/astronautes.txt exit 0 diff --git a/ASTROBOT/VOEUX.create.sh b/ASTROBOT/VOEUX.create.sh index ba6c90a4..8fd30125 100755 --- a/ASTROBOT/VOEUX.create.sh +++ b/ASTROBOT/VOEUX.create.sh @@ -1,6 +1,7 @@ #!/bin/bash ######################################################################## -# Version: 0.4 +# Author: Fred (support@qo-op.com) +# Version: 0.5 # License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/) ######################################################################## MY_PATH="`dirname \"$0\"`" # relative diff --git a/ASTROBOT/VOEUX.refresh.sh b/ASTROBOT/VOEUX.refresh.sh index 41be0876..0439e6d7 100755 --- a/ASTROBOT/VOEUX.refresh.sh +++ b/ASTROBOT/VOEUX.refresh.sh @@ -10,24 +10,50 @@ ME="${0##*/}" ################################################################################ # Inspect game wishes, refresh latest IPNS version # SubProcess Backup and chain +INDEX="$1" +[[ ! $INDEX ]] && echo "Please provide path to source TW index.html" && exit 1 +[[ ! -f $INDEX ]] && echo "Fichier TW absent. $INDEX" && exit 1 -############################################ -echo "## WORLD VOEUX" -myIP=$(hostname -I | awk '{print $1}' | head -n 1) +PLAYER="$2" ## IPNS KEY NAME - G1PUB - PLAYER ... +[[ ! $PLAYER ]] && echo "Please provide IPFS publish key" && exit 1 +ASTRONAUTENS=$(ipfs key list -l | grep -w $PLAYER | cut -d ' ' -f1) -for v in $(cat ~/.zen/game/players/*/VOEUx/*/.title); do echo $v ;done +[[ ! $ASTRONAUTENS ]] && echo "$PLAYER IPNS INTROUVABLE" && exit 1 -for VOEU in $(ls ~/.zen/game/world/); +############################### +## EXTRACT G1Voeu from PLAYER TW +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]]' + +## GET VoeuTitle LIST +for WISH in "$(cat ~/.zen/tmp/g1voeu.json | jq -r '.[].wish')" do - [[ ! -d ~/.zen/game/world/$VOEU ]] && echo "BAD $VOEU - CONTINUE -" && continue + echo "G1Voeu $WISH" + ## Get $WISHNAME TW + WISHNAME=$(cat ~/.zen/game/world/$WISH/.pepper) + [[ ! $WISHNAME ]] && echo "ERROR - Missing WISHNAME !! CONTINUE" && continue + + 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 !" + echo "________________________________ Running it *****" + ${MY_PATH}/G1${WISHNAME}.sh "$INDEX" "$PLAYER" + echo "________________________________ Finished ******" + + fi + + ## RUN TW search & copy treatment + echo "Search & Collect default program" + ## CLEAN OLD CACHE rm -Rf ~/.zen/tmp/work mkdir -p ~/.zen/tmp/work echo "===============================" - echo "VOEU : $VOEU" - VOEUNS=$(ipfs key list -l | grep $VOEU | cut -d ' ' -f1) - WISHNAME=$(cat ~/.zen/game/world/$VOEU/.pepper 2>/dev/null) - echo "$WISHNAME" + echo "VOEU : $WISHNAME : $WISH" + VOEUNS=$(ipfs key list -l | grep $WISH | cut -d ' ' -f1) + echo "/ipns/$VOEUNS" echo "===============================" YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1); @@ -44,14 +70,40 @@ do echo "=============================================" echo "ipfs name publish -t 72h /ipfs/$(cat ~/.zen/game/world/$VOEU/.chain)" echo "=============================================" - + ## CONTINUE - COULD WORK ON LOCAL CACHE ?? continue else - echo "SEARCH VOEU TW FOR tag=tube" - ## TAG="tube" tiddler => Dowload youtube video links (playlist accepted) ## WISHKEY=G1PUB ! - $MY_PATH/G1CopierYoutube.sh ~/.zen/tmp/work/index.html $VOEU + ################################## + ## Search for [tag[G1$WISHNAME]] in all Friends TW. + ## Copy tiddlers ... + ################################## echo "NEXT SEARCH Ŋ1 FRIENDS TW's FOR tag=$WISHNAME" + ## Search in Local World (NB! G1Voeu TW copied by Connect_PLAYER_To_Gchange.sh) + for pepperpath in $(grep -lw "$WISHNAME" ~/.zen/game/world/*/.pepper); + 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 + + [[ ! $FRIENDNS ]] && echo "MISSING /ipns/astroport FOR THAT WISH" && continue + [[ $FRIENDNS == $ASTRONAUTENS ]] && echo "One of My Wish !! " && continue + + FINDEX="$HOME/.zen/game/players/$PLAYER/FRIENDS/$G1FRIEND/index.html" + 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 + + # TODO Add Friends G1Voeu Tiddlers to my G1Voeu + + ##### + done + echo "DIFFERENCE ?" DIFF=$(diff ~/.zen/tmp/work/index.html ~/.zen/game/world/$VOEU/index.html) @@ -71,7 +123,7 @@ do # PUBLISH VOEU TW IPUSH=$(ipfs add -Hq ~/.zen/game/world/$VOEU/index.html | tail -n 1) - ipfs name publish -t 72h --key=${VOEU} /ipfs/$IPUSH 2>/dev/null + 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 @@ -84,6 +136,19 @@ do echo echo "*****************************************************" + + +done + +############################################ +echo "## WORLD VOEUX" +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 + done exit 0 diff --git a/tools/Connect_PLAYER_To_Gchange.sh b/tools/Connect_PLAYER_To_Gchange.sh index 6f3bf373..a72531a7 100755 --- a/tools/Connect_PLAYER_To_Gchange.sh +++ b/tools/Connect_PLAYER_To_Gchange.sh @@ -6,18 +6,24 @@ MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized ME="${0##*/}" ######################################################################### CONNECT PLAYER WITH GCHANGE # Check who is .current PLAYER -PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) || ( echo "noplayer" && exit 1 ) -PSEUDO=$(cat ~/.zen/game/players/.current/.pseudo 2>/dev/null) || ( echo "nopseudo" && exit 1 ) -G1PUB=$(cat ~/.zen/game/players/.current/.g1pub 2>/dev/null) || ( echo "nog1pub" && exit 1 ) +PLAYER="$1" + +[[ $PLAYER == "" ]] && PLAYER=$(cat ~/.zen/game/players/.current/.player 2>/dev/null) +[[ $PLAYER == "" ]] && echo "ERROR PLAYER - EXIT" && exit 1 +PSEUDO=$(cat ~/.zen/game/players/$PLAYER/.pseudo 2>/dev/null) +[[ $G1PUB == "" ]] && G1PUB=$(cat ~/.zen/game/players/$PLAYER/.g1pub 2>/dev/null) +[[ $G1PUB == "" ]] && echo "ERROR G1PUB - EXIT" && exit 1 ASTRONAUTENS=$(ipfs key list -l | grep -w "$PLAYER" | cut -d ' ' -f 1) +[[ ! $ASTRONAUTENS ]] && echo "ERROR ASTRONAUTENS - EXIT" && exit 1 +## Directory is created, So this script already run once. if [[ ! -d ~/.zen/game/players/$PLAYER/FRIENDS/ ]]; then ######################################################################## echo "CREATING $PLAYER GCHANGE+ PROFILE" ######################################################################## - $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" set --name "Astronaute $PSEUDO" --avatar "/home/$USER/.zen/Astroport.ONE/images/logo.png" --site "https://astroport.com/ipns/$ASTRONAUTENS" #GCHANGE+ - [[ ! $? == 0 ]] && echo "GCHANGE PROFILE CREATION FAILED" && echo "Action Manuelle " $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" set --name "Astronaute $PSEUDO" --avatar "/home/$USER/.zen/Astroport.ONE/images/logo.png" --site "https://tube.copylaradio.com/ipns/$ASTRONAUTENS" #GCHANGE+ + $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" set --name "Astronaute $PSEUDO" --avatar "/home/$USER/.zen/Astroport.ONE/images/logo.png" --site "http://qo-op.com:8080/ipns/$ASTRONAUTENS" #GCHANGE+ + [[ ! $? == 0 ]] && echo "GCHANGE PROFILE CREATION FAILED" && echo "Action Manuelle " $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" set --name "Astronaute $PSEUDO" --avatar "/home/$USER/.zen/Astroport.ONE/images/logo.png" --site "http://qo-op.com:8080/ipns/$ASTRONAUTENS" #GCHANGE+ ######################################################################## #echo "CREATING $PLAYER CESIUM+ PROFILE" @@ -29,27 +35,30 @@ fi ######################################################################## ######################################################################## -echo "SCANNING $PLAYER Gchange FRIENDS" +echo "SCANNING $PLAYER - $G1PUB - Gchange FRIENDS" ######################################################################## ################## CHECKING WHO GAVE ME STARS ################## BOOTSTRAP LIKES THEM BACK ################## SEND ipfstryme MESSAGES to FRIENDS rm -f ~/.zen/tmp/my_star_level ## Getting Gchange liking_me list -echo "Reading received stars" +echo "Getting received stars" ################################## JAKLIS PLAYER stars ~/.zen/Astroport.ONE/tools/timeout.sh -t 20 \ ~/.zen/Astroport.ONE/tools/jaklis/jaklis.py \ -k ~/.zen/game/players/$PLAYER/secret.dunikey \ --n "https://data.gchange.fr" stars | jq -r '.likes[].issuer' | uniq > ~/.zen/tmp/liking_me +-n "https://data.gchange.fr" stars > ~/.zen/tmp/received_stars.json + +cat ~/.zen/tmp/received_stars.json | jq -r '.likes[].issuer' | uniq > ~/.zen/tmp/liking_me +echo "cat ~/.zen/tmp/received_stars.json | jq -r" for liking_me in $(cat ~/.zen/tmp/liking_me | sort | uniq); do - [[ "$liking_me" == "" ]] && continue ## Protect from empty line !! + [[ "${liking_me}" == "" ]] && continue ## Protect from empty line !! - ipfsnodeid=$(~/.zen/Astroport.ONE/tools/g1_to_ipfs.py $liking_me) - echo "$liking_me is Astronaut ?" - echo "Check TW Capsule https://tube.copylaradio.com/ipns/$ipfsnodeid " + ipfsnodeid=$(~/.zen/Astroport.ONE/tools/g1_to_ipfs.py ${liking_me}) + echo "${liking_me} is Astronaut ?" + echo "Get TW Capsule http://qo-op.com:8080/ipns/$ipfsnodeid " ##### CHECKING IF WE LIKE EACH OTHER Ŋ1 LEVEL ################################## JAKLIS LIKING_ME stars @@ -57,36 +66,37 @@ do ~/.zen/Astroport.ONE/tools/jaklis/jaklis.py \ -k ~/.zen/game/players/$PLAYER/secret.dunikey \ -n "https://data.gchange.fr" \ - stars -p $liking_me > ~/.zen/tmp/Gstars.json + stars -p ${liking_me} > ~/.zen/tmp/${liking_me}.Gstars.json + echo "Got Stars : cat ~/.zen/tmp/${liking_me}.Gstars.json | jq -r" ## ZOMBIE PROTECTION - [[ "$?" == "0" && ! -s ~/.zen/tmp/Gstars.json ]] && rm -Rf ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me && echo "$liking_me is a ZOMBIE..." && continue + [[ "$?" == "0" && ! -s ~/.zen/tmp/${liking_me}.Gstars.json ]] && rm -Rf ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me} && echo "${liking_me} is a ZOMBIE..." && continue #### RECUP ANNONCES Gchange ## https://www.gchange.fr/#/app/records/wallet?q=2geH4d2sndR47XWtfDWsfLLDVyNNnRsnUD3b1sk9zYc4&old ## https://www.gchange.fr/#/app/market/records/42LqLa7ARTZqUKGz2Msmk79gwsY8ZSoFyMyPyEnoaDXR - ## DATA EXTRACTION FROM ~/.zen/tmp/Gstars.json - my_star_level=$(cat ~/.zen/tmp/Gstars.json | jq -r '.yours.level'); - f_score=$(cat ~/.zen/tmp/Gstars.json | jq -r '.score'); - myfriendship=$(cat ~/.zen/tmp/Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$G1PUB'"))') + ## DATA EXTRACTION FROM ~/.zen/tmp/${liking_me}.Gstars.json + my_star_level=$(cat ~/.zen/tmp/${liking_me}.Gstars.json | jq -r '.yours.level'); + f_score=$(cat ~/.zen/tmp/${liking_me}.Gstars.json | jq -r '.score'); + myfriendship=$(cat ~/.zen/tmp/${liking_me}.Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$G1PUB'"))') ## OH MY FRIEND ! - if [[ "$my_star_level" != "null" && "$liking_me" != "$G1PUB" ]] + if [[ "$my_star_level" != "null" && "${liking_me}" != "$G1PUB" ]] then - # ADD $liking_me TO MY ipfs FRIENDS list - echo "$liking_me ($my_star_level stars) : Ŋ1 SCORE $f_score " - mkdir -p ~/.zen/game/players/$PLAYER/FRsIENDS/$liking_me + # ADD ${liking_me} TO MY ipfs FRIENDS list + echo "${liking_me} ($my_star_level stars) : Ŋ1 SCORE $f_score " + mkdir -p ~/.zen/game/players/$PLAYER/FRsIENDS/${liking_me} # REFRESH & PUBLISH stars friends map if [[ "$my_star_level" == "null" || "$my_star_level" == "" ]]; then - rm -Rf ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me - echo "$my_star_level NO STAR !! Removing $liking_me" + rm -Rf ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me} + echo "$my_star_level NO STAR !! Removing ${liking_me}" ## TODO : remove "ipfs pin" in "~/.zen/PIN/" continue ## REMOVE NO GOOD FRIENDS (no star) fi - cp ~/.zen/tmp/Gstars.json ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/ && rm -f ~/.zen/tmp/Gstars.json - echo "$my_star_level" > ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/stars.level && echo "***** $my_star_level STARS *****" + cp ~/.zen/tmp/${liking_me}.Gstars.json ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/ && rm -f ~/.zen/tmp/${liking_me}.Gstars.json + echo "$my_star_level" > ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/stars.level && echo "***** $my_star_level STARS *****" ## GET FRIEND TW !! echo "Getting latest online TW..." @@ -94,40 +104,88 @@ do LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | cut -d ' ' -f 2) echo "$LIBRA/ipns/$ipfsnodeid" echo "http://$myIP:8080/ipns/$ipfsnodeid ($YOU)" - [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$ipfsnodeid > ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/index.html \ - || curl -m 12 -so ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/index.html "$LIBRA/ipns/$ipfsnodeid" + [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$ipfsnodeid > ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/index.html \ + || curl -m 12 -so ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/index.html "$LIBRA/ipns/$ipfsnodeid" ## PLAYER TW IS ONLINE ? - if [ ! -s ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/index.html ]; then + if [ ! -s ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/index.html ]; then # # # # # # # # # # # # # # # - ## AUCUN VISA ASTRONAUTE + ## AUCUN VISA ASTRONAUTE ENVOYER UN MESSAGE PAR GCHANGE echo "AUCUN TW ACTIF. ENVOYONS LUI UN MESSAGE..." - $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" send -d "$liking_me" -t "SALUT. Je suis sur 'Astroport' Et toi ?" -m "Active ta 'Capsule Interplanétaire' et raccordons nos TW : https://qo-op.com" + $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" send -d "${liking_me}" -t "SALUT. Je suis sur 'Astroport' Et toi ?" -m "Active ta 'Capsule Interplanétaire' et raccordons nos TW : https://qo-op.com" else - echo "COOL MON AMI EST SUR IPFS" - ls -al ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/index.html + echo "COOL MON AMI PUBLIE SUR IPFS" + ls -al ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/index.html # # # # # # # # # # # # # # # TODO - # CHECK Dessin de Moa + # CHECK Dessin de Moa ?? For Now Gchange contains official friends stars level # # # # # # # # # # # # # # # - # # # # # # # # # # # # # # # - ## ASTROBOT POST TREATMENT + # GET G1Voeux + # # # # # # # # # # # # # # # + ## EXPORT [tag[voeu]] + echo "## EXPORT FROM $PLAYER TW [tag[voeu]] $INDEX" + rm -f ~/.zen/tmp/g1amig1voeu.json + tiddlywiki --load ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/index.html \ + --output ~/.zen/tmp --render '.' 'g1amig1voeu.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[G1Voeu]]' + + if [[ -s ~/.zen/tmp/g1amig1voeu.json ]]; + then + for VOEUNS in "$(cat ~/.zen/tmp/g1amig1voeu.json | jq -r '.[].ipns')" + do + # GET SUB JSON VALUES + cat ~/.zen/tmp/g1amig1voeu.json | jq -r '.[] | select(.ipns | strings | test("'$VOEUNS'"))' > ~/.zen/tmp/wish.json + WISH=$(cat ~/.zen/tmp/wish.json | jq -r '.wish' ) + TITLE=$(cat ~/.zen/tmp/wish.json | jq -r '.title' ) + TAGS=$(cat ~/.zen/tmp/wish.json | jq -r '.tags' ) + IPNS=$(cat ~/.zen/tmp/wish.json | jq -r '.ipns' ) + + [[ ! $WISH ]] && echo "JSON G1WISH ERROR - CHECK - ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/index.html" && continue + + # IPNS could contain VOEUNS or /ipns/VOEUNS (/ tailing) + VOEUNS=$(echo $IPNS | rev | cut -d '/' -f 1 | rev) + + echo "Getting latest $VOEUNS TW into Local World" + mkdir -p ~/.zen/game/world/$WISH + [[ $YOU ]] && ipfs --timeout 12s cat /ipns/$VOEUNS > ~/.zen/tmp/$VOEUNS.html \ + || curl -m 12 -so ~/.zen/tmp/$VOEUNS.html "$LIBRA/ipns/$ipfsnodeid" + + [[ -s ~/.zen/tmp/$VOEUNS.html ]] && cp ~/.zen/tmp/$VOEUNS.html ~/.zen/game/world/$WISH/index.html + + echo "$TITLE FRIEND G1WISH COPY !" + echo "$TITLE" > ~/.zen/game/world/$WISH/.pepper + ls -al ~/.zen/game/world/$WISH/index.html + + done + + else + + echo "ERROR -- NOT COMPATIBLE TW -- AUCUN G1VOEU CHEZ CET AMI ?" + + fi + fi ## APPLIQUER FILTRAGE TAG ## Get Ŋ2 LEVEL - for nid in $(cat ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/Gstars.json | jq -r '.likes[].issuer'); + for nid in $(cat ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[].issuer'); do echo "Ami(s) de cet Ami $linking_me : $nid" - friend_of_friend=$(~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$nid'"))') - echo "$friend_of_friend" | jq -r > ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/fof.json + friend_of_friend=$(cat ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$nid'"))') + echo "$friend_of_friend" | jq -r > ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/fof.json done echo "***** Keep G1/IPNS conversion *****" - echo ${ipfsnodeid} > ~/.zen/game/players/$PLAYER/FRIENDS/$liking_me/ipfsnodeid + echo ${ipfsnodeid} > ~/.zen/game/players/$PLAYER/FRIENDS/${liking_me}/ipfsnodeid + + else + echo "ETOILES!! ... ENVOI MOI UN MESSAGE POUR CONNAITRE QUI" + $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/$PLAYER/secret.dunikey -n "https://data.gchange.fr" send -d "${G1PUB}" -t "Etoiles de ($my_star_level stars) : Ŋ1 SCORE $f_score" -m "https://www.gchange.fr/#/app/user?q=${liking_me} " + + echo "Not Linking ;( YET." fi + sleep $((1 + RANDOM % 2)) # SLOW DOWN done diff --git a/tools/VOEUX.print.sh b/tools/VOEUX.print.sh index 81dbf0d6..235dac73 100755 --- a/tools/VOEUX.print.sh +++ b/tools/VOEUX.print.sh @@ -17,7 +17,7 @@ ASTRONAUTENS=$(ipfs key list -l | grep -w "${PLAYER}" | cut -d ' ' -f 1) for v in $(cat ~/.zen/game/players/*/voeux/*/.title); do - g1pub=$(grep -r $v ~/.zen/game/players/*/voeux/ $v 2>/dev/null | rev | cut -d '/' -f 2 | rev ) + g1pub=$(grep -r $v ~/.zen/game/players/*/voeux/ 2>/dev/null | rev | cut -d '/' -f 2 | rev ) # echo "$v : $g1pub" # echo '------------------------------------------------------------------' vlist=($v:$g1pub ${vlist[@]})