forked from TobyG74/ChisatoBOT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtobz.js
4049 lines (3980 loc) · 250 KB
/
tobz.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
/*
THX BUAT YANG UDAH GUNAIN SCRIPT INI!
JANGAN LUPA JOIN GRUP WHATSAPP!
AGAR BISA MENGEMBANGKAN BOT BUKAN COPY DOANG
JANGAN LUPA CREDIT KALO COPAS!
SCRIPT INI BUKAN UNTUK DIJUAL BELIKAN!
SCRIPT INI TERBUKA UNTUK SIAPA SAJA!
JIKA KALIAN INGIN MENAMBAHKAN MENU
SILAHKAN KONTRIBUSI/PULL REQUEST
BAGI YANG NANYA2 MASANG APIKEY DIMANA??
BACA README NYA, PERCUMA W BUAT README
INGAT JANGAN JUAL SCRIPT ELAINA KEPADA ORANG LAIN!
INGIN PREMIUM? CHAT TOBZ!
ELAINA BOT V3
*/
require('dotenv').config()
const { decryptMedia } = require('@open-wa/wa-decrypt')
const fs = require('fs-extra')
const ffmpeg = require('fluent-ffmpeg')
const axios = require('axios')
const moment = require('moment-timezone')
const getYouTubeID = require('get-youtube-id')
const os = require('os')
const get = require('got')
const speed = require('performance-now')
const fetch = require('node-fetch')
const { spawn, exec } = require('child_process')
const nhentai = require('nhentai-js')
const { API } = require('nhentai-api')
const google = require('google-it')
const translatte = require('translatte')
const { stdout } = require('process')
const translate = require('translatte')
const Math_js = require('mathjs');
const imageToBase64 = require('image-to-base64')
const bent = require('bent')
const request = require('request')
//const { getStickerMaker } = require('./lib/ttp')
const quotedd = require('./lib/quote')
const color = require('./lib/color')
const urlShortener = require('./lib/shortener')
const { addFilter, isFiltered } = require('./lib/msgFilter')
const cariKasar = require('./lib/kataKotor')
const {
downloader,
liriklagu,
quotemaker,
randomNimek,
sleep,
jadwalTv,
processTime,
nulis
} = require('./lib/functions')
const {
help,
admincmd,
ownercmd,
nsfwcmd,
kerangcmd,
mediacmd,
animecmd,
othercmd,
downloadcmd,
praycmd,
groupcmd,
funcmd,
bahasalist,
sewa,
snk,
info,
sumbang,
readme,
listChannel,
commandArray
} = require('./lib/help')
const {
instagram,
tiktok,
facebook,
smule,
starmaker,
twitter,
joox
} = require('./lib/downloader')
const {
stickerburn,
stickerlight
} = require('./lib/sticker')
const {
uploadImages,
custom
} = require('./lib/fetcher')
// LOAD FILE
let banned = JSON.parse(fs.readFileSync('./lib/database/banned.json'))
let nsfw_ = JSON.parse(fs.readFileSync('./lib/database/nsfwz.json'))
let simi_ = JSON.parse(fs.readFileSync('./lib/database/Simsimi.json'))
let limit = JSON.parse(fs.readFileSync('./lib/database/limit.json'))
let welkom = JSON.parse(fs.readFileSync('./lib/database/welcome.json'))
let left = JSON.parse(fs.readFileSync('./lib/database/left.json'))
let muted = JSON.parse(fs.readFileSync('./lib/database/muted.json'))
let setting = JSON.parse(fs.readFileSync('./lib/database/setting.json'))
let msgLimit = JSON.parse(fs.readFileSync('./lib/database/msgLimit.json'))
let adminNumber = JSON.parse(fs.readFileSync('./lib/database/admin.json'))
// PROTECT
let antilink = JSON.parse(fs.readFileSync('./lib/database/antilink.json'))
let antibadword = JSON.parse(fs.readFileSync('./lib/database/antibadword.json'))
let antisticker = JSON.parse(fs.readFileSync('./lib/database/antisticker.json'))
let msgBadword = JSON.parse(fs.readFileSync('./lib/database/msgBadword.json'))
let dbbadword = JSON.parse(fs.readFileSync('./lib/database/katakasar.json'))
let badword = JSON.parse(fs.readFileSync('./lib/database/badword.json'))
let pendaftar = JSON.parse(fs.readFileSync('./lib/database/user.json'))
let stickerspam = JSON.parse(fs.readFileSync('./lib/database/stickerspam.json'))
let {
limitCount,
memberLimit,
groupLimit,
banChats,
barbarkey,
vhtearkey,
prefix,
restartState: isRestart,
mtc: mtcState
} = setting
let state = {
status: () => {
if(banChats){
return 'Nonaktif'
}else if(mtcState){
return 'Nonaktif'
}else if(!mtcState){
return 'Aktif'
}else{
return 'Aktif'
}
}
}
moment.tz.setDefault('Asia/Jakarta').locale('id')
module.exports = tobz = async (tobz, message) => {
try {
const { type, id, from, t, sender, isGroupMsg, chat, chatId, caption, isMedia, mimetype, quotedMsg, quotedMsgObj, author, mentionedJidList } = message
let { body } = message
const { name, formattedTitle } = chat
let { pushname, verifiedName } = sender
pushname = pushname || verifiedName
const commands = caption || body || ''
const chats = (type === 'chat') ? body : (type === 'image' || type === 'video') ? caption : ''
const argx = commands.toLowerCase()
const args = commands.split(' ')
const command = commands.toLowerCase().split(' ')[0] || ''
const time = moment(t * 1000).format('DD/MM HH:mm:ss')
const botNumber = await tobz.getHostNumber()
const blockNumber = await tobz.getBlockedIds()
const groupId = isGroupMsg ? chat.groupMetadata.id : ''
const groupAdmins = isGroupMsg ? await tobz.getGroupAdmins(groupId) : ''
const isGroupAdmins = isGroupMsg ? groupAdmins.includes(sender.id) : false
const isBotGroupAdmins = isGroupMsg ? groupAdmins.includes(botNumber + '@c.us') : false
const SN = GenerateSerialNumber("000000000000000000000000")
const isBanned = banned.includes(sender.id)
const isBlocked = blockNumber.includes(sender.id)
const isNsfw = isGroupMsg ? nsfw_.includes(chat.id) : false
const isSimi = isGroupMsg ? simi_.includes(chat.id) : false
const uaOverride = 'WhatsApp/2.2029.4 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36'
const isUrl = new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/gi)
const url = args.length !== 0 ? args[0] : ''
const isQuotedImage = quotedMsg && quotedMsg.type === 'image'
const isQuotedVideo = quotedMsg && quotedMsg.type === 'video'
const isQuotedAudio = quotedMsg && (quotedMsg.type === 'audio' || quotedMsg.type === 'ptt' || quotedMsg.type === 'ppt')
const isQuotedFile = quotedMsg && quotedMsg.type === 'document'
const isBadword = badword.includes(chatId)
body = (type === 'chat' && body.startsWith(prefix)) ? body : (((type === 'image' || type === 'video') && caption) && caption.startsWith(prefix)) ? caption : ''
const arg = body.substring(body.indexOf(' ') + 1)
const isKasar = await cariKasar(chats)
const GroupLinkDetector = antilink.includes(chatId)
const AntiStickerSpam = antisticker.includes(chatId)
const isPrivate = sender.id === chat.contact.id
const stickermsg = message.type === 'sticker'
const isCmd = command.startsWith(prefix)
const serial = sender.id
const isAdmin = adminNumber.includes(sender.id)
const ownerNumber = '[email protected]'
const isOwner = ownerNumber.includes(sender.id)
if (isGroupMsg && GroupLinkDetector && !isGroupAdmins && !isAdmin && !isOwner){
if (chats.match(/(https:\/\/chat.whatsapp.com)/gi)) {
const check = await tobz.inviteInfo(chats);
if (!check) {
return
} else {
tobz.reply(from, `*「 GROUP LINK DETECTOR 」*\nKamu mengirimkan link grup chat, maaf kamu di kick dari grup :(`, id).then(() => {
tobz.removeParticipant(groupId, sender.id)
})
}
}
}
if (isGroupMsg && AntiStickerSpam && !isGroupAdmins && !isAdmin && !isOwner){
if(stickermsg === true){
if(isStickerMsg(serial)) return
addStickerCount(serial)
}
}
if(!isCmd && isKasar && isGroupMsg && isBadword && !isGroupAdmins) {
console.log(color('[BADWORD]', 'red'), color(moment(t * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`${argx}`), 'from', color(pushname), 'in', color(name || formattedTitle))
if(isBadwordMsg(serial)) return
addBadCount(serial)
}
// [BETA] Avoid Spam Message
//if (isCmd && isFiltered(from) && !isGroupMsg) { return console.log(color('[SPAM]', 'red'), color(moment(t * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname)) }
//if (isCmd && isFiltered(from) && isGroupMsg) { return console.log(color('[SPAM]', 'red'), color(moment(t * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname), 'in', color(name || formattedTitle)) }
// AKTIFKAN APABILA TIDAK INGIN TERKENA SPAM!!
//addFilter(from)
if (isCmd && !isGroupMsg) {console.log(color('[EXEC]'), color(moment(t * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname))}
if (isCmd && isGroupMsg) {console.log(color('[EXEC]'), color(moment(t * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname), 'in', color(name || formattedTitle))}
// FUNCTION
// Serial Number Generator
function GenerateRandomNumber(min,max){
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Generates a random alphanumberic character
function GenerateRandomChar() {
var chars = "1234567890ABCDEFGIJKLMNOPQRSTUVWXYZ";
var randomNumber = GenerateRandomNumber(0,chars.length - 1);
return chars[randomNumber];
}
// Generates a Serial Number, based on a certain mask
function GenerateSerialNumber(mask){
var serialNumber = "";
if(mask != null){
for(var i=0; i < mask.length; i++){
var maskChar = mask[i];
serialNumber += maskChar == "0" ? GenerateRandomChar() : maskChar;
}
}
return serialNumber;
}
var nmr = sender.id
var obj = pendaftar.some((val) => {
return val.id === nmr
})
var cekage = pendaftar.some((val) => {
return val.id === nmr && val.umur >= 15
})
function monospace(string) {
return '```' + string + '```'
}
function isReg(obj){
if (obj === true){
return false
} else {
return tobz.reply(from, `Kamu belum terdaftar sebagai Teman Elaina\nuntuk mendaftar kirim ${prefix}daftar |nama|umur\n\ncontoh format: ${prefix}daftar |tobz|17\n\ncukup gunakan nama depan/panggilan saja`, id) //if user is not registered
}
}
function cekumur(obj){
if (obj === true){
return false
} else {
return tobz.reply(from, `Kamu belum cukup umur untuk menggunakan Elaina, min 16 tahun\n\nKamu bisa mendaftar ulang dengan cara donasi terlebih dahulu, bales ${prefix}donasi\nHubungi Owner : wa.me/6281311850715`, id) //if user is not registered
}
}
const apakah = [
'Ya',
'Tidak',
'Coba Ulangi'
]
const bisakah = [
'Bisa',
'Tidak Bisa',
'Coba Ulangi'
]
const kapankah = [
'1 Minggu lagi',
'1 Bulan lagi',
'1 Tahun lagi'
]
const rate = [
'100%',
'95%',
'90%',
'85%',
'80%',
'75%',
'70%',
'65%',
'60%',
'55%',
'50%',
'45%',
'40%',
'35%',
'30%',
'25%',
'20%',
'15%',
'10%',
'5%'
]
const mess = {
wait: '[ WAIT ] Sedang di proses⏳ silahkan tunggu sebentar',
magernulissatu: 'Harap Tunggu, BOT Sedang Menulis Di Buku 1!',
error: {
St: '[❗] Kirim gambar dengan caption *#sticker* atau tag gambar yang sudah dikirim',
Ti: '[❗] Replay sticker dengan caption *#stickertoimg* atau tag sticker yang sudah dikirim',
Qm: '[❗] Terjadi kesalahan, mungkin themenya tidak tersedia!',
Yt3: '[❗] Terjadi kesalahan, tidak dapat meng konversi ke mp3!',
Yt4: '[❗] Terjadi kesalahan, mungkin error di sebabkan oleh sistem.',
Ig: '[❗] Terjadi kesalahan, mungkin karena akunnya private',
Ki: '[❗] Bot tidak bisa mengeluarkan Admin group!',
Sp: '[❗] Bot tidak bisa mengeluarkan Admin',
Ow: '[❗] Bot tidak bisa mengeluarkan Owner',
Bk: '[❗] Bot tidak bisa memblockir Owner',
Ad: '[❗] Tidak dapat menambahkan target, mungkin karena di private',
Iv: '[❗] Link yang anda kirim tidak valid!'
}
}
const tutor = 'https://i.ibb.co/Hp1XGbL/a4dec92b8922.jpg'
const errorurl = 'https://steamuserimages-a.akamaihd.net/ugc/954087817129084207/5B7E46EE484181A676C02DFCAD48ECB1C74BC423/?imw=512&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false'
const errorurl2 = 'https://steamuserimages-a.akamaihd.net/ugc/954087817129084207/5B7E46EE484181A676C02DFCAD48ECB1C74BC423/?imw=512&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false'
const isMuted = (chatId) => {
if(muted.includes(chatId)){
return false
}else{
return true
}
}
function banChat () {
if(banChats == true) {
return false
}else{
return true
}
}
// FUNCTION
function isStickerMsg(id){
if (isAdmin) {return false;}
let found = false;
for (let i of stickerspam){
if(i.id === id){
if (i.msg >= 12) {
found === true
tobz.reply(from, `*「 𝗔𝗡𝗧𝗜 𝗦𝗣𝗔𝗠 𝗦𝗧𝗜𝗖𝗞𝗘𝗥 」*\nKamu telah SPAM STICKER di grup, kamu akan di kick otomatis oleh Elaina`, id).then(() => {
tobz.removeParticipant(groupId, id)
})
return true;
}else if(i.msg >= 12){
found === true
tobz.reply(from, `*「 𝗔𝗡𝗧𝗜 𝗦𝗣𝗔𝗠 𝗦𝗧𝗜𝗖𝗞𝗘𝗥 」*\nKamu terdeteksi spam sticker!\nMohon tidak spam 5 sticker lagi atau nomor akan di kick oleh Elaina!`, id)
return true
}else{
found === true
return false;
}
}
}
if (found === false){
let obj = {id: `${id}`, msg:1};
stickerspam.push(obj);
fs.writeFileSync('./lib/database/stickerspam.json',JSON.stringify(stickerspam));
return false;
}
}
function addStickerCount(id){
if (isAdmin) {return;}
var found = false
Object.keys(stickerspam).forEach((i) => {
if(stickerspam[i].id == id){
found = i
}
})
if (found !== false) {
stickerspam[found].msg += 1;
fs.writeFileSync('./lib/database/stickerspam.json',JSON.stringify(stickerspam));
}
}
function isBadwordMsg(id){
if (isAdmin) {return false;}
let kasar = false;
for (let i of msgBadword){
if(i.id === id){
let msg = i.msg
if (msg >= 3) { // 3X BADWORD AKAN TERKENA KICK
kasar === true
tobz.reply(from, `*「 𝗔𝗡𝗧𝗜 𝗕𝗔𝗗𝗪𝗢𝗥𝗗 」*\nKamu telah berkata kasar di grup ini, kamu akan di kick otomatis oleh Elaina!`, id).then(() => {
tobz.removeParticipant(groupId, id)
})
return true;
}else{
kasar === true
return false;
}
}
}
if (kasar === false){
let obj = {id: `${id}`, msg:1};
msgBadword.push(obj);
fs.writeFileSync('./lib/database/msgBadword.json',JSON.stringify(msgBadword));
return false;
}
}
function addBadCount(id){
if (isAdmin) {return;}
var kasar = false
Object.keys(msgBadword).forEach((i) => {
if(msgBadword[i].id == id){
kasar = i
}
})
if (kasar !== false) {
msgBadword[kasar].msg += 1;
fs.writeFileSync('./lib/database/msgBadword.json',JSON.stringify(msgBadword));
}
}
function isMsgLimit(id){
if (isAdmin) {return false;}
let found = false;
for (let i of msgLimit){
if(i.id === id){
if (i.msg >= 8) {
found === true
tobz.reply(from, `*「 𝗔𝗡𝗧𝗜 𝗦𝗣𝗔𝗠 」*\nMaaf, akun anda kami blok karena SPAM, dan tidak bisa di UNBLOK!`, id)
tobz.contactBlock(id)
banned.push(id)
fs.writeFileSync('./lib/database/banned.json', JSON.stringify(banned))
return true;
}else if(i.msg >= 8){
found === true
tobz.reply(from, `*「 𝗔𝗡𝗧𝗜 𝗦𝗣𝗔𝗠 」*\nNomor anda terdeteksi spam!\nMohon tidak spam 5 pesan lagi atau nomor anda AUTO BLOK!`, id)
return true
}else{
found === true
return false;
}
}
}
if (found === false){
let obj = {id: `${id}`, msg:1};
msgLimit.push(obj);
fs.writeFileSync('./lib/database/msgLimit.json',JSON.stringify(msgLimit));
return false;
}
}
function addMsgLimit(id){
if (isAdmin) {return;}
var found = false
Object.keys(msgLimit).forEach((i) => {
if(msgLimit[i].id == id){
found = i
}
})
if (found !== false) {
msgLimit[found].msg += 1;
fs.writeFileSync('./lib/database/msgLimit.json',JSON.stringify(msgLimit));
}
}
function isLimit(id){
if (isAdmin) {return false;}
let found = false;
for (let i of limit){
if(i.id === id){
let limits = i.limit;
if (limits >= limitCount) {
found = true;
tobz.reply(from, `Perintah BOT anda sudah mencapai batas, coba esok hari :)`, id)
return true;
}else{
limit
found = true;
return false;
}
}
}
if (found === false){
let obj = {id: `${id}`, limit:1};
limit.push(obj);
fs.writeFileSync('./lib/database/limit.json',JSON.stringify(limit));
return false;
}
}
function limitAdd (id) {
if (isAdmin) {return;}
var found = false;
Object.keys(limit).forEach((i) => {
if(limit[i].id == id){
found = i
}
})
if (found !== false) {
limit[found].limit += 1;
fs.writeFileSync('./lib/database/limit.json',JSON.stringify(limit));
}
}
// END HELPER FUNCTION
// FUNCTION DAFTAR! NEXT UPDATE
function monospace(string) {
return '```' + string + '```'
}
// Serial Number Generator
function GenerateRandomNumber(min,max){
return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Generates a random alphanumberic character
function GenerateRandomChar() {
var chars = "1234567890ABCDEFGIJKLMNOPQRSTUVWXYZ";
var randomNumber = GenerateRandomNumber(0,chars.length - 1);
return chars[randomNumber];
}
// Generates a Serial Number, based on a certain mask
function GenerateSerialNumber(mask){
var serialNumber = "";
if(mask != null){
for(var i=0; i < mask.length; i++){
var maskChar = mask[i];
serialNumber += maskChar == "0" ? GenerateRandomChar() : maskChar;
}
}
return serialNumber;
}
if(body === '#mute' && isMuted(chatId) == true){
if(isGroupMsg) {
if (!isAdmin) return tobz.reply(from, 'Maaf, perintah ini hanya dapat dilakukan oleh admin Elaina!', id)
if(isMsgLimit(serial)){
return
}else{
addMsgLimit(serial)
}
muted.push(chatId)
fs.writeFileSync('./lib/database/muted.json', JSON.stringify(muted, null, 2))
tobz.reply(from, 'Bot telah di mute pada chat ini! #unmute untuk unmute!', id)
}else{
if(isMsgLimit(serial)){
return
}else{
addMsgLimit(serial)
}
muted.push(chatId)
fs.writeFileSync('./lib/database/muted.json', JSON.stringify(muted, null, 2))
reply(from, 'Bot telah di mute pada chat ini! #unmute untuk unmute!', id)
}
}
if(body === '#unmute' && isMuted(chatId) == false){
if(isGroupMsg) {
if (!isAdmin) return tobz.reply(from, 'Maaf, perintah ini hanya dapat dilakukan oleh admin Elaina!', id)
if(isMsgLimit(serial)){
return
}else{
addMsgLimit(serial)
}
let index = muted.indexOf(chatId);
muted.splice(index,1)
fs.writeFileSync('./lib/database/muted.json', JSON.stringify(muted, null, 2))
tobz.reply(from, 'Bot telah di unmute!', id)
}else{
if(isMsgLimit(serial)){
return
}else{
addMsgLimit(serial)
}
let index = muted.indexOf(chatId);
muted.splice(index,1)
fs.writeFileSync('./lib/database/muted.json', JSON.stringify(muted, null, 2))
tobz.reply(from, 'Bot telah di unmute!', id)
}
}
if (body === '#unbanchat') {
if (!isOwner) return tobz.reply(from, 'Maaf, perintah ini hanya dapat dilakukan oleh Owner Elaina!', id)
if(setting.banChats === false) return
setting.banChats = false
banChats = false
fs.writeFileSync('./lib/database/setting.json', JSON.stringify(setting, null, 2))
tobz.reply('Global chat has been disable!')
}
if (isMuted(chatId) && banChat() && !isBlocked && !isBanned || isOwner ) {
switch(command) {
case prefix+'banchat':
if (setting.banChats === true) return
if (!isOwner) return tobz.reply(from, 'Perintah ini hanya bisa di gunakan oleh Owner Elaina!', id)
setting.banChats = true
banChats = true
fs.writeFileSync('./lib/database/setting.json', JSON.stringify(setting, null, 2))
tobz.reply('Global chat has been enable!')
break
case prefix+'unmute':
console.log(`Unmuted ${name}!`)
await tobz.sendSeen(from)
break
case prefix+'unbanchat':
console.log(`Banchat ${name}!`)
await tobz.sendSeen(from)
break
case prefix+'sticker':
case prefix+'stiker':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isMedia && type === 'image') {
const mediaData = await decryptMedia(message, uaOverride)
const imageBase64 = `data:${mimetype};base64,${mediaData.toString('base64')}`
await tobz.sendImageAsSticker(from, imageBase64)
} else if (quotedMsg && quotedMsg.type == 'image') {
const mediaData = await decryptMedia(quotedMsg, uaOverride)
const imageBase64 = `data:${quotedMsg.mimetype};base64,${mediaData.toString('base64')}`
await tobz.sendImageAsSticker(from, imageBase64)
} else if (args.length === 2) {
const url = args[1]
if (url.match(isUrl)) {
await tobz.sendStickerfromUrl(from, url, { method: 'get' })
.catch(err => console.log('Caught exception: ', err))
} else {
tobz.reply(from, mess.error.Iv, id)
}
} else {
tobz.reply(from, mess.error.St, id)
}
break
case prefix+'ttp':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (!isGroupMsg) return tobz.reply(from, 'Perintah ini hanya bisa di gunakan dalam group!', message.id)
try
{
const string = body.toLowerCase().includes('#ttp') ? body.slice(5) : body.slice(5)
if(args)
{
if(quotedMsgObj == null)
{
const gasMake = await getStickerMaker(string)
if(gasMake.status == true)
{
try{
await tobz.sendImageAsSticker(from, gasMake.base64)
}catch(err) {
await tobz.reply(from, 'Gagal membuat.', id)
}
}else{
await tobz.reply(from, gasMake.reason, id)
}
}else if(quotedMsgObj != null){
const gasMake = await getStickerMaker(quotedMsgObj.body)
if(gasMake.status == true)
{
try{
await tobz.sendImageAsSticker(from, gasMake.base64)
}catch(err) {
await tobz.reply(from, 'Gagal membuat.', id)
}
}else{
await tobz.reply(from, gasMake.reason, id)
}
}
}else{
await tobz.reply(from, 'Tidak boleh kosong.', id)
}
}catch(error)
{
console.log(error)
}
break;
case prefix+'ttp2':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *#ttp2 [ Teks ]*, contoh *#ttp2 Elaina*`, id)
const ttp2t = body.slice(6)
const lttp2 = ["Orange","White","Green","Black","Purple","Red","Yellow","Blue","Navy","Grey","Magenta","Brown","Gold"]
const rttp2 = lttp2[Math.floor(Math.random() * (lttp2.length))]
await tobz.sendStickerfromUrl(from, `https://api.vhtear.com/textmaker?text=${ttp2t}&warna=${rttp2}&apikey=${vhtearkey}`)
break
case prefix+'ttg':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (!isGroupMsg) return tobz.reply(from, `Perintah ini hanya bisa di gunakan dalam group!`, id)
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
try {
if (quotedMsgObj == null) {
if (args.length === 1) return tobz.reply(from, `Kirim perintah *#ttg [ Teks ]*, contoh *#ttg aku bukan boneka*`, id)
await tobz.sendStickerfromUrl(from, `https://api.vhtear.com/textxgif?text=${body.slice(5)}&apikey=${vhtearkey}`)
limitAdd(serial)
} else {
await tobz.sendStickerfromUrl(from, `https://api.vhtear.com/textxgif?text=${quotedMsgObj}&apikey=${vhtearkey}`)
limitAdd(serial)
}
} catch(e) {
console.log(e)
tobz.reply(from, 'Maaf, Server sedang Error')
}
break
case prefix+'magernulis1': // BY MFARELS
if(isReg(obj)) return
if(cekumur(cekage)) return
if (args.length === 1) return await tobz.reply(from, 'Kirim perintah *prefix+magernulis1 [teks]*', id) // BY MFARELS
const farel = body.slice(13) // YOUTUBE : MFARELS CH
await tobz.reply(from, mess.magernulissatu, id) // INSTAGRAM : @mfarelsyahtiawan
const zahra = farel.replace(/(\S+\s*){1,10}/g, '$&\n') // INSTALL IMAGEMAGICK KALO WAU WORK
const farelzahra = zahra.split('\n').slice(0, 33).join('\n') // WAKTU INSTALL IMAGEMAGICK CENTANG KOLOM 1,2,3,5,6
var months = ['- 1 -', '- 2 -', '- 3 -', '- 4 -', '- 5 -', '- 6 -', '- 7 -', '- 8 -', '- 9 -', '- 10 -', '- 11 -', '- 12 -'];
var myDays = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
var date = new Date();
var day = date.getDate();
var month = date.getMonth();
var thisDay = date.getDay(),
thisDay = myDays[thisDay];
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
const zahrafarel = (day + ' ' + months[month] + ' ' + year)
const farelllzahraaa = (thisDay)
spawn('convert', [
'./mager/magernulis/magernulis1.jpg',
'-font',
'./font/Zahraaa.ttf',
'-size',
'700x960',
'-pointsize',
'100',
'-interline-spacing',
'1',
'-annotate',
'+4100+460',
farelllzahraaa,
'-font',
'./font/Zahraaa.ttf',
'-size',
'700x960',
'-pointsize',
'100',
'-interline-spacing',
'1',
'-annotate',
'+4100+640',
zahrafarel,
'-font',
'./font/Zahraaa.ttf',
'-size',
'6000x8000',
'-pointsize',
'130',
'-interline-spacing',
'1',
'-annotate',
'+1010+1010',
farelzahra,
'./mager/magernulis√/magernulis1√.jpg'
])
.on('error', () => tobz.reply(from, 'Error Bjeer', id))
.on('exit', () => {
tobz.sendImage(from, './mager/magernulis√/magernulis1√.jpg', 'magernulis.jpg', '*Sukses Nulis DiBuku✓*\n\n*YouTube : MFarelS CH*\n*Instagram : @mfarelsyahtiawan*\n\n*© Powered By MFarelS | RajinNulis-BOT*', id)
})
break // BY MFARELS
case prefix+'stickertoimg':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (quotedMsg && quotedMsg.type == 'sticker') {
const mediaData = await decryptMedia(quotedMsg)
tobz.reply(from, `[WAIT] Sedang di proses⏳ silahkan tunggu!`, id)
const imageBase64 = `data:${quotedMsg.mimetype};base64,${mediaData.toString('base64')}`
await tobz.sendFile(from, imageBase64, 'imagesticker.jpg', 'Success Convert Sticker to Image!', id)
} else if (!quotedMsg) return tobz.reply(from, `Mohon tag sticker yang ingin dijadikan gambar!`, id)
break
case prefix+'stickergif': // INSTALL FFMPEG, IF YOU WANT THIS COMMAND WORK!
case prefix+'stikergif': // TUTORIAL IN README, PLEASE READ!
case prefix+'sgif': // MRHRTZ
tobz.reply(from, `[WAIT] Sedang di proses⏳ silahkan tunggu ± 1 min!`, id)
if (isMedia && type === 'video' || mimetype === 'image/gif') {
try {
const mediaData = await decryptMedia(message, uaOverride)
await tobz.sendMp4AsSticker(from, mediaData, {fps: 10, startTime: `00:00:00.0`, endTime : `00:00:05.0`,loop: 0})
} catch (e) {
tobz.reply(from, `Size media terlalu besar! mohon kurangi durasi video.`)
}
} else if (quotedMsg && quotedMsg.type == 'video' || quotedMsg && quotedMsg.mimetype == 'image/gif') {
const mediaData = await decryptMedia(quotedMsg, uaOverride)
await tobz.sendMp4AsSticker(from, mediaData, {fps: 10, startTime: `00:00:00.0`, endTime : `00:00:05.0`,loop: 0})
} else {
tobz.reply(from, `Kesalahan ⚠️ Hanya bisa video/gif apabila file media berbentuk gambar ketik #stickergif`, id)
}
break
case prefix+'stickerlightning':
case prefix+'slightning':
if(isReg(obj)) return
if(cekumur(cekage)) return
tobz.reply(from, `[WAIT] Sedang di proses⏳ silahkan tunggu ± 1 min!`, id)
if (isMedia && type === 'image') {
const mediaData = await decryptMedia(message, uaOverride)
const getUrle = await uploadImages(mediaData, false)
const imgnye = await stickerlight(getUrle)
const Slight = imgnye.result.imgUrl
await tobz.sendStickerfromUrl(from, Slight)
} else if (quotedMsg && quotedMsg.type == 'image') {
const mediaData = await decryptMedia(quotedMsg, uaOverride)
const getUrle = await uploadImages(mediaData, false)
const imgnye = await stickerlight(getUrle)
const Slight = imgnye.result.imgUrl
await tobz.sendStickerfromUrl(from, Slight)
} else {
await tobz.reply(from, `Wrong Format!\n⚠️ Harap Kirim Gambar Dengan #stickerlightning`, id)
}
break
case prefix+'stickerfire':
case prefix+'sfire':
if(isReg(obj)) return
if(cekumur(cekage)) return
tobz.reply(from, `[WAIT] Sedang di proses⏳ silahkan tunggu ± 1 min!`, id)
if (isMedia && type === 'image') {
const mediaData = await decryptMedia(message, uaOverride)
const getUrli = await uploadImages(mediaData, false)
const imgnya = await stickerburn(getUrli)
const Sfire = imgnya.result.imgUrl
await tobz.sendStickerfromUrl(from, Sfire)
} else if (quotedMsg && quotedMsg.type == 'image') {
const mediaData = await decryptMedia(quotedMsg, uaOverride)
const getUrli = await uploadImages(mediaData, false)
const imgnya = await stickerburn(getUrli)
const Sfire = imgnya.result.imgUrl
await tobz.sendStickerfromUrl(from, Sfire)
} else {
await tobz.reply(from, `Wrong Format!\n⚠️ Harap Kirim Gambar Dengan #stickerfire`, id)
}
break
case prefix+'lovemessage':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *${prefix}lovemessage [ Teks ]*, contoh *${prefix}lovemessage Tobz*`, id)
tobz.reply(from, mess.wait, id)
const lovemsg = body.slice(12)
if (lovemsg.length > 10) return tobz.reply(from, '*Teks Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
await tobz.sendFileFromUrl(from, `https://api.vhtear.com/lovemessagetext?text=${lovemsg}&apikey=${vhtearkey}`, 'lovemsg.jpg', '', id)
break
case prefix+'romance':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *${prefix}romance [ Teks ]*, contoh *${prefix}romance Tobz*`, id)
tobz.reply(from, mess.wait, id)
const rmnc = body.slice(9)
if (rmnc.length > 10) return tobz.reply(from, '*Teks Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
await tobz.sendFileFromUrl(from, `https://api.vhtear.com/romancetext?text=${rmnc}&apikey=${vhtearkey}`, 'romance.jpg', '', id)
break
case prefix+'party':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *${prefix}party [ Teks ]*, contoh *${prefix}party Tobz*`, id)
tobz.reply(from, mess.wait, id)
const prty = body.slice(7)
if (prty.length > 10) return tobz.reply(from, '*Teks Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
await tobz.sendFileFromUrl(from, `https://api.vhtear.com/partytext?text=${prty}&apikey=${vhtearkey}`, 'party.jpg', '', id)
break
case prefix+'silk':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *${prefix}silk [ Teks ]*, contoh *${prefix}silk Tobz*`, id)
tobz.reply(from, mess.wait, id)
const slkz = body.slice(5)
if (slkz.length > 10) return tobz.reply(from, '*Teks Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
await tobz.sendFileFromUrl(from, `https://api.vhtear.com/silktext?text=${slkz}&apikey=${vhtearkey}`, 'silk.jpg', '', id)
break
case prefix+'blackpink':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *#blackpink [ Teks ]*, contoh *#blackpink Elaina*`, id)
tobz.reply(from, mess.wait, id)
const blpk = body.slice(11)
if (blpk.length > 10) return tobz.reply(from, '*Teks Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
await tobz.sendFileFromUrl(from, `https://api.vhtear.com/blackpinkicon?text=${blpk}&apikey=${vhtearkey}`, 'blackpink.jpg', '', id)
break
case prefix+'thunder':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *#thunder [ Teks ]*, contoh *#thunder Tobz*`, id)
tobz.reply(from, mess.wait, id)
const thndr = body.slice(9)
if (thndr.length > 10) return tobz.reply(from, '*Teks Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
await tobz.sendFileFromUrl(from, `https://api.vhtear.com/thundertext?text=${thndr}&apikey=${vhtearkey}`, 'thndr.jpg', '', id)
break
case prefix+'pornhub':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *#pornhub [ |Teks1|Teks2 ]*, contoh *#pornhub |Tobz|Dev Elaina*`, id)
argz = body.trim().split('|')
if (argz.length >= 2) {
tobz.reply(from, mess.wait, id)
const lpornhub = argz[1]
const lpornhub2 = argz[2]
if (lpornhub.length > 10) return tobz.reply(from, '*Teks1 Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
if (lpornhub2.length > 10) return tobz.reply(from, '*Teks2 Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
tobz.sendFileFromUrl(from, `https://api.vhtear.com/pornlogo?text1=${lpornhub}&text2=${lpornhub2}&apikey=${vhtearkey}`)
await limitAdd(serial)
} else {
await tobz.reply(from, `Wrong Format!\n[❗] Kirim perintah *#pornhub [ |Teks1|Teks2 ]*, contoh *#pornhub |Tobz|Dev Elaina*`, id)
}
break
case prefix+'glitch':
if(isReg(obj)) return
if(cekumur(cekage)) return
if (isLimit(serial)) return tobz.reply(from, `Maaf ${pushname}, Kuota Limit Kamu Sudah Habis, Ketik ${prefix}limit Untuk Mengecek Kuota Limit Kamu`, id)
if (args.length === 1) return tobz.reply(from, `Kirim perintah *#glitch [ |Teks1|Teks2 ]*, contoh *#glitch |Tobz|Dev Elaina*`, id)
argz = body.trim().split('|')
if (argz.length >= 2) {
tobz.reply(from, mess.wait, id)
const glitch1 = argz[1]
const glitch2 = argz[2]
if (glitch1.length > 10) return tobz.reply(from, '*Teks1 Terlalu Panjang!*\n_Maksimal 10 huruf!_', id)
if (glitch2.length > 15) return tobz.reply(from, '*Teks2 Terlalu Panjang!*\n_Maksimal 15 huruf!_', id)
tobz.sendFileFromUrl(from, `https://api.vhtear.com/glitchtext?text1=${glitch1}&text2=${glitch2}&apikey=${vhtearkey}`)
await limitAdd(serial)
} else {
await tobz.reply(from, `Wrong Format!\n[❗] Kirim perintah *#glitch [ |Teks1|Teks2 ]*, contoh *#glitch |Tobz|Dev Elaina*`, id)
}
break
case prefix+'daftar': // NAMBAHIN NOMOR DI DATABASE
argz = body.trim().split('|')
if (argz.length >= 2) {
const nonye = sender.id
const namanye = argz[1]
const umurnye = argz[2]
if(isNaN(umurnye)) return await tobz.reply(from, 'Umur harus berupa angka!!', id)
if(umurnye >= 40) return await tobz.reply(from, 'Kamu terlalu tua, kembali lagi ke masa muda untuk menggunakan Elaina', id)
const jenenge = namanye.replace(' ','')
var ceknya = nonye
var obj = pendaftar.some((val) => {
return val.id === ceknya
})
if (obj === true){
return tobz.reply(from, 'kamu sudah terdaftar', id) // BAKAL RESPON JIKA NO UDAH ADA
} else {
const mentah = await tobz.checkNumberStatus(nonye) // PENDAFTARAN
const msg = monospace(`Pendaftaran berhasil dengan SN: ${SN} pada ${moment().format('DD/MM/YY HH:mm:ss')}
₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋
[Nama]: ${jenenge} [@${nonye.replace(/[@c.us]/g, '')}]
[Nomor]: wa.me/${nonye.replace('@c.us', '')}
[Umur]: ${umurnye}
⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻
Untuk menggunakan bot silahkan kirim ${prefix}menu
Total Pengguna yang telah terdaftar ${pendaftar.length}`)
const hasil = mentah.canReceiveMessage ? msg : false
if (!hasil) return tobz.reply(from, 'Nomor WhatsApp tidak valid [ Tidak terdaftar di WhatsApp ]', id)
{
const register = ({
id: mentah.id._serialized,
nama: jenenge,
umur: umurnye
})
pendaftar.push(register)
fs.writeFileSync('./lib/database/user.json', JSON.stringify(pendaftar)) // DATABASE
tobz.sendTextWithMentions(from, hasil)
}
}
} else {
await tobz.reply(from, `Format yang kamu masukkan salah, kirim ${prefix}daftar |nama|umur\n\ncontoh format: ${prefix}daftar |ahmad|17\n\ncukup gunakan nama depan/panggilan saja`, id) //if user is not registered
}
break