-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.js
1248 lines (1199 loc) · 35.7 KB
/
handler.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
import {
smsg
} from './lib/simple.js'
import {
plugins
} from './lib/plugins.js'
import {
format
} from 'util'
import {
fileURLToPath
} from 'url'
import path, {
join
} from 'path'
import {
unwatchFile,
watchFile
} from 'fs'
import chalk from 'chalk'
import Connection from './lib/connection.js'
import printMessage from './lib/print.js'
import Helper from './lib/helper.js'
import db, {
loadDatabase
} from './lib/database.js'
import Queque from './lib/queque.js'
/** @type {import('@adiwajshing/baileys')} */
var {
getContentType,
proto,
WAMessageStubType
} = (await import('@adiwajshing/baileys')).default
var isNumber = x => typeof x === 'number' && !isNaN(x)
/**
* Handle messages upsert
* @this {import('./lib/connection').Socket}
* @param {import('@adiwajshing/baileys').BaileysEventMap<unknown>['messages.upsert']} chatUpdate
*/
export async function handler(chatUpdate) {
this.msgqueque = this.msgqueque || new Queque()
if (!chatUpdate)
return
var m = chatUpdate.messages[chatUpdate.messages.length - 1]
if (!m)
return
if (db.data == null)
await loadDatabase()
try {
m = smsg(this, m) || m
if (!m)
return
m.exp = 0
m.limit = false
try {
// TODO: use loop to insert data instead of this
var user = db.data.users[m.sender]
if (typeof user !== 'object')
db.data.users[m.sender] = {}
if (user) {
if (!isNumber(user.exp))
user.exp = 0
if (!isNumber(user.limit))
user.limit = 10
if (!isNumber(user.lastclaim))
user.lastclaim = 0
if (!('registered' in user))
user.registered = false
if (!user.registered) {
if (!('name' in user))
user.name = m.name
if (!isNumber(user.age))
user.age = -1
if (!isNumber(user.regTime))
user.regTime = -1
}
if (!isNumber(user.afk))
user.afk = -1
if (!('afkReason' in user))
user.afkReason = ''
if (!('banned' in user))
user.banned = false
if (!isNumber(user.warn))
user.warn = 0
if (!isNumber(user.level))
user.level = 0
if (!('role' in user))
user.role = 'Beginner'
if (!('autolevelup' in user))
user.autolevelup = true
if (!isNumber(user.money))
user.money = 0
if (!isNumber(user.atm))
user.atm = 0
if (!isNumber(user.fullatm))
user.fullatm = 0
if (!isNumber(user.bank))
user.bank = 0
if (!isNumber(user.health))
user.health = 100
if (!isNumber(user.stamina))
user.stamina = 100
if (!isNumber(user.limit))
user.limit = 0
if (!isNumber(user.potion))
user.potion = 0
if (!isNumber(user.trash))
user.trash = 0
if (!isNumber(user.wood))
user.wood = 0
if (!isNumber(user.rock))
user.rock = 0
if (!isNumber(user.brick))
user.brick = 0
if (!isNumber(user.glass))
user.glass = 0
if (!isNumber(user.stick))
user.stick = 0
if (!isNumber(user.string))
user.string = 0
if (!isNumber(user.petFood))
user.petFood = 0
//building
if (!isNumber(user.fortress))
user.fortress = 0
if (!isNumber(user.house))
user.house = 0
if (!isNumber(user.kastel))
user.kastel = 0
if (!isNumber(user.peternakan))
user.peternakan = 0
if (!isNumber(user.perkebunan))
user.perkebunan = 0
if (!isNumber(user.pertambangan))
user.pertambangan = 0
//SDA
if (!isNumber(user.emerald))
user.emerald = 0
if (!isNumber(user.diamond))
user.diamond = 0
if (!isNumber(user.gold))
user.gold = 0
if (!isNumber(user.iron))
user.iron = 0
if (!isNumber(user.coal))
user.coal = 0
if (!isNumber(user.clay))
user.clay = 0
if (!isNumber(user.sand))
user.sand = 0
if (!isNumber(user.upgrader))
user.upgrader = 0
//chest
if (!isNumber(user.common))
user.common = 0
if (!isNumber(user.uncommon))
user.uncommon = 0
if (!isNumber(user.mythic))
user.mythic = 0
if (!isNumber(user.legendary))
user.legendary = 0
if (!isNumber(user.superior))
user.superior = 0
if (!isNumber(user.pet))
user.pet = 0
//pet
if (!isNumber(user.horse))
user.horse = 0
if (!isNumber(user.cat))
user.cat = 0
if (!isNumber(user.fox))
user.fox = 0
if (!isNumber(user.dog))
user.dog = 0
if (!isNumber(user.robo))
user.robo = 0
if (!isNumber(user.lion))
user.lion = 0
if (!isNumber(user.dragon))
user.dragon = 0
if (!isNumber(user.wolf))
user.wolf = 0
if (!isNumber(user.rhinoceros))
user.rhinoceros = 0
if (!isNumber(user.phonix))
user.phonix = 0
if (!isNumber(user.griffin))
user.griffin = 0
if (!isNumber(user.centaur))
user.centaur = 0
if (!isNumber(user.kyubi))
user.kyubi = 0
//exp pet
if (!isNumber(user.horseexp))
user.horseexp = 0
if (!isNumber(user.catexp))
user.catexp = 0
if (!isNumber(user.foxexp))
user.foxexp = 0
if (!isNumber(user.dogexp))
user.dogexp = 0
if (!isNumber(user.roboxp))
user.roboxp = 0
if (!isNumber(user.lionexp))
user.lionexp = 0
if (!isNumber(user.wolfexp))
user.wolfexp = 0
if (!isNumber(user.rhinocerosexp))
user.rhinocerosexp = 0
if (!isNumber(user.dragonexp))
user.dragonexp = 0
if (!isNumber(user.phonixexp))
user.phonixexp = 0
if (!isNumber(user.griffinexp))
user.griffinexp = 0
if (!isNumber(user.kyubiexp))
user.kyubiexp = 0
if (!isNumber(user.centaurexp))
user.centaurexp = 0
//last feed pet
if (!isNumber(user.horselastfeed))
user.horselastfeed = 0
if (!isNumber(user.catlastfeed))
user.catlastfeed = 0
if (!isNumber(user.foxlastfeed))
user.foxlastfeed = 0
if (!isNumber(user.doglastfeed))
user.doglastfeed = 0
if (!isNumber(user.lionlastfeed))
user.lionlastfeed = 0
if (!isNumber(user.dragonlastfeed))
user.dragonlastfeed = 0
if (!isNumber(user.wolflastfeed))
user.wolflastfeed = 0
if (!isNumber(user.rhinoceroslastfeed))
user.rhinoceroslastfeed = 0
if (!isNumber(user.phonixlastfeed))
user.phonixlastfeed = 0
if (!isNumber(user.griffinlastfeed))
user.griffinlastfeed = 0
if (!isNumber(user.centaurlastfeed))
user.centaurlastfeed = 0
if (!isNumber(user.kyubilastfeed))
user.kyubilastfeed = 0
//toold
if (!isNumber(user.armor))
user.armor = 0
if (!isNumber(user.armordurability))
user.armordurability = 0
if (!isNumber(user.sword))
user.sword = 0
if (!isNumber(user.sworddurability))
user.sworddurability = 0
if (!isNumber(user.pickaxe))
user.pickaxe = 0
if (!isNumber(user.pickaxedurability))
user.pickaxedurability = 0
if (!isNumber(user.fishingrod))
user.fishingrod = 0
if (!isNumber(user.fishingroddurability))
user.fishingroddurability = 0
if (!isNumber(user.bow))
user.bow = 0
if (!isNumber(user.bowdurability))
user.bowdurability = 0
if (!isNumber(user.axe))
user.axe = 0
if (!isNumber(user.axedurability))
user.axedurability = 0
if (!isNumber(user.lastclaim))
user.lastclaim = 0
if (!isNumber(user.lastadventure))
user.lastadventure = 0
if (!isNumber(user.lastfishing))
user.lastfishing = 0
if (!isNumber(user.lastdungeon))
user.lastdungeon = 0
if (!isNumber(user.lastduel))
user.lastduel = 0
if (!isNumber(user.lastmining))
user.lastmining = 0
if (!isNumber(user.lasthunt))
user.lasthunt = 0
if (!isNumber(user.lastweekly))
user.lastweekly = 0
if (!isNumber(user.lastmonthly))
user.lastmonthly = 0
if (!isNumber(user.lastbunga))
user.lastbunga = 0
if (!isNumber(user.lastgrab))
user.lastgrab = 0
if (!isNumber(user.lastgojek))
user.lastgojek = 0
if (!isNumber(user.lastdagang))
user.lastdagang = 0
if (!isNumber(user.lastlumber))
user.lastlumber = 0
//makanan
if (!isNumber(user.ganja))
user.ganja = 0
if (!isNumber(user.bandage))
user.bandage = 0
if (!isNumber(user.soda))
user.soda = 0
if (!isNumber(user.vodka))
user.vodka = 0
if (!isNumber(user.sushi))
user.sushi = 0
if (!isNumber(user.roti))
user.roti = 0
if (!isNumber(user.tumiskangkung))
user.tumiskangkung = 0
if (!isNumber(user.suplabu))
user.suplabu = 0
if (!isNumber(user.kentanggoreng))
user.kentanggoreng = 0
if (!isNumber(user.jagungbakar))
user.jagungbakar = 0
if (!isNumber(user.gadodado))
user.gadogado = 0
if (!isNumber(user.sop))
user.sop = 0
if (!isNumber(user.gulai))
user.gulai = 0
if (!isNumber(user.ayamgoreng))
user.ayamgoreng = 0
if (!isNumber(user.rendang))
user.rendang = 0
if (!isNumber(user.oporayam))
user.oporayam = 0
if (!isNumber(user.steak))
user.steak = 0
if (!isNumber(user.ayambakar))
user.ayambakar = 0
if (!isNumber(user.pepesikan))
user.pepesikan = 0
if (!isNumber(user.babipanggang))
user.babipanggang = 0
//sayuran
if (!isNumber(user.kangkung))
user.kangkung = 0
if (!isNumber(user.wortel))
user.wortel = 0
if (!isNumber(user.tomat))
user.tomat = 0
if (!isNumber(user.brokoli))
user.brokoli = 0
if (!isNumber(user.labu))
user.labu = 0
if (!isNumber(user.kentang))
user.kentang = 0
if (!isNumber(user.jagung))
user.jagung = 0
if (!isNumber(user.bayam))
user.bayam = 0
if (!isNumber(user.kubis))
user.kubis = 0
//seed
if (!isNumber(user.seedkangkung))
user.seedkangkung = 0
if (!isNumber(user.seedwortel))
user.seedwortel = 0
if (!isNumber(user.seedtomat))
user.seedtomat = 0
if (!isNumber(user.seedbrokoli))
user.seedbrokoli = 0
if (!isNumber(user.seedlabu))
user.seedlabu = 0
if (!isNumber(user.seedkentang))
user.seedkentang = 0
if (!isNumber(user.seedjagung))
user.seedjagung = 0
if (!isNumber(user.seedbayam))
user.seedbayam = 0
if (!isNumber(user.seedkubis))
user.seedkubis = 0
//database berburu
if (!isNumber(user.as))
user.as = 0
if (!isNumber(user.paus))
user.paus = 0
if (!isNumber(user.kepiting))
user.kepiting = 0
if (!isNumber(user.gurita))
user.gurita = 0
if (!isNumber(user.cumi))
user.cumi = 0
if (!isNumber(user.buntal))
user.buntal = 0
if (!isNumber(user.dory))
user.dory = 0
if (!isNumber(user.lumba))
user.lumba = 0
if (!isNumber(user.lobster))
user.lobster = 0
if (!isNumber(user.hiu))
user.hiu = 0
if (!isNumber(user.udang))
user.udang = 0
if (!isNumber(user.ikan))
user.ikan = 0
if (!isNumber(user.orca))
user.orca = 0
if (!isNumber(user.banteng))
user.banteng = 0
if (!isNumber(user.harimau))
user.harimau = 0
if (!isNumber(user.gajah))
user.gajah = 0
if (!isNumber(user.kambing))
user.kambing = 0
if (!isNumber(user.panda))
user.panda = 0
if (!isNumber(user.buaya))
user.buaya = 0
if (!isNumber(user.kerbau))
user.kerbau = 0
if (!isNumber(user.sapi))
user.sapi = 0
if (!isNumber(user.monyet))
user.monyet = 0
if (!isNumber(user.babihutan))
user.babihutan = 0
if (!isNumber(user.babi))
user.babi = 0
if (!isNumber(user.ayam))
user.ayam = 0
if (!('premium' in user))
user.premium = false
if (!user.premium) {
if (!isNumber(user.expired))
user.expired = 0
}
if (!('sewa' in user))
user.sewa = false
if (!isNumber(user.limitjoinprem))
user.limitjoinprem = 0
if (!isNumber(user.limitjoinfree))
user.limitjoinfree = 1
if (!('pasangan' in user))
user.pasangan = ''
} else
db.data.users[m.sender] = {
exp: 0,
limit: 10,
lastclaim: 0,
registered: false,
name: m.name,
age: -1,
regTime: -1,
afk: -1,
afkReason: '',
banned: false,
warn: 0,
level: 0,
role: 'Beginner',
autolevelup: true,
money: 0,
bank: 0,
atm: 0,
fullatm: 0,
health: 100,
stamina: 100,
limit: 100,
potion: 10,
trash: 0,
wood: 0,
rock: 0,
brick: 0,
glass: 0,
stick: 0,
string: 0,
//building
fortress: 0,
kastel: 0,
house: 0,
peternakan: 0,
perkebunan: 0,
pertambangan: 0,
//makanan
gulai: 0,
rendang: 0,
oporayam: 0,
steak: 0,
pepesikan: 0,
babipanggang: 0,
sop: 0,
gadogado: 0,
jagungbakar: 0,
kentanggoreng: 0,
suplabu: 0,
tumiskangkung: 0,
ayambakar: 0,
ayamgoreng: 0,
ganja: 0,
bandage: 0,
soda: 0,
vodka: 0,
sushi: 0,
roti: 0,
//sayuran
kangkung: 0,
wortel: 0,
tomat: 0,
brokoli: 0,
labu: 0,
kentang: 0,
jagung: 0,
bayam: 0,
kubis: 0,
//seed
seedkangkung: 0,
seedwortel: 0,
seedtomat: 0,
seedbrokoli: 0,
seedlabu: 0,
seedkentang: 0,
seedjagung: 0,
seedbayam: 0,
seedkubis: 0,
//SDA
emerald: 0,
diamond: 0,
gold: 0,
iron: 0,
coal: 0,
clay: 0,
sand: 0,
upgrader: 0,
//crate
common: 0,
uncommon: 0,
mythic: 0,
legendary: 0,
superior: 0,
pet: 0,
//pet
horse: 0,
horseexp: 0,
cat: 0,
catngexp: 0,
fox: 0,
foxexp: 0,
dog: 0,
dogexp: 0,
horselastfeed: 0,
catlastfeed: 0,
foxlastfeed: 0,
doglastfeed: 0,
rhinoceros: 0,
rhinoceroslastfeed: 0,
rhinocerosexp: 0,
lion: 0,
lionlastfeed: 0,
lionexp: 0,
wolf: 0,
wolflastfeed: 0,
wolfexp: 0,
griffin: 0,
griffinlastfeed: 0,
griffinexp: 0,
dragon: 0,
dragonlastfeed: 0,
dragonexp: 0,
centaur: 0,
centaurlastfeed: 0,
centaurexp: 0,
phonix: 0,
phonixlastfeed: 0,
phonixexp: 0,
//tools
armor: 0,
armordurability: 0,
sword: 0,
sworddurability: 0,
pickaxe: 0,
pickaxedurability: 0,
fishingrod: 0,
fishingroddurability: 0,
bow: 0,
bowdurability: 0,
axe: 0,
axedurability: 0,
lastclaim: 0,
lastadventure: 0,
lastfishing: 0,
lastdungeon: 0,
lastduel: 0,
lastmining: 0,
lasthunt: 0,
lastweekly: 0,
lastmonthly: 0,
lastbunga: 0,
lastgrab: 0,
lastgojek: 0,
lastdagang: 0,
lastlumber: 0,
//hasil berburu
as: 0,
paus: 0,
kepiting: 0,
gurita: 0,
cumi: 0,
buntal: 0,
dory: 0,
lumba: 0,
lobster: 0,
hiu: 0,
udang: 0,
ikan: 0,
orca: 0,
banteng: 0,
harimau: 0,
gajah: 0,
kambing: 0,
panda: 0,
buaya: 0,
kerbau: 0,
sapi: 0,
monyet: 0,
babihutan: 0,
babi: 0,
ayam: 0,
premium: false,
expired: 0,
limitjoinfree: 1,
limitjoinprem: 0,
sewa: false,
pasangan: ''
}
var chat = db.data.chats[m.chat]
if (typeof chat !== 'object')
db.data.chats[m.chat] = {}
if (chat) {
if (!('isBanned' in chat))
chat.isBanned = false
if (!('stiker' in chat))
chat.stiker = false
if (!('simi' in chat))
chat.simi = false
if (!('welcome' in chat))
chat.welcome = false
if (!('detect' in chat))
chat.detect = false
if (!('sWelcome' in chat))
chat.sWelcome = ''
if (!('sBye' in chat))
chat.sBye = ''
if (!('sPromote' in chat))
chat.sPromote = ''
if (!('sDemote' in chat))
chat.sDemote = ''
if (!('delete' in chat))
chat.delete = true
if (!('antiLink' in chat))
chat.antiLink = false
if (!('viewonce' in chat))
chat.viewonce = false
if (!('antiToxic' in chat))
chat.antiToxic = false
if (!('reminder' in chat))
chat.reminder = false
if (!('nofirtex' in chat))
chat.nofirtext = false
if (!('groupexpired' in chat))
chat.groupexpired = false
if (!chat.groupexpired) {
if (!isNumber(chat.expired))
chat.expired = 0
}
} else
db.data.chats[m.chat] = {
isBanned: false,
stiker: false,
simi: false,
welcome: false,
detect: false,
sWelcome: '',
sBye: '',
sPromote: '',
sDemote: '',
delete: true,
antiLink: false,
viewonce: false,
antiToxic: false,
reminder: false,
nofirtex: false,
groupexpired: false,
expired: 0,
}
var settings = db.data.settings[this.user.jid]
if (typeof settings !== 'object') db.data.settings[this.user.jid] = {}
if (settings) {
if (!('self' in settings)) settings.self = false
if (!('autoread' in settings)) settings.autoread = false
if (!('restrict' in settings)) settings.restrict = false
if (!('pconly' in settings)) settings.pconly = false
} else db.data.settings[this.user.jid] = {
self: false,
autoread: false,
restrict: false,
pconly: false
}
} catch (e) {
console.error({
db: e
})
}
if (opts['nyimak'])
return
if (!m.fromMe && opts['self'])
return
if (opts['pconly'] && m.chat.endsWith('g.us'))
return
if (opts['gconly'] && !m.chat.endsWith('g.us'))
return
if (opts['swonly'] && m.chat !== 'status@broadcast')
return
if (m.chat == 'status@broadcast')
return
if (typeof m.text !== 'string')
m.text = ''
var isROwner = [this.decodeJid(this.user.id), ...global.owner.map(([number]) => number)].map(v => v?.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
var isOwner = isROwner || m.fromMe
var settinge = db.data.settings[this.user.jid]
if (!isOwner && settinge.self)
return
var isMods = isOwner || global.mods.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
var isPrems = isROwner || global.prems.map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender) || db.data.users[m.sender].premium
if (opts['queque'] && m.text && !m.fromMe && !(isMods || isPrems)) {
var id = m.id
this.msgqueque.add(id)
await this.msgqueque.waitQueue(id)
}
if (m.isBaileys)
return
m.exp += Math.ceil(Math.random() * 10)
var usedPrefix
var _user = db.data?.users?.[m.sender]
var groupMetadata = (m.isGroup ? await Connection.store.fetchGroupMetadata(m.chat, this.groupMetadata) : {}) || {}
var participants = (m.isGroup ? groupMetadata.participants : []) || []
var user = (m.isGroup ? participants.find(u => this.decodeJid(u.id) === m.sender) : {}) || {} // User Data
var bot = (m.isGroup ? participants.find(u => this.decodeJid(u.id) == this.user.jid) : {}) || {} // Your Data
var isRAdmin = user?.admin == 'superadmin' || false
var isAdmin = isRAdmin || user?.admin == 'admin' || false // Is User Admin?
var isBotAdmin = bot?.admin || false // Are you Admin?
var enable = db.data.chats[m.chat]
var users = db.data.users[m.sender]
var stp = m.messageStubType ? WAMessageStubType[m.messageStubType] : ''
var settinges = db.data.settings[this.user.jid]
if (settinges.restrict && enable.nofirtek && !m.fromMe && m.isGroup && isBotAdmin) {
if (!m.fromMe && m.text.match(/(৭৭৭|๒๒๒|؋.ᄻ.ྜྷ.ᇸ.ྙ|๖ۣۜy๖ۣۜF๖ۣۜr๖|๑๑๑|৭৭৭৭৭৭৭৭|๑๑๑๑๑๑๑๑|ผิดุท้่เึางืผิดุท้่เึางื|๒๒๒๒๒๒๒๒|ผิดุท้่เึางืผิดุท้่เึางื)/gi) && m.text.length >= 66255 || stp == "OVERSIZED") {
conn.reply(m.chat, " ngapain ngirim firtex bang😅☝", m)
await delay(2000)
//conn.reply(m.chat, "kamu harus di kick sih bang", false)
//await delay(2000)
conn.groupParticipantsUpdate(m.chat, [m.sender], 'remove')
}
}
if (settinges.restrict && enable.antiToxic && !m.fromMe && m.isGroup && !isAdmin && !isOwner && isBotAdmin) {
if (!m.fromMe && m.text.match(/(asadebangsat|Dakjal|anak setan|ngntd|ngentot|jancuk|kuntul|babi|kampang|kenthu|tempik|kimak|patek|kondom|bugil|seks|sex|sexy|tai|Tai|jancok|jembut|bokep|xnxx|xxx|xvideos|xvid|jilboob|seksi|Anjing|Babi|Kunyuk|Bajingan|Bangsat|Kampret|Kontol|Memek|Ngentot|Pentil|Perek|Pepek|Pecun|Bencong|Banci|Maho|Sinting|Lonte|Hencet|Taptei|Kampang|Keparat|Bejad|Gembel|Brengsek|Taek|Anjrit|Fuck|Tetek|Ngulum|Jembut|Totong|Kolop|Pukimak|bacot|Bacot|Juancok|asw|Bodat|Heang|Jancuk|Burit|Titit|Nenen|Bejat|Silit|Sempak|Fucking|Asshole|Bitch|Penis|Vagina|Klitoris|Kelentit|Borjong|Dancuk|anjg|Anjg|Bcd|bct|Bgsd|Bgst|bgsd|bgst|ajg|tolol|Tolol|Pantek|kondom|Teho|Bejat|Pantat|Bagudung|Babami|Kanciang|Bungul|Idiot|Kimak|Henceut|Kacuk|pukimak|goblok|bodo|Pussy|ngewe|Dick|Damn|Assu|tempek|celeng|shit|jingan|ngentot anjing ngewe|Dont use unlisted command|kontol|ngentod|colmek|alat vital|bangkinang|tits|tetek|coli|ngocok peli|ANJING!!!|kntl|ngtd|anying|amjin|sikontol|bang bros|ngocok|toket|A n j i n g|Tahi|anjass|biadap|bbii|biadab|Tomlol|dongo|dungu|anjk|bcot|BURUNG KECIL JAN SOK KERAS:V|nude|p3n1s|p3nis)/gi)) {
await conn.sendPresenceUpdate('composing', m.chat)
var cBad = db.data.users[m.sender].warn += 1
var warning = db.data.users[m.sender].warn
if (warning >= 6) {
conn.reply(m.chat, `*Over badword!*\nyou will be removed after 3 second`, m).then(() => {
setTimeout(() => {
conn.groupParticipantsUpdate(m.chat, [m.sender], 'remove')
}, 2000)
db.data.users[m.sender].warn = 0
})
} else {
conn.reply(m.chat, `*⺀ BADWORD DETECTOR ⺀*\n\n*Kamu mendapat peringatan : [ ${warning} / 6 ]*\n\n*Jangan berkata kasar atau menggunakan kalimat sampah sebanyak 6x atau kamu akan dikeluarkan dari grup secara otomatis.*\n\n▌│█║▌║▌║║▌║▌║█│▌▌│█║`, m)
}
}
}
if (!m.fromMe && m.text.match(/(makasi|thanks|thank|terima kasih|suwon)/gi)) {
conn.reply(m.chat, "hooh😅👆", false)
}
var ___dirname = path.join(path.dirname(fileURLToPath(
import.meta.url)), './plugins')
for (var name in plugins) {
var plugin = plugins[name]
if (!plugin)
continue
if (plugin.disabled)
continue
var __filename = join(___dirname, name)
if (typeof plugin.all === 'function') {
try {
await plugin.all.call(this, m, {
chatUpdate,
__dirname: ___dirname,
__filename
})
} catch (e) {
// if (typeof e === 'string') continue
console.error(e)
for (var [jid] of global.owner.filter(([number, _, isDeveloper]) => isDeveloper && number)) {
var data = (await this.onWhatsApp(jid))[0] || {}
if (data.exists)
m.reply(`*Plugin:* ${name}\n*Sender:* ${m.sender}\n*Chat:* ${m.chat}\n*Command:* ${m.text}\n\n\`\`\`${format(e)}\`\`\``.trim(), data.jid)
}
}
}
/*if (!opts['restrict'])
if (plugin.tags && plugin.tags.includes('admin')) {
// global.dfail('restrict', m, this)
continue
}*/
var strict = db.data.settings[this.user.jid].restrict
if (!strict) {
db.data.chats[m.chat].antiToxic = false
db.data.chats[m.chat].antiLink = false
if (plugin.tags && plugin.tags.includes('admin')) {
// global.dfail('restrict', m, this)
continue
}
}
var str2Regex = str => str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
var _prefix = plugin.customPrefix ? plugin.customPrefix : this.prefix ? this.prefix : global.prefix
var match = (_prefix instanceof RegExp ? // RegExp Mode?
[
[_prefix.exec(m.text), _prefix]
] :
Array.isArray(_prefix) ? // Array?
_prefix.map(p => {
var re = p instanceof RegExp ? // RegExp in Array?
p :
new RegExp(str2Regex(p))
return [re.exec(m.text), re]
}) :
typeof _prefix === 'string' ? // String?
[
[new RegExp(str2Regex(_prefix)).exec(m.text), new RegExp(str2Regex(_prefix))]
] : [
[
[], new RegExp
]
]
).find(p => p[1])
if (typeof plugin.before === 'function') {
if (await plugin.before.call(this, m, {
match,
conn: this,
participants,
groupMetadata,
user,
bot,
isROwner,
isOwner,
isRAdmin,
isAdmin,
isBotAdmin,
isPrems,
chatUpdate,
__dirname: ___dirname,
__filename
}))
continue
}
if (typeof plugin !== 'function')
continue
if ((usedPrefix = (match[0] || '')[0])) {
var noPrefix = m.text.replace(usedPrefix, '')
var [command, ...args] = noPrefix.trim().split` `.filter(v => v)
args = args || []
var _args = noPrefix.trim().split` `.slice(1)
var text = _args.join` `
command = (command || '').toLowerCase()
var fail = plugin.fail || global.dfail // When failed
var isAccept = plugin.command instanceof RegExp ? // RegExp Mode?
plugin.command.test(command) :
Array.isArray(plugin.command) ? // Array?
plugin.command.some(cmd => cmd instanceof RegExp ? // RegExp in Array?
cmd.test(command) :
cmd === command
) :
typeof plugin.command === 'string' ? // String?
plugin.command === command :
false
if (!isAccept)
continue
m.plugin = name
if (m.chat in db.data.chats || m.sender in db.data.users || this.user.jid in db.data.settings) {
var chat = db.data.chats[m.chat]
var user = db.data.users[m.sender]
var settings = db.data.settings[this.user.jid]
if (!['owner-unbanchat.cjs', 'group-info.cjs', 'owner-exec.cjs', 'owner-exec2.cjs', 'tool-devare.cjs', 'info-runtime.cjs', 'exp-ceksn.cjs', 'exp-daftar.cjs', 'exp-my.cjs', 'exp-unreg.cjs', 'group-link.cjs', 'enable.cjs', 'user-profile.cjs'].includes(name) && chat?.isBanned)
return // Except this
if (!['owner-unbanuser.cjs', 'user-profile.cjs', 'info-runtime.cjs'].includes(name) && user?.banned)
return
if (!['owner-unbanchat.cjs', 'user-profile.cjs', 'info-runtime.cjs', 'group-info.cjs', 'enable.cjs', 'owner-exec.cjs', 'owner-exec2.cjs'].includes(name) && settings?.pconly && m.isGroup && !isOwner)
return
}
if (plugin.rowner && plugin.owner && !(isROwner || isOwner)) { // Both Owner
fail('owner', m, this)
continue
}
if (plugin.rowner && !isROwner) { // Real Owner
fail('rowner', m, this)
continue
}
if (plugin.owner && !isOwner) { // Number Owner
fail('owner', m, this)
continue
}
if (plugin.mods && !isMods) { // Moderator
fail('mods', m, this)
continue
}
if (plugin.premium && !isPrems) { // Premium
fail('premium', m, this)
continue
}
if (plugin.group && !m.isGroup) { // Group Only
fail('group', m, this)
continue
} else if (plugin.botAdmin && !isBotAdmin) { // You Admin
fail('botAdmin', m, this)
continue
} else if (plugin.admin && !isAdmin) { // User Admin
fail('admin', m, this)
continue
}
if (plugin.private && m.isGroup) { // Private Chat Only
fail('private', m, this)
continue
}
if (plugin.register == true && _user.registered == false) { // Butuh daftar?
fail('unreg', m, this)
continue
}
m.isCommand = true
var xp = 'exp' in plugin ? parseInt(plugin.exp) : 17 // XP Earning per command
/* if (xp > 200)
m.reply('Ngecit -_-') // Hehehe
else*/
m.exp += xp
if (!isPrems && plugin.limit && db.data.users[m.sender].limit < plugin.limit * 1) {
this.reply(m.chat, `Limit anda habis, silahkan beli melalui *${usedPrefix}buy\n*atau tunggu besok*`, m)
continue // Limit habis
}
if (plugin.level > _user.level) {
this.reply(m.chat, `diperlukan level ${plugin.level} untuk menggunakan perintah ini. Level kamu ${_user.level}`, m)
continue // If the level has not been reached
}
var extra = {
match,
usedPrefix,
noPrefix,
_args,
args,
command,
text,
conn: this,
participants,
groupMetadata,
user,
bot,
isROwner,
isOwner,
isRAdmin,