Astroport.ONE/tools/Connect_PLAYER_To_Gchange.sh

388 lines
22 KiB
Bash
Raw Permalink Normal View History

2022-06-01 16:17:20 +02:00
#!/bin/bash
2023-10-07 15:58:55 +02:00
################################################################################
# Author: Fred (support@qo-op.com)
2024-04-21 21:27:15 +02:00
# Version: 0.3
2023-10-07 15:58:55 +02:00
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
################################################################################
# Takes care of analysing GChange+ Pod key and stars relations
################################################################################
# TODO: could make better ES stars requests
# https://forum.monnaie-libre.fr/t/proposition-damelioration-de-gchange/1940/49
2022-08-23 16:31:40 +02:00
################################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
2022-12-29 14:51:05 +01:00
. "$MY_PATH/my.sh"
2022-12-10 20:07:32 +01:00
export PLAYERFEEDS=""
2022-11-05 22:32:28 +01:00
2022-06-01 16:17:20 +02:00
######################################################################### CONNECT PLAYER WITH GCHANGE
# Check who is .current PLAYER
PLAYER="$1"
2022-11-05 22:32:28 +01:00
[[ ${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)
2023-04-25 18:17:46 +02:00
[[ ${G1PUB} == "" ]] && G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub 2>/dev/null)
[[ ${G1PUB} == "" ]] && echo "ERROR G1PUB - EXIT" && exit 1
2022-06-01 16:17:20 +02:00
PSEUDO=$(cat ~/.zen/game/players/${PLAYER}/.pseudo 2>/dev/null)
G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub 2>/dev/null)
ASTRONS=$(cat ~/.zen/game/players/${PLAYER}/.playerns 2>/dev/null)
ZLAT=$(cat ~/.zen/game/players/${PLAYER}/GPS.json | jq -r .[].lat)
ZLON=$(cat ~/.zen/game/players/${PLAYER}/GPS.json | jq -r .[].lon)
## REFRESH ASTRONAUTE TW
ASTRONAUTENS=$(ipfs key list -l | grep -w ${PLAYER} | cut -d ' ' -f1)
[[ ! $ASTRONAUTENS ]] && echo "WARNING No ${PLAYER} in keystore -- EXIT" && exit 1
[[ ! -f ~/.zen/game/players/${PLAYER}/QR.png ]] && echo "NOT MY ${PLAYER} -- EXIT" && exit 1
2022-11-05 22:32:28 +01:00
mkdir -p ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/
2022-08-15 19:07:39 +02:00
## REFRESH GCHANGE PROFILE
${MY_PATH}/timeout.sh -t 20 \
curl -s ${myDATA}/user/profile/${G1PUB} > ~/.zen/tmp/coucou/${G1PUB}.gchange.json
[[ ! $? == 0 ]] && echo "xxxxx ERROR PROBLEM WITH GCHANGE+ NODE ${myDATA} xxxxx" && exit 1
2023-01-16 15:16:25 +01:00
2023-01-16 19:12:10 +01:00
[[ ! $(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.title' 2>/dev/null) ]] \
&& echo "xxxxx GCHANGE+ MISSING ACCOUNT ${myDATA} xxxxx" \
&& ${MY_PATH}/timeout.sh -t 20 \
${MY_PATH}/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey set -n "qo-op" -v " " -a " " -d " " -pos ${ZLAT} ${ZLON} -s https://qo-op.com -A ${MY_PATH}/../images/plain.png \
&& exit 0
2023-01-16 19:12:10 +01:00
## GET AVATAR PICTURE
2024-04-21 21:17:42 +02:00
cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '._source.avatar._content' | base64 -d > "$HOME/.zen/tmp/coucou/${G1PUB}_g1.gchange_avatar.png" 2>/dev/null
# CLEANING BAD FILE TYPE
2024-04-21 21:17:42 +02:00
[[ ! $(file -b "$HOME/.zen/tmp/coucou/${G1PUB}_g1.gchange_avatar.png" | grep PNG) ]] && rm "$HOME/.zen/tmp/coucou/${G1PUB}_g1.gchange_avatar.png"
## GET CESIUM PUBKEY & C+ PROFILE
CPUB=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '._source.pubkey' 2>/dev/null)
if [[ $CPUB && $CPUB != 'null' ]]; then
echo "OHH ... GET CPUB+ PROFILE .... $CPUB"
2023-01-16 19:12:10 +01:00
${MY_PATH}/timeout.sh -t 20 \
curl -s ${myCESIUM}/user/profile/${CPUB} > ~/.zen/tmp/coucou/${G1PUB}.cesium.json 2>/dev/null
[[ ! $? == 0 ]] && echo "xxxxx ERROR PROBLEM WITH CESIUM+ NODE ${myCESIUM} xxxxx"
2023-01-16 19:12:10 +01:00
2024-04-21 21:17:42 +02:00
cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '._source.avatar._content' | base64 -d > "$HOME/.zen/tmp/coucou/${G1PUB}_g1.cesium_avatar.png" 2>/dev/null
# CLEANING NOT PNG FILE
2024-04-21 21:17:42 +02:00
[[ ! $(file -b "$HOME/.zen/tmp/coucou/${G1PUB}_g1.cesium_avatar.png" | grep PNG) ]] && rm "$HOME/.zen/tmp/coucou/${G1PUB}_g1.cesium_avatar.png"
2023-01-16 19:12:10 +01:00
2023-01-16 19:59:55 +01:00
CPSEUDO=$(cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '.title' 2>/dev/null)
2023-01-16 19:59:55 +01:00
[[ ${CPSEUDO} ]] \
2024-04-21 21:27:15 +02:00
&& echo "ZEN PARTNER ${CPSEUDO}" \
&& echo "$CPUB" > ~/.zen/tmp/coucou/${G1PUB}G1CPUB \
|| echo "NO CPUB CESIUM PROFILE"
2023-01-16 19:12:10 +01:00
else
2023-01-16 19:12:10 +01:00
echo "NO CPUB CESIUM PROFILE"
fi
2023-01-16 19:12:10 +01:00
echo "... TRY TO GET CESIUM+ WALLET PROFILE .... "
2022-11-16 18:53:07 +01:00
${MY_PATH}/timeout.sh -t 20 \
curl -s ${myCESIUM}/user/profile/${G1PUB} > ~/.zen/tmp/coucou/${G1PUB}.cesium.json 2>/dev/null
[[ ! $? == 0 ]] && echo "xxxxx ERROR PROBLEM WITH CESIUM+ NODE ${myCESIUM} xxxxx"
2023-01-16 19:12:10 +01:00
2024-04-21 21:17:42 +02:00
cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '._source.avatar._content' | base64 -d > "$HOME/.zen/tmp/coucou/${G1PUB}_g1.cesium_avatar.png" 2>/dev/null
[[ ! $(file -b "$HOME/.zen/tmp/coucou/${G1PUB}_g1.cesium_avatar.png" | grep PNG) ]] && rm "$HOME/.zen/tmp/coucou/${G1PUB}_g1.cesium_avatar.png"
2023-01-16 19:12:10 +01:00
CPSEUDO=$(cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '.title' 2>/dev/null)
2023-01-16 19:12:10 +01:00
[[ ${CPSEUDO} ]] \
&& echo "Ğ1 WALLET " \
2024-04-21 21:27:15 +02:00
&& echo "${G1PUB}" > ~/.zen/tmp/coucou/${G1PUB}G1WALLET \
|| echo "NO WALLET FOR THIS PLAYER"
2022-11-16 06:17:54 +01:00
## KEEPING ALREADY EXISTING PROFILE DATA
GPSEUDO=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.title' 2>/dev/null)
[[ ! ${GPSEUDO} || ${GPSEUDO} == "null" ]] && GPSEUDO="$PSEUDO"
CPSEUDO=$(cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '.title' 2>/dev/null)
[[ ! ${CPSEUDO} || ${CPSEUDO} == "null" ]] && CPSEUDO="${PLAYER}"
2022-11-15 18:57:16 +01:00
GDESCR=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.description' 2>/dev/null)
[[ ! ${GDESCR} || ${GDESCR} == "null" ]] && GDESCR="Astronaute GChange"
CDESCR=$(cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '.description' 2>/dev/null)
[[ ! ${CDESCR} || ${CDESCR} == "null" ]] && CDESCR="Portefeuille Astro"
2023-01-16 15:16:25 +01:00
GVILLE=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.city' 2>/dev/null)
[[ ! ${GVILLE} || ${GVILLE} == "null" ]] && GVILLE=""
CVILLE=$(cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '.city' 2>/dev/null)
[[ ! ${CVILLE} || ${CVILLE} == "null" ]] && CVILLE=""
2023-01-16 19:12:10 +01:00
GADRESSE=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.address' 2>/dev/null)
[[ ! ${GADRESSE} || ${GADRESSE} == "null" ]] && GADRESSE=""
CADRESSE=$(cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json | jq -r '.address' 2>/dev/null)
[[ ! ${CADRESSE} || ${CADRESSE} == "null" ]] && CADRESSE=""
2023-01-16 19:12:10 +01:00
# POSITION=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.geoPoint')
# SITE=$(cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json | jq -r '.socials' 2>/dev/null)
echo ">> GCHANGE+ : ${GPSEUDO} - ${GDESCR} : ${G1PUB} ($CPUB) <<"
echo ">> CESIUM+ : ${CPSEUDO} - ${CDESCR} : ${G1PUB} <<"
2023-01-16 19:12:10 +01:00
########################################################################
# echo "set -n "${GPSEUDO}" -d "${GDESCR}" -v "${GVILLE}" -a "${GADRESSE}""
########################################################################
2024-04-21 21:27:15 +02:00
#~ if [[ ! -s ~/.zen/tmp/coucou/${G1PUB}G1WALLET && -s ~/.zen/game/players/${PLAYER}/QRTWavatar.png ]]; then
#~ echo "CREATING GCHANGE+ PROFILE https://www.gchange.fr/#/app/user?q=${G1PUB}"
#~ ${MY_PATH}/timeout.sh -t 20 \
#~ $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey set -n "${GPSEUDO}" -d "${GDESCR}" -v "${GVILLE}" -a "${GADRESSE}" -s "$LIBRA/ipns/$ASTRONAUTENS" -A ~/.zen/game/players/${PLAYER}/QRG1avatar.png #GCHANGE+
#~ [[ ! $? == 0 ]] && echo "GCHANGE PROFILE CREATION FAILED" \
2024-04-21 21:27:15 +02:00
#~ || cat ~/.zen/tmp/coucou/${G1PUB}.gchange.json > ~/.zen/tmp/coucou/${G1PUB}gchange.1st.json
#~ echo " CREATING CESIUM+ https://demo.cesium.app/#/app/wot/lg?q=${G1PUB}"
2023-01-16 19:59:55 +01:00
#~ ${MY_PATH}/timeout.sh -t 20 \
#~ $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n ${myCESIUM} set -n "${CPSEUDO}" -d "${CDESCR}" -v "${CVILLE}" -a "${CADRESSE}" --s "http://ipfs.localhost:8080/ipns/$ASTRONAUTENS" -A ~/.zen/game/players/${PLAYER}/QRTWavatar.png #CESIUM+
#~ [[ ! $? == 0 ]] && echo "CESIUM PROFILE CREATION FAILED" \
2024-04-21 21:27:15 +02:00
#~ || cat ~/.zen/tmp/coucou/${G1PUB}.cesium.json > ~/.zen/tmp/coucou/${G1PUB}cesium.1st.json
#~ fi
2022-08-28 19:09:06 +02:00
2023-01-16 19:12:10 +01:00
## GET LAST ONLINE gchange & cesium PROFILE
2023-01-17 18:49:07 +01:00
${MY_PATH}/timeout.sh -t 20 \
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n ${myDATA} get > ~/.zen/tmp/coucou/${G1PUB}.gchange.json
2023-01-17 18:49:07 +01:00
${MY_PATH}/timeout.sh -t 20 \
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n ${myCESIUM} get > ~/.zen/tmp/coucou/${G1PUB}.cesium.json
2022-12-08 23:19:09 +01:00
2023-01-16 23:58:20 +01:00
########################################################################
2024-04-21 21:27:15 +02:00
# Get PLAYER wallet amount :: ~/.zen/tmp/coucou/${G1PUB}COINS
2023-04-25 18:17:46 +02:00
COINS=$($MY_PATH/COINScheck.sh ${G1PUB} | tail -n 1)
echo "+++ YOU have ${COINS} Ğ1 Coins +++"
2023-01-16 23:58:20 +01:00
########################################################################
2022-06-01 16:17:20 +02:00
########################################################################
2023-01-16 19:59:55 +01:00
########################################################################
2022-12-11 18:51:48 +01:00
echo "### ${PLAYER} #################"
2023-04-25 18:17:46 +02:00
echo "SCANNING - ${G1PUB} STAR FRIENDS"
2022-11-02 18:51:55 +01:00
echo "########################################################################"
2022-09-27 00:09:24 +02:00
################## CHECKING WHO GAVE ME STARS
################## SEND ipfstryme MESSAGES to FRIENDS
rm -f ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/my_star_level
2023-07-10 12:39:33 +02:00
2022-09-27 00:09:24 +02:00
## Getting Gchange liking_me list
2023-01-16 19:59:55 +01:00
echo "Checking received stars ON $myDATA"
################################## JAKLIS PLAYER stars
2023-01-17 18:49:07 +01:00
${MY_PATH}/timeout.sh -t 30 \
${MY_PATH}/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n "$myDATA" stars > ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/received_stars.json
2023-01-16 23:58:20 +01:00
[[ ! $? == 0 ]] && echo "> WARNING $myDATA UNREACHABLE"
[[ ! $(cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/received_stars.json | jq -r '.likes[].issuer') ]] && echo "Activez votre Toile de Confiance Ŋ1" && exit 0
2022-12-08 23:19:09 +01:00
2023-01-17 18:49:07 +01:00
## GETTING ALL INCOMING liking_me FRIENDS
cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/received_stars.json | jq -r '.likes[].issuer' | sort | uniq > ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/liking_me
# echo "cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/received_stars.json | jq -r" # DEBUG
2023-01-17 18:49:07 +01:00
## ADD ALREADY FRIENDS (in case Gchange+ timout)
find ~/.zen/game/players/${PLAYER}/FRIENDS/* -type d | rev | cut -d '/' -f 1 | rev >> ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/liking_me
2022-09-27 00:09:24 +02:00
for liking_me in $(cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/liking_me | sort | uniq);
2022-09-27 00:09:24 +02:00
do
[[ "${liking_me}" == "" ]] && continue ## Protect from empty line !!
2022-10-24 16:38:59 +02:00
echo "........................."
2024-05-03 15:53:28 +02:00
[[ $(echo ${liking_me} | grep '@') ]] && continue ## filter emails
2023-01-17 18:49:07 +01:00
FRIENDNS=$(${MY_PATH}/g1_to_ipfs.py ${liking_me})
2022-11-02 18:51:55 +01:00
echo "==========================="
echo "${liking_me} IS LIKING ME"
2023-04-25 18:17:46 +02:00
echo "TW ? $LIBRA/ipns/${FRIENDNS} "
2022-09-27 00:09:24 +02:00
2022-10-07 00:32:33 +02:00
##### CHECKING IF WE LIKE EACH OTHER Ŋ1 LEVEL
################################## JAKLIS LIKING_ME stars
2023-01-17 18:49:07 +01:00
${MY_PATH}/timeout.sh -t 20 \
${MY_PATH}/jaklis/jaklis.py \
2022-11-05 22:32:28 +01:00
-k ~/.zen/game/players/${PLAYER}/secret.dunikey \
stars -p ${liking_me} > ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json
cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json | jq -rc
2023-03-01 20:17:24 +01:00
2023-01-17 21:53:10 +01:00
## ZOMBIE PROTECTION - PURGE AFTER 365 DAYS
find ~/.zen/game/players/${PLAYER}/FRIENDS/* -mtime +365 -type d -exec rm -Rf '{}' \; 2>/dev/null
2023-01-17 18:49:07 +01:00
## COUNT NUMBER OF STAR COLLECT TRIES
try=$(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}.try 2>/dev/null) || try=0
[[ $try > 2 && ( $try < 29 || $try > 31 ) ]] \
2023-03-20 13:39:09 +01:00
&& echo "${liking_me} TOO MANY TRY ( $try )" \
2023-03-24 00:05:02 +01:00
&& ((try++)) && echo $try > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}.try \
2023-03-20 13:39:09 +01:00
&& continue
2022-09-27 00:09:24 +02:00
#########################################################################################
#########################################################################################
#### TODO RECUP ANNONCES Gchange ADD TO TW + email tiddler
2022-10-06 21:18:54 +02:00
## https://www.gchange.fr/#/app/records/wallet?q=2geH4d2sndR47XWtfDWsfLLDVyNNnRsnUD3b1sk9zYc4&old
2022-10-07 17:09:07 +02:00
## https://www.gchange.fr/#/app/market/records/42LqLa7ARTZqUKGz2Msmk79gwsY8ZSoFyMyPyEnoaDXR
#########################################################################################
## https://forum.monnaie-libre.fr/t/proposition-damelioration-de-gchange/1940/49
#########################################################################################
2022-10-06 21:18:54 +02:00
## DATA EXTRACTION FROM ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json
my_star_level=$(cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json | jq -r '.yours.level') || my_star_level=1
gscore=$(cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json | jq -r '.score')
myfriendship=$(cat ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'${G1PUB}'"))')
## OH MY FRIEND !
2023-04-25 18:17:46 +02:00
if [[ "${my_star_level}" != "null" && "${liking_me}" != "${G1PUB}" ]]
2022-09-27 00:09:24 +02:00
then
# ADD ${liking_me} TO MY ipfs FRIENDS list
2023-04-25 18:17:46 +02:00
echo "LIKING with ${my_star_level} stars : Friend Ŋ1 SCORE $gscore "
2022-11-05 22:32:28 +01:00
mkdir -p ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}
2022-10-24 16:38:59 +02:00
2023-09-10 14:58:59 +02:00
cp ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.Gstars.json ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/
echo "${my_star_level}" > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/stars.level ## LOCAL
echo "${my_star_level}" > ~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.stars.level ## SWARM
echo "***** ${my_star_level} STARS *****"
2022-09-27 00:09:24 +02:00
2022-11-27 13:59:03 +01:00
## GET FRIEND GCHANGE PROFILE
2023-01-10 17:53:33 +01:00
echo "GET FRIEND gchange.json"
2022-11-27 13:59:03 +01:00
${MY_PATH}/timeout.sh -t 20 \
2022-11-27 21:54:40 +01:00
${MY_PATH}/jaklis/jaklis.py get \
2022-11-27 13:59:03 +01:00
-p ${liking_me} > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/gchange.json
2023-09-10 14:58:59 +02:00
cp ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/gchange.json \
~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.gchange.json
2022-11-27 13:59:03 +01:00
FRIENDTITLE=$(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/gchange.json | jq -r '.title')
## GET FRIEND TW !!
2023-01-10 17:53:33 +01:00
echo "SEARCHING $FRIENDTITLE - ONLINE TW -"
2024-04-14 17:37:53 +02:00
YOU=$(ipfs swarm peers >/dev/null 2>&1 && echo "$USER" || ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | xargs | cut -d " " -f 1);
LIBRA=$(head -n 2 ~/.zen/Astroport.ONE/A_boostrap_nodes.txt | tail -n 1 | xargs | cut -d ' ' -f 2)
2022-12-14 17:34:55 +01:00
2023-01-10 17:53:33 +01:00
[[ $YOU ]] \
2024-04-02 11:49:53 +02:00
&& echo "ipfs --timeout 120s cat --progress=false /ipns/${FRIENDNS} > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html" \
&& ipfs --timeout 120s cat --progress=false /ipns/${FRIENDNS} > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html
2023-01-10 17:53:33 +01:00
[[ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]] \
2023-04-25 18:17:46 +02:00
&& echo "curl -m 120 -so ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html $LIBRA/ipns/${FRIENDNS}" \
&& curl -m 120 -so ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html "$LIBRA/ipns/${FRIENDNS}"
2022-11-02 18:51:55 +01:00
## PLAYER TW EXISTING ?
if [ ! -s ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html ]; then
2022-11-02 18:51:55 +01:00
## AUCUN VISA ASTRONAUTE ENVOYER UN MESSAGE PAR GCHANGE
2024-04-21 21:44:05 +02:00
echo "AUCUN TW ACTIF $try " -t "HEY BRO !" -m "G1 TW : https://ipfs.copylaradio.com/ipns/$ASTRONAUTENS"
2023-12-31 00:12:33 +01:00
${MY_PATH}/timeout.sh -t 20 \
2024-04-21 21:44:05 +02:00
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey send -d "${liking_me}" -t "HEY BRO !" -m "G1 TW UPlanet : https://ipfs.copylaradio.com/ipns/$ASTRONAUTENS"
2022-11-02 18:51:55 +01:00
2023-02-13 13:27:12 +01:00
## +1 TRY
try=$((try+1)) && echo $try > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}.try
else
2022-11-02 18:51:55 +01:00
2023-01-11 00:04:28 +01:00
FTW="$HOME/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/index.html"
2022-12-15 21:06:01 +01:00
echo "COOL MON AMI PUBLIE SUR IPFS : $FTW"
2023-01-10 17:53:33 +01:00
# LOG
2023-01-11 00:04:28 +01:00
# echo tiddlywiki --load ${FTW} --output ~/.zen/tmp --render '.' "${liking_me}.MadeInZion.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
2022-12-15 21:06:01 +01:00
tiddlywiki --load ${FTW} --output ~/.zen/tmp --render '.' "${liking_me}.MadeInZion.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'MadeInZion'
[[ ! -s ~/.zen/tmp/${liking_me}.MadeInZion.json ]] && echo "~~~ BROKEN $FTW (☓‿‿☓) BAD ~/.zen/tmp/${liking_me}.MadeInZion.json ~~~" && continue
FPLAYER=$(cat ~/.zen/tmp/${liking_me}.MadeInZion.json | jq -r .[].player)
[[ ! $FPLAYER ]] \
&& echo "NO PLAYER = BAD MadeInZion Tiddler" \
&& rm -Rf ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me} \
&& continue
tiddlywiki --load ${FTW} --output ~/.zen/tmp --render '.' "${liking_me}.Astroport.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
[[ ! -s ~/.zen/tmp/${liking_me}.Astroport.json ]] && echo "~~~ BROKEN $FTW (☓‿‿☓) BAD ~/.zen/tmp/${liking_me}.Astroport.json ~~~" && continue
FASTRONAUTENS=$(cat ~/.zen/tmp/${liking_me}.Astroport.json | jq -r .[].astronautens)
export ASTRONAUTS="$FASTRONAUTENS\n${ASTRONAUTS}"
2024-01-01 04:48:35 +01:00
mkdir -p ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/
echo "${ASTRONAUTS}" > ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/ASTRONAUTS
## CREATING 30 DAYS RSS STREAM
tiddlywiki --load ${FTW} \
2022-12-04 15:12:18 +01:00
--output ~/.zen/game/players/${PLAYER}/ipfs --render '.' "${FPLAYER}.rss.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[days:created[-30]]'
2022-12-15 21:06:01 +01:00
[[ ! -s ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.rss.json ]] && echo "NO ${FPLAYER} RSS - BAD ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.rss.json -" && continue
echo "> DEBUG RSS : cat ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.rss.json | jq -r"
2022-12-15 21:06:01 +01:00
echo
2022-12-11 04:40:50 +01:00
tiddlywiki --load ${FTW} \
--output ~/.zen/game/players/${PLAYER}/ipfs --render '.' "${FPLAYER}.lightbeam-key.json" 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '$:/plugins/astroport/lightbeams/saver/ipns/lightbeam-key'
[[ ! -s ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.lightbeam-key.json ]] && echo "NO ${FPLAYER} lightbeam-key - CONTINUE -" && continue
ASTRONAUTEFEED=$(cat ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.lightbeam-key.json | jq -r .[].text)
2022-12-15 21:06:01 +01:00
echo "DEBUG LIGHTBEAM : cat ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.lightbeam-key.json | jq -r"
echo
2023-01-17 19:01:20 +01:00
## RESET try
echo 0 > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}.try
2023-01-17 18:49:07 +01:00
## ★★★★★ ############################################################################
2023-04-25 18:17:46 +02:00
#~ ## liking_me IS A GOOD FRIEND. PLAYER Send ${my_star_level} COIN
#~ $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey pay -a ${my_star_level} -p ${liking_me} -c "BRO:star:${my_star_level}" -m
#~ [[ ! $? == 0 ]] \
#~ && echo "PLAYER BROKE. G00D FRIEND. ${liking_me}" \
2023-04-25 18:17:46 +02:00
#~ && $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey send -d "${G1PUB}" -t "BRO YOU BROKE" -m "PLEASE REFILL WALLET: ${G1PUB} ~:star:~ ${my_star_level} stars : Friend Ŋ1 SCORE $gscore ${liking_me} "
#~ ############################################################################### ★★★★★
#~ ## DEFAULT SAME CONFIDENCE LEVEL
2023-04-25 18:17:46 +02:00
#~ echo "★ SENDING ${my_star_level} STAR(s) ★"
#~ $MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey stars -p $liking_me -n ${my_star_level}
2023-01-17 18:49:07 +01:00
######################################
## ADD THIS FPLAYER RSS FEED INTO PLAYER TW
## PUSH DATA TO 12345 SWARM KEY
2023-09-06 14:16:59 +02:00
mkdir -p ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}
cp -f ~/.zen/game/players/${PLAYER}/ipfs/${FPLAYER}.rss.json ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/${FPLAYER}.rss.json
2023-04-25 18:17:46 +02:00
export FRIENDSFEEDS="$ASTRONAUTEFEED\n${FRIENDSFEEDS}"
2023-09-06 14:16:59 +02:00
echo "${FRIENDSFEEDS}" > ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/FRIENDSFEEDS
2022-12-14 00:24:14 +01:00
2023-04-25 18:17:46 +02:00
echo "(☉_☉ ) (☉_☉ ) (☉_☉ ) : FRIENDSFEEDS=" ${FRIENDSFEEDS}
2022-12-14 00:24:14 +01:00
2023-04-25 18:17:46 +02:00
export IFRIENDHEAD="<a target='you' href='/ipns/"${FRIENDNS}"'>$FRIENDTITLE</a> ${IFRIENDHEAD}"
2023-09-06 14:16:59 +02:00
echo "${IFRIENDHEAD}" > ~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/IFRIENDHEAD
2022-12-14 00:24:14 +01:00
2023-04-25 18:17:46 +02:00
echo "(☉_☉ ) (☉_☉ ) (☉_☉ ) : IFRIENDHEAD=" ${IFRIENDHEAD}
2022-12-14 00:24:14 +01:00
2023-10-08 20:42:00 +02:00
echo "APP=RSS : PLAYER $FPLAYER RSS PUBLICATION READY"
2023-09-06 14:16:59 +02:00
echo "~/.zen/tmp/${IPFSNODEID}/RSS/${PLAYER}/${FPLAYER}.rss.json"
fi
2022-10-07 00:32:33 +02:00
## Get Ŋ2 LEVEL
2022-11-05 22:32:28 +01:00
echo "(°▃▃°) (°▃▃°) (°▃▃°) Ŋ2 scraping ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/friend_of_friend.json"
for nid in $(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[].issuer');
2022-10-07 00:32:33 +02:00
do
2022-11-27 13:59:03 +01:00
2022-10-07 00:32:33 +02:00
echo "Ami(s) de cet Ami $linking_me : $nid"
2022-11-05 22:32:28 +01:00
friend_of_friend=$(cat ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/${liking_me}.Gstars.json | jq -r '.likes[] | select(.issuer | strings | test("'$nid'"))')
2022-11-27 13:59:03 +01:00
echo "$friend_of_friend" | jq -r > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/FoF_$nid.json
2022-10-07 00:32:33 +02:00
2023-09-10 14:58:59 +02:00
cp ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}/FoF_$nid.json \
~/.zen/tmp/${IPFSNODEID}/GCHANGE/${PLAYER}/${liking_me}.FoF_$nid.json
## TODO : Send message to Friend(s) of my Friend
2022-10-07 00:32:33 +02:00
done
else
2022-12-15 21:06:01 +01:00
#########################################
## COOL FEATURE FOR GCHANGE ACCOUNT CONFIDENCE
## IS IT REALLY A FRIEND I LIKE ?
2022-12-09 02:08:22 +01:00
echo "BRO?"
2023-12-31 00:12:33 +01:00
${MY_PATH}/timeout.sh -t 20 \
2022-12-30 22:55:10 +01:00
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey send -d "${G1PUB}" -t "Bro ?" -m "$myGCHANGE/#/app/user/${liking_me}/"
2023-12-31 00:12:33 +01:00
${MY_PATH}/timeout.sh -t 20 \
$MY_PATH/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey -n ${myCESIUM} send -d "${G1PUB}" -t "Bro ?" -m "$myGCHANGE/#/app/user/${liking_me}/"
2023-04-16 00:03:49 +02:00
mkdir -p ~/.zen/game/players/${PLAYER}/FRIENDS/
try=$((try+1)) && echo $try > ~/.zen/game/players/${PLAYER}/FRIENDS/${liking_me}.try
2022-09-27 00:09:24 +02:00
2022-11-02 18:51:55 +01:00
fi
2022-09-27 00:09:24 +02:00
sleep $((1 + RANDOM % 2)) # SLOW DOWN
2022-11-02 18:51:55 +01:00
2022-09-27 00:09:24 +02:00
done
2022-06-01 16:17:20 +02:00
2022-08-18 03:47:49 +02:00
exit 0