-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgroupe.js
988 lines (650 loc) · 29.2 KB
/
groupe.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
const { zokou } = require("../framework/zokou")
//const { getGroupe } = require("../bdd/groupe")
const { Sticker, StickerTypes } = require('wa-sticker-formatter');
const {ajouterOuMettreAJourJid,mettreAJourAction,verifierEtatJid} = require("../bdd/antilien")
const {atbajouterOuMettreAJourJid,atbverifierEtatJid} = require("../bdd/antibot")
const { search, download } = require("aptoide-scraper");
const fs = require("fs-extra");
const conf = require("../set");
const { default: axios } = require('axios');
//const { uploadImageToImgur } = require('../framework/imgur');
zokou({ nomCom: "tagall", categorie: 'Group', reaction: "📣" }, async (dest, zk, commandeOptions) => {
const { ms, repondre, arg, verifGroupe, nomGroupe, infosGroupe, nomAuteurMessage, verifAdmin, superUser } = commandeOptions
if (!verifGroupe) { repondre("✋🏿 ✋🏿this command is reserved for groups ❌"); return; }
if (!arg || arg === ' ') {
mess = 'Aucun Message'
} else {
mess = arg.join(' ')
} ;
let membresGroupe = verifGroupe ? await infosGroupe.participants : ""
var tag = "";
tag += `========================\n
🌟 *𝐀𝐍𝐘𝐖𝐀𝐘-𝐌𝐃* 🌟
========================\n
👥 Group : ${nomGroupe} 🚀
👤 Autor : *${nomAuteurMessage}* 👋
📜 Message : *${mess}* 📝
========================\n
\n
` ;
let emoji = ['🦴', '👀', '😮💨', '❌', '✔️', '😇', '⚙️', '🔧', '🎊', '😡', '🙏🏿', '⛔️', '$','😟','🥵','🐅']
let random = Math.floor(Math.random() * (emoji.length - 1))
for (const membre of membresGroupe) {
tag += `${emoji[random]} @${membre.id.split("@")[0]}\n`
}
if (verifAdmin || superUser) {
zk.sendMessage(dest, { text: tag, mentions: membresGroupe.map((i) => i.id) }, { quoted: ms })
} else { repondre('command reserved for admins')}
});
zokou({ nomCom: "link", categorie: 'Group', reaction: "🙋" }, async (dest, zk, commandeOptions) => {
const { repondre, nomGroupe, nomAuteurMessage, verifGroupe } = commandeOptions;
if (!verifGroupe) { repondre("wait bro , you want the link to my dm?"); return; };
var link = await zk.groupInviteCode(dest)
var lien = `https://chat.whatsapp.com/${link}`;
let mess = `hello ${nomAuteurMessage} , here is the group link for ${nomGroupe} \n
Grp link :${lien} \n\n★𝙿𝚘𝚠𝚎𝚛𝚎𝚍 𝚋𝚢 anyway team`
repondre(mess)
});
/** *nommer un membre comme admin */
zokou({ nomCom: "promote", categorie: 'Group', reaction: "👨🏿💼" }, async (dest, zk, commandeOptions) => {
let { repondre, msgRepondu, infosGroupe, auteurMsgRepondu, verifGroupe, auteurMessage, superUser, idBot } = commandeOptions;
let membresGroupe = verifGroupe ? await infosGroupe.participants : ""
if (!verifGroupe) { return repondre("For groups only"); }
const verifMember = (user) => {
for (const m of membresGroupe) {
if (m.id !== user) {
continue;
}
else { return true }
//membre=//(m.id==auteurMsgRepondu? return true) :false;
}
}
const memberAdmin = (membresGroupe) => {
let admin = [];
for (m of membresGroupe) {
if (m.admin == null) continue;
admin.push(m.id);
}
// else{admin= false;}
return admin;
}
const a = verifGroupe ? memberAdmin(membresGroupe) : '';
let admin = verifGroupe ? a.includes(auteurMsgRepondu) : false;
let membre = verifMember(auteurMsgRepondu)
let autAdmin = verifGroupe ? a.includes(auteurMessage) : false;
zkad = verifGroupe ? a.includes(idBot) : false;
try {
// repondre(verifZokouAdmin)
if (autAdmin || superUser) {
if (msgRepondu) {
if (zkad) {
if (membre) {
if (admin == false) {
var txt = `🎊🎊🎊 @${auteurMsgRepondu.split("@")[0]} rose in rank.\n
he/she has been named group administrator.`
await zk.groupParticipantsUpdate(dest, [auteurMsgRepondu], "promote");
zk.sendMessage(dest, { text: txt, mentions: [auteurMsgRepondu] })
} else { return repondre("This member is already an administrator of the group.") }
} else { return repondre("This user is not part of the group."); }
}
else { return repondre("Sorry, I cannot perform this action because I am not an administrator of the group.") }
} else { repondre("please tag the member to be nominated"); }
} else { return repondre("Sorry I cannot perform this action because you are not an administrator of the group.") }
} catch (e) { repondre("oups " + e) }
})
//fin nommer
/** ***demettre */
zokou({ nomCom: "demote", categorie: 'Group', reaction: "👨🏿💼" }, async (dest, zk, commandeOptions) => {
let { repondre, msgRepondu, infosGroupe, auteurMsgRepondu, verifGroupe, auteurMessage, superUser, idBot } = commandeOptions;
let membresGroupe = verifGroupe ? await infosGroupe.participants : ""
if (!verifGroupe) { return repondre("For groups only"); }
const verifMember = (user) => {
for (const m of membresGroupe) {
if (m.id !== user) {
continue;
}
else { return true }
//membre=//(m.id==auteurMsgRepondu? return true) :false;
}
}
const memberAdmin = (membresGroupe) => {
let admin = [];
for (m of membresGroupe) {
if (m.admin == null) continue;
admin.push(m.id);
}
// else{admin= false;}
return admin;
}
const a = verifGroupe ? memberAdmin(membresGroupe) : '';
let admin = verifGroupe ? a.includes(auteurMsgRepondu) : false;
let membre = verifMember(auteurMsgRepondu)
let autAdmin = verifGroupe ? a.includes(auteurMessage) : false;
zkad = verifGroupe ? a.includes(idBot) : false;
try {
// repondre(verifZokouAdmin)
if (autAdmin || superUser) {
if (msgRepondu) {
if (zkad) {
if (membre) {
if (admin == false) {
repondre("This member is not a group administrator.")
} else {
var txt = `@${auteurMsgRepondu.split("@")[0]} was removed from his position as a group administrator\n`
await zk.groupParticipantsUpdate(dest, [auteurMsgRepondu], "demote");
zk.sendMessage(dest, { text: txt, mentions: [auteurMsgRepondu] })
}
} else { return repondre("This user is not part of the group."); }
}
else { return repondre("Sorry I cannot perform this action because I am not an administrator of the group.") }
} else { repondre("please tag the member to be removed"); }
} else { return repondre("Sorry I cannot perform this action because you are not an administrator of the group.") }
} catch (e) { repondre("oups " + e) }
})
/** ***fin démettre**** **/
/** **retirer** */
zokou({ nomCom: "remove", categorie: 'Group', reaction: "👨🏿💼" }, async (dest, zk, commandeOptions) => {
let { repondre, msgRepondu, infosGroupe, auteurMsgRepondu, verifGroupe, nomAuteurMessage, auteurMessage, superUser, idBot } = commandeOptions;
let membresGroupe = verifGroupe ? await infosGroupe.participants : ""
if (!verifGroupe) { return repondre("for groups only"); }
const verifMember = (user) => {
for (const m of membresGroupe) {
if (m.id !== user) {
continue;
}
else { return true }
//membre=//(m.id==auteurMsgRepondu? return true) :false;
}
}
const memberAdmin = (membresGroupe) => {
let admin = [];
for (m of membresGroupe) {
if (m.admin == null) continue;
admin.push(m.id);
}
// else{admin= false;}
return admin;
}
const a = verifGroupe ? memberAdmin(membresGroupe) : '';
let admin = verifGroupe ? a.includes(auteurMsgRepondu) : false;
let membre = verifMember(auteurMsgRepondu)
let autAdmin = verifGroupe ? a.includes(auteurMessage) : false;
zkad = verifGroupe ? a.includes(idBot) : false;
try {
// repondre(verifZokouAdmin)
if (autAdmin || superUser) {
if (msgRepondu) {
if (zkad) {
if (membre) {
if (admin == false) {
const gifLink = "https://raw.githubusercontent.com/djalega8000/Zokou-MD/main/media/remover.gif"
var sticker = new Sticker(gifLink, {
pack: 'Anyway-Md', // The pack name
author: nomAuteurMessage, // The author name
type: StickerTypes.FULL, // The sticker type
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 50, // The quality of the output file
background: '#000000'
});
await sticker.toFile("st.webp")
var txt = `@${auteurMsgRepondu.split("@")[0]} was removed from the group.\n`
/* zk.sendMessage(dest, { sticker: fs.readFileSync("st.webp") }, { quoted: ms.message.extendedTextMessage.contextInfo.stanzaId})*/
await zk.groupParticipantsUpdate(dest, [auteurMsgRepondu], "remove");
zk.sendMessage(dest, { text: txt, mentions: [auteurMsgRepondu] })
} else { repondre("This member cannot be removed because he is an administrator of the group.") }
} else { return repondre("This user is not part of the group."); }
}
else { return repondre("Sorry, I cannot perform this action because I am not an administrator of the group.") }
} else { repondre("please tag the member to be removed"); }
} else { return repondre("Sorry I cannot perform this action because you are not an administrator of the group .") }
} catch (e) { repondre("oups " + e) }
})
/** *****fin retirer */
zokou({ nomCom: "del", categorie: 'Group',reaction:"🧹" }, async (dest, zk, commandeOptions) => {
const { ms, repondre, verifGroupe,auteurMsgRepondu,idBot, msgRepondu, verifAdmin, superUser} = commandeOptions;
if (!msgRepondu) {
repondre("Please mention the message to delete.");
return;
}
if(superUser && auteurMsgRepondu==idBot )
{
if(auteurMsgRepondu==idBot)
{
const key={
remoteJid:dest,
fromMe: true,
id: ms.message.extendedTextMessage.contextInfo.stanzaId,
}
await zk.sendMessage(dest,{delete:key});return;
}
}
if(verifGroupe)
{
if(verifAdmin || superUser)
{
try{
const key= {
remoteJid : dest,
id : ms.message.extendedTextMessage.contextInfo.stanzaId ,
fromMe : false,
participant : ms.message.extendedTextMessage.contextInfo.participant
}
await zk.sendMessage(dest,{delete:key});return;
}catch(e){repondre( "I need admin rights.")}
}else{repondre("Sorry, you are not an administrator of the group.")}
}
});
zokou({ nomCom: "info", categorie: 'Group' }, async (dest, zk, commandeOptions) => {
const { ms, repondre, verifGroupe } = commandeOptions;
if (!verifGroupe) { repondre("order reserved for the group only"); return };
try { ppgroup = await zk.profilePictureUrl(dest ,'image') ; } catch { ppgroup = conf.IMAGE_MENU}
const info = await zk.groupMetadata(dest)
/*console.log(metadata.id + ", title: " + metadata.subject + ", description: " + metadata.desc)*/
let mess = {
image: { url: ppgroup },
caption: `*━━━━『Group Info』━━━━*\n\n*🎐Name:* ${info.subject}\n\n*🔩Group's ID:* ${dest}\n\n*🔍Desc:* \n\n${info.desc}`
}
zk.sendMessage(dest, mess, { quoted: ms })
});
//------------------------------------antilien-------------------------------
zokou({ nomCom: "antilink", categorie: 'Group', reaction: "🔗" }, async (dest, zk, commandeOptions) => {
var { repondre, arg, verifGroupe, superUser, verifAdmin } = commandeOptions;
if (!verifGroupe) {
return repondre("*for groups only*");
}
if( superUser || verifAdmin) {
const enetatoui = await verifierEtatJid(dest)
try {
if (!arg || !arg[0] || arg === ' ') { repondre("antilink on to activate the anti-link feature\nantilink off to deactivate the anti-link feature\nantilink action/remove to directly remove the link without notice\nantilink action/warn to give warnings\nantilink action/delete to remove the link without any sanctions\n\nPlease note that by default, the anti-link feature is set to delete.") ; return};
if(arg[0] === 'on') {
if(enetatoui ) { repondre("the antilink is already activated for this group")
} else {
await ajouterOuMettreAJourJid(dest,"oui");
repondre("the antilink is activated successfully") }
} else if (arg[0] === "off") {
if (enetatoui) {
await ajouterOuMettreAJourJid(dest , "non");
repondre("The antilink has been successfully deactivated");
} else {
repondre("antilink is not activated for this group");
}
} else if (arg.join('').split("/")[0] === 'action') {
let action = (arg.join('').split("/")[1]).toLowerCase() ;
if ( action == 'remove' || action == 'warn' || action == 'delete' ) {
await mettreAJourAction(dest,action);
repondre(`The anti-link action has been updated to ${arg.join('').split("/")[1]}`);
} else {
repondre("The only actions available are warn, remove, and delete") ;
}
} else repondre("antilink on to activate the anti-link feature\nantilink off to deactivate the anti-link feature\nantilink action/remove to directly remove the link without notice\nantilink action/warn to give warnings\nantilink action/delete to remove the link without any sanctions\n\nPlease note that by default, the anti-link feature is set to delete.")
} catch (error) {
repondre(error)
}
} else { repondre('You are not entitled to this order') ;
}
});
//------------------------------------antibot-------------------------------
zokou({ nomCom: "antibot", categorie: 'Group', reaction: "😬" }, async (dest, zk, commandeOptions) => {
var { repondre, arg, verifGroupe, superUser, verifAdmin } = commandeOptions;
if (!verifGroupe) {
return repondre("*for groups only*");
}
if( superUser || verifAdmin) {
const enetatoui = await atbverifierEtatJid(dest)
try {
if (!arg || !arg[0] || arg === ' ') { repondre('antibot on to activate the anti-bot feature\nantibot off to deactivate the antibot feature\nantibot action/remove to directly remove the bot without notice\nantibot action/warn to give warnings\nantilink action/delete to remove the bot message without any sanctions\n\nPlease note that by default, the anti-bot feature is set to delete.') ; return};
if(arg[0] === 'on') {
if(enetatoui ) { repondre("the antibot is already activated for this group")
} else {
await atbajouterOuMettreAJourJid(dest,"oui");
repondre("the antibot is successfully activated") }
} else if (arg[0] === "off") {
if (enetatoui) {
await atbajouterOuMettreAJourJid(dest , "non");
repondre("The antibot has been successfully deactivated");
} else {
repondre("antibot is not activated for this group");
}
} else if (arg.join('').split("/")[0] === 'action') {
let action = (arg.join('').split("/")[1]).toLowerCase() ;
if ( action == 'remove' || action == 'warn' || action == 'delete' ) {
await mettreAJourAction(dest,action);
repondre(`The anti-bot action has been updated to ${arg.join('').split("/")[1]}`);
} else {
repondre("The only actions available are warn, remove, and delete") ;
}
} else {
repondre('antibot on to activate the anti-bot feature\nantibot off to deactivate the antibot feature\nantibot action/remove to directly remove the bot without notice\nantibot action/warn to give warnings\nantilink action/delete to remove the bot message without any sanctions\n\nPlease note that by default, the anti-bot feature is set to delete.') ;
}
} catch (error) {
repondre(error)
}
} else { repondre('You are not entitled to this order') ;
}
});
//----------------------------------------------------------------------------
zokou({ nomCom: "group", categorie: 'Group' }, async (dest, zk, commandeOptions) => {
const { repondre, verifGroupe, verifAdmin, superUser, arg } = commandeOptions;
if (!verifGroupe) { repondre("order reserved for group only"); return };
if (superUser || verifAdmin) {
if (!arg[0]) { repondre('Instructions:\n\nType group open or close'); return; }
const option = arg.join(' ')
switch (option) {
case "open":
await zk.groupSettingUpdate(dest, 'not_announcement')
repondre('group open')
break;
case "close":
await zk.groupSettingUpdate(dest, 'announcement');
repondre('Group close successfully');
break;
default: repondre("Please don't invent an option")
}
} else {
repondre("order reserved for the administratorr");
return;
}
});
zokou({ nomCom: "left", categorie: "Mods" }, async (dest, zk, commandeOptions) => {
const { repondre, verifGroupe, superUser } = commandeOptions;
if (!verifGroupe) { repondre("order reserved for group only"); return };
if (!superUser) {
repondre("command reserved for the bot owner");
return;
}
await repondre('sayonnara') ;
zk.groupLeave(dest)
});
zokou({ nomCom: "gname", categorie: 'Group' }, async (dest, zk, commandeOptions) => {
const { arg, repondre, verifAdmin } = commandeOptions;
if (!verifAdmin) {
repondre("order reserved for administrators of the group");
return;
};
if (!arg[0]) {
repondre("Please enter the group name");
return;
};
const nom = arg.join(' ')
await zk.groupUpdateSubject(dest, nom);
repondre(`group name refresh: *${nom}*`)
}) ;
zokou({ nomCom: "gdesc", categorie: 'Group' }, async (dest, zk, commandeOptions) => {
const { arg, repondre, verifAdmin } = commandeOptions;
if (!verifAdmin) {
repondre("order reserved for administrators of the group");
return;
};
if (!arg[0]) {
repondre("Please enter the group description");
return;
};
const nom = arg.join(' ')
await zk.groupUpdateDescription(dest, nom);
repondre(`group description update: *${nom}*`)
}) ;
zokou({ nomCom: "gpp", categorie: 'Group' }, async (dest, zk, commandeOptions) => {
const { repondre, msgRepondu, verifAdmin } = commandeOptions;
if (!verifAdmin) {
repondre("order reserved for administrators of the group");
return;
};
if (msgRepondu.imageMessage) {
const pp = await zk.downloadAndSaveMediaMessage(msgRepondu.imageMessage) ;
await zk.updateProfilePicture(dest, { url: pp })
.then( () => {
zk.sendMessage(dest,{text:"Group pfp changed"})
fs.unlinkSync(pp)
}).catch(() => zk.sendMessage(dest,{text:err})
)
} else {
repondre('Please mention an image')
}
});
/////////////
zokou({nomCom:"hidetag",categorie:'Group',reaction:"🎤"},async(dest,zk,commandeOptions)=>{
const {repondre,msgRepondu,verifGroupe,arg ,verifAdmin , superUser}=commandeOptions;
if(!verifGroupe) { repondre('This command is only allowed in groups.')} ;
if (verifAdmin || superUser) {
let metadata = await zk.groupMetadata(dest) ;
//console.log(metadata.participants)
let tag = [] ;
for (const participant of metadata.participants ) {
tag.push(participant.id) ;
}
//console.log(tag)
if(msgRepondu) {
console.log(msgRepondu)
let msg ;
if (msgRepondu.imageMessage) {
let media = await zk.downloadAndSaveMediaMessage(msgRepondu.imageMessage) ;
// console.log(msgRepondu) ;
msg = {
image : { url : media } ,
caption : msgRepondu.imageMessage.caption,
mentions : tag
}
} else if (msgRepondu.videoMessage) {
let media = await zk.downloadAndSaveMediaMessage(msgRepondu.videoMessage) ;
msg = {
video : { url : media } ,
caption : msgRepondu.videoMessage.caption,
mentions : tag
}
} else if (msgRepondu.audioMessage) {
let media = await zk.downloadAndSaveMediaMessage(msgRepondu.audioMessage) ;
msg = {
audio : { url : media } ,
mimetype:'audio/mp4',
mentions : tag
}
} else if (msgRepondu.stickerMessage) {
let media = await zk.downloadAndSaveMediaMessage(msgRepondu.stickerMessage)
let stickerMess = new Sticker(media, {
pack: 'Bmw-mdtag',
type: StickerTypes.CROPPED,
categories: ["🤩", "🎉"],
id: "12345",
quality: 70,
background: "transparent",
});
const stickerBuffer2 = await stickerMess.toBuffer();
msg = { sticker: stickerBuffer2 , mentions : tag}
} else {
msg = {
text : msgRepondu.conversation,
mentions : tag
}
}
zk.sendMessage(dest,msg)
} else {
if(!arg || !arg[0]) { repondre('Enter the text to announce or mention the message to announce');
; return} ;
zk.sendMessage(
dest,
{
text : arg.join(' ') ,
mentions : tag
}
)
}
} else {
repondre('Command reserved for administrators.')
}
});
zokou({ nomCom: "apk", reaction: "✨", categorie: "Recherche" }, async (dest, zk, commandeOptions) => {
const { repondre, arg, ms } = commandeOptions;
try {
const appName = arg.join(' ');
if (!appName) {
return repondre("*Enter the name of the application to search for*");
}
const searchResults = await search(appName);
if (searchResults.length === 0) {
return repondre("*can't find application, please enter another name*");
}
const appData = await download(searchResults[0].id);
const fileSize = parseInt(appData.size);
if (fileSize > 300) {
return repondre("The file exceeds 300 MB, unable to download.");
}
const downloadLink = appData.dllink;
const captionText =
"『 *Bmw-Md Application* 』\n\n*Name :* " + appData.name +
"\n*Id :* " + appData["package"] +
"\n*Last Update :* " + appData.lastup +
"\n*Size :* " + appData.size +
"\n";
const apkFileName = (appData?.["name"] || "Downloader") + ".apk";
const filePath = apkFileName;
const response = await axios.get(downloadLink, { 'responseType': "stream" });
const fileWriter = fs.createWriteStream(filePath);
response.data.pipe(fileWriter);
await new Promise((resolve, reject) => {
fileWriter.on('finish', resolve);
fileWriter.on("error", reject);
});
const documentMessage = {
'document': fs.readFileSync(filePath),
'mimetype': 'application/vnd.android.package-archive',
'fileName': apkFileName
};
// Utilisation d'une seule méthode sendMessage pour envoyer l'image et le document
zk.sendMessage(dest, { image: { url: appData.icon }, caption: captionText }, { quoted: ms });
zk.sendMessage(dest, documentMessage, { quoted: ms });
// Supprimer le fichier après envoi
fs.unlinkSync(filePath);
} catch (error) {
console.error('Erreur lors du traitement de la commande apk:', error);
repondre("*Error during apk command processing*");
}
});
/******************************* automute && autoummute ***************************/
const cron = require(`../bdd/cron`) ;
zokou({
nomCom : 'automute',
categorie : 'Group'
} , async (dest,zk,commandeOptions) => {
const {arg , repondre , verifAdmin } = commandeOptions ;
if (!verifAdmin) { repondre('You are not an administrator of the group') ; return}
group_cron = await cron.getCronById(dest) ;
if (!arg || arg.length == 0) {
let state ;
if (group_cron == null || group_cron.mute_at == null) {
state = "No time set for automatic mute"
} else {
state = `The group will be muted at ${(group_cron.mute_at).split(':')[0]} ${(group_cron.mute_at).split(':')[1]}`
}
let msg = `* *State:* ${state}
* *Instructions:* To activate automatic mute, add the minute and hour after the command separated by ':'
Example automute 9:30
* To delete the automatic mute, use the command *automute del*`
repondre(msg) ;
return ;
} else {
let texte = arg.join(' ')
if (texte.toLowerCase() === `del` ) {
if (group_cron == null) {
repondre('No cronometrage is active') ;
} else {
await cron.delCron(dest) ;
repondre("The automatic mute has been removed; restart to apply changes")
.then(() => {
exec("pm2 restart all");
}) ;
}
} else if (texte.includes(':')) {
//let { hr , min } = texte.split(':') ;
await cron.addCron(dest,"mute_at",texte) ;
repondre(`Setting up automatic mute for ${texte} ; restart to apply changes`)
.then(() => {
exec("pm2 restart all");
}) ;
} else {
repondre('Please enter a valid time with hour and minute separated by :') ;
}
}
});
zokou({
nomCom : 'autounmute',
categorie : 'Group'
} , async (dest,zk,commandeOptions) => {
const {arg , repondre , verifAdmin } = commandeOptions ;
if (!verifAdmin) { repondre('You are not an administrator of the group') ; return}
group_cron = await cron.getCronById(dest) ;
if (!arg || arg.length == 0) {
let state ;
if (group_cron == null || group_cron.unmute_at == null) {
state = "No time set for autounmute" ;
} else {
state = `The group will be un-muted at ${(group_cron.unmute_at).split(':')[0]}H ${(group_cron.unmute_at).split(':')[1]}`
}
let msg = `* *State:* ${state}
* *Instructions:* To activate autounmute, add the minute and hour after the command separated by ':'
Example autounmute 7:30
* To delete autounmute, use the command *autounmute del*`
repondre(msg) ;
return ;
} else {
let texte = arg.join(' ')
if (texte.toLowerCase() === `del` ) {
if (group_cron == null) {
repondre('No cronometrage has been activated') ;
} else {
await cron.delCron(dest) ;
repondre("The autounmute has been removed; restart to apply the changes")
.then(() => {
exec("pm2 restart all");
}) ;
}
} else if (texte.includes(':')) {
await cron.addCron(dest,"unmute_at",texte) ;
repondre(`Setting up autounmute for ${texte}; restart to apply the changes`)
.then(() => {
exec("pm2 restart all");
}) ;
} else {
repondre('Please enter a valid time with hour and minute separated by :') ;
}
}
});
zokou({
nomCom : 'fkick',
categorie : 'Group'
} , async (dest,zk,commandeOptions) => {
const {arg , repondre , verifAdmin , superUser , verifZokouAdmin } = commandeOptions ;
if (verifAdmin || superUser) {
if(!verifZokouAdmin){ repondre('You need administrative rights to perform this command') ; return ;}
if (!arg || arg.length == 0) { repondre('Please enter the country code whose members will be removed') ; return ;}
let metadata = await zk.groupMetadata(dest) ;
let participants = metadata.participants ;
for (let i = 0 ; i < participants.length ; i++) {
if (participants[i].id.startsWith(arg[0]) && participants[i].admin === null ) {
await zk.groupParticipantsUpdate(dest, [participants[i].id], "remove") ;
}
}
} else {
repondre('Sorry, you are not an administrator of the group')
}
}) ;
zokou({
nomCom : 'nsfw',
categorie : 'Group'
}, async (dest,zk,commandeOptions) => {
const {arg , repondre , verifAdmin } = commandeOptions ;
if(!verifAdmin) { repondre('Sorry, you cannot enable NSFW content without being an administrator of the group') ; return}
let hbd = require('../bdd/hentai') ;
let isHentaiGroupe = await hbd.checkFromHentaiList(dest) ;
if (arg[0] == 'on') {
if(isHentaiGroupe) {repondre('NSFW content is already active for this group') ; return} ;
await hbd.addToHentaiList(dest) ;
repondre('NSFW content is now active for this group') ;
} else if (arg[0] == 'off') {
if(!isHentaiGroupe) {repondre('NSFW content is already disabled for this group') ; return} ;
await hbd.removeFromHentaiList(dest) ;
repondre('NSFW content is now disabled for this group') ;
} else {
repondre('You must enter "on" or "off"') ;
}
} ) ;