-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
1033 lines (912 loc) · 31.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
const fs = require("fs");
const moment = require("moment");
const qrcode = require("qrcode-terminal");
const { Client, MessageMedia } = require("whatsapp-web.js");
const mqtt = require("mqtt");
const listen = mqtt.connect("mqtt://test.mosquitto.org");
const fetch = require("node-fetch");
const User = require("./user.js");
const delay = require("delay");
let urlen = require("urlencode");
const puppeteer = require("puppeteer");
const cheerio = require("cheerio");
const corona = require("./CoronaService/covid19.js");
const SESSION_FILE_PATH = "./session.json";
// file is included here
let sessionCfg;
if (fs.existsSync(SESSION_FILE_PATH)) {
sessionCfg = require(SESSION_FILE_PATH);
}
client = new Client({
puppeteer: {
executablePath: '/usr/bin/chromium-browser',
headless: true
},
session: sessionCfg
});
// You can use an existing session and avoid scanning a QR code by adding a "session" object to the client options.
client.initialize();
// ======================= Begin initialize WAbot
client.on("qr", qr => {
// NOTE: This event will not be fired if a session is specified.
qrcode.generate(qr, {
small: true
});
console.log(`[ ${moment().format("HH:mm:ss")} ] Please Scan QR with app!`);
});
client.on("authenticated", session => {
console.log(`[ ${moment().format("HH:mm:ss")} ] Authenticated Success!`);
// console.log(session);
sessionCfg = session;
fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), function(err) {
if (err) {
console.error(err);
}
});
});
client.on('message', async (msg) => {
if(msg === '!join') {
const chat = await msg.getChat();
let text = "sini oy ";
let mentions = [];
for(let participant of chat.participants) {
const contact = await client.getContactById(participant.id._serialized);
mentions.push(contact);
text += `@${participant.id.user} `;
}
chat.sendMessage(text, { mentions });
}
});
client.on("auth_failure", msg => {
// Fired if session restore was unsuccessfull
console.log(
`[ ${moment().format("HH:mm:ss")} ] AUTHENTICATION FAILURE \n ${msg}`
);
fs.unlink("./session.json", function(err) {
if (err) return console.log(err);
console.log(
`[ ${moment().format("HH:mm:ss")} ] Session Deleted, Please Restart!`
);
process.exit(1);
});
});
client.on("ready", () => {
console.log(`[ ${moment().format("HH:mm:ss")} ] Whatsapp bot ready!`);
});
// ======================= Begin initialize mqtt broker
listen.on("connect", () => {
listen.subscribe("corona", function(err) {
if (!err) {
console.log(`[ ${moment().format("HH:mm:ss")} ] Mqtt topic subscribed!`);
}
});
});
// ======================= WaBot Listen on Event
client.on("message_create", msg => {
// Fired on all message creations, including your own
if (msg.fromMe) {
// do stuff here
}
});
client.on("message_revoke_everyone", async (after, before) => {
// Fired whenever a message is deleted by anyone (including you)
// console.log(after); // message after it was deleted.
if (before) {
console.log(before.body); // message before it was deleted.
}
});
client.on("message_revoke_me", async msg => {
// Fired whenever a message is only deleted in your own view.
// console.log(msg.body); // message before it was deleted.
});
client.on("message_ack", (msg, ack) => {
/*
== ACK VALUES ==
ACK_ERROR: -1
ACK_PENDING: 0
ACK_SERVER: 1
ACK_DEVICE: 2
ACK_READ: 3
ACK_PLAYED: 4
*/
if (ack == 3) {
// The message was read
}
});
client.on("group_join", notification => {
// User has joined or been added to the group.
console.log("join", notification);
notification.reply("User joined.");
});
client.on("group_leave", notification => {
// User has left or been kicked from the group.
console.log("leave", notification);
notification.reply("User left.");
});
client.on("group_update", notification => {
// Group picture, subject or description has been updated.
console.log("update", notification);
});
client.on("disconnected", reason => {
console.log("Client was logged out", reason);
});
// ======================= WaBot Listen on message
client.on("message", async msg => {
console.log(
`[ ${moment().format("HH:mm:ss")} ] Message:`,
msg.from.replace("@c.us", ""),
`| ${msg.type}`,
msg.body ? `| ${msg.body}` : ""
);
if (msg.type == "ciphertext") {
// Send a new message as a reply to the current one
msg.reply("kirim ! menu atau !help untuk melihat menu.");
} else if (msg.body == "!ping reply") {
// Send a new message as a reply to the current one
msg.reply("pong");
}
else if (msg.body.startsWith("!fb ")) {
const request = require('request');
var req = msg.body.split(" ")[1];
const { exec } = require("child_process");
var crypto = require('crypto');
var fs = require('fs');
var chat = await msg.getChat();
var filename = 'video'+crypto.randomBytes(4).readUInt32LE(0)+'saya';
var path = require('path');
request.get({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'https://fbdownloader.net/download/?url='+ req,
},function(error, response, body){
let $ = cheerio.load(body);
var gehu = $('a[rel="noreferrer no-follow"]').attr('href');
exec('wget "' + gehu + '" -O mp4/gue.mp4', (error, stdout, stderr) => {
const media = MessageMedia.fromFilePath('mp4/gue.mp4');
chat.sendMessage(media);
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
});
}else if (msg.body.startsWith("!ig ")) {
msg.reply(`*Hai, Kita Proses Dulu Ya . . .*`);
let link = msg.body.split(" ")[1];
var namafile = link.split("/p/")[1].split("/")[0];
var chat = await msg.getChat();
const { exec } = require("child_process");
const browser = await puppeteer.launch({
headless: false,
args: [
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-accelerated-2d-canvas",
"--disable-gpu",
"--window-size=1920x1080",
],
});
const page = await browser.newPage();
await page
.goto("https://id.savefrom.net/download-from-instagram", {
waitUntil: "networkidle2",
})
.then(async () => {
await page.type("#sf_url", `${link}`);
await page.click("#sf_submit");
try {
msg.reply("Mendownload Video!");
await page.waitForSelector(
"#sf_result > div > div.result-box.video > div.info-box > div.link-box.single > div.def-btn-box > a"
);
const element = await page.$(
"#sf_result > div > div.result-box.video > div.info-box > div.link-box.single > div.def-btn-box > a"
);
const text = await (await element.getProperty("href")).jsonValue();
const judul = await page.$(
"#sf_result > div > div.result-box.video > div.info-box > div.meta > div"
);
const judul1 = await (await judul.getProperty("title")).jsonValue();
console.log(
`[${moment().format("hh:mm:ss")}][!fb][${
msg.from
}] > Berhasil Dilakukan`
);
msg.reply(
`*BERHASIL!!!*
Judul : ${judul1}
👾 Instagram Downloader By InsideHeartz 👾`
);
exec('wget "' + text + '" -O mp4/'+ namafile +'.mp4', (error, stdout, stderr) => {
const media = MessageMedia.fromFilePath('mp4/'+ namafile +'.mp4');
chat.sendMessage(media);
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
browser.close();
} catch (error) {
console.log(
`[${moment().format("hh:mm:ss")}][!fb][${
msg.from
}] > GAGAL Dilakukan`
);
msg.reply(
`[GAGAL] PASTIKAN LINK VIDEO BERSIFAT PUBLIK DAN DAPAT DIAKSES OLEH SEMUA ORANG!*`
);
browser.close();
}
})
.catch((err) => {
console.log(
`[${moment().format("hh:mm:ss")}][!fb][${msg.from}] > GAGAL Dilakukan`
);
msg.reply(
`[GAGAL] Server Sedang Down!\n\nSilahkan Coba Beberapa Saat Lagi!`
);
browser.close();
});
}
else if (msg.body.startsWith("!brainly ")) {
var tanya = msg.body.split(" ")[1];
const fetch = require('node-fetch')
const url = "https://tools.aqin.my.id/api/brainly/?q="+ tanya;
const solution = () => {
fetch(url).then(res => res.json()).then((res) => {
res.data.questionSearch.edges.forEach(item => {
console.log("==[content]==")
client.sendMessage(
msg.from,
` $(item.node.content) `);
console.log("=============")
console.log("==[answer]==")
item.node.answers.nodes.forEach(item => {
msg.reply(item['content']);
})
console.log("=========")
})
})
}
}
else if (msg.body.startsWith("!sial ")) {
const request = require('request');
var req = msg.body;
var tanggal = req.split(" ")[1];
var kk = req.split(" ")[2];
var bulan = kk.replace("0", "");
var tahun = req.split(" ")[3];
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'http://www.primbon.com/primbon_hari_naas.php',
body: "tgl="+ tanggal +"&bln="+ bulan +"&thn="+ tahun +"&submit=+Submit%21+"
},function(error, response, body){
let $ = cheerio.load(body);
var y = $.html().split('<b>PRIMBON HARI NAAS</b><br><br>')[1];
var t = y.split('.</i><br><br>')[1];
var f = y.replace(t ," ");
var x = f.replace(/<br\s*[\/]?>/gi, "\n\n");
var h = x.replace(/<[^>]*>?/gm, '');
var d = h.replace("&", '&')
console.log(""+ d);
msg.reply(`
-----------------------------------
Cek Hari Naas Kamu ~
${d}
----------------------------------
👾 InsideBot 2020👾
`);
});
}
else if (msg.body.startsWith("!pasangan ")) {
const request = require('request');
var req = msg.body;
var gh = req.split("!pasangan ")[1];
var namamu = gh.split("&")[0];
var pasangan = gh.split("&")[1];
request.get({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'http://www.primbon.com/kecocokan_nama_pasangan.php?nama1='+ namamu +'&nama2='+ pasangan +'&proses=+Submit%21+',
},function(error, response, body){
let $ = cheerio.load(body);
var y = $.html().split('<b>KECOCOKAN JODOH BERDASARKAN NAMA PASANGAN</b><br><br>')[1];
var t = y.split('.<br><br>')[1];
var f = y.replace(t ," ");
var x = f.replace(/<br\s*[\/]?>/gi, "\n");
var h = x.replace(/<[^>]*>?/gm, '');
var d = h.replace("&", '&')
console.log(""+ d);
msg.reply(`
-----------------------------------
*Cek Kecocokan Jodoh Berdasarkan Nama ~*
${d}
----------------------------------
👾 InsideBot 2020 👾
`);
});
}
else if (msg.body.startsWith("!ytmp3 ")) {
var url = msg.body.split(" ")[1];
var videoid = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
var chat = await msg.getChat();
if(videoid != null) {
console.log("video id = ",videoid[1]);
} else {
msg.reply("Videonya gavalid gan.");
}
msg.reply(" Tunggu sebentar kak .. Lagi di proses ☺");
var YoutubeMp3Downloader = require("youtube-mp3-downloader");
//Configure YoutubeMp3Downloader with your settings
var YD = new YoutubeMp3Downloader({
"ffmpegPath": "ffmpeg",
"outputPath": "./mp3", // Where should the downloaded and en>
"youtubeVideoQuality": "highest", // What video quality sho>
"queueParallelism": 2, // How many parallel down>
"progressTimeout": 2000 // How long should be the>
});
//Download video and save as MP3 file
YD.download(videoid[1]);
YD.on("finished", function(err, data) {
const media = MessageMedia.fromFilePath(data.file);
msg.reply(`
Mp3 Berhasil di download
----------------------------------
Nama File : *${data.videoTitle}*
Nama : *${data.title}*
Artis : *${data.artist}*
----------------------------------
👾 👾
_Ytmp3 WhatsApp By InsideBot_
`);
chat.sendMessage(media);
});
YD.on("progress", function(data) {
});
}
else if (msg.body.startsWith("!quotes")) {
const request = require('request');
request.get({
headers: {
'user-agent' : 'Mozilla/5.0 (Linux; Android 8.1.0; vivo 1820) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Mobile Safari/537.36'
},
url: 'https://jagokata.com/kata-bijak/acak.html',
},function(error, response, body){
let $ = cheerio.load(body);
var author = $('a[class="auteurfbnaam"]').contents().first().text();
var kata = $('q[class="fbquote"]').contents().first().text();
client.sendMessage(
msg.from,
`
_${kata}_
*~${author}*
`
);
});
}
else if (msg.body.startsWith("!nama ")) {
const cheerio = require('cheerio');
const request = require('request');
var nama = msg.body.split("!nama ")[1];
var req = nama.replace(/ /g,"+");
request.get({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'http://www.primbon.com/arti_nama.php?nama1='+ req +'&proses=+Submit%21+',
},function(error, response, body){
let $ = cheerio.load(body);
var y = $.html().split('arti:')[1];
var t = y.split('method="get">')[1];
var f = y.replace(t ," ");
var x = f.replace(/<br\s*[\/]?>/gi, "\n");
var h = x.replace(/<[^>]*>?/gm, '');
console.log(""+ h);
msg.reply(
`
*Arti Dari Namamu*
----------------------------------
Nama _*${nama}*_ ${h}
----------------------------------
_InsideBot_
`
);
});
}
else if (msg.body.startsWith("!sifat ")) {
const cheerio = require('cheerio');
const request = require('request');
var req = msg.body.split("[")[1].split("]")[0];
var nama = req.replace(/ /g," ");
var pesan = msg.body;
var y = pesan.replace(/ /g,"+ ");
var tanggal = y.split("]+")[1].split("-")[0];
var bulan = y.split("-")[1];
var tahun = y.split("-")[2];
request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded'},
url: 'http://www.primbon.com/sifat_karakter_tanggal_lahir.php',
body: "nama="+ req +"&tanggal="+ tanggal +"&bulan="+ bulan +"&tahun="+ tahun +"&submit=+Submit%21+"
},function(error, response, body){
let $ = cheerio.load(body);
$('title').after('body')
var y = $.html().split('<b>Nama :</b>')[1];
var t = y.split('</i><br><br>')[1];
var f = y.replace(t ," ");
var x = f.replace(/<br\s*[\/]?>/gi, "\n");
var h = x.replace(/<[^>]*>?/gm, '');
console.log(""+ h);
msg.reply(
`
*Sifat Dari Nama dan Tanggal Lahir*
----------------------------------
Nama ${h}
----------------------------------
_Primbon WhatsApp By InsideBot_
`
);
});
}else if (msg.body.startsWith("!quora ")) {
const imel = msg.body.split(" ")[1];
var url = 'http://tools.aqin.my.id/api/quora/api.php?q=' + imel;
const fetch = require("node-fetch");
fetch(url)
.then(res => res.text())
.then(body =>
client.sendMessage(
msg.from,
`
${body}
Powered by _fdcibot_
`));
}
else if (msg.body.startsWith("!yt ")) {
const url = msg.body.split(" ")[1];
const fs = require('fs');
const chat = await msg.getChat();
var videoid = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
const media = MessageMedia.fromFilePath('mp4/'+ videoid[1] +'.mp4');
client.sendMessage(
msg.from,
`
Tunggu....
`);
var ytdl = require('ytdl-core');
// TypeScript: import ytdl from 'ytdl-core'; with --esModuleInterop
// TypeScript: import * as ytdl from 'ytdl-core'; with --allowSyntheticDefaultImports
// TypeScript: import ytdl = require('ytdl-core'); with neither of the above
ytdl(url)
.pipe(fs.createWriteStream('mp4/'+ videoid[1] +'.mp4'));
chat.sendMessage(media);
}
else if (msg.body.startsWith("!cek ")) {
const imel = msg.body.split(" ")[1];
var url = 'https://taqin.my.id/cek.php?email=' + imel;
const fetch = require("node-fetch");
fetch(url)
.then(res => res.text())
.then(body =>
client.sendMessage(
msg.from,
`
${body}
Powered by _fdcibot_
`));
}
else if (msg.body.startsWith("!resi ")) {
let kurir = msg.body.split(" ")[1];
let resi = msg.body.split(" ")[2];
console.log(kurir + resi);
if (kurir.length != 2 || resi.length != 6) {
fetch(`https://api.terhambar.com/resi?resi=${resi}&kurir=${kurir}`)
.then((resss) => resss.json())
.then((resst) => {
if (resst.status != "OK") {
msg.reply("*Maaf Server Mencapai Batas Harian! Coba Lagi Besok!*");
} else {
let ar = [];
let sem = "";
for (let i = 0; i < Object.keys(resst.lacak.stats).length; i++) {
let sendlah =
"moment().format('hh:mm:ss') : " +
resst.lacak.stats[i].moment().format("hh:mm:ss") +
"\nKeterangan : " +
resst.lacak.stats[i].keterangan +
"\nKota : " +
resst.lacak.stats[i].kota +
"\n\n";
ar.push(sendlah);
sem = ar.join("");
}
console.log(
`[${moment().format("hh:mm:ss")}][!fb][${
msg.from
}] > Berhasil Dilakukan`
);
msg.reply(
"*Berhasil Melacak*\n\n" +
"Nama Penerima : " +
resst.name +
"\nKurir : " +
resst.kurir +
"\nmoment().format('hh:mm:ss') Input Resi : " +
resst.tlg_input +
`\n\n*Pelacakan* :\n${sem}`
);
}
});
} else {
console.log(
`[${moment().format("hh:mm:ss")}][!resi][${msg.from}] > GAGAL Dilakukan`
);
msg.reply("*DATA TIDAK BISA DILACAK!*");
}
} else if (msg.body == "!resi") {
let balas = `_CEK RESI VIA WHATSAPP_\n\nformat cek resi *_!resi kurir nomor resi_*\n\ncontoh > *!resi jnt 6969696969*\n`;
msg.reply(balas);
console.log(
`[${moment().format("hh:mm:ss")}][!resi][${
msg.from
}] > Berhasil Dilakukan`
);
}
else if (msg.body == "p" ||
msg.body === "P") {
// Send a new message to the same chat
client.sendMessage(msg.from, "kok");
} else if (msg.body == " assallamuallaikum") {
client.sendMesssage(msg.from, "Waalaikumusallam");
} else if (msg.body.startsWith("!sendto ")) {
// Direct send a new message to specific id
let number = msg.body.split(" ")[1];
let messageIndex = msg.body.indexOf(number) + number.length;
let message = msg.body.slice(messageIndex, msg.body.length);
number = number.includes("@c.us") ? number : `${number}@c.us`;
let chat = await msg.getChat();
chat.sendSeen();
client.sendMessage(number, message);
} else if (msg.body == "!chats") {
const chats = await client.getChats();
client.sendMessage(msg.from, `The bot has ${chats.length} chats open.`);
} else if (msg.body == "info" || msg.body == "!help" || msg.body == "!menu") {
let localData = client.localData;
// console.log(localData);
client.sendMessage(
msg.from,
`
◦•●◉✿ ஜ۩۞۩ஜ 𝐈𝐧𝐬𝐢𝐝𝐞 𝐁𝐨𝐭 ஜ۩۞۩ஜ ✿◉●•◦
👾 List Menu Bot :
◦🌉 *_ɦσɾσรcσρε* ~_
🌠 *!nama* <nama>
*_cari arti dari namamu_*
contoh _!nama Maudy Ayunda_
🌠 *!quotes*
*_random quotes dari tokoh terkenal_*
🌠 *!sifat* [nama] tt-mm-yy
*_cari sifat berdasarkan nama dan tanggal lahir_*
contoh _!sifat [Maudy Ayunda] 31-08-199_
🌠 *!sial* tt mm yy
*_cek hari apes mu_*
contoh _!sial 17 08 1945_
🌠 *!pasangan* namamu & pasanganmu
*_Cek kecocokan jodoh_*
contoh _!pasangan Riska & Ali_
🗃 *_ժօաղlօαժҽɾ* ~_
🔖 *!fb* <url>
*downloader facebook_*
🔖 *!ig* <url>
*downloader instagram*
🔖 *!ytmp3* <url>
*konversi youtube ke mp3_*
🅜🅞🅡🅔
🅕🅔🅐🅣🅤🅡🅔🅢 🅘🅢
🅒🅞🅞🅜🅘🅝🅖 🅢🅞🅞🅝
_Powered By_ : 💞 *InsideHeartz*
`
);
} else if (msg.body == "!localData") {
let localData = client.localData;
// console.log(localData);
client.sendMessage(
msg.from,
`
*Connection localData*
User name: ${localData.pushname}
My number: ${localData.me.user}
Device: ${localData.phone.device_manufacturer} | ${localData.phone.device_model}
Platform: ${localData.platform} ${localData.phone.os_version}
WhatsApp version: ${localData.phone.wa_version}
`
);
} else if (msg.body == "!medial" && msg.hasMedia) {
const attachmentData = await msg.downloadMedia();
// console.log(attachmentData)
msg.reply(`
*Media localData*
MimeType: ${attachmentData.mimetype}
Filename: ${attachmentData.filename}
Data (length): ${attachmentData.data.length}
`);
} else if (msg.body == "!quotel" && msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
quotedMsg.reply(`
ID: ${quotedMsg.id._serialized}
Type: ${quotedMsg.type}
Author: ${quotedMsg.author || quotedMsg.from}
Timestamp: ${quotedMsg.timestamp}
Has Media? ${quotedMsg.hasMedia}
`);
} else if (msg.body == "!resendmedia" && msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
if (quotedMsg.hasMedia) {
const attachmentData = await quotedMsg.downloadMedia();
client.sendMessage(msg.from, attachmentData, {
caption: "Here's your requested media."
});
}
} else if (msg.body == "!location") {
msg.reply(
new Location(37.422, -122.084, "Googleplex\nGoogle Headquarters")
);
} else if (msg.body == "!mention") {
const contact = await msg.getContact();
const chat = await msg.getChat();
chat.sendMessage(`Hi @${contact.number}!`, {
mentions: [contact]
});
} else if (msg.body == "!delete" && msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
if (quotedMsg.fromMe) {
quotedMsg.delete(true);
} else {
msg.reply("I can only delete my own messages");
}
} else if (msg.body === "!archive") {
const chat = await msg.getChat();
chat.archive();
} else if (msg.body === "!recording") {
const chat = await msg.getChat();
// simulates recording audio in the chat
chat.sendStateRecording();
} else if (msg.body === "!clearstate") {
const chat = await msg.getChat();
// stops typing or recording in the chat
chat.clearState();
} else if (msg.body === "!mati") {
let chat = await msg.getChat();
if (chat.isGroup) {
msg.reply("Maaf, perintah ini tidak bisa digunakan di dalam grup!");
} else {
User.checkUser(msg.from).then(result => {
if (result) {
User.removeUser(msg.from).then(result => {
if (result) {
client.sendMessage(
msg.from,
"Berhasil menonaktifkan, anda tidak akan mendapat notifikasi lagi."
);
} else {
client.sendMessage(
msg.from,
"Gagal menonaktifkan, nomor tidak terdaftar."
);
}
});
} else {
client.sendMessage(
msg.from,
"Gagal menonaktifkan, nomor tidak terdaftar."
);
}
});
}
} else if (msg.body === "!aktif" || msg.body === "!daftar") {
let chat = await msg.getChat();
if (chat.isGroup) {
msg.reply("Maaf, perintah ini tidak bisa digunakan di dalam grup!");
} else {
User.addUser(msg.from).then(result => {
if (!result) {
client.sendMessage(msg.from, "Notifikasi sudah aktif.");
} else {
client.sendMessage(msg.from, "Berhasil mengaktifkan notifikasi.");
}
});
}
} else if (msg.body === "!coronaOld") {
fs.readFile("./CoronaService/data.json", "utf-8", function(err, data) {
if (err) throw err;
const localData = JSON.parse(data);
const newCases = localData.NewCases === "" ? 0 : localData.NewCases;
const newDeaths = localData.NewDeaths === "" ? 0 : localData.NewDeaths;
client.sendMessage(
msg.from,
` *COVID-19 Update!!*
Negara: ${localData.Country}
*Kasus aktif: ${localData.ActiveCases}*
*Total Kasus: ${localData.TotalCases}*
Kasus Baru: ${newCases}
*Meninggal: ${localData.TotalDeaths}*
Meninggal Baru: ${newDeaths}
*Total Sembuh: ${localData.TotalRecovered}*
Sumber: _https://www.worldometers.info/coronavirus/_
`
);
var imageAsBase64 = fs.readFileSync(
"./CoronaService/corona.png",
"base64"
);
var CoronaImage = new MessageMedia("image/png", imageAsBase64);
client.sendMessage(msg.from, CoronaImage);
});
} else if (
msg.body === "!corona" ||
msg.body === "Corona" ||
msg.body === "/corona"
) {
corona.getAll().then(result => {
var aktifIndo =
result[0].confirmed - result[0].recovered - result[0].deaths;
// var aktifGlob = result[1].confirmed - result[1].recovered - result[1].
// Kasus *Global*
// Total Kasus: ${result[1].confirmed}
// Kasus aktif: ${aktifGlob}
// Sembuh: ${result[1].recovered}
// Meninggal: ${result[1].deaths}
// Update Pada:
// ${result[1].lastUpdate}
client.sendMessage(
msg.from,
`
*COVID-19 Update!!*
Kasus *Indonesia* 🇮🇩
😞 Total Kasus: ${result[0].confirmed}
😷 Kasus aktif: ${aktifIndo}
😊 Sembuh: ${result[0].recovered}
😭 Meninggal: ${result[0].deaths}
🕓 Update Pada:
${result[0].lastUpdate.replace("pukul", "|")} WIB
Stay safe ya semuanya , jaga kesehatan nya masing masing`
);
var imageAsBase64 = fs.readFileSync(
"./CoronaService/corona.png",
"base64"
);
var CoronaImage = new MessageMedia("image/png", imageAsBase64);
client.sendMessage(msg.from, CoronaImage);
});
// ============================================= Groups
} else if (msg.body.startsWith("!subject ")) {
// Change the group subject
let chat = await msg.getChat();
if (chat.isGroup) {
let newSubject = msg.body.slice(9);
chat.setSubject(newSubject);
} else {
msg.reply("This command can only be used in a group!");
}
} else if (msg.body.startsWith("!echo ")) {
// Replies with the same message
msg.reply(msg.body.slice(6));
} else if (msg.body.startsWith("!desc ")) {
// Change the group description
let chat = await msg.getChat();
if (chat.isGroup) {
let newDescription = msg.body.slice(6);
chat.setDescription(newDescription);
} else {
msg.reply("This command can only be used in a group!");
}
} else if (msg.body.startsWith("baca ")) {
const newStatus = msg.body.split(" ")[1];
const fetch = require("node-fetch");
let url =
"https://al-quran-8d642.firebaseio.com/surat/" +
newStatus +
".json?print=pretty";
fetch(url)
.then(res => {
return res.json();
})
.then(resJSON => {
resJSON.forEach(item => {
client.sendMessage(
msg.from,
`
Ayat , :
*${item.ar}*
----------------------------------
Terjemah :
_${item.id}_
----------------------------------
_Al-Quran WhatsApp By Abdul Muttaqin_
`
);
});
});
} else if (msg.body == "!leave") {
// Leave the group
let chat = await msg.getChat();
if (chat.isGroup) {
chat.leave();
} else {
msg.reply("This command can only be used in a group!");
}
} else if (msg.body.startsWith("!join ")) {
const inviteCode = msg.body.split(" ")[1];
try {
await client.acceptInvite(inviteCode);
msg.reply("Joined the group!");
} catch (e) {
msg.reply("That invite code seems to be invalid.");
}
} else if (msg.body == "!grouplocalData") {
let chat = await msg.getChat();
if (chat.isGroup) {
msg.reply(`
*Group Details*
Name: ${chat.name}
Description: ${chat.description}
Created At: ${chat.createdAt.toString()}
Created By: ${chat.owner.user}
Participant count: ${chat.participants.length}
`);
} else {
msg.reply("This command can only be used in a group!");
}
}
});
listen.on("message", (topic, message) => {
console.log(`[ ${moment().format("HH:mm:ss")} ] MQTT: ${message.toString()}`);
fs.readFile("./CoronaService/user.json", "utf-8", function(err, data) {
if (err) throw err;
const userData = JSON.parse(data);
for (var i = 0; i < userData.length; i++) {
let number = userData[i].user;
// number = number.includes('@c.us') ? number : `${number}@c.us`;
setTimeout(function() {
console.log(
`[ ${moment().format("HH:mm:ss")} ] Send Corona Update to ${number}`
);
if (message.toString() === "New Update!") {
fs.readFile("./CoronaService/data.json", "utf-8", function(
err,
data
) {
if (err) throw err;