G1PalPay Astroport.ONE - ♥BOX Edition

This commit is contained in:
fred 2023-01-03 05:03:53 +01:00
parent 87b9d0b6cd
commit 6c5fbe3ab2
4 changed files with 258 additions and 15 deletions

189
ASTROBOT/G1PalPay.sh Executable file
View File

@ -0,0 +1,189 @@
#!/bin/bash
########################################################################
# Version: 0.4
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
. "${MY_PATH}/../tools/my.sh"
CESIUM="https://g1.data.le-sou.org"
GCHANGE="https://data.gchange.fr"
echo "(✜‿‿✜) G1PalPay : Receiving & Relaying payments to emails found in comment"
echo "$ME RUNNING"
########################################################################
# PALPAY SERVICE
########################################################################
# CHECK TODAY INCOMING PAYMENT
# IF COMMENT CONTAINS EMAIL ADDRESSES
# THEN CREATE VISA+TW AND SEND PAIMENT REMOVING FIRST FROM LIST
########################################################################
# this couls lead in several account creation sharing % of incomes each time
########################################################################
INDEX="$1"
[[ ! ${INDEX} ]] && INDEX="$HOME/.zen/game/players/.current/ipfs/moa/index.html"
[[ ! -s ${INDEX} ]] && echo "ERROR - Please provide path to source TW index.html" && exit 1
[[ ! -s ${INDEX} ]] && echo "ERROR - Fichier TW absent. ${INDEX}" && exit 1
PLAYER="$2"
[[ ! ${PLAYER} ]] && PLAYER="$(cat ~/.zen/game/players/.current/.player 2>/dev/null)"
[[ ! ${PLAYER} ]] && echo "ERROR - Please provide IPFS publish key" && exit 1
ASTONAUTENS=$(ipfs key list -l | grep -w ${PLAYER} | cut -d ' ' -f1)
[[ ! $ASTONAUTENS ]] && echo "ERROR - Clef IPNS ${PLAYER} introuvable!" && exit 1
G1PUB=$(cat ~/.zen/game/players/${PLAYER}/.g1pub)
# Extract tag=tube from TW
MOATS="$3"
[[ ! $MOATS ]] && MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
###################################################################
## CREATE APP NODE PLAYER PUBLICATION DIRECTORY
###################################################################
mkdir -p $HOME/.zen/tmp/${IPFSNODEID}/G1PalPay/${PLAYER}/
mkdir -p $HOME/.zen/game/players/${PLAYER}/G1PalPay/
~/.zen/Astroport.ONE/tools/timeout.sh -t 12 \
${MY_PATH}/../tools/jaklis/jaklis.py -k ~/.zen/game/players/${PLAYER}/secret.dunikey history -n 10 -j > $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json
[[ ! -s $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json ]] && echo "NO PAYMENT HISTORY" && exit 1
cat $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json | jq -r
## GET @ in
PLINES=("$(cat $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json | jq -r .[].comment | grep 'Financement du JEu')")
for LINE in "${PLINES[@]}"; do
echo "MATCHING INCOMING COMMENT : $LINE"
JSON=$(cat $HOME/.zen/game/players/${PLAYER}/G1PalPay/$PLAYER.history.json | jq .[] | jq -r 'select(.comment=="'"$LINE"'")')
IDATE=$(echo $JSON | jq -r .date)
IPUBKEY=$(echo $JSON | jq -r .pubkey)
IAMOUNT=$(echo $JSON | jq -r .amount)
IAMOUNTUD=$(echo $JSON | jq -r .amountUD)
echo $IDATE $IPUBKEY $IAMOUNT [$IAMOUNTUD]
EMAILS=("${LINE}")
for EMAIL in "${EMAILS[@]}"; do
if [[ "${EMAIL}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then
echo "VALID EMAIL : ${EMAIL}"
$($MY_PATH/../tools/search_for_this_email_in_players.sh ${EMAIL}) ## export FOUND
if [[ ! ${FOUND} ]]; then
echo "# NEW VISA $(date)"
SALT="" && PEPPER=""
echo "VISA.new : \"$SALT\" \"$PEPPER\" \"${EMAIL}\" \"$PSEUDO\" \"${URL}\""
$(${MY_PATH}/../tools/VISA.new.sh "$SALT" "$PEPPER" "${EMAIL}" "$PSEUDO" "${URL}" | tail -n 1) # export ASTROTW=$ASTRONAUTENS ASTROG1=$G1PUB ASTROMAIL=$EMAIL ASTROFEED=$FEEDNS
${MY_PATH}/../tools/mailjet.sh "${EMAIL}" "BRO. VOILA TO TW. $PLAYER" ## WELCOME NEW PLAYER
fi
## MAKE FRIEND & SEND PROPORTIONNAL G1
else
echo "BAD EMAIL : ${EMAIL}"
continue
fi
done
done
#~ ###################################################################
#~ ## tag[PalPay] EXTRACT ~/.zen/tmp/PalPay.json FROM TW
#~ ###################################################################
#~ rm -f ~/.zen/game/players/${PLAYER}/G1PalPay/PalPay.json
#~ tiddlywiki --load ${INDEX} \
#~ --output ~/.zen/game/players/${PLAYER}/G1PalPay \
#~ --render '.' 'PalPay.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' '[tag[PalPay]]'
#~ echo "DEBUG : cat ~/.zen/game/players/${PLAYER}/G1PalPay/PalPay.json | jq -r"
#~ ## GOT PalPay TIDDLER
#~ echo "Creating Youtube ${YID} tiddler : G1PalPay !"
#~ echo $TEXT
#~ echo '[
#~ {
#~ "created": "'${MOATS}'",
#~ "resolution": "'${RES}'",
#~ "duree": "'${DUREE}'",
#~ "duration": "'${DURATION}'",
#~ "giftime": "'${PROBETIME}'",
#~ "gifanime": "'/ipfs/${ANIMH}'",
#~ "modified": "'${MOATS}'",
#~ "title": "'$ZFILE'",
#~ "type": "'text/vnd.tiddlywiki'",
#~ "vtratio": "'${VTRATIO}'",
#~ "text": "'$TEXT'",
#~ "g1pub": "'${G1PUB}'",
#~ "mime": "'${MIME}'",
#~ "size": "'${FILE_BSIZE}'",
#~ "filesize": "'${FILE_SIZE}'",
#~ "sec": "'${SEC}'",
#~ "dur": "'${dur}'",
#~ "ipfs": "'/ipfs/${ILINK}'",
#~ "youtubeid": "'${YID}'",
#~ "tags": "'ipfs G1PalPay ${PLAYER} ${EXTRATAG} ${MIME}'"
#~ }
#~ ]
#~ ' > "$HOME/.zen/tmp/${IPFSNODEID}/G1PalPay/${PLAYER}/$YID.TW.json"
#~ TIDDLER="$HOME/.zen/tmp/${IPFSNODEID}/G1PalPay/${PLAYER}/$YID.TW.json"
#~ else
#~ ###################################################################
#~ echo '# TIDDLER WAS IN CACHE'
#~ ###################################################################
#~ ## TODO : ADD EMAIL TAG ( TIMESTAMP & ADD SIGNATURE over existing ones)
#~ fi
#~ cp -f "${TIDDLER}" "$HOME/.zen/game/players/${PLAYER}/G1PalPay/"
#~ #################################################################
#~ ### ADDING $YID.TW.json to ASTONAUTENS INDEX.html
#~ #################################################################
#~ echo "=========================="
#~ echo "Adding $YID tiddler to TW /ipns/$ASTONAUTENS "
#~ rm -f ~/.zen/tmp/${IPFSNODEID}/newindex.html
#~ echo ">>> Importing $HOME/.zen/game/players/${PLAYER}/G1PalPay/$YID.TW.json"
#~ tiddlywiki --load ${INDEX} \
#~ --import "$HOME/.zen/game/players/${PLAYER}/G1PalPay/$YID.TW.json" "application/json" \
#~ --output ~/.zen/tmp/${IPFSNODEID} --render "$:/core/save/all" "newindex.html" "text/plain"
#~ # --deletetiddlers '[tag[PalPay]]' ### REFRESH CHANNEL COPY
#~ if [[ -s ~/.zen/tmp/${IPFSNODEID}/newindex.html ]]; then
#~ ## COPY JSON TIDDLER TO PLAYER
#~ ln -s "$HOME/.zen/game/players/${PLAYER}/G1PalPay/$YID.TW.json" "$HOME/.zen/game/players/${PLAYER}/G1PalPay/$ZFILE.json"
#~ [[ $(diff ~/.zen/tmp/${IPFSNODEID}/newindex.html ${INDEX} ) ]] && cp ~/.zen/tmp/${IPFSNODEID}/newindex.html ${INDEX} && echo "===> Mise à jour ${INDEX}"
#~ else
#~ echo "Problem with tiddlywiki command. Missing ~/.zen/tmp/${IPFSNODEID}/newindex.html"
#~ echo "XXXXXXXXXXXXXXXXXXXXXXX"
#~ fi
exit 0

View File

@ -57,6 +57,10 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
rm -f ~/.zen/tmp/${MOATS}/TW/index.html
echo "CREATION TW Astronaute" ## Nouveau Compte Astronaute
echo
echo "***** Activation du Canal TW Astronaute $PLAYER *****"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
else
#############################################
@ -66,27 +70,31 @@ if [[ $SALT != "" && PEPPER != "" ]]; then
ASTROPORT=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].astroport)
if [[ $ASTROPORT ]]; then
IPNSTAIL=$(echo $ASTROPORT | rev | cut -f 1 -d '/' | rev)
echo "TW ASTROPORT GATEWAY : ${ASTROPORT}"
[[ $IPNSTAIL == "_ASTROPORT_" ]] \
&& echo "GET CYBERSPACE TW : TODO CONNECT TO DOCK"
&& echo "_ASTROPORT_ TW : CONNECT TO DOCK" \
&& mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/ \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html \
&& echo "- WARNING - WARNING - WARNING - WARNING - PLEASE VERIFY TW -"
[[ $IPNSTAIL == $IPFSNODEID ]] \
&& echo "UPDATING $PLAYER LOCAL CACHE ~/.zen/game/players/$PLAYER/ipfs/moa" \
&& mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa \
&& cp ~/.zen/tmp/${MOATS}/TW/index.html ~/.zen/game/players/$PLAYER/ipfs/moa/ \
|| echo "PLAYER CONNECTED TO $ASTROPORT STATION"
|| ( echo "PLAYER ALREADY CONNECTED TO $ASTROPORT STATION" && exit 1)
else
echo "ERROR BAD TW - Missing Astroport Tiddler ?"
exit 1
fi
# DO NOT CONTINUE
echo "TW ADDRESS IN USE"
rm -Rf ~/.zen/tmp/${MOATS}
exit 1
fi
fi
@ -202,10 +210,6 @@ WID="https://ipfs.$CLYUSER$YOMAIN.$(myHostName)/api"
### INITALISATION WIKI dans leurs répertoires de publication IPFS
############ TODO améliorer templates, sed, ajouter index.html, etc...
echo
echo "***** Activation du Canal TW Astronaute $PLAYER *****"
mkdir -p ~/.zen/game/players/$PLAYER/ipfs/moa/
cp ~/.zen/Astroport.ONE/templates/twdefault.html ~/.zen/game/players/$PLAYER/ipfs/moa/index.html
sed -i "s~_BIRTHDATE_~${MOATS}~g" ~/.zen/game/players/$PLAYER/ipfs/moa/index.html

View File

@ -0,0 +1,43 @@
#!/bin/bash
########################################################################
# Version: 0.4
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
. "${MY_PATH}/tools/my.sh"
start=`date +%s`
MOATS=$(date -u +"%Y%m%d%H%M%S%4N")
EMAIL="$1"
if [[ "${EMAIL}" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$ ]]; then
INDEX=$(ls $HOME/.zen/tmp/game/players/${EMAIL}/ipfs/moa/index.html 2>/dev/null)
[[ ! $INDEX ]] && INDEX=$(ls $HOME/.zen/tmp/$IPFSNODEID/${EMAIL}/index.html 2>/dev/null)
[[ ! $INDEX ]] && INDEX=$(ls $HOME/.zen/tmp/swarm/*/${EMAIL}/index.html 2>/dev/null)
[[ ! $INDEX ]] && exit 1
## TODO ? SEARCH WITH DNSLINK
## EXTRACT DATA FROM TW
mkdir -p ~/.zen/tmp/${MOATS}
rm -f ~/.zen/tmp/${MOATS}/Astroport.json
tiddlywiki --load ~/.zen/tmp/${MOATS}/TW/index.html --output ~/.zen/tmp/${MOATS} --render '.' 'Astroport.json' 'text/plain' '$:/core/templates/exporters/JsonFile' 'exportFilter' 'Astroport'
ASTRONAUTENS=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].astroport)
ASTROG1=$(cat ~/.zen/tmp/${MOATS}/Astroport.json | jq -r .[].g1pub)
rm -Rf ~/.zen/tmp/${MOATS}
else
echo "NO PLAYER WITH ${EMAIL} FOUND"
fi
echo "export ASTROTW=$ASTRONAUTENS ASTROG1=$G1PUB ASTROMAIL=$EMAIL ASTROFEED=$FEEDNS"
exit 0

View File

@ -66,14 +66,21 @@
position:absolute;
z-index: -1;
}
</style>
<script type="text/javascript"></script>
<title>Page not found</title>
</style>
<script type="text/javascript">
window.onload = function() {
document.getElementById('urltag').innerHTML = document.location; // location.protocol + '//' + location.host; //
setTimeout(function(){document.getElementById('pic').style.visibility = "visible";},800);
setTimeout(function(){document.getElementById('urltag').style.visibility = "visible";},2000);
setTimeout(function(){document.getElementById('reason').style.visibility = "visible";},2000);
}
</script>
<title>Ğ1 PalPay - Offrez de la JUNE et un TW à vos amis -</title>
</head>
<body>
<div id="pic" style="visibility:hidden;"><img src="/localhost/404.png" alt="Light bulb"/></div>
<div class="infotxt">
<div id="head">Hey, who turned off the lights?</div>
<div id="head">?</div>
<div id="urltag" style="visibility:hidden;">proxerror</div>
<div id="reason" style="visibility:hidden;">You are looking for the sun? ask IPFS.</div>
</div>