This repository has been archived by the owner on Feb 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 89
/
index.js
1160 lines (939 loc) · 30.7 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
//code by InsideHeartz
// github.com/fdciabdul
// please don't sell this fucking scripts
// jika menjualnya ya boleh boleh ajasi , tapi hasilnya bagi bagi dong kan saya gadapet apa apa kwkwkw
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 puppeteer = require("puppeteer");
const cheerio = require("cheerio");
const SESSION_FILE_PATH = "./session.json";
const request = require("request");
const urlencode = require("urlencode");
const yts = require("./lib/cmd.js");
// file is included here
let sessionCfg;
if (fs.existsSync(SESSION_FILE_PATH)) {
sessionCfg = require(SESSION_FILE_PATH);
}
client = new Client({
puppeteer: {
executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',
headless: true,
args: [
"--log-level=3", // fatal only
"--no-default-browser-check",
"--disable-infobars",
"--disable-web-security",
"--disable-site-isolation-trials",
"--no-experiments",
"--ignore-gpu-blacklist",
"--ignore-certificate-errors",
"--ignore-certificate-errors-spki-list",
"--disable-extensions",
"--disable-default-apps",
"--enable-features=NetworkService",
"--disable-setuid-sandbox",
"--no-sandbox",
"--no-first-run",
"--no-zygote"
]
},
session: sessionCfg
});
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("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
// ======================= 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', async (notification) => {
// User has joined or been added to the group.
console.log('join', notification);
const botno = notification.chatId.split('@')[0];
let number = await notification.id.remote;
client.sendMessage(number, `Hai perkenalkan aku Inside Bot, selamat datang di group ini`);
const chats = await client.getChats();
for (i in chats) {
if (number == chats[i].id._serialized) {
chat = chats[i];
}
}
var participants = {};
var admins = {};
var i;
for (let participant of chat.participants) {
if (participant.id.user == botno) { continue; }
//participants.push(participant.id.user);
const contact = await client.getContactById(participant.id._serialized);
participants[contact.pushname] = participant.id.user;
// participant needs to send a message for it to be defined
if (participant.isAdmin) {
//admins.push(participant.id.user);
admins[contact.pushname] = participant.id.user;
client.sendMessage(participant.id._serialized, 'Hai admin, ada member baru di group mu');
const media = MessageMedia.fromFilePath('./test/test.pdf');
client.sendMessage(participant.id._serialized, media);
}
}
console.log('Group Details');
console.log('Name: ', chat.name);
console.log('Participants: ', participants);
console.log('Admins: ', admins);
//notification.reply('User joined.'); // sends message to self
});
client.on('group_leave', async (notification) => {
// User has joined or been added to the group.
console.log('leave', notification);
const botno = notification.chatId.split('@')[0];
let number = await notification.id.remote;
client.sendMessage(number, `Selamat tinggal kawan`);
const chats = await client.getChats();
for (i in chats) {
if (number == chats[i].id._serialized) {
chat = chats[i];
}
}
var participants = {};
var admins = {};
var i;
for (let participant of chat.participants) {
if (participant.id.user == botno) { continue; }
//participants.push(participant.id.user);
const contact = await client.getContactById(participant.id._serialized);
participants[contact.pushname] = participant.id.user;
// participant needs to send a message for it to be defined
if (participant.isAdmin) {
//admins.push(participant.id.user);
admins[contact.pushname] = participant.id.user;
client.sendMessage(participant.id._serialized, 'Hai admin, ada member yang keluar di group mu');
const media = MessageMedia.fromFilePath('./test/test.pdf');
client.sendMessage(participant.id._serialized, media);
}
}
console.log('Group Details');
console.log('Name: ', chat.name);
console.log('Participants: ', participants);
console.log('Admins: ', admins);
//notification.reply('User joined.'); // sends message to self
});
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('MESSAGE RECEIVED', msg);
const chat = await msg.getChat();
const users = await msg.getContact()
const dariGC = msg['author']
const dariPC = msg['from']
console.log(`[ ${moment().format("HH:mm:ss")} ] => New Message : ${msg.body}
`)
const botTol = () => {
msg.reply('[!] Maaf, fitur ini hanya untuk admin(owner).')
return
}
const botTol2 = () => {
msg.reply(`[!] Maaf, fitur ini hanya untuk 'Group Chat'.`)
return
}
if (msg.body.startsWith('!subject ')) {
if (chat.isGroup) {
if (dariGC.replace('@c.us', '') == chat.owner.user) {
let title = msg.body.slice(9)
chat.setSubject(title)
} else {
botTol()
}
} else {
botTol2()
}
} else if (msg.body === '!getmember') {
const chat = await msg.getChat();
let text = "";
let mentions = [];
for(let participant of chat.participants) {
const contact = await client.getContactById(participant.id._serialized);
mentions.push(contact);
text += "Hai ";
text += `@${participant.id.user} `;
text += "\n";
}
chat.sendMessage(text, { mentions });
} else if (msg.body.startsWith('!deskripsi ')) {
if (chat.isGroup) {
if (dariGC.replace('@c.us', '') == chat.owner.user ) {
let title = msg.body.split("!deskripsi ")[1]
chat.setDescription(title)
} else {
botTol()
}
} else {
botTol2()
}
} else if (msg.body.startsWith('!promote ')) {
if (chat.isGroup) {
if (dariGC.replace('@c.us', '') == chat.owner.user) {
const contact = await msg.getContact();
const title = msg.mentionedIds[0]
chat.promoteParticipants([`${title}`])
chat.sendMessage(`[:] @${title.replace('@c.us', '')} sekarang anda adalah admin sob 🔥`)
} else {
botTol()
}
} else {
botTol2()
}
} else if (msg.body.startsWith('!demote ')) {
if (chat.isGroup) {
if (dariGC.replace('@c.us', '') == chat.owner.user) {
let title = msg.mentionedIds[0]
chat.demoteParticipants([`${title}`])
} else {
botTol()
}
} else {
botTol2()
}
} else if (msg.body.startsWith('!add ')) {
if (chat.isGroup) {
if (dariGC.replace('@c.us', '')) {
let title = msg.body.slice(5)
if (title.indexOf('62') == -1) {
chat.addParticipants([`${title.replace('0', '62')}@c.us`])
msg.reply(`[:] Selamat datang @${title}! jangan lupa baca Deskripsi group yah 😎👊🏻`)
} else {
msg.reply('[:] Format nomor harus 0821xxxxxx')
}
} else {
botTol()
}
} else {
botTol2()
}
} else if (msg.body.startsWith('!kick ')) {
if (chat.isGroup) {
if (dariGC.replace('@c.us', '') == chat.owner.user) {
let title = msg.mentionedIds
chat.removeParticipants([...title])
// console.log([...title]);
} else {
botTol()
}
} else {
botTol2()
}
} else if (msg.body == '!owner') {
if (chat.isGroup) {
msg.reply(JSON.stringify({
owner: chat.owner.user
}))
} else {
botTol2()
}
}
if (msg.type == "ciphertext") {
// Send a new message as a reply to the current one
msg.reply("Hallo kak , salam dari aku Simsimi , ada yang bisa di bantu ?");
}
// Menu List
else if (msg.body == "!menu") {
client.sendMessage(msg.from, `
*SELAMAT DATANG 😎*
Join Grup update bot ini , untuk melihat
fitur baru serta aktif / tidak nya
https://chat.whatsapp.com/CD1DOWJsJXWJvhpY8ud4S5
️*List Menu*
➡️ !admin = Menu Khusus Admin Grup🏅
➡️ !menu1 = Fun Menu 🌞
➡️ !menu2 = Downloader Menu🎞
➡️ !menu3 = Horoscope Menu 🎇
➡️ !menu4 = Edukasi Menu 📕
`);
}
// Admin Menu
else if (msg.body == "!admin") {
client.sendMessage(msg.from, `
*!subject* = Ganti nama grup.
*!kick* = Kick member grup.
*!promote* = Promote admin grup.
*!demote* = Menurunkan admin group.
*!add* = Menambah member group.
*!deskripsi* = Ganti deskripsi grup.
`);
}
// Menu 1
else if (msg.body == "!menu1") {
client.sendMessage(msg.from, `
*Welcome To Fun Menu*
*!randomanime* = untuk melihat gambar anime secara random
*!quotes* : Melihat quotes dari tokoh terkenal
*!play nama lagu*
contoh: *!play whatever it takes*
*tts teks* : mengubah teks menjadi suara
*!wait* : Menampilkan informasi anime dengan mengirim gambar dengan caption !wait
*!ptl1* : Menampilkan gambar gambar cewek cantik 🤩
*!ptl2* : Menampilkan gambar gambar cowok ganteng 😎
*!chord nama lagu* : Menampilkan Chord Gitar
*!searchimage kata kunci* : Cari gambar berdasarkat kata
contoh ( _*!sesrchimage kata bijak*_ )
`);
}
else if (msg.body == "!menu2") {
client.sendMessage(msg.from, `
*Welcome To Downloader Menu*
*!yt url* : Mendownload video dari youtube
contoh : !yt https://youtu.be/K9jR4hSCbG4
*!ytmp3 url* : Mendownload mp3 dari youtube
contoh : !ytmp3 https://youtu.be/xUVz4nRmxn4
*!fb url* : Mendownload video dari facebook
contoh : !fb url
*!ig url* : Mendownload media foto/video dari instagram
contoh : !ig url
*!pin url* : Mendownload video dari pinterest
contoh : !pin url
`);
}
else if (msg.body == "!menu3") {
client.sendMessage (msg.from, `
*!nama* : Melihat arti dari nama kamu
contoh : !nama Bondan
*!pasangan* : Check kecocokan jodoh
contoh : !pasangan Dimas & Dinda
`);
}
// Download Feature
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&]+)/);
const ytdl = require("ytdl-core")
const { exec } = require("child_process");
if(videoid != null) {
console.log("video id = ",videoid[1]);
} else {
msg.reply("Videonya gavalid gan.");
}
ytdl.getInfo(videoid[1]).then(info => {
if (info.length_seconds > 3000){
msg.reply("terlalu panjang.. ")
}else{
console.log(info.length_seconds)
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": 100, // How many parallel down>
"progressTimeout": 40 // How long should be the>
});
YD.download(videoid[1]);
YD.on("finished", function(err, data) {
var musik = 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(musik);
});
YD.on("error", function(error) {
console.log(error);
});
}});
}
// Youtube Play
else if (msg.body.startsWith("!play ")) {
var ytdl = require("ytdl-core");
var hh = msg.body.split("!play ")[1];
var keyword = hh.replace(/ /g, "+");
function foreach(arr, func){
for(var i in arr){
func(i, arr[i]);
}
}
//////////Calling Async Function//////////
const id= "";
(async () => {
var id = await yts.searchYoutube(keyword);
let result ="";
var teks = `
New Request Song
Title
${result} `;
console.log( "New Request Play Song " +id[0])
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": 100, // How many parallel down>
"progressTimeout": 2000 // How long should be the>
});
//Download video and save as MP3 file
YD.download(id[0]);
YD.on("finished", function(err, data) {
const musik = MessageMedia.fromFilePath(data.file);
var ehe = `
🎶 Now Playing 🎶
🔉 *${data.videoTitle}*
Youtube Play Songs By InsideHeartz :)
`;
let media = MessageMedia.fromFilePath('./zerotwo.jpg');
client.sendMessage(msg.from, media, {
caption: ehe });
chat.sendMessage(musik);
});
YD.on("progress", function(data) {
});
})();
}
// Facebook Downloaderelse if (msg.body.startsWith("!fb ")) {
else if (msg.body.startsWith("!fb ")) {
var teks = msg.body.split("!fb ")[1];
const { exec } = require("child_process");
var url = "http://api.fdci.se/sosmed/fb.php?url="+ teks;
request.get({
headers: {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'},
url: url,
},function(error, response, body){
let $ = cheerio.load(body);
var b = JSON.parse(body);
var teks = `
Berhasil Mendownload
Judul = ${b.judul}
Facebook Downloader By InsideHeartz (*´∇`*)
`;
exec('wget "' + b.link + '" -O mp4/fbvid.mp4', (error, stdout, stderr) => {
let media = MessageMedia.fromFilePath('mp4/fbvid.mp4');
client.sendMessage(msg.from, media, {
caption: teks });
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
});
}
// random fakta unik
// pajaar - 2020
else if (msg.body == "!fakta") {
const fetch = require("node-fetch");
fetch('https://raw.githubusercontent.com/pajaar/grabbed-results/master/pajaar-2020-fakta-unik.txt')
.then(res => res.text())
.then(body => {
let tod = body.split("\n");
let pjr = tod[Math.floor(Math.random() * tod.length)];
msg.reply(pjr);
});
}
// Download Youtube Video
else if (msg.body.startsWith("!yt ")) {
const url = msg.body.split(" ")[1];
const exec = require('child_process').exec;
var videoid = url.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
const ytdl = require("ytdl-core")
if(videoid != null) {
console.log("video id = ",videoid[1]);
} else {
msg.reply("Videonya gavalid gan.");
}
msg.reply(" Tunggu sebentar kak .. Lagi di proses ☺");
ytdl.getInfo(videoid[1]).then(info => {
if (info.length_seconds > 1000){
msg.reply("terlalu panjang.. \n sebagai gantinya \n kamu bisa klik link dibawah ini \π \n "+ info.formats[0].url)
}else{
console.log(info.length_seconds)
function os_func() {
this.execCommand = function (cmd) {
return new Promise((resolve, reject)=> {
exec(cmd, (error, stdout, stderr) => {
if (error) {
reject(error);
return;
}
resolve(stdout)
});
})
}
}
var os = new os_func();
os.execCommand('ytdl ' + url + ' -q highest -o mp4/'+ videoid[1] +'.mp4').then(res=> {
var media = MessageMedia.fromFilePath('mp4/'+ videoid[1] +'.mp4');
chat.sendMessage(media);
}).catch(err=> {
console.log("os >>>", err);
})
}
});
}
// Download Instagram
else if (msg.body.startsWith("!ig ")) {
const imageToBase64 = require('image-to-base64');
var link = msg.body.split("!ig ")[1];
var url = "http://api.fdci.se/sosmed/insta.php?url="+ link;
const { exec } = require("child_process");
request.get({
headers: {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'},
url: url,
},function(error, response, body){
let $ = cheerio.load(body);
var b = JSON.parse(body);
var teks = ` Download Berhasil
Instagram Downloader By InsideHeartz`;
if(b.link == false){
msg.reply(" maaf Kak link nya gaada :P ");
}else if( b.link.indexOf(".jpg") >= 0){
imageToBase64(b.link) // Path to the image
.then(
(response) => {
; // "cGF0aC90by9maWxlLmpwZw=="
const media = new MessageMedia('image/jpeg', response);
client.sendMessage(msg.from, media, {
caption: teks });
}
)
.catch(
(error) => {
console.log(error); // Logs an error if there was one
}
)
}else if( b.link.indexOf(".mp4") >= 0){
exec('wget "' + b.link + '" -O mp4/insta.mp4', (error, stdout, stderr) => {
let media = MessageMedia.fromFilePath('mp4/insta.mp4');
client.sendMessage(msg.from, media, {
caption: teks });
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
}
});
}
/// Fun Menu
// Glow text maker
else if (msg.body.startsWith("!glowtext ")) {
msg.reply("sebentarr.. kita proses dulu")
var h = msg.body.split("!glowtext ")[1];
const { exec } = require("child_process");
(async () => {
const browser = await puppeteer.launch({
headless: false,
});
const page = await browser.newPage();
await page
.goto("https://en.ephoto360.com/advanced-glow-effects-74.html", {
waitUntil: "networkidle2",
})
.then(async () => {
await page.type("#text-0", h);
await page.click("#submit");
await new Promise(resolve => setTimeout(resolve, 10000));
try {
await page.waitForSelector(
"#link-image"
);
const element = await page.$(
"div.thumbnail > img"
);
const text = await (await element.getProperty("src")).jsonValue();
console.log(text);
exec('wget "' + text + '" -O mp4/glow.jpg', (error, stdout, stderr) => {
const media = MessageMedia.fromFilePath('mp4/glow.jpg');
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(error);
}
})
.catch((err) => {
console.log(error);
});
})();
}
// Text to mp3
else if (msg.body.startsWith("!tts")) {
var texttomp3 = require("text-to-mp3");
var fs = require("fs");
var suara = msg.body.split("!tts ")[1];
var text = suara;
var fn = "tts/suara.mp3";
if(process.argv.indexOf("-?")!== -1){
return;
}
if(process.argv.indexOf("-t")!== -1)
text=suara;
if(process.argv.indexOf("-f")!== -1)
fn=suara;
text = text.replace(/ +(?= )/g,'');//remove all multiple space
if(typeof text === "undefined" || text === ""
|| typeof fn === "undefined" || fn === "") { // just if I have a text I'm gona parse
}
//HERE WE GO
texttomp3.getMp3(text, function(err, data){
if(err){
console.log(err);
return;
}
if(fn.substring(fn.length-4, fn.length) !== ".mp3"){ // if name is not well formatted, I add the mp3 extention
fn+=".mp3";
}
var file = fs.createWriteStream(fn); // write it down the file
file.write(data);
console.log("MP3 SAVED!");
});
await new Promise(resolve => setTimeout(resolve, 500));
if(text.length > 200){ // check longness of text, because otherways google translate will give me a empty file
msg.reply("Text to long, split in text of 200 characters")
}else{
const media = MessageMedia.fromFilePath(fn);
chat.sendMessage(media);
}
}
// Penyegar TimeLine
else if (msg.body == "!ptl2" ){
const imageToBase64 = require('image-to-base64');
var items = ["ullzang boy", "cowo ganteng", "cogan", "korean boy"];
var cewe = items[Math.floor(Math.random() * items.length)];
var url = "http://api.fdci.se/rep.php?gambar=" + cewe;
request.get({
headers: {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'},
url: url,
},function(error, response, body){
var b = JSON.parse(body);
var cewek = b[Math.floor(Math.random() * b.length)];
imageToBase64(cewek) // Path to the image
.then(
(response) => {
const media = new MessageMedia('image/jpeg', response);
client.sendMessage(msg.from, media, {
caption: `
Hai Manis 😊` });
}
)
.catch(
(error) => {
console.log(error); // Logs an error if there was one
}
)
});
}
else if (msg.body == "!ptl1" ){
const imageToBase64 = require('image-to-base64');
var items = ["ullzang girl", "cewe cantik", "hijab cantik", "korean girl"];
var cewe = items[Math.floor(Math.random() * items.length)];
var url = "http://api.fdci.se/rep.php?gambar=" + cewe;
request.get({
headers: {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'},
url: url,
},function(error, response, body){
var b = JSON.parse(body);
var cewek = b[Math.floor(Math.random() * b.length)];
imageToBase64(cewek) // Path to the image
.then(
(response) => {
const media = new MessageMedia('image/jpeg', response);
client.sendMessage(msg.from, media, {
caption: `
Hai Kak 😊` });
}
)
.catch(
(error) => {
console.log(error); // Logs an error if there was one
}
)
});
}
// Search Image
else if (msg.body.startsWith("!searchimage ")) {
var nama = msg.body.split("!searchimage ")[1];
var req = urlencode(nama.replace(/ /g,"+"));
const imageToBase64 = require('image-to-base64');
var url = "http://api.fdci.se/rep.php?gambar=" + req;
request.get({
headers: {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'},
url: url,
},function(error, response, body){
var b = JSON.parse(body);
var cewek = b[Math.floor(Math.random() * b.length)];
imageToBase64(cewek) // Path to the image
.then(
(response) => {
const media = new MessageMedia('image/jpeg', response);
client.sendMessage(msg.from, media, {
caption: `
Whoaaaa gambar di temukan 😲` });
}
)
.catch(
(error) => {
msg.reply(`Yaahhhh gambar tidak ditemukan 🤧`); // Logs an error if there was one
}
)
});
}
else if (msg.body == "!randomanime" ){
const imageToBase64 = require('image-to-base64');
var items = ["anime aesthetic", "anime cute", "anime", "kawaii anime"];
var cewe = items[Math.floor(Math.random() * items.length)];
var url = "http://api.fdci.se/rep.php?gambar=" + cewe;
request.get({
headers: {'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0'},
url: url,
},function(error, response, body){
var b = JSON.parse(body);
var cewek = b[Math.floor(Math.random() * b.length)];
imageToBase64(cewek) // Path to the image
.then(
(response) => {
const media = new MessageMedia('image/jpeg', response);
client.sendMessage(msg.from, media, {
caption: `
Whoaaaa gambar di temukan 😲` });
}
)
.catch(
(error) => {
console.log(error); // Logs an error if there was one
}
)
});
}
// Quotes Terkenal
else if (msg.body == "!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}*