Skip to content

Instantly share code, notes, and snippets.

@febritecno
Last active Apr 19, 2021
Embed
What would you like to do?
bot whatsapp kirim pesan ke kumpulan kotak nomer secara otomatis dengan cronjobs
// ~~~ PERHATIAN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// KODE INI SUDAH TIDAK BEKERJA LAGI, KARNA PERUBAHAN
// STUKTUR DAN SISTEM DARI WHATSAPPIE API
//
// ~~~ PERHATIAN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//copy dan paste kode dibawah ini ke file package.json
{
"name": "hello-express",
"version": "0.0.1",
"description": "A simple Node app built on Express, instantly up and running.",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"express": "^4.17.1",
"qjobs": "^1.2.0",
"cloudscraper": "^4.6.0",
"request": "^2.88.2"
},
"engines": {
"node": "12.x"
},
"repository": {
"url": "https://glitch.com/edit/#!/hello-express"
},
"license": "MIT",
"keywords": [
"node",
"glitch",
"express"
]
}
// ~~~ PERHATIAN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// KODE INI SUDAH TIDAK BEKERJA LAGI, KARNA PERUBAHAN
// STUKTUR DAN SISTEM DARI WHATSAPPIE API
//
// ~~~ PERHATIAN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const express = require("express");
const request = require("cloudscraper");
const antrian = require("qjobs");
const app = express();
// satuan dalam milidetik (default 1 menit = 60000milis)
// untuk mencegah nomer diblokir
// jeda tiap task job antian kirim pesan ke semua kontak WA
const delay_kirim_pernomor = 60000;
// jeda request ke api wa
const delay_request_api = 30000;
// tambahkan saran ke daftar saran sesuka anda.
const daftar_saran = [
"cuci tangan setelah berpergian",
"hindari menyentuh area wajah",
"hindari berjabat tangan",
"selalu jaga jarak ya",
"jaga kesehatan!"
];
// api coronavirus dan whatsapp - - - - -
//https://api.kawalcorona.com/indonesia => corona report case
const info_coronavirus = "https://api.kawalcorona.com/indonesia";
//https://app.whatspie.com/ => whatapps
const wa = "https://app.whatspie.com/api/messages";
// - - - - - -
//********* jangan lupa isi variable - variable dibawah ini *****
// dibawah ini nomer telpon kamu.
const device_number = "nomer kamu";
//ubah daftar kontak, ubah dengan nomer yang mau kamu kirimin info.
const target_number = ["nomer1","nomer2","dsb"];
// ubah API Key, bisa dilihat di menu profil setting https://app.whatspie.com
const wa_token = "token api WA whatspie kamu";
// ***************
// fungsi dapatkan waktu dan memilih acak untuk saran
var waktu_sekarang = split => {
var d = new Date();
var date =
d.getDate() +
split +
(d.getMonth() + 1) +
split +
d.getFullYear() +
split +
d.getHours() +
":" +
d.getMinutes();
return date;
};
var acak_saran = array => {
return array[Math.floor(Math.random() * array.length)];
};
app.get("/kirim", (req, res) => {
try {
request.get(info_coronavirus, async function(err, response, body) {
const wait_data = await JSON.parse(body);
if (typeof body !== "undefined") {
const data_indonesia = await wait_data[0];
res.send([data_indonesia]);
var message = `~~> [ Last Update : ${waktu_sekarang("-")} ]
- - - - - - - - - - - - - - - - - - -
- - *Data Coronavirus Indonesia* - -
- - - - - - - - - - - - - - - - - - -
*- Total Positif* = ${data_indonesia.positif}
*- Total Sembuh* = ${data_indonesia.sembuh}
*- Total Meninggal* = ${data_indonesia.meninggal}
- - - - - - - - - - - - - - - - - - -
- Sumber Data : https://kemkes.go.id
!(•̀ᴗ•́)و ̑̑ _" ${acak_saran(daftar_saran)} "_`;
var send_message = function(args, next) {
setTimeout(function() {
request.post(
wa,
{
form: {
receiver: target_number[args[0]],
device: device_number,
message: message,
type: "chat"
},
auth: {
bearer: wa_token
}
},
function(err, respon, body) {
console.log(args);
console.log("status: " + respon.statusCode);
}
);
next();
}, delay_request_api);
};
var qj = new antrian({ maxConcurrency: 1 });
qj.on("start", function() {
console.log(" ");
console.log("*********** Starting Antrian Kirim Pesan **********");
console.log(" ");
});
qj.on("jobStart", function(args) {
console.log(" ");
console.log("-------- Task Jobs Start --------");
console.log(" ");
console.log("[-] JobStart => ", args);
console.log(" ");
});
qj.on("jobEnd", function(args) {
console.log(" ");
console.log("[X] Jobend => ", args);
console.log(" ");
console.log(" ");
console.log("-------- Task Jobs Done --------");
console.log(" ");
// If job end, then make a pause
qj.pause(true);
setTimeout(function() {
qj.pause(false);
}, delay_kirim_pernomor);
});
qj.on("pause", function(since) {
console.log("in pause since " + since + " milliseconds");
});
qj.on("unpause", function() {
console.log(" ");
console.log("[P] Job pause end, continu ..");
console.log(" ");
});
qj.on("end", function() {
console.log(" ");
console.log("************ Semua Pesan Telah Terkirim ************");
console.log(" ");
});
for (var i = 0; i < target_number.length; i++) {
// task antrian kirim pesan ke banyak nomer
qj.add(
send_message,
[ i , " Send message to number phone [ " + target_number[i]+ " ]"]
);
}
qj.run();
} else {
//jika request gagal maka akan reload.
setTimeout(function() {
res.redirect("/kirim");
}, 5000);
res.send("auto reload after 5s …");
}
});
} catch (e) {
setTimeout(function() {
//jika request gagal maka akan reload.
res.redirect("/kirim");
}, 5000);
res.send("auto reload page after 5s …");
}
});
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
});
@armadill

This comment has been minimized.

Copy link

@armadill armadill commented Jul 1, 2020

kalu untuk atur durasi kirim nya gmna ?
misalkan
setiap krm ke 10 nomor jeda dlu 10 menit bru lanjut lg nomor 20 dst

@febritecno

This comment has been minimized.

Copy link
Owner Author

@febritecno febritecno commented Jul 3, 2020

kalu untuk atur durasi kirim nya gmna ?
misalkan
setiap krm ke 10 nomor jeda dlu 10 menit bru lanjut lg nomor 20 dst

sudah saya perbaiki gan. semoga bisa.

@ramdan123

This comment has been minimized.

Copy link

@ramdan123 ramdan123 commented Aug 10, 2020

kalo untuk menambahkan const nama ["a","b","c"] pada var message itu gmana ya gan ?

@Zxce3

This comment has been minimized.

Copy link

@Zxce3 Zxce3 commented Sep 29, 2020

gan mau nanya kalo buat bot untuk aplikasi whatsauto gimana??

@wahidhusni24

This comment has been minimized.

Copy link

@wahidhusni24 wahidhusni24 commented Oct 30, 2020

Iya gan gimana ya untuk bot server whatsauto? Tolong dong

@X-PrCx12

This comment has been minimized.

Copy link

@X-PrCx12 X-PrCx12 commented Dec 5, 2020

gan mau nanya kalo buat bot untuk aplikasi whatsauto gimana??

Wkwkwk Ini Run Di PC / RDP VPS bro, bukan di WaAuto

Termux juga gak bisa yak? Awoakwowk

@wahidhusni24

This comment has been minimized.

Copy link

@wahidhusni24 wahidhusni24 commented Dec 6, 2020

gan mau nanya kalo buat bot untuk aplikasi whatsauto gimana??

Wkwkwk Ini Run Di PC / RDP VPS bro, bukan di WaAuto

Masnya tau aplikasi whatsauto ? Klo belum cek di google play dulu deh mas biar ga salah paham hheeee

@ffhitmanff

This comment has been minimized.

Copy link

@ffhitmanff ffhitmanff commented Jan 21, 2021

Apikey Harta tahta ada gk gan ?

@X-PrCx12

This comment has been minimized.

Copy link

@X-PrCx12 X-PrCx12 commented Jan 21, 2021

Apikey Harta tahta ada gk gan ?

Kayaknya ada gan!, kalo gak ada bisa cek :

  1. github.com/MhankBarBar
  2. github.com/TobyG74
  3. github.com/ArugaZ
@Zxce3

This comment has been minimized.

Copy link

@Zxce3 Zxce3 commented Jan 21, 2021

gan mau nanya kalo buat bot untuk aplikasi whatsauto gimana??

Wkwkwk Ini Run Di PC / RDP VPS bro, bukan di WaAuto

Iya tau gan, kira" algoritma nya seperti apa kalo untuk aplikasi whatsauto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment