Skip to content

Instantly share code, notes, and snippets.

@ibnux
Created March 24, 2021 08:29
Show Gist options
  • Save ibnux/e0f4a6411bcc5dfae1aef13ae9898b8c to your computer and use it in GitHub Desktop.
Save ibnux/e0f4a6411bcc5dfae1aef13ae9898b8c to your computer and use it in GitHub Desktop.

Revisions

  1. ibnux revised this gist Mar 24, 2021. No changes.
  2. ibnux created this gist Mar 24, 2021.
    32 changes: 32 additions & 0 deletions check.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <?php
    /**
    * Simpan di folder project go whatsapp rest
    * disebelah Dockerfile
    * jalankan cronjob setiap 5 menit
    * cronjob: */5 * * * * cd /path/to/go-whatsapp-rest && php check.php
    */

    $file = "./config/085156812578.gob";
    $path = "./config/stores/085156812578.gob";

    $bot_telegram = '';
    $chat_id = '1234567';

    if(!file_exists($path)){
    copy($file,$path);
    echo "sudah dicopy \n";
    if(!empty($bot_telegram)){
    file_get_contents('https://api.telegram.org/bot'.$bot_telegram.'/sendMessage?chat_id='.$chat_id.'&text='.urlencode("Wa dicopy lagi"));
    }
    }else{
    $md5a = md5_file($file);
    $md5b = md5_file($path);
    if($md5a!=$md5b){
    unlink($file);
    copy($path,$file);
    echo "update file\n";
    if(!empty($bot_telegram)){
    file_get_contents('https://api.telegram.org/bot'.$bot_telegram.'/sendMessage?chat_id='.$chat_id.'&text='.urlencode("Session Wa baru dicopy lagi"));
    }
    }else echo "masih ada \n";
    }