Compare commits

...

4 Commits

14 changed files with 275 additions and 26 deletions

View File

@@ -268,7 +268,7 @@ class blockchain
]; ];
$color = $couleur; $color = $couleur;
if ($color == -1) $color = rand(0,count($color_tab)-1); if (($color == -1) || ($color > (count($color_tab)-1))) $color = rand(0,count($color_tab)-1);
// Rajout des HASHES // Rajout des HASHES
$white = imagecolorallocate($vImage, 254, 254, 254); $white = imagecolorallocate($vImage, 254, 254, 254);

View File

@@ -33,6 +33,9 @@ if ($the_block === FALSE) die();
echo $block_hash.' '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; echo $block_hash.' '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
if ($block_hash == 'LAST') if ($block_hash == 'LAST')
{
// On a demandé le dernier block
// On remonte sur les huits derniers pour accélerer les prochaines navigations
for($max=0;($max<8)&&(!file_exists(DATA_PATH.'/json/'.$the_block->prev_block.'.zip'));$max++) for($max=0;($max<8)&&(!file_exists(DATA_PATH.'/json/'.$the_block->prev_block.'.zip'));$max++)
{ {
$block_hash = $the_block->prev_block; $block_hash = $the_block->prev_block;
@@ -40,5 +43,5 @@ if ($block_hash == 'LAST')
if ($the_block === FALSE) die(); if ($the_block === FALSE) die();
echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL; echo 'CACHE '.$the_block->hash." ".$the_block->height." ".$the_block->n_tx.PHP_EOL;
} }
}
?> ?>

View File

@@ -13,12 +13,12 @@ cd $APPS_PATH/blockchain
rm -f $DATA_PATH/block_list.tmp rm -f $DATA_PATH/block_list.tmp
LISTBLOCKS="LAST \ LISTBLOCKS="GENESIS THE_ANSWER LUCIFER LEET \
GENESIS THE_ANSWER LUCIFER LEET \
TOPISTO PIZZA HALVING_1 WHALE201311 \ TOPISTO PIZZA HALVING_1 WHALE201311 \
HALVING_2 BIP_91_LOCK BCC SEGWIT_LOCK \ HALVING_2 BIP_91_LOCK BCC SEGWIT_LOCK \
SEGWIT HURRICANE_1 WHALE201810 \ SEGWIT HURRICANE_1 WHALE201810 \
BLOCK21E800" BLOCK21E800 \
LAST"
for BLOCK in $LISTBLOCKS for BLOCK in $LISTBLOCKS
do do

View File

@@ -15,7 +15,7 @@ for BLOCK in `awk '{print $2}' $DATA_PATH/block_list.txt`
do do
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then then
php robot.php $BLOCK $((RANDOM % 6)) php robot.php $BLOCK 99999
fi fi
done done

View File

@@ -49,10 +49,12 @@ for($i=0; $i<$nb_max; $i++)
{ {
$the_block = blockchain::getBlockWithHash($block_hash); $the_block = blockchain::getBlockWithHash($block_hash);
if ($the_block === FALSE) die(); if ($the_block === FALSE) die();
$hash=DATA_PATH.'/hashes/'.$the_block->hash.'.png';
$block_hash = $the_block->prev_block; $block_hash = $the_block->prev_block;
$hash=DATA_PATH.'/hashes/'.$the_block->hash.'.png';
if ($final_hash == 'default') $final_hash = $the_block->hash;
if (file_exists($hash)) if (file_exists($hash))
{ {
$src_img = imagecreatefrompng($hash); $src_img = imagecreatefrompng($hash);

View File

@@ -8,8 +8,10 @@ export TMP_PATH=$APPS_PATH/../tmp
export DATA_PATH=$APPS_PATH/../data export DATA_PATH=$APPS_PATH/../data
export FLAG_PATH=$APPS_PATH/../flags export FLAG_PATH=$APPS_PATH/../flags
export TS=`date +%s`
export MINUTE=`date +%M | sed 's/^0*//'` export MINUTE=`date +%M | sed 's/^0*//'`
export DATE=`date +%Y%m%d0000` export DATE=`date +%Y%m%d0000`
export DATEHOUR=`date +%Y%m%d%H`
# #
# Synchronize the Blockchain # Synchronize the Blockchain

View File

@@ -59,28 +59,36 @@ while IFS='' read -r line || [[ -n "$line" ]]; do
# #
# CHOISIR UNE METHODE2 AU HASARD # CHOISIR UNE METHODE2 AU HASARD
# #
for METHODE in `ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1` # LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf`
# LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1`
# en rajoutant le head, on ne fait qu'un seul dessin
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v robot | shuf | head -n 1`
if [ $HEIGHT -eq 1 ]
then
LISTE_METHODE=`ls $APPS_PATH/methode2 | grep -v treemap | grep -v robot | shuf | head -n 1`
fi
cd $APPS_PATH/methode2
for METHODE in $LISTE_METHODE
do do
if [ ! -d $DATA_PATH/$METHODE ] if [ ! -d $DATA_PATH/$METHODE ]
then then
mkdir -p $DATA_PATH/$METHODE mkdir -p $DATA_PATH/$METHODE
fi fi
echo $BLOCK $NAME $METHODE
if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ] if [ ! -f $DATA_PATH/$METHODE/$BLOCK.png ]
then then
cd $APPS_PATH/methode2
php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2 php robot.php $METHODE $BLOCK $((RANDOM % 6)) $2
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/$METHODE/$BLOCK.png
fi fi
done done
cd - >> /dev/null
if [ ! -f $DATA_PATH/hasard/$BLOCK.png ] if [ ! -f $DATA_PATH/hasard/$BLOCK.png ]
then then
cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png cp $DATA_PATH/last/$BLOCK.png $DATA_PATH/hasard/$BLOCK.png
fi fi
touch $DATA_PATH/hasard/$BLOCK.png
rm -f $flag rm -f $flag
done < $DATA_PATH/block_list.txt done < $DATA_PATH/block_list.txt

View File

@@ -1,5 +1,14 @@
#!/bin/bash #!/bin/bash
# Antidater les données des blocks connus
date=`date +%Y%m%d0000`
touch -t $date $DATA_PATH/emptybot/*
for BLOCK in `grep -v LAST $DATA_PATH/block_list.txt | grep -v CACHE | awk '{print $2}'`
do
touch -t $date $DATA_PATH/*/$BLOCK.*
done
# Effacer ce qui trop vieux
if [ "$#" -eq "0" ] if [ "$#" -eq "0" ]
then then
if [ -d $DATA_PATH ] if [ -d $DATA_PATH ]

View File

@@ -53,11 +53,28 @@ then
echec echec
fi fi
if [ ! -d $DATA_PATH/twitterbot ]
then
mkdir -p $DATA_PATH/twitterbot
fi
if [ ! -d $DATA_PATH/emptybot ]
then
mkdir -p $DATA_PATH/emptybot
fi
# #
# TWEET # TWEET
# #
TWEET=8
if [ $((MINUTE % $TWEET)) -eq 0 ] # tweet Topisto : empty blocks
$APPS_PATH/twitter/emptybot/robot.sh 2>&1
# tweet frequency : 2 Hours
#TWEETFREQ=7200
#if [ $((TS % $TWEETFREQ)) -eq 0 ]
# Tweet freq : One per Hour
if [ ! -f $DATA_PATH/twitterbot/$DATEHOUR ]
then then
debug "send a TWEET" debug "send a TWEET"
@@ -66,8 +83,10 @@ then
# "auto likes" from Topisto # "auto likes" from Topisto
$APPS_PATH/twitter/likebot/robot.sh 2>&1 $APPS_PATH/twitter/likebot/robot.sh 2>&1
touch $DATA_PATH/twitterbot/$DATEHOUR
else else
debug "no TWEET" debug "skip TWEET"
fi fi
# #

View File

@@ -0,0 +1 @@
["topisto42","UnnaxPayments","aureliusdrusus","solacedotcom","omgbtc","ohiobitcoin","LogicScience","redunisproject","Cryptocracy2020","fullstache","callblockapp","marketranger","TheCryptodamus","crypt0co","CryptoassetsUSA","Nadeem_nadi797","cryptomoneyz","BaseCyberSec","Tweetsintoabyss","anthkell98","grattonboy","mac_a_dam","devnullius","123wolfArmy","03018333860","JeffinkoGuru","BitJob_Team","rugigana","Crypto_info321","cointopic_","Chef_JeanPierre","Cienencom","btcltcdigger","AdzCoin_Gift","treyptrsn","n2yolo","SHL0M0ABADD0N","EdwardCulligan","promote_crypto","TheFutureShift","ErickCoval","RIMCorpPK","arhiezvanhoute1","ttoff85","actu_fintech","BeautyBubble","PDX_Trader","Yasirperdesi","cre8hyperledger","Thurse8","cre8capital","icobountyprogs","rob67803423","AphexTwin4ever"]

View File

@@ -0,0 +1,88 @@
<?php
use Abraham\TwitterOAuth\TwitterOAuth;
// Twitter OAuth Settings:
/* TOPISTO */
define('CONSUMER_KEY', 'HBInbm93bM80z86XVJ34rtjxO');
define('CONSUMER_SECRET', 'zpdSp8yv9R2VODgPRA0RZbiO7VE8vSPNLVNg9zI0HjWnJKADO8');
define('ACCESS_TOKEN', '315679287-EjINhav5VbJPscb4h9pw3WwveeeX0ShpnIjcawDe');
define('ACCESS_TOKEN_SECRET', 'SIFKfPYEoIdlAyeQKVS3y067uNFuLpy013wRycJ8VxNcd');
/* R. Topisto
define('CONSUMER_KEY', '9Ie6CjwM5eZSQu5Xnbel4PBqm');
define('CONSUMER_SECRET', 'pI4ha5gW7Lft6Lg5xP7nH49Yqbm8PwLn1EP8D1qKg1q0SYd5t2');
define('ACCESS_TOKEN', '840479603143630849-c3xFLJFvo77ubP1njoXHpFu9LQqKLR8');
define('ACCESS_TOKEN_SECRET', 'EW4Zi10cQnNfoOunnEF1svJ3omz223U57G6KuYo5ZZ2Ls');
*/
define('TWITTER_WIDTH', 880);
define('TWITTER_HEIGHT', 440);
class twitter
{
public static function tweet($message, $media='')
{
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$content = $twitter->get('account/verify_credentials');
if ($twitter->getLastHttpCode() !== 200) return FALSE;
$parameters = array("status" => $message);
if (($media != NULL)&&($media != ''))
{
$imageMedia = $twitter->upload('media/upload', array('media' => $media));
if ($twitter->getLastHttpCode() !== 200) return FALSE;
$parameters = array(
"status" => $message,
"media_ids" => $imageMedia->media_id_string);
}
$statuses = $twitter->post("statuses/update", $parameters);
if ($twitter->getLastHttpCode() !== 200) return FALSE;
return TRUE;
}
public static function thanksRetweet()
{
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$content = $twitter->get('account/verify_credentials');
if ($twitter->getLastHttpCode() !== 200) return FALSE;
$results = $twitter->get('statuses/retweets_of_me');
if ($twitter->getLastHttpCode() !== 200) return FALSE;
/* TO DO */
return TRUE;
}
public static function thanksFollowers()
{
$twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);
$content = $twitter->get('account/verify_credentials');
if ($twitter->getLastHttpCode() !== 200) return FALSE;
$results = $twitter->get('followers/list');
if ($twitter->getLastHttpCode() !== 200) return FALSE;
$followers = json_decode(file_get_contents('followers.json'));
foreach($results->users as $user)
if (!in_array($user->screen_name, $followers))
{
$parameters = array("status" => '@'.$user->screen_name.' thanks following me !');
$followers[] = $user->screen_name;
$statuses = $twitter->post("statuses/update", $parameters);
if ($twitter->getLastHttpCode() !== 200) return FALSE;
break; // Un à la fois ...
}
file_put_contents('followers.json', json_encode($followers));
return TRUE;
}
}
?>

View File

@@ -0,0 +1,81 @@
<?php
// ---
// --- Listening to blockchain.info to get the last block
// --- Drawing the block as a Treemap
// --- Tweet it
// ---
// ---
// --- La config globale
// ---
require_once '../../global/inc/config.php';
// ---
// --- External dependances
// ---
require TOPISTO_PATH.'/ressources/vendor/autoload.php';
// ---
// --- Internal dependances
// ---
require_once APP_PATH.'/blockchain/inc/block.php';
require 'inc/twitter.php';
$midnight = strtotime('today midnight');
$methode='spline';
if (isset($argv[3])) $methode=$argv[3];
$block_hash = $argv[1];
$the_block = blockchain::getBlockWithHash($block_hash);
if ($the_block === FALSE) die();
// ---
// --- Remercier les followers ?
// ---
// twitter::thanksFollowers();
$image_file=DATA_PATH."/$methode/".$argv[1].'.png';
if (file_exists($image_file))
{
$image_origine = imagecreatefrompng($image_file);
$image_twitter = imagecreatetruecolor(TWITTER_WIDTH, TWITTER_HEIGHT);
$fond = imagecolorallocate($image_twitter, 255, 255, 255);
//imagecolortransparent($image_twitter, $fond);
imagefilledrectangle($image_twitter, 0, 0, TWITTER_WIDTH, TWITTER_HEIGHT, $fond);
$ratio = TWITTER_HEIGHT / imagesy($image_origine);
$new_width = $ratio * imagesx($image_origine);
$xpos = floor((TWITTER_WIDTH - $new_width) / 2);
$ypos = 0;
imagecopyresized($image_twitter, $image_origine, $xpos, $ypos, 0, 0, $new_width, TWITTER_HEIGHT, imagesx($image_origine), imagesy($image_origine));
$image_file = DATA_PATH."/emptybot/".$argv[1].'.png';
imagepng($image_twitter,$image_file);
// ---
// --- Un petit peu de stéganographie ...
// ---
/* Ca fait des fichiers trop gros !
$processor = new KzykHys\Steganography\Processor();
$image = $processor->encode($image_file, 'TOPISTO is making art with block '.$the_block->height);
$image->write($image_file);
*/
// ---
// --- Tweet
// ---
$tweet = "Lucky One on #bitcoin #blockchain 's".PHP_EOL;
$tweet .= "Someone put an empty block and get the reward for it !".PHP_EOL;
$tweet .= "Block height : ".$the_block->height.PHP_EOL;
$tweet .= "[ See more on www.topisto.net ]";
$success = twitter::tweet($tweet, $image_file);
}
?>

38
twitter/emptybot/robot.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
flag=$TMP_PATH/emptybot_bot.flag
if [ -f $flag ];
then
echo "empty_bot is already running !"
exit 0
fi
touch $flag
cd $APPS_PATH/twitter/emptybot
#
# Se lancer pour un tweet sur un block unique
#
BLOCK_LINE=`grep LAST $DATA_PATH/block_list.txt`
BLOCK_HASH=`echo ${BLOCK_LINE} | awk '{print $2}'`
BLOCK_NAME=`echo ${BLOCK_LINE} | awk '{print $1}'`
BLOCK_HEIGHT=`echo ${BLOCK_LINE} | awk '{print $3}'`
BLOCK_SIZE=`echo ${BLOCK_LINE} | awk '{print $4}'`
if [ $BLOCK_SIZE -eq 1 ]
then
if [ -f $DATA_PATH/hasard/$BLOCK_HASH.png ]
then
if [ ! -f $DATA_PATH/emptybot/$BLOCK_HASH.png ]
then
echo Tweet EmptyBlock for $BLOCK_HASH
echo $BLOCK_LINE >> $DATA_PATH/emptybot/list.txt
php robot.php $BLOCK_HASH $BLOCK_NAME hasard $BLOCK_HEIGHT
# Don't TWEET it again ...
touch $DATA_PATH/twitterbot/$BLOCK_HASH
fi
fi
fi
rm -f $flag

View File

@@ -14,19 +14,17 @@ cd $APPS_PATH/twitter/twitterbot
# #
# Tweet pour un assemblage de hash # Tweet pour un assemblage de hash
# #
for fichier in `ls $DATA_PATH/hashes2hashes/*.png` for fichier in `ls -tr $DATA_PATH/hashes2hashes/*.png`
do do
BLOCK=`basename $fichier .png` BLOCK_HASH=`basename $fichier .png`
if [ ! -f $DATA_PATH/twitterbot/assemblage_$BLOCK ]
then
php robot.php $BLOCK CONFIRMED hashes2hashes
touch $DATA_PATH/twitterbot/assemblage_$BLOCK
#rm -f $flag
#exit 0
sleep 30
fi
done done
if [ 5 -gt $((RANDOM % 100)) ]
then
php robot.php $BLOCK_HASH CONFIRMED hashes2hashes
touch $DATA_PATH/twitterbot/$BLOCK_HASH
fi
# #
# Se lancer pour un tweet sur un block unique # Se lancer pour un tweet sur un block unique
# #