forked from IndonesianDev/whatsapp-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
HandleMsg.js
4544 lines (4421 loc) · 243 KB
/
HandleMsg.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
require('dotenv').config()
const { decryptMedia } = require('@open-wa/wa-automate')
const moment = require('moment-timezone')
moment.tz.setDefault('Asia/Jakarta').locale('id')
const axios = require('axios')
const { spawn } = require('child_process')
const fetch = require('node-fetch')
const appRoot = require('app-root-path')
const emojiUnicode = require('emoji-unicode')
const toMs = require('ms')
const low = require('lowdb')
const requests = require("node-fetch")
const ms = require('parse-ms')
const FileSync = require('lowdb/adapters/FileSync')
const feature = require('./lib/poll');
const ffmpeg = require('fluent-ffmpeg')
const util = require('util')
const quiziz = require('quizizz.js')
const hackq = new quiziz.QuizizzClient();
const { Readable, Writable } = require('stream')
const db_group = new FileSync(appRoot+'/lib/data/group.json')
const db = low(db_group)
const notice = ['piyobot', 'piyobot']
const { getUser, getPost, searchUser } = require('./lib/Insta')
const path = require('path')
const bent = require('bent')
const Math_js = require('mathjs')
const fs = require('fs-extra')
const errorImg = 'https://i.imgur.com/VKoNMIR.png'
db.defaults({ group: []}).write()
var tanggal = moment.tz('Asia/Jakarta').format('YYYY-MM-DD')
const {
removeBackgroundFromImageBase64
} = require('remove.bg')
const {
exec
} = require('child_process')
const {
insert
} = require('././database')
const {
menuId,
menupremium,
menuhiburan,
nsfwmenu,
menulama,
menubaru,
diamondd,
payment,
mentol,
wibuarea,
Toxic,
menunulis,
help,
diamond,
rules,
ownermenu,
songmenu,
menutobat,
menupenting,
Jsholat,
tiktokmenu,
Lirik,
cekResi,
urlShortener,
meme,
translate,
nekopoi,
brainly,
getLocationData,
images,
premium,
sewa,
resep,
nsfw,
ptlcewek,
kbbi,
rugapoi,
rugaapi
} = require('./lib')
const {
msgFilter,
color,
processTime,
createcode,
isUrl
} = require('./utils')
const { uploadImages } = require('./utils/fetcher')
const { imagetotext } = require('./lib/rdt')
//////////////////////////////FOLDER SYSTEM///////////////////////////////////
const banned = JSON.parse(fs.readFileSync('./settings/banned.json'))
const simi = JSON.parse(fs.readFileSync('./settings/simi.json'))
const chatt = JSON.parse(fs.readFileSync('./settings/piyo.json'))
const ngegas = JSON.parse(fs.readFileSync('./settings/ngegas.json'))
const setting = JSON.parse(fs.readFileSync('./settings/setting.json'))
const isPorn = JSON.parse(fs.readFileSync('./settings/antiporn.json'))
const uang = JSON.parse(fs.readFileSync('./settings/uang.json'))
const kuis = JSON.parse(fs.readFileSync('./settings/kuis.json'))
const code15 = JSON.parse(fs.readFileSync('./settings/code15.json'))
const code30 = JSON.parse(fs.readFileSync('./settings/code30.json'))
const code60 = JSON.parse(fs.readFileSync('./settings/code60.json'))
const premiumcode = JSON.parse(fs.readFileSync('./settings/premiumcode.json'))
const _nsfw = JSON.parse(fs.readFileSync('./settings/nsfw.json'))
const _welcome = JSON.parse(fs.readFileSync('./settings/welcome.json'))
const _reminder = JSON.parse(fs.readFileSync('./settings/reminder.json'))
const _autostiker = JSON.parse(fs.readFileSync('./settings/autostiker.json'))
const _afk = JSON.parse(fs.readFileSync('./settings/afk.json'))
const _premium = JSON.parse(fs.readFileSync('./settings/premium.json'))
const _sewa = JSON.parse(fs.readFileSync('./settings/sewa.json'))
const _biodata = JSON.parse(fs.readFileSync('./settings/biodata.json'))
const _registered = JSON.parse(fs.readFileSync('./settings/registered.json'))
const _tebak = JSON.parse(fs.readFileSync('./settings/tebakgambar.json'))
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////LET SYSTEM////////////////////////////////////
let dbcot = JSON.parse(fs.readFileSync('./settings/bacot.json'))
let updatepiyobot = JSON.parse(fs.readFileSync('./settings/update.json'))
let adminNumber = JSON.parse(fs.readFileSync('./settings/admin.json'))
let limit = JSON.parse(fs.readFileSync('./settings/limit.json'))
let stickerspam = JSON.parse(fs.readFileSync('./settings/stickerspam.json'))
let antisticker = JSON.parse(fs.readFileSync('./settings/antisticker.json'))
///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////SETTING///////////////////////////////////////
let {
ownerNumber,
groupLimit,
limitCount,
memberLimit,
prefix,
apikeyz,
lolhuman,
vhtearkey
} = setting
///////////////////////////////API JSON///////////////////////////////////////
const {
apiNoBg,
apiSimi
} = JSON.parse(fs.readFileSync('./settings/api.json'))
//////////////////////////////////////////////////////////////////////////////
function formatin(duit){
let reverse = duit.toString().split('').reverse().join('');
let ribuan = reverse.match(/\d{1,3}/g);
ribuan = ribuan.join('.').split('').reverse().join('');
return ribuan;
}
const inArray = (needle, haystack) => {
let length = haystack.length;
for(let i = 0; i < length; i++) {
if(haystack[i].id == needle) return i;
}
return false;
}
module.exports = HandleMsg = async (piyo, message) => {
try {
const { type, id, content, from, t, sender, isGroupMsg, chat, chatId, caption, isMedia, mimetype, quotedMsg, author, quotedMsgObj, mentionedJidList } = message
let { body } = message
var { items, name, formattedTitle } = chat
let { text } = message
let { pushname, verifiedName, formattedName } = sender
pushname = pushname || verifiedName || formattedName // verifiedName is the name of someone who uses a business account
const botNumber = await piyo.getHostNumber() + '@c.us'
const groupId = isGroupMsg ? chat.groupMetadata.id : ''
const groupAdmins = isGroupMsg ? await piyo.getGroupAdmins(groupId) : ''
const groupMembers = isGroupMsg ? await piyo.getGroupMembersId(groupId) : ''
const isOwner = sender.id === ownerNumber.includes
const isGroupAdmins = groupAdmins.includes(sender.id) || false
const chats = (type === 'chat') ? body : (type === 'image' || type === 'video') ? caption : ''
const pengirim = sender.id
const pengirimm = JSON.parse(fs.readFileSync('./settings/registered.json'))
const uwong = pengirimm[Math.floor(Math.random() * pengirimm.length)];
const serial = sender.id
const time = moment(t * 1000).format('DD/MM/YY HH:mm:ss')
const timee = moment(t * 1000).format('HH:mm:ss')
const isBotGroupAdmins = groupAdmins.includes(botNumber) || false
const { ind } = require('./message/text/lang/')
const isAdmin = adminNumber.includes(sender.id)
const isPremium = premium.checkPremiumUser(sender.id, _premium)
const isSewa = sewa.checkSewa(chat.id , _sewa)
const userId = sender.id.substring(9, 13)
const isRegistered = _registered.includes(sender.id)
global.pollfile = 'poll_Config_' + chat.id + '.json'
global.voterslistfile = 'poll_voters_Config_' + chat.id + '.json'
const isAutoStikerOn = isGroupMsg ? _autostiker.includes(chat.id) : false
// Bot Prefix
body = (type === 'chat' && body.startsWith(prefix)) ? body : (((type === 'image' || type === 'video') && caption) && caption.startsWith(prefix)) ? caption : ''
const command = body.slice(1).trim().split(/ +/).shift().toLowerCase()
const commandd = caption || body || ''
const arg = body.substring(body.indexOf(' ') + 1)
const validMessage = caption ? caption : body;
const arguments = validMessage.trim().split(' ').slice(1)
const args = body.trim().split(/ +/).slice(1)
const argv = body.slice(1).trim().split(/ +/).shift().toLowerCase()
const isCmd = body.startsWith(prefix)
const arghh = commandd.split(' ')
const argus = commandd.split(' ')
const uaOverride = process.env.UserAgent
const q = args.join(' ')
const ar = body.trim().split(/ +/).slice(1)
const url = args.length !== 0 ? args[0] : ''
const errorurl2 = 'https://steamuserimages-a.akamaihd.net/ugc/954087817129084207/5B7E46EE484181A676C02DFCAD48ECB1C74BC423/?imw=512&&ima=fit&impolicy=Letterbox&imcolor=%23000000&letterbox=false'
const errorur121= 'https://i.imgur.com/VKoNMIR.png'
const _antilink = JSON.parse(fs.readFileSync('./settings/antilink.json'))
const isNsfw = isGroupMsg ? _nsfw.includes(chat.id) : false
const isWelcomeOn = isGroupMsg ? _welcome.includes(chat.id) : false
const isKuis = isGroupMsg ? kuis.includes(chat.id) : false
const isAntiPorn = isGroupMsg ? isPorn.includes(chat.id) : false
const isImage = type === 'image'
const reason = q ? q : 'Nothing.'
const isQuotedImage = quotedMsg && quotedMsg.type === 'image'
const isQuotedVideo = quotedMsg && quotedMsg.type === 'video'
const isQuotedFile = quotedMsg && quotedMsg.type === 'file'
const isQuotedAudio = quotedMsg && quotedMsg.type === 'audio'
const isQuotedGif = quotedMsg && quotedMsg.type === 'gif'
const isQuotedSticker = quotedMsg && quotedMsg.type === 'sticker'
const stickermsg = message.type === 'sticker'
const cecan = [
{
lahwoi : "Pacar piyo yang ke 1",
imagex : "https://i.ibb.co/VT4ggGj/Instagram.jpg",
},
{
lahwoi : "Pacar piyo yang ke 2",
imagex : "https://i.ibb.co/x1nD1HD/Instagram-1.jpg",
},
{
lahwoi : "Pacar piyo yang ke 3",
imagex : "https://i.ibb.co/ZXPPFKF/Argumentasi-Dimensi.jpg",
},
{
lahwoi : "Pacar piyo yang ke 4",
imagex : "https://i.ibb.co/NpY5ZBR/image.jpg",
},
{
lahwoi : "Pacar piyo yang ke 5",
imagex : "https://i.ibb.co/PWsL6HF/download-1.jpg",
},
{
lahwoi : "Pacar piyo yang ke 6",
imagex :"https://i.ibb.co/JFkDWjB/RASANYA-ANJING-BANGET.jpg",
},
{
lahwoi : "Pacar piyo yang ke 7",
imagex : "https://i.ibb.co/5W2gMq6/download-2.jpg",
},
{
lahwoi : "Pacar piyo yang ke 8",
imagex : "https://i.ibb.co/QNWhdgC/download-3.jpg",
},
{
lahwoi : "Pacar piyo yang ke terakhir",
imagex : "https://i.ibb.co/RS1vWC3/Blur.jpg"
}
]
const santet = [
'Muntah Paku',
'Meninggoy',
'Berak Paku',
'Muntah Rambut',
'Ketempelan MONYET!!!',
'Berak di Celana Terus',
'Menjadi Gila',
'Menjadi manusiawi',
'jomblo selamanya',
'ga bisa berak',
'ketiban pesawat',
'jadi anak mulung',
'ga jadi pacar zeus',
'jadi jelek'
]
const kutuk = [
'Sapi',
'Batu',
'Babi',
'Anak soleh dan soleha',
'pohon pisang',
'janda',
'bangsat',
'buaya',
'Jangkrik',
'Kambbiingg',
'Bajing',
'kang seblak',
'kang gorengan',
'kang siomay',
'badut ancol',
'Tai',
'Kebo',
'Badak biar Asli',
'tai kotok',
'Bwebwek',
'Orang Suksesss...... tapi boong',
'Beban Keluarga' //tambahin aja
]
const estetek = [
"https://i.ibb.co/Xk1kggV/Aesthetic-Wallpaper-for-Phone.jpg",
"https://i.ibb.co/wBNyv8X/image.jpg",
"https://i.ibb.co/hgcJbg7/Leaving-Facebook.jpg",
"https://i.ibb.co/27TW3bT/Pinterest.jpg",
"https://i.ibb.co/2MR16Ct/Image-about-vintage-in-ALittle-Bit-Of-This-And-That-by-Little-Nerdy-Gnome.jpg",
"https://i.ibb.co/WfrzTWH/minteyroul-on-We-Heart-It.jpg",
"https://i.ibb.co/dMpkfWT/1001-Kreative-Aesthetic-Wallpaper-Ideen-f-r-das-Handy.jpg",
"https://i.ibb.co/cN3Br2J/red-grunge-wallpaper-dark-edgy-aesthetic-collage-background-trendy-cool-dark-red-iphone-wallpaper.jpg",
"https://i.ibb.co/c8QMXZv/ee16de425985d4a1b628dddc1461b546.jpg"
]
const kapan = [
'1 Minggu lagi',
'1 Bulan lagi',
'1 Tahun lagi',
'100 tahun lagi',
'gatau',
'2030'
]
const rate = [
'100%',
'95%',
'90%',
'85%',
'80%',
'75%',
'70%',
'65%',
'60%',
'55%',
'50%',
'45%',
'40%',
'35%',
'30%',
'25%',
'20%',
'15%',
'10%',
'5%'
]
const nomormutualan = ['Isi nomor yang ada di registered']
// [IDENTIFY]
const isOwnerBot = ownerNumber.includes(pengirim)
const isBanned = banned.includes(pengirim)
const isSimi = simi.includes(chatId)
const isChat = chatt.includes(chatId)
const isDetectorOn = _antilink.includes(chat.id)
const isInviteLink = await piyo.inviteInfo(body)
const isNgegas = ngegas.includes(chatId)
const isKode = premiumcode.includes(q)
const AntiStickerSpam = antisticker.includes(chatId)
// Log
if (isCmd && !isGroupMsg && !isBanned) console.log(color('[CMD]'), color(time, 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname))
if (isCmd && isGroupMsg && !isBanned) console.log(color('[CMD]'), color(time, 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname), 'in', color(name || formattedTitle))
// IsBanned
if (isCmd && isBanned && !isGroupMsg) return console.log(color('[BAN]', 'red'), color(time, 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname))
if (isCmd && isBanned && isGroupMsg) return console.log(color('[BAN]', 'red'), color(time, 'yellow'), color(`${command} [${args.length}]`), 'from', color(pushname), 'in', color(name || formattedTitle))
// 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;
}
const SN = GenerateSerialNumber("000000000000000000000000")
////////////////////////////////////////AFK///////////////////////////////////////////
const addAfk = (userId, time) => {
let obj = {id: `${userId}`, time: `${time}` , reason: `${reason}`}
_afk.push(obj)
fs.writeFileSync('./settings/afk.json', JSON.stringify(_afk))
}
const getAfk = (userId) => {
let isAfk = false
Object.keys(_afk).forEach((i) => {
if (_afk[i].id === userId) {
isAfk = true
}
})
return isAfk
}
const getAfkReason = (userId) => {
let position = false
Object.keys(_afk).forEach((i) => {
if (_afk[i].id === userId) {
position = i
}
})
if (position !== false) {
return _afk[position].reason
}
}
const getAfkTime = (userId) => {
let position = false
Object.keys(_afk).forEach((i) => {
if (_afk[i].id === userId) {
position = i
}
})
if (position !== false) {
return _afk[position].time
}
}
const getAfkId = (userId) => {
let position = false
Object.keys(_afk).forEach((i) => {
if (_afk[i].id === userId) {
position = i
}
})
if (position !== false) {
return _afk[position].id
}
}
////////////////////////////////////////AFK///////////////////////////////////////////
////////////////////////////////REPLY WITH AUDIO////////////////////////////////////////
const vn = [
'./media/an2.ogg',
'./media/an1.ogg',
'./media/ana4.ogg'
]
//AUTOMATE
if (chats == 'assalamualaikum'){
piyo.sendPtt(from, './media/ana3.ogg' , id)
}
if (chats == 'Assalamualaikum'){
piyo.sendPtt(from, './media/ana3.ogg' , id)
}
if (chats == 'p'){
if (!isGroupMsg){
let randomvn = vn[Math.floor(Math.random() * vn.length)]
piyo.sendPtt(from , randomvn , id)
}
}
if (chats == 'P'){
if (!isGroupMsg){
let randomvn = vn[Math.floor(Math.random() * vn.length)]
piyo.sendPtt(from , randomvn , id)
}
}
if (chats == 'bot'){
if (!isGroupMsg){
let randomvn = vn[Math.floor(Math.random() * vn.length)]
piyo.sendPtt(from , randomvn , id)
}
}
if (chats == 'bot'){
if (isGroupMsg){
let randomvn = vn[Math.floor(Math.random() * vn.length)]
piyo.sendPtt(from , randomvn , id)
}
}
if (chats == 'bot ini owner'){
if (isOwnerBot){
piyo.sendPtt(from , './media/owner.ogg' , id)
}
}
if (chats == 'kontol'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'memek'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'anjing'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'bangsat'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'ngentot'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'babi'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'monyet'){
piyo.sendPtt(from, './media/ana2.ogg' , id)
}
if (chats == 'Bot'){
let randomvn = vn[Math.floor(Math.random() * vn.length)]
piyo.sendPtt(from , randomvn , id)
}
//////////////////////////////////////REMINDER///////////////////////////////////////
const addReminder = (userId, message, time) => {
const obj = { id: userId, msg: message, time: Date.now() + toMs(time) }
_reminder.push(obj)
fs.writeFileSync('./settings/reminder.json', JSON.stringify(_reminder))
}
const getReminderTime = (userId) => {
let position = false
Object.keys(_reminder).forEach((i) => {
if(_reminder[i].id === userId) {
position = i
}
})
if (position !== false) {
return _reminder[position].time
}
}
const getReminderMsg = (userId) => {
let position = false
Object.keys(_reminder).forEach((i) => {
if (_reminder[i].id === userId) {
position = i
}
})
if (position !== false) {
return _reminder[position].msg
}
}
const getReminderPosition = (userId) => {
let position = false
Object.keys(_reminder).forEach((i) => {
if (_reminder[i].id === userId) {
position = i
}
})
return position
}
//////////////////////////////////////TEBAK GAMBAR/////////////////////////////////
if (isGroupMsg){
if (_tebak.includes(chats))
{
await piyo.reply(from, `Jawaban Benar , Kamu mendapatkan 5 Points` , id)
let tebak = _tebak.indexOf(chats);
_tebak.splice(tebak,1)
fs.writeFileSync('./settings/tebakgambar.json', JSON.stringify(_tebak , null, 2))
let kuiis = kuis.indexOf(chatId)
kuis.splice(kuiis,1)
fs.writeFileSync('./settings/kuis.json', JSON.stringify(kuis , null, 2))
}
}
//////////////////////////////////////PREMIUM CODE///////////////////////////////////
if (code15.includes(q))
{
let hari = '15'
await piyo.reply(from, `Sukses Memasukan Premium Code 15 Hari` , id)
premium.addPremiumUser(sender.id, '15d', _premium)
await piyo.reply(from, `*「 PREMIUM 15 HARI 」*\n\n➸ *NAMA*: ${pushname}\n➸ *ID*: ${sender.id}\n➸ *Expired*: ${ms(toMs(hari)).days} day(s) ${ms(toMs(hari)).hours} hour(s) ${ms(toMs(hari)).minutes} minute(s)`, id)
let codee = code15.indexOf(q);
code15.splice(codee,1)
fs.writeFileSync('./settings/code15.json', JSON.stringify(code15 , null, 2))
let prem = premiumcode.indexOf(q);
premiumcode.splice(prem,1)
fs.writeFileSync('./settings/premiumcode.json', JSON.stringify(premiumcode , null, 2))
}
if (code30.includes(q))
{
let hari = '30d'
await piyo.reply(from, `Sukses Memasukan Premium Code 30 Hari / 1BULAN` , id)
premium.addPremiumUser(sender.id, '30d', _premium)
await piyo.reply(from, `*「 PREMIUM 30 HARI 」*\n\n➸ *NAMA*: ${pushname}\n➸ *ID*: ${sender.id}\n➸ *Expired*: ${ms(toMs(hari)).days} day(s) ${ms(toMs(hari)).hours} hour(s) ${ms(toMs(hari)).minutes} minute(s)`, id)
let codeee = code30.indexOf(q);
code30.splice(codeee,1)
fs.writeFileSync('./settings/code30.json', JSON.stringify(code30 , null, 2))
let prem = premiumcode.indexOf(q);
premiumcode.splice(prem,1)
fs.writeFileSync('./settings/premiumcode.json', JSON.stringify(premiumcode , null, 2))
}
if (code60.includes(q))
{
let hari = '60d'
await piyo.reply(from, `Sukses Memasukan Premium Code 60 Hari / 2BULAN` , id)
premium.addPremiumUser(sender.id, '60d', _premium)
await piyo.reply(from, `*「 PREMIUM 60 HARI 」*\n\n➸ *NAMA*: ${pushname}\n➸ *ID*: ${sender.id}\n➸ *Expired*: ${ms(toMs(hari)).days} day(s) ${ms(toMs(hari)).hours} hour(s) ${ms(toMs(hari)).minutes} minute(s)`, id)
let codeeee = code60.indexOf(q);
code60.splice(codeeee,1)
fs.writeFileSync('./settings/code60.json', JSON.stringify(code60 , null, 2))
let prem = premiumcode.indexOf(q);
premiumcode.splice(prem,1)
fs.writeFileSync('./settings/premiumcode.json', JSON.stringify(premiumcode , null, 2))
}
//////////////////////////////////////REMINDER///////////////////////////////////////
const isAfkOn = getAfk(sender.id)
// AFK
if (isGroupMsg) {
const checking = getAfk(sender.id)
for (let ment of mentionedJidList) {
if (getAfk(ment)) {
const getId = getAfkId(ment)
const getReason = getAfkReason(getId)
const getTime = getAfkTime(getId)
await piyo.reply(from, ind.afkMentioned(getReason, getTime), id)
}
}
if (checking && !isCmd) {
_afk.splice(sender.id, 1)
fs.writeFileSync('./settings/afk.json', JSON.stringify(_afk))
await piyo.sendText(from, ind.afkDone(pushname))
}
}
//////////////////////////////////////FUNCTION BALANCE/////////////////////////////////////
const addATM = (serial) => {
const obj = {id: serial, uang : 0}
uang.push(obj)
fs.writeFileSync('./settings/uang.json', JSON.stringify(uang))
}
const addKoinUser = (serial, amount) => {
let position = false
Object.keys(uang).forEach((i) => {
if (uang[i].id === serial) {
position = i
}
})
if (position !== false) {
uang[position].uang += amount;
fs.writeFileSync('./settings/uang.json', JSON.stringify(uang))
}
}
const checkATMuser = (serial) => {
let position = false
Object.keys(uang).forEach((i) => {
if (uang[i].id === serial) {
position = i
}
})
if (position !== false) {
return uang[position].uang
}
}
const bayarLimit = (serial, amount) => {
let position = false
Object.keys(limit).forEach((i) => {
if (limit[i].id === serial) {
position = i
}
})
if (position !== false) {
limit[position].limit -= amount;
fs.writeFileSync('./settings/limit.json', JSON.stringify(limit))
}
}
const confirmATM = (serial, amount) => {
let position = false
Object.keys(uang).forEach((i) => {
if (uang[i].id === serial) {
position = i
}
})
if (position !== false) {
uang[position].uang -= amount
fs.writeFileSync('./settings/uang.json', JSON.stringify(uang))
}
}
if (isRegistered) {
const checkATM = checkATMuser(serial)
try {
if (checkATM === undefined) addATM(serial)
const uangsaku = Math.floor(Math.random() * 10) + 50
addKoinUser(serial, uangsaku)
} catch (err) {
console.error(err)
}
}
//////////////////////////////////////ANTI STICKER SPAM////////////////////////////////
function isStickerMsg(id){
if (isOwnerBot, isAdmin) {return false;}
let found = false;
for (let i of stickerspam){
if(i.id === id){
if (i.msg >= 5) {
found === true
piyo.reply(from, '*「 𝗔𝗡𝗧𝗜 𝗦𝗣𝗔𝗠 𝗦𝗧𝗜𝗖𝗞𝗘𝗥 」*\nKamu telah SPAM STICKER di grup, kamu akan di kick otomatis oleh Piyobot', message.id).then(() => {
piyo.removeParticipant(groupId, id)
}).then(() => {
const cus = id
var found = false
Object.keys(stickerspam).forEach((i) => {
if(stickerspam[i].id == cus){
found = i
}
})
if (found !== false) {
stickerspam[found].msg = 1;
const resultx = 'Database telah direset!'
console.log(stickerspam[found])
fs.writeFileSync('./settings/stickerspam.json',JSON.stringify(stickerspam));
piyo.reply(from, resultx)
} else {
piyo.reply(from, `Nomor itu tidak terdaftar didalam database!`, id)
}
})
return true;
}else{
found === true
return false;
}
}
}
if (found === false){
let obj = {id: `${id}`, msg:1};
stickerspam.push(obj);
fs.writeFileSync('./settings/stickerspam.json',JSON.stringify(stickerspam));
return false;
}
}
function addStickerCount(id){
if (isOwnerBot, 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('./settings/stickerspam.json',JSON.stringify(stickerspam));
}
}
if (isGroupMsg && AntiStickerSpam && !isGroupAdmins && !isAdmin && !isOwner){
if(stickermsg === true){
if(isStickerMsg(serial)) return
addStickerCount(serial)
}
}
///////////////////////////////////////////////////////////BASS////////////////////////////////////
function stream2Buffer(cb = noop) {
return new Promise(resolve => {
let write = new Writable()
write.data = []
write.write = function (chunk) {
this.data.push(chunk)
}
write.on('finish', function () {
resolve(Buffer.concat(this.data))
})
cb(write)
})
}
/**
* Convert Buffer to Readable Stream
* @param {Buffer} buffer
* @returns {ReadableStream}
*/
function buffer2Stream(buffer) {
return new Readable({
read() {
this.push(buffer)
this.push(null)
}
})
}
//////////////
if (!isGroupMsg && isMedia && isImage && !isCmd)
{
const mediaData = await decryptMedia(message, uaOverride)
const imageBase64 = `data:${mimetype};base64,${mediaData.toString('base64')}`
await piyo.sendImageAsSticker(from, imageBase64)
.then(async () => {
console.log(`Sticker processed for ${processTime(t, moment())} seconds`)
})
.catch(async (err) => {
console.error(err)
await piyo.reply(from, `Error!\n${err}`, id)
})
}
// Anti-Porn Lol Human , Diusahakan apikeya beli premium atau vip
// Thanks to Vide Frelan / vide fikri
// Kalo mau yang detek sticker juga , chat saya aja
if (isGroupMsg && isAntiPorn && !isGroupAdmins && isBotGroupAdmins) {
if (type === 'image') {
const datafacol = await decryptMedia(message)
const fotofacol = await uploadImages(datafacol, `fotoface.${sender.id}`)
const getnsfw = await axios.get(`https://lolhuman.herokuapp.com/api/nsfwcheck?apikey=${lolhuman}&img=${fotofacol}`)
const persen = getnsfw.data.result
console.log(persen)
if (Number(getnsfw.data.result.split('%')[0]) >= 30.00) return piyo.reply(from, `*Terdeteksi Mengirim Gambar Yang Berbau Porno*\nKeyakinan Gambar : ${persen}`, id).then(() => piyo.removeParticipant(groupId, sender.id))
}
}
// Anti-group link detector
if (isGroupMsg && !isGroupAdmins && isBotGroupAdmins && isDetectorOn && !isOwner) {
if (chats.match(new RegExp(/(https:\/\/chat.whatsapp.com)/gi))) {
await piyo.reply(from, ind.linkDetected(), id)
await piyo.removeParticipant(groupId, sender.id)
}
}
function isLimit(id){
if (isOwnerBot) {return false;}
let found = false;
for (let i of limit){
if(i.id === id){
let limits = i.limit;
if (limits >= limitCount) {
found = true;
piyo.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('./settings/limit.json',JSON.stringify(limit));
return false;
}
}
function limitAdd (id) {
if (isOwnerBot) {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('./settings/limit.json',JSON.stringify(limit));
}
}
function baseURI(buffer = Buffer.from([]), metatype = 'text/plain') {
return `data:${metatype};base64,${buffer.toString('base64')}`
}
// PREMIUM + SEWA
premium.expiredCheck(_premium)
sewa.expiredCheck(_sewa , piyo , message , groupId)
switch (command) {
// Menu and TnC
///////////////////////////////////////////////////MENU////////////////////////////////////////////////////////////
case 'speed':
case 'ping':
await piyo.sendText(from, `Pong!!!!\nSpeed: ${processTime(t, moment())} _Second_`)
break
case 'tnc':
await piyo.sendText(from, menuId.textTnC())
break
case 'menuhiburan':
await piyo.sendText(from, menuId.textmenuhiburan (pushname))
break
case 'nulis': {
await piyo.sendText(from, menuId.textmenunulis())
}
break
case 'mentol':
await piyo.sendText(from, menuId.textmentol (pushname))
break
case 'menulogo':
await piyo.sendText(from, menuId.menulogo (pushname))
break
case 'menusticker':
await piyo.sendText(from, menuId.menusticker (pushname))
break
case 'menuhiburan':
await piyo.sendText(from, menuId.textmenuhiburan (pushname))
break
case 'menutobat':
await piyo.sendText(from, menuId.textmenutobat (pushname))
break
case 'wibuarea':
await piyo.sendText(from, menuId.textwibuarea (pushname))
break
case 'menupremium':
await piyo.sendText(from, menuId.textmenupremium (pushname))
break
case 'menupenting':
await piyo.sendText(from, menuId.textmenupenting (pushname))
break
case 'help':
const contol = await piyo.getAllChatIds()
const premiu = isPremium ? 'Premium' : 'Free'
await piyo.sendText(from, menuId.texthelp(pushname, premiu , _registered , contol))
break
case 'menubaru':
const nadhirasayang = './media/azure.png'
await piyo.sendFile(from, nadhirasayang , 'piyo.png' , menuId.textmenubaru(pushname))
break
case 'menulama':
const updater = updatepiyobot ? 'yes' : 'no'
await piyo.sendText(from, menuId.textmenulama(pushname, updater))
.then(() => ((isGroupMsg) && (isGroupAdmins)) ? piyo.sendText(from, `Menu Admin Grup: *${prefix}menuadmin*`) : null)
break
case 'menu':
const premi = isPremium ? 'Premium' : 'Free'
const coloo = await piyo.getAllChatIds()
let tod = `${timee}`;
await piyo.sendText(from, menuId.textmenu(pushname, premi , _registered , coloo , tod))
break
case 'rules':
case 'rule':
await piyo.sendText(from, menuId.textRules())
break
case 'ownermenu':
if (!isOwnerBot) return piyo.reply(from, 'Fitur ini hanya untuk owner' , id)
await piyo.sendText(from, menuId.textownermenu())
break
case 'menuadmin':
if (!isGroupMsg) return piyo.reply(from, 'Maaf, perintah ini hanya dapat dipakai didalam grup!', id)
if (!isGroupAdmins) return piyo.reply(from, 'Gagal, perintah ini hanya dapat digunakan oleh admin grup!', id)
await piyo.sendText(from, menuId.textAdmin())
break
case 'donate':
case 'donasi':
await piyo.sendText(from, menuId.textDonasi())
break
case 'ownerbot':
await piyo.sendContact(from, ownerNumber)
.then(() => piyo.sendText(from, 'Jika kalian ingin request fitur silahkan chat nomor owner!'))
break
case 'bal':
if (!isRegistered) return piyo.reply(from, `Maaf ${pushname}, sepertinya kamu belum terdaftar sebagai user Piyobot, untuk pendaftaran bisa menggunakan /register nama | Jenis Kelamin. Contoh: /register ${pushname}|cewe`, id)
const kantong = checkATMuser(serial)
piyo.reply(from, `Halo ${pushname}, Kamu Memiliki Uang Sejumlah Rp. ${kantong}`, id)
break
///////////////////////////////////////////////////MENU STICKER////////////////////////////////////////////////////
case 'stickermeme':
if ((isMedia || isQuotedImage) && args.length >= 2) {
const top = arg.split('|')[0]
const bottom = arg.split('|')[1]
const encryptMedia = isQuotedImage ? quotedMsg : message
const mediaData = await decryptMedia(encryptMedia, uaOverride)
const getUrl = await uploadImages(mediaData, false)
const ImageBase64 = await meme.custom(getUrl, top, bottom)
piyo.sendImageAsSticker(from, ImageBase64, '', null, true)
.then(() => {
piyo.reply(from, 'Ini makasih!',id)
})
.catch(() => {
piyo.reply(from, 'Ada yang error!')
})
} else {
await piyo.reply(from, `Tidak ada gambar! Silahkan kirim gambar dengan caption ${prefix}meme <teks_atas> | <teks_bawah>\ncontoh: ${prefix}meme teks atas | teks bawah`, id)
}
break
case 'addsticker':
if (!q) return piyo.reply(from, `Hai Kak ${pushname} untuk menggunakan fitur save stiker ketik */addsticker* _Nama nya_`, id)
if (quotedMsg) {
if (quotedMsg.type === 'sticker') {
try {
mediaData = await decryptMedia(quotedMsg, uaOverride)
fs.writeFileSync(`./media/sticker/${q}.jpg`, mediaData)
piyo.reply(from, `Stiker berhasil tersimpan!\n\nUntuk melihat list ketik */liststiker*`, id)
} catch(err) {
piyo.reply(from, `Gagal save sticker!`, id)
piyo.reply(ownerNumber, util.format(err), id)
}
} else {
piyo.reply(from, `Harus reply stiker!`, id)
}
} else {
piyo.reply(from, `Gaada data yang direply gan`, id)
}
break
case 'liststiker':
const liststicker = fs.readdirSync('./media/sticker/')
let capliststik = `Ketik perintah */getstiker _Nama nya_* untuk mengambil data stiker\n\n*Jumlah stiker* : ${liststicker.length}\n\n*Stiker tersimpan :*\n`
for (let i = 0; i < liststicker.length; i++) {
capliststik += `\n➣ ${liststicker[i].replace('.jpg','')}`
}
piyo.reply(from, capliststik, id)
break
case 'getstiker':
if (!q) return piyo.reply(from, `Hai Kak ${pushname} untuk menggunakan fitur get stiker ketik */getstiker* _Nama nya_`, id)
try {
const datastick = await fs.readFileSync('./media/sticker/' + q + '.jpg', { encoding: "base64" })
const imageBase64 = `data:image/jpeg;base64,${datastick.toString('base64')}`