Script Notifikasi WA Gateway Pengingat Pembayaran dengan Userman
Script Notifikasi WA Gateway Pengingat Pembayaran dengan Userman

Script ini dibuat untuk melengkapi tutorial video di Chanel Labkom TV

Script di profile on login jika tanggal pemasang dan tanggal jatuh temponya sama 

:local date [ /system clock get date ];
:local tgl [ :pick $date 4 6 ];
:local comment [/tool user-manager user get [/tool user-manager user find where username="$user"] comment];
:if ($comment = "") do={ 
/tool user-manager user set comment=$tgl [find username=$user];
}

Script di profile on login jika tanggal jatuh temponya 30 hari setelah aktivasi

:local date [ /system clock get date ];
:local comment [/tool user-manager user get [/tool user-manager user find where username="$user"] comment];
:if ($comment = "") do={ 
/sys sch add name=$user disable=no start-date=$date interval="30d"; 
:local tglexp [ /sys sch get [ /sys sch find where name="$user" ] next-run];
:delay 5; 
:local tgl [ :pick $tglexp 4 6 ]; 
/tool user-manager user set comment=$tgl [find username=$user];
delay 10; 
/sys sch remove [find where name=$user];
}

Script untuk schedule

:local date [ /system clock get date ];
:local varDay [:pick $date 4 6];
:local varDayINT [:tonum $varDay];
:local user value=[/tool user-manager user find];
:local pesan "Pelanggan Labkom yang terhormat";
:foreach users in=$user do={
:local wa [/tool user-manager user get $users value-name=phone];
:local tgl [/tool user-manager user get $users value-name=comment];
:local tglnotif ($tgl - 3);
:if ($varDayINT = $tglnotif) do={ 
/tool fetch http-header-field="content-type: application/x-www-form-urlencoded" http-method=post http-data="number=$wa&message=$pesan" url="http://XXXXX/send" keep-result=no;
:log warning "Pesan terkirim ke $wa";
}
};
:log warning "Pesan berhasil terkirim semua";

Leave a Reply