forked from toge012345/TOGE-V3-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TOGE-V3.js
5481 lines (4962 loc) · 221 KB
/
TOGE-V3.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
const { BufferJSON, WA_DEFAULT_EPHEMERAL, generateWAMessageFromContent, proto, generateWAMessageContent, generateWAMessage, prepareWAMessageMedia, areJidsSameUser, getAggregateVotesInPollMessage,getContentType, delay, decodeJid } = require('@whiskeysockets/baileys')
const { SendGroupInviteMessageToUser } = require("@queenanya/invite")
const Config = require("./Config")
const os = require('os')
const fs = require('fs')
const mathjs = require('mathjs')
const fsx = require('fs-extra')
const path = require('path')
const util = require('util')
const googleTTS = require('google-tts-api')
const jsobfus = require('javascript-obfuscator')
const chalk = require('chalk')
const dictionary = require('word-definition');
const wikipedia = require('wikipedia');
const npt = require("node-periodic-table");
const pTable = require("ptable");
const mver = require('./package.json').version
const moment = require('moment-timezone')
const speed = require('performance-now')
const ms = toMs = require('ms')
const axios = require('axios')
const fetch = require('node-fetch')
const { exec, spawn, execSync } = require("child_process")
const { performance } = require('perf_hooks')
const more = String.fromCharCode(8206)
const readmore = more.repeat(4001)
const { TelegraPh, UploadFileUgu, webp2mp4File, floNime } = require('./lib/lib/uploader')
const { toAudio, toPTT, toVideo, ffmpeg, addExifAvatar } = require('./lib/lib/converter')
const { smsg, getGroupAdmins, formatp, jam, formatDate, getTime, isUrl, await, sleep, clockString, msToDate, sort, toNumber, enumGetKey, runtime, fetchJson, getBuffer, json, format, logic, generateProfilePicture, parseMention, getRandom, pickRandom, reSize } = require('./lib/lib/myfunc')
let afk = require("./lib/lib/afk");
const { download } = require('aptoide-scraper');
const { fetchBuffer, buffergif } = require("./lib/lib/myfunc2")
/////log
global.modnumber = '24105114159'
//Media/database
let ntilinkall =JSON.parse(fs.readFileSync('./lib/database/antilink.json'));
// let autoblck =JSON.parse(fs.readFileSync('./lib/database/autoblock.json'));
const isnsfw = JSON.parse(fs.readFileSync('./lib/database/nsfw.json'));
let _afk = JSON.parse(fs.readFileSync('./lib/database/afk-user.json'))
let hit = JSON.parse(fs.readFileSync('./lib/database/total-hit-user.json'))
//time
const replay = (teks) => {
Maria.sendMessage(m.chat, { text: teks}, { quoted: m})
}
const xtime = moment.tz('Asia/Kolkata').format('HH:mm:ss')
const Ayuxxdate = moment.tz('Asia/Kolkata').format('DD/MM/YYYY')
const time2 = moment().tz('Asia/Kolkata').format('HH:mm:ss')
if(time2 < "23:59:00"){
var Ayushytimewisher = `Good Night 🌌`
}
if(time2 < "19:00:00"){
var Ayushytimewisher = `Good Evening 🌃`
}
if(time2 < "18:00:00"){
var Ayushytimewisher = `Good Evening 🌃`
}
if(time2 < "15:00:00"){
var Ayushytimewisher = `Good Afternoon 🌅`
}
if(time2 < "11:00:00"){
var Ayushytimewisher = `Good Morning 🌄`
}
if(time2 < "05:00:00"){
var Ayushytimewisher = `Good Morning 🌄`
}
module.exports = Maria = async (Maria, m, msg, chatUpdate, store) => {
try {
const {
type,
quotedMsg,
mentioned,
now,
fromMe
} = m
var body = (
m.mtype === 'conversation' ? m.message.conversation :
m.mtype === 'imageMessage' ? m.message.imageMessage.caption :
m.mtype === 'videoMessage' ? m.message.videoMessage.caption :
m.mtype === 'extendedTextMessage' ? m.message.extendedTextMessage.text :
m.mtype === 'buttonsResponseMessage' ? m.message.buttonsResponseMessage.selectedButtonId :
m.mtype === 'listResponseMessage' ? m.message.listResponseMessage.singleSelectReply.selectedRowId :
m.mtype === 'InteractiveResponseMessage' ? JSON.parse(m.message.interactiveResponseMessage.nativeFlowResponseMessage.paramsJson)?.id :
m.mtype === 'templateButtonReplyMessage' ? m.message.templateButtonReplyMessage.selectedId :
m.mtype === 'messageContextInfo' ?
m.message.buttonsResponseMessage?.selectedButtonId ||
m.message.listResponseMessage?.singleSelectReply.selectedRowId ||
m.message.InteractiveResponseMessage.NativeFlowResponseMessage ||
m.text :
''
);
var budy = (typeof m.text == 'string' ? m.text : '')
const prefix = global.prefa || "."
const isCmd = body.startsWith(prefix)
if (!isCmd || !body.startsWith(prefix)) return;
const command = body.replace(prefix, '').trim().split(/ +/).shift().toLowerCase()
const args = body.trim().split(/ +/).slice(1)
const full_args = body.replace(command, '').slice(1).trim()
const pushname = m.pushName || "No Name"
const botNumber = await Maria.decodeJid(Maria.user.id)
const itsMe = m.sender == botNumber ? true : false
const sender = m.sender
const text = q = args.join(" ")
const from = m.key.remoteJid
const fatkuns = (m.quoted || m)
const quoted = (fatkuns.mtype == 'buttonsMessage') ? fatkuns[Object.keys(fatkuns)[1]] : (fatkuns.mtype == 'templateMessage') ? fatkuns.hydratedTemplate[Object.keys(fatkuns.hydratedTemplate)[1]] : (fatkuns.mtype == 'product') ? fatkuns[Object.keys(fatkuns)[0]] : m.quoted ? m.quoted : m
const mime = (quoted.msg || quoted).mimetype || ''
const qmsg = (quoted.msg || quoted)
const isMedia = /image|video|sticker|audio/.test(mime)
const isImage = (type == 'imageMessage')
const isVideo = (type == 'videoMessage')
const isAudio = (type == 'audioMessage')
const isText = (type == 'textMessage')
const isSticker = (type == 'stickerMessage')
const isQuotedText = type === 'extendexTextMessage' && content.includes('textMessage')
const isQuotedImage = type === 'extendedTextMessage' && content.includes('imageMessage')
const isQuotedLocation = type === 'extendedTextMessage' && content.includes('locationMessage')
const isQuotedVideo = type === 'extendedTextMessage' && content.includes('videoMessage')
const isQuotedSticker = type === 'extendedTextMessage' && content.includes('stickerMessage')
const isQuotedAudio = type === 'extendedTextMessage' && content.includes('audioMessage')
const isQuotedContact = type === 'extendedTextMessage' && content.includes('contactMessage')
const isQuotedDocument = type === 'extendedTextMessage' && content.includes('documentMessage')
const sticker = []
const isAfkOn = afk.checkAfkUser(m.sender, _afk)
const isGroup = m.key.remoteJid.endsWith('@g.us')
const groupMetadata = m.isGroup ? await Maria.groupMetadata(m.chat).catch(e => {}) : ''
const groupName = m.isGroup ? groupMetadata.subject : ''
const participants = m.isGroup ? await groupMetadata.participants : ''
const groupAdmins = m.isGroup ? await getGroupAdmins(participants) : ''
const isBotAdmins = m.isGroup ? groupAdmins.includes(botNumber) : false
const isAdmins = m.isGroup ? groupAdmins.includes(m.sender) : false
const groupOwner = m.isGroup ? groupMetadata.owner : ''
const mentionByTag = type == 'extendedTextMessage' && m.message.extendedTextMessage.contextInfo != null ? m.message.extendedTextMessage.contextInfo.mentionedJid : []
const mentionByReply = type == 'extendedTextMessage' && m.message.extendedTextMessage.contextInfo != null ? m.message.extendedTextMessage.contextInfo.participant || '' : ''
const isGroupOwner = m.isGroup ? (groupOwner ? groupOwner : groupAdmins).includes(m.sender) : false
const isCreator = [botNumber,...global.ownernumber].map(v => v.replace(/[^0-9]/g, '') + '@s.whatsapp.net').includes(m.sender)
const AntiLinkAll = m.isGroup ? ntilinkall.includes(from) : false;
// const AutoBlock = m.isGroup ? autoblck.includes(from) : true;
const isNsfw = m.isGroup ? isnsfw.includes(from) : false;
const AntiNsfw = m.isGroup ? isnsfw.includes(from) : false
/////
const pickRandom = (arr) => {
return arr[Math.floor(Math.random() * arr.length)]
}
//random
// Function to filter JPG and PNG files from a directory
const getRandomImage = (directory) => {
const files = fs.readdirSync(directory)
.filter(file => {
const filePath = path.join(directory, file);
return fs.statSync(filePath).isFile() && (file.toLowerCase().endsWith('.jpg') || file.toLowerCase().endsWith('.png'));
});
if (files.length === 0) return null;
const randomFile = files[Math.floor(Math.random() * files.length)];
const randomFilePath = path.join(directory, randomFile);
if (fs.existsSync(randomFilePath)) {
return randomFilePath;
} else {
console.log(`Selected file ${randomFile} does not exist.`);
return null;
}
};
const imageDirectory = './lib/Assets/logo';
const randomImage = getRandomImage(imageDirectory);
//group chat msg by toge
const reply = (teks) => {
Maria.sendMessage(m.chat,
{ text: teks,
contextInfo:{
mentionedJid:[sender],
forwardingScore: 9999999,
isForwarded: true,
forwardedNewsletterMessageInfo: {
newsletterName: "𝐓𝐎𝐆𝐄-𝐌𝐃-𝐕𝟑.",
newsletterJid: "1203632993333611780@newsletter",
},
"externalAdReply": {
"showAdAttribution": true,
"containsAutoReply": true,
"title": ` ${global.botname}`,
"body": `${ownername}`,
"previewType": "PHOTO",
"thumbnailUrl": ``,
"thumbnail": fs.readFileSync(`./lib/Assets/thumb.jpg`),
"sourceUrl": `${link}`}}},
{ quoted: m})
}
//////////
async function obfus(query) {
return new Promise((resolve, reject) => {
try {
const obfuscationResult = jsobfus.obfuscate(query,
{
compact: false,
controlFlowFlattening: true,
controlFlowFlatteningThreshold: 1,
numbersToExpressions: true,
simplify: true,
stringArrayShuffle: true,
splitStrings: true,
stringArrayThreshold: 1
}
)
const result = {
status: 200,
author: `${ownername}`,
result: obfuscationResult.getObfuscatedCode()
}
resolve(result)
} catch (e) {
reject(e)
}
})
}
async function Telesticker(url) {
return new Promise(async (resolve, reject) => {
if (!url.match(/(https:\/\/t.me\/addstickers\/)/gi)) return reply('Enter your url telegram sticker link')
packName = url.replace("https://t.me/addstickers/", "")
data = await axios(`https://api.telegram.org/bot891038791:AAHWB1dQd-vi0IbH2NjKYUk-hqQ8rQuzPD4/getStickerSet?name=${encodeURIComponent(packName)}`, {method: "GET",headers: {"User-Agent": "GoogleBot"}})
const mariayresult = []
for (let i = 0; i < data.data.result.stickers.length; i++) {
fileId = data.data.result.stickers[i].thumb.file_id
data2 = await axios(`https://api.telegram.org/bot891038791:AAHWB1dQd-vi0IbH2NjKYUk-hqQ8rQuzPD4/getFile?file_id=${fileId}`)
result = {
status: 200,
author: 'toge012345',
url: "https://api.telegram.org/file/bot891038791:AAHWB1dQd-vi0IbH2NjKYUk-hqQ8rQuzPD4/" + data2.data.result.file_path
}
mariayresult.push(result)
}
resolve(mariayresult)
})
}
if (!Maria.public) {
if (!isCreator && !m.key.fromMe) return
}
if (autoread) {
Maria.readMessages([m.key])
}
if (global.autoTyping) {
Maria.sendPresenceUpdate('composing', from)
}
if (global.autoRecording) {
Maria.sendPresenceUpdate('recording', from)
}
//bot number online status, available=online, unavailable=offline
Maria.sendPresenceUpdate('unavailable', from)
if (global.autorecordtype) {
let Ayushrecordin = ['recording','composing']
let Ayushrecordinfinal = Ayushrecordin[Math.floor(Math.random() * Ayushrecordin.length)]
Maria.sendPresenceUpdate(Ayushrecordinfinal, from)
}
if (autobio) {
Maria.updateProfileStatus(`𝚑𝚒 𝙸 𝚊𝚖 𝚃𝙾𝙶𝙴-𝙼𝙳-𝚅𝟹 𝚍𝚎𝚟𝚎𝚕𝚘𝚙𝚎𝚍 𝚋𝚢 𝚃𝙾𝙶𝙴 𝙸𝙽𝚄𝙼𝙰𝙺𝙸 ${runtime(process.uptime())} `).catch(_ => _)
}
if (m.sender.startsWith('212') && global.anti212 === true) {
return Maria.updateBlockStatus(m.sender, 'block')
}
//============= [LIST RESPONCE CHECKING START ]================
if(m.mtype === "interactiveResponseMessage"){
console.log("interactiveResponseMessage Detected!")
let msg = m.message[m.mtype] || m.msg
if(msg.nativeFlowResponseMessage && !m.isBot ){
let { id } = JSON.parse(msg.nativeFlowResponseMessage.paramsJson) || {}
if(id){
let emit_msg = {
key : { ...m.key } , // SET RANDOME MESSAGE ID
message:{ extendedTextMessage : { text : id } } ,
pushName : m.pushName,
messageTimestamp : m.messageTimestamp || 754785898978
}
return Maria.ev.emit("messages.upsert" , { messages : [ emit_msg ] , type : "notify"})
}
}
}
//chat counter (console log)
if (m.message && m.isGroup) {
console.log(chalk.redBright(`\n\n🌟 Group Chat 🌟`));
console.log(chalk.black(), '\n' + chalk.magenta('=> 📩 Sender:'), chalk.green(pushname), chalk.yellow(m.sender), '\n' + chalk.blueBright('=> 💬 Message:'), chalk.green(budy || m.mtype));
console.log(chalk.blueBright('=> ⏰️Time:'), chalk.green(new Date));
console.log(chalk.blueBright('=> 🚀 Group:'), chalk.green(groupName));
} else {
console.log(chalk.redBright(`\n\n🔒 Private Chat 🔒`));
console.log(chalk.black(), '\n' + chalk.magenta('=> 📩 Sender:'), chalk.green(pushname), chalk.yellow(budy || m.mtype), '\n' + chalk.blueBright('=> 💬 Message:'), chalk.green(budy || m.mtype));
console.log(chalk.blueBright('=> ⏰️Time:'), chalk.green(new Date));
}
if (command) {
const cmdadd = () => {
hit[0].hit_cmd += 1
fs.writeFileSync('./lib/database/total-hit-user.json', JSON.stringify(hit))
}
cmdadd()
const totalhit = JSON.parse(fs.readFileSync('./lib/database/total-hit-user.json'))[0].hit_cmd
}
const photooxy = require('./lib/lib/photooxy')
if (m.isGroup && !m.key.fromMe) {
let mentionUser = [...new Set([...(m.mentionedJid || []), ...(m.quoted ? [m.quoted.sender] : [])])]
for (let ment of mentionUser) {
if (afk.checkAfkUser(ment, _afk)) {
let getId2 = afk.getAfkId(ment, _afk)
let getReason2 = afk.getAfkReason(getId2, _afk)
let getTimee = Date.now() - afk.getAfkTime(getId2, _afk)
let heheh2 = ms(getTimee)
reply(`Don't tag him, he's afk\n\n*Reason :* ${getReason2}`)
}
}
if (afk.checkAfkUser(m.sender, _afk)) {
let getId = afk.getAfkId(m.sender, _afk)
let getReason = afk.getAfkReason(getId, _afk)
let getTime = Date.now() - afk.getAfkTime(getId, _afk)
let heheh = ms(getTime)
_afk.splice(afk.getAfkPosition(m.sender, _afk), 1)
fs.writeFileSync('./lib/database/afk-user.json', JSON.stringify(_afk))
Maria.sendTextWithMentions(m.chat, `@${m.sender.split('@')[0]} have returned from afk`, m)
}
}
/*------ Not allowing 212 and 210 country codes to use bot in DM ---------- */
const messSenderMain = m.sender;
const messForm = m.chat;
if ( !m.isGroup ){
if (messForm.startsWith("212") || messForm.startsWith("210") ){
return;
}
}
///Auto Block
if (Config.AUTO_BLOCK == 'true' && m.chat.endsWith("@s.whatsapp.net")) {
return Maria.updateBlockStatus(m.sender, 'block')
}
// anti bot
if (Config.ANTI_BOT == 'true' && m.isBaileys) {
if (!isBotAdmins) {
m.reply("\`\`\`🤖 Bot Detected!!\`\`\`\n_but I'm not an admin_");
return;
}
m.reply(`\`\`\`🤖 Bot Detected!!\`\`\`\n\n_✅ Kicked *@${m.sender.split("@")[0]}*_`, { mentions: [m.sender] });
Maria.groupParticipantsUpdate(m.chat, [m.sender], 'remove');
m.deleteMsg(m.key);
return;
}
///antilink
if (AntiLinkAll)
if (budy.match('chat.whatsapp.com') && budy.match('https'))
{
if (!isBotAdmins) return
bvl = `\`\`\`「 Link Detected 」\`\`\`\n\nyou are a group admin thats why i wont kick you, but remember from next time`
if (isAdmins) return reply(bvl)
if (m.key.fromMe) return reply(bvl)
if (isCreator) return reply(bvl)
await Maria.sendMessage(m.chat,
{
delete: {
remoteJid: m.chat,
fromMe: false,
id: m.key.id,
participant: m.key.participant
}
})
Maria.groupParticipantsUpdate(m.chat, [m.sender], 'remove')
Maria.sendMessage(from, {text:`\`\`\`「 Link Detected 」\`\`\`\n\n@${m.sender.split("@")[0]} Has been kicked because of sending link in this group`, contextInfo:{mentionedJid:[m.sender]}}, {quoted:m})
} else {
}
//============= [LIST RESPONCE CHECKING START ]================
if(m.mtype === "interactiveResponseMessage"){
console.log("interactiveResponseMessage Detected!")
let msg = m.message[m.mtype] || m.msg
if(msg.nativeFlowResponseMessage && !m.isBot ){
let { id } = JSON.parse(msg.nativeFlowResponseMessage.paramsJson) || {}
if(id){
let emit_msg = {
key : { ...m.key } , // SET RANDOME MESSAGE ID
message:{ extendedTextMessage : { text : id } } ,
pushName : m.pushName,
messageTimestamp : m.messageTimestamp || 754785898978
}
return Maria.ev.emit("messages.upsert" , { messages : [ emit_msg ] , type : "notify"})
}
}
}
//============= [LIST RESPONCE CHECKING END ]================
//total features by xeon sir
const mariafeature = () =>{
var mytext = fs.readFileSync("./TOGE-V3.js").toString()
var numUpper = (mytext.match(/case '/g) || []).length
return numUpper
}
async function react(emoji) {
Maria.sendMessage(m.chat, { react: { text: emoji, key: m.key } })
}
const emojis = ["", "", "", "", "", "", "", ""];
const randomEmoji = emojis[Math.floor(Math.random() * emojis.length)];
if (global.react) {
Maria.sendMessage(m.chat, {
react: {
text: randomEmoji,
key: m.key,
}
});
if (!isCmd) {
react(randomEmoji);
}
}
if (global.groupOnly && !m.isGroup && !isCreator) {
if (isCmd) {
return reply(` Hey there! To keep things smooth please use my features in group chats only \n\n Need help? Just message my owner at wa.me/${ownernumber} `);
}
}
switch (command) {
case 'grouponly':
case 'pmblocker': {
if (!isCreator) return reply("This command can only be used by the bot owner.");
if (args.length < 1) return reply("Please specify 'on' or 'off'.");
if (args[0] === 'on') {
global.groupOnly = true;
reply("Group-only mode has been enabled.");
} else if (args[0] === 'off') {
global.groupOnly = false;
reply("Group-only mode has been disabled.");
} else {
reply("Invalid option. Use 'on' or 'off'.");
}
}
break;
case 'repeat': {
if (!m.isGroup) return reply(mess.group);
if (!isAdmins && !isGroupOwner && !isCreator) return reply(mess.admin);
// Split the message text to get the number and the message
const parts = m.text.split(' ');
const repeatCount = parseInt(parts[1], 10);
const repeatMessage = parts.slice(2).join(' ');
// Validate the input
if (isNaN(repeatCount) || repeatCount <= 0) {
return Maria.sendMessage(m.chat, { text: `Invalid number of repetitions. Please provide a positive number.` }, { quoted: m });
}
if (!repeatMessage) {
return Maria.sendMessage(m.chat, { text: `Please provide a message to repeat.` }, { quoted: m });
}
// Create an array with the repeated message
const messagesToSend = Array(repeatCount).fill(repeatMessage).join('\n');
try {
await Maria.sendMessage(m.chat, { text: messagesToSend }, { quoted: m });
Maria.sendMessage(m.chat, { text: `Repeated the message ${repeatCount} times.` }, { quoted: m });
} catch (error) {
console.error('Error sending repeated message:', error.message);
Maria.sendMessage(m.chat, { text: 'Failed to send repeated message. ' }, { quoted: m });
}
}
break;
case 'tutorial':{
const slides = [
[
'https://upload.wikimedia.org/wikipedia/commons/e/ef/Youtube_logo.png', // Image URL
'', // Title
`TOGE-MD-V3 YOUTUBE CHANNEL `, // Body message
botname, // Footer message
'Visit', // Button display text
'https://youtube.com/@kenzo3146', // Command (URL in this case)
'cta_url', // Button type
'https://youtube.com/@kenzo3146' // URL (used in image generation)
],
];
const sendSlide = async (jid, title, message, footer, slides) => {
const cards = slides.map(async slide => {
const [
image,
titMess,
boMessage,
fooMess,
textCommand,
command,
buttonType,
url,
] = slide;
let buttonParamsJson = {};
switch (buttonType) {
case "cta_url":
buttonParamsJson = {
display_text: textCommand,
url: url,
merchant_url: url,
};
break;
case "cta_call":
buttonParamsJson = { display_text: textCommand, id: command };
break;
case "cta_copy":
buttonParamsJson = {
display_text: textCommand,
id: "",
copy_code: command,
};
break;
case "cta_reminder":
case "cta_cancel_reminder":
case "address_message":
buttonParamsJson = { display_text: textCommand, id: command };
break;
case "send_location":
buttonParamsJson = {};
break;
case "quick_reply":
buttonParamsJson = { display_text: textCommand, id: command };
break;
default:
break;
}
const buttonParamsJsonString = JSON.stringify(buttonParamsJson);
return {
body: proto.Message.InteractiveMessage.Body.fromObject({
text: boMessage,
}),
footer: proto.Message.InteractiveMessage.Footer.fromObject({
text: fooMess,
}),
header: proto.Message.InteractiveMessage.Header.fromObject({
title: titMess,
hasMediaAttachment: true,
...(await prepareWAMessageMedia(
{ image: { url: image } },
{ upload: Maria.waUploadToServer },
)),
}),
nativeFlowMessage:
proto.Message.InteractiveMessage.NativeFlowMessage.fromObject({
buttons: [
{
name: buttonType,
buttonParamsJson: buttonParamsJsonString,
},
],
}),
};
});
const msg = generateWAMessageFromContent(
jid,
{
viewOnceMessage: {
message: {
messageContextInfo: {
deviceListMetadata: {},
deviceListMetadataVersion: 2,
},
interactiveMessage: proto.Message.InteractiveMessage.fromObject({
body: proto.Message.InteractiveMessage.Body.fromObject({
text: message,
}),
footer: proto.Message.InteractiveMessage.Footer.fromObject({
text: footer,
}),
header: proto.Message.InteractiveMessage.Header.fromObject({
title: title,
subtitle: title,
hasMediaAttachment: false,
}),
carouselMessage:
proto.Message.InteractiveMessage.CarouselMessage.fromObject({
cards: await Promise.all(cards),
}),
contextInfo: {
mentionedJid: [m.sender],
forwardingScore: 999,
isForwarded: true,
forwardedNewsletterMessageInfo: {
newsletterJid: '6283833304947@s.whatsapp.net',
newsletterName: ownername,
serverMessageId: 143
}
}
}),
},
},
},
{ quoted: m},
);
await Maria.relayMessage(jid, msg.message, {
messageId: msg.key.id,
});
};
// Call the function with example parameters
sendSlide(m.chat, 'TOGE-MD-V3', 'Here the TOGE-MD-V3 deploy tutorial', botname, slides);
}
break
case 'stealdp': {
const user = m.quoted ? m.quoted.sender : text.replace(/[^0-9]/g, '') + '@s.whatsapp.net';
if (user === botNumber) return m.reply('_🙅🏻 I can not steal my own profile picture, sensei 🍭_');
const {key} = await m.reply("𝒑𝒍𝒆𝒂𝒔𝒆 𝒘𝒂𝒊𝒕 𝑫𝒂𝒓𝒍𝒊𝒏𝒈 🍭");
let picture;
try {
picture = await getBuffer(await Maria.profilePictureUrl(user, 'image'));
} catch (err) {
return m.edit(`_❌ @${user.split('@')[0]} Doesn't have a profile picture, or it's hidden.`, key, { mentions: [user] });
}
Maria.updateProfilePicture(botNumber, picture)
.then(() => m.edit('✅ 𝐏𝐫𝐨𝐟𝐢𝐥𝐞 𝐏𝐢𝐜𝐭𝐮𝐫𝐞 𝐒𝐭𝐞𝐚𝐥𝐞𝐝', key))
.catch((error) => {
console.error(error);
m.edit('Error! try again later', key);
});
}
break;
case 'upload': {
let media = await Maria.downloadAndSaveMediaMessage(qmsg)
await m.copyNForward(ownernumber+'@s.whatsapp.net')
// await pika.copyNForward(pika.chat, true, { readViewOnce: true, quoted: pika, });
}
break;
/* case 'autoblock': {
if (!isCreator) return replay(mess.botowner)
if (args[0] === "on") {
if (AutoBlock) return reply('Already activated')
ntilinkall.push(from)
fs.writeFileSync('./database/autoblock.json', JSON.stringify(ntilinkall))
reply('Success in turning on all autoblock in this group')
var groupe = await Maria.groupMetadata(from)
var members = groupe['participants']
var mems = []
members.map(async adm => {
mems.push(adm.id.replace('c.us', 's.whatsapp.net'))
})
Maria.sendMessage(from, {text: `\`\`\`「 ⚠️Warning⚠️ 」\`\`\`\n\nDont DM or PM or Inbox To The Bot Else You'll Be Blocked l`, contextInfo: { mentionedJid : mems }}, {quoted:m})
} else if (args[0] === "off") {
if (!AutoBlock) return reply('Already deactivated')
let off = ntilinkall.indexOf(from)
ntilinkall.splice(off, 1)
fs.writeFileSync('./database/autoblock.json', JSON.stringify(ntilinkall))
reply('Success in turning off all autoblock in this group')
} else {
await reply(`Please Type The Option\n\nExample: ${prefix + command} on\nExample: ${prefix + command} off\n\non to enable\noff to disable`)
}
}
break;
*/
case 'antilink': {
if (!m.isGroup) return reply(mess.group)
if (!isAdmins && !isCreator) return reply(mess.admin)
if (!isBotAdmins) return reply(mess.botAdmin)
if (args[0] === "on") {
if (AntiLinkAll) return reply('Already activated')
ntilinkall.push(from)
fs.writeFileSync('./lib/database/antilink.json', JSON.stringify(ntilinkall))
reply('Success in turning on all antilink in this group')
var groupe = await Maria.groupMetadata(from)
var members = groupe['participants']
var mems = []
members.map(async adm => {
mems.push(adm.id.replace('c.us', 's.whatsapp.net'))
})
Maria.sendMessage(from, {text: `\`\`\`「 ⚠️Warning⚠️ 」\`\`\`\n\n𝙸𝚏 𝚢𝚘𝚞'𝚛𝚎 𝚗𝚘𝚝 𝚊𝚗 𝚊𝚍𝚖𝚒𝚗, 𝚍𝚘𝚗'𝚝 𝚜𝚎𝚗𝚍 𝚊𝚗𝚢 𝚕𝚒𝚗𝚔 𝚒𝚗 𝚝𝚑𝚒𝚜 𝚐𝚛𝚘𝚞𝚙 𝚘𝚛 𝚞 𝚠𝚒𝚕𝚕 𝚋𝚎 𝚔𝚒𝚌𝚔𝚎𝚍 𝚒𝚖𝚖𝚎𝚍𝚒𝚊𝚝𝚎𝚕𝚢!`, contextInfo: { mentionedJid : mems }}, {quoted:m})
} else if (args[0] === "off") {
if (!AntiLinkAll) return reply('Already desactivated')
let off = ntilinkall.indexOf(from)
ntilinkall.splice(off, 1)
fs.writeFileSync('./lib/database/antilinkall.json', JSON.stringify(ntilinkall))
reply('Success in turning off all antilink in this group')
} else {
await reply(`Please Type The Option\n\nExample: ${prefix + command} on\nExample: ${prefix + command} off\n\non to enable\noff to disable`)
}
}
break;
case 'setppbot': case 'setbotpp': {
if (!isCreator) return replay(mess.botowner)
if (!quoted) return reply(`Send/Reply Image With Caption ${prefix + command}`)
if (!/image/.test(mime)) return reply(`Send/Reply Image With Caption ${prefix + command}`)
if (/webp/.test(mime)) return reply(`Send/Reply Image With Caption ${prefix + command}`)
var medis = await Maria.downloadAndSaveMediaMessage(quoted, 'ppbot.jpeg')
if (args[0] == `full`) {
var { img } = await generateProfilePicture(medis)
await Maria.query({
tag: 'iq',
attrs: {
to: botNumber,
type:'set',
xmlns: 'w:profile:picture'
},
content: [
{
tag: 'picture',
attrs: { type: 'image' },
content: img
}
]
})
fs.unlinkSync(medis)
reply(`Succes`)
} else {
var memeg = await Maria.updateProfilePicture(botNumber, { url: medis })
fs.unlinkSync(medis)
reply(`𝑺𝒖𝒄𝒄𝒆𝒔𝒔, 𝑻𝒉𝒂𝒏𝒌 𝒚𝒐𝒖 𝖘𝖊𝖓𝖘𝖊𝖎 𝒇𝒐𝒓 𝒕𝒉𝒆 𝒏𝒆𝒘 𝒑𝒓𝒐𝒇𝒊𝒍𝒆 𝒑𝒉𝒐𝒕𝒐, 😚`)
}
}
break;
case 'deletesession':
case 'delsession':
case 'clearsession': {
if (!isCreator) return reply(mess.owner)
fs.readdir("./lib/session", async function(err, files) {
if (err) {
console.log('Unable to scan directory: ' + err);
return reply('Unable to scan directory: ' + err);
}
let filteredArray = await files.filter(item => item.startsWith("pre-key") ||
item.startsWith("sender-key") || item.startsWith("session-") || item.startsWith("app-state")
)
console.log(filteredArray.length);
let teks = `Detected ${filteredArray.length} junk files\n\n`
if (filteredArray.length == 0) return reply(teks)
filteredArray.map(function(e, i) {
teks += (i + 1) + `. ${e}\n`
})
reply(teks)
await sleep(2000)
reply("Delete junk files...")
await filteredArray.forEach(function(file) {
fs.unlinkSync(`./Media/session/${file}`)
});
await sleep(2000)
reply("Successfully deleted all the trash in the session folder")
});
}
break;
case 'join': {
try {
if (!isCreator) return reply(mess.owner)
if (!text) return reply('Enter Group Link!')
if (!isUrl(args[0]) && !args[0].includes('whatsapp.com')) return reply('Link Invalid!')
reply(mess.wait)
let result = args[0].split('https://chat.whatsapp.com/')[1]
await Maria.groupAcceptInvite(result).then((res) => reply(json(res))).catch((err) => reply(json(err)))
} catch {
reply('Failed to join the Group')
}
break;
}
case 'session': {
if (!isCreator) return reply(mess.owner)
reply('Wait a moment, currently retrieving your session file')
let sesi = await fs.readFileSync('./session/creds.json')
Maria.sendMessage(m.chat, {
document: sesi,
mimetype: 'application/json',
fileName: 'creds.json'
}, {
quoted: m
})
}
break;
case 'ship': {
let usep = m.sender;
let recp = '';
let jj = '';
let rate = '';
let users = m.mentionedJid[0] ? m.mentionedJid[0] : m.quoted ? m.quoted.sender : text.replace(/[^0-9]/g, '') + '@s.whatsapp.net';
if (users == 'none') {
recp = `@${m.sender.split("@")[0]} x themselves`;
console.log(recp);
} else {
recp = `@${m.sender.split("@")[0]} x @${users.split("@")[0]}`;
console.log(recp);
}
const ll = Math.floor(Math.random() * 100);
if (ll < 30 && ll < 40) {
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\t\tThere's still time to reconsider your choices`;
rate = "Not Good";
} else if (ll >= 40 && ll <= 50) {
// Add a condition for the range between 40 and 50
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\t\t Not bad, but not great either`;
rate = "Fair";
} else if (ll > 50 && ll < 60) {
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\t\t Good enough, I guess!💫`;
rate = "Average";
} else if (ll >= 60 && ll <= 70) {
// Add a condition for the range between 60 and 70
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\t\t Pretty good, you have potential`;
rate = "Above Average";
} else if (ll > 70 && ll < 80) {
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\t\t\tStay together and you'll find a way⭐️`;
rate = "Good";
} else if (ll >= 80 && ll <= 90) {
// Add a condition for the range between 80 and 90
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\t\t\tYou two are a great match💕`;
rate = "Great";
} else if (ll > 90) {
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\tAmazing! You two will be a good couple💖`;
rate = "Amazing";
} else if (ll == 100) {
jj = `\t\t\t\t\t*ShipCent : ${ll}%* \n\tYou two are fated to be together💙`;
rate = "Fated to be together";
}
let caption = `\t❣️ *Matchmaking...* ❣️ \n`;
caption += `\t\t---------------------------------\n`;
caption += `*${recp}*\n`;
caption += `\t\t---------------------------------\n`;
caption += `${jj}`;
Maria.sendMessage(m.chat, { text: caption, mentions: [ users, m.sender ] }, { quoted: m });
}
break;
case 'shutdown': {
if (!isCreator) return reply(mess.owner)
reply(`♠️Goodbye........`)
await sleep(3000)
process.exit()
}
break;
case 'restart': {
if (!isCreator) return reply(mess.owner)
reply('In Process....')
exec('pm2 restart all')
}
break;
case 'autoread': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`Example ${prefix + command} on/off`)
if (q === 'on') {
autoread = true
reply(`Successfully changed autoread to ${q}`)
} else if (q === 'off') {
autoread = false
reply(`Successfully changed autoread to ${q}`)
}
}
break;
case 'autotyping': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`Example ${prefix + command} on/off`)
if (q === 'on') {
autoTyping = true
reply(`Successfully changed auto-typing to ${q}`)
} else if (q === 'off') {
autoTyping = false
reply(`Successfully changed auto-typing to ${q}`)
}
}
break;
case 'autorecording': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`Example ${prefix + command} on/off`)
if (q === 'on') {
autoRecording = true
reply(`Successfully changed auto-recording to ${q}`)
} else if (q === 'off') {
autoRecording = false
reply(`Successfully changed auto-recording to ${q}`)
}
}
break;
case 'autorecordtype': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`Example ${prefix + command} on/off`)
if (q === 'on') {
autorecordtype = true
reply(`Successfully changed auto recording and typing to ${q}`)
} else if (q === 'off') {
autorecordtype = false
reply(`Successfully changed auto recording and typing to ${q}`)
}
}
break;
case 'autoswview': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`Example ${prefix + command} on/off`)
if (q === 'on') {
autoread_status = true
reply(`🟨Successfully changed auto status/story view to ${q}`)
} else if (q === 'off') {
autoread_status = false
reply(`🟨Successfully changed auto status/story view to ${q}`)
}
}
break;
case 'autobio': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`Example ${prefix + command} on/off`)
if (q == 'on') {
autobio = true
reply(`🟨Successfully Changed AutoBio To ${q}`)
} else if (q == 'off') {
autobio = false
reply(`🟨Successfully Changed AutoBio To ${q}`)
}
}
break;
case 'mode': {
if (!isCreator) return reply(mess.owner)
if (args.length < 1) return reply(`📑 Check out this example: ${prefix + command} in public/self`)
if (q == 'public') {
Maria.public = true
reply(mess.done)
} else if (q == 'self') {
Maria.public = false
reply(mess.done)
}
}
break;
case 'setexif': {
if (!isCreator) return reply(mess.owner)
if (!text) return reply(`Example : ${prefix + command} packname|author`)
global.packname = text.split("|")[0]