-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathconn.js
890 lines (833 loc) · 39.2 KB
/
conn.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
"use strict";
const { BufferJSON,
WA_DEFAULT_EPHEMERAL,
proto,
prepareWAMessageMedia,
areJidsSameUser,
getContentType } = require('@adiwajshing/baileys')
const { downloadContentFromMessage,
generateWAMessage,
generateWAMessageFromContent,
MessageType } = require("@adiwajshing/baileys")
const { exec, spawn } = require("child_process");
const { color, bgcolor, pickRandom, randomNomor } = require('./function/Data_Server_Bot/Console_Data')
const { removeEmojis, bytesToSize, getBuffer, fetchJson, getRandom, getGroupAdmins, runtime, sleep, makeid, isUrl } = require("./function/func_Server");
const { TelegraPh } = require("./function/uploader_Media");
const { addResponList, delResponList, isAlreadyResponList, isAlreadyResponListGroup, sendResponList, updateResponList, getDataResponList } = require('./function/func_Addlist');
const { setting_JSON, server_eror_JSON, db_respon_list_JSON } = require('./function/Data_Location.js')
const { mediafireDl } = require('./function/scrape_Mediafire')
const { webp2mp4File } = require("./function/Webp_Tomp4")
//module
const { youtube, facebook } = require("@xct007/frieren-scraper")
const { File } = require("megajs")
const { youtubedl, snapsave } = require("@bochilteam/scraper")
const fs = require("fs");
const ms = require("ms");
const chalk = require('chalk');
const axios = require("axios");
const qs = require("querystring");
const fetch = require("node-fetch");
const colors = require('colors/safe');
const ffmpeg = require("fluent-ffmpeg");
const moment = require("moment-timezone");
const util = require("util");
const { Sticker, StickerTypes } = require('wa-sticker-formatter');
// DB
const setting = setting_JSON
const server_eror = server_eror_JSON
const db_respon_list = db_respon_list_JSON
moment.tz.setDefault("Asia/Jakarta").locale("id");
module.exports = async (conn, msg, m, setting, store) => {
try {
const { type, quotedMsg, mentioned, now, fromMe, isBaileys } = msg
if (msg.isBaileys) return
const jam = moment.tz('asia/jakarta').format('HH:mm:ss')
const tanggal = moment().tz("Asia/Jakarta").format("ll")
let dt = moment(Date.now()).tz('Asia/Jakarta').locale('id').format('a')
const content = JSON.stringify(msg.message)
const from = msg.key.remoteJid
const time = moment(new Date()).format("HH:mm");
var chats = (type === 'conversation' && msg.message.conversation) ? msg.message.conversation : (type === 'imageMessage') && msg.message.imageMessage.caption ? msg.message.imageMessage.caption : (type === 'videoMessage') && msg.message.videoMessage.caption ? msg.message.videoMessage.caption : (type === 'extendedTextMessage') && msg.message.extendedTextMessage.text ? msg.message.extendedTextMessage.text : (type === 'buttonsResponseMessage') && quotedMsg.fromMe && msg.message.buttonsResponseMessage.selectedButtonId ? msg.message.buttonsResponseMessage.selectedButtonId : (type === 'templateButtonReplyMessage') && quotedMsg.fromMe && msg.message.templateButtonReplyMessage.selectedId ? msg.message.templateButtonReplyMessage.selectedId : (type === 'messageContextInfo') ? (msg.message.buttonsResponseMessage?.selectedButtonId || msg.message.listResponseMessage?.singleSelectReply.selectedRowId) : (type == 'listResponseMessage') && quotedMsg.fromMe && msg.message.listResponseMessage.singleSelectReply.selectedRowId ? msg.message.listResponseMessage.singleSelectReply.selectedRowId : ""
if (chats == undefined) { chats = 'undefined' }
const prefix = setting.prefix
const isGroup = msg.key.remoteJid.endsWith('@g.us')
const sender = isGroup ? (msg.key.participant ? msg.key.participant : msg.participant) : msg.key.remoteJid
const isOwner = [`${setting.ownerNumber}@s.whatsapp.net`].includes(sender) ? true : false
const pushname = msg.pushName
const body = chats.startsWith(prefix) ? chats : ''
const args = body.trim().split(/ +/).slice(1);
const q = args.join(" ");
const isCommand = body.startsWith(prefix);
const command = body.slice(1).trim().split(/ +/).shift().toLowerCase()
const isCmd = isCommand ? body.slice(1).trim().split(/ +/).shift().toLowerCase() : null;
const botNumber = conn.user.id.split(':')[0] + '@s.whatsapp.net'
const groupMetadata = isGroup ? await conn.groupMetadata(from) : ''
const groupName = isGroup ? groupMetadata.subject : ''
const groupId = isGroup ? groupMetadata.id : ''
const participants = isGroup ? await groupMetadata.participants : ''
const groupMembers = isGroup ? groupMetadata.participants : ''
const groupAdmins = isGroup ? getGroupAdmins(groupMembers) : ''
const isBotGroupAdmins = groupAdmins.includes(botNumber) || false
const isGroupAdmins = groupAdmins.includes(sender)
const quoted = msg.quoted ? msg.quoted : msg
const isImage = (type == 'imageMessage')
const isQuotedMsg = (type == 'extendedTextMessage')
const isMedia = (type === 'imageMessage' || type === 'videoMessage');
const isQuotedImage = isQuotedMsg ? content.includes('imageMessage') ? true : false : false
const isVideo = (type == 'videoMessage')
const isQuotedVideo = isQuotedMsg ? content.includes('videoMessage') ? true : false : false
const isSticker = (type == 'stickerMessage')
const isQuotedSticker = isQuotedMsg ? content.includes('stickerMessage') ? true : false : false
const isQuotedAudio = isQuotedMsg ? content.includes('audioMessage') ? true : false : false
const mentionByTag = type == "extendedTextMessage" && msg.message.extendedTextMessage.contextInfo != null ? msg.message.extendedTextMessage.contextInfo.mentionedJid : []
const mentionByReply = type == "extendedTextMessage" && msg.message.extendedTextMessage.contextInfo != null ? msg.message.extendedTextMessage.contextInfo.participant || "" : ""
const mention = typeof (mentionByTag) == 'string' ? [mentionByTag] : mentionByTag
mention != undefined ? mention.push(mentionByReply) : []
const mentionUser = mention != undefined ? mention.filter(n => n) : []
/*try {
var pp_user = await conn.profilePictureUrl(sender, 'image')
} catch {
var pp_user = 'https://i.ibb.co/0M6Hppv/3626e36344a1.jpg'
}*/
function mentions(teks, mems = [], id) {
if (id == null || id == undefined || id == false) {
let res = conn.sendMessage(from, { text: teks, mentions: mems })
return res
} else {
let res = conn.sendMessage(from, { text: teks, mentions: mems }, { quoted: msg })
return res
}
}
function monospace(string) {
return '```' + string + '```'
}
const more = String.fromCharCode(8206)
const readmore = more.repeat(4001)
function parseMention(text = '') {
return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net')
}
const isEmoji = (emo) => {
let emoji_ranges = /(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|\ud83c[\ude32-\ude3a]|\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])/g;
let regexEmoji = new RegExp(emoji_ranges, 'gi');
return emo.match(regexEmoji)
}
const reply = (teks) => { conn.sendMessage(from, { text: teks }, { quoted: msg }) }
const adReply = async (teks, judul, isi, quo) => {
conn.sendMessage(from, {
text: teks,
contextInfo: {
"externalAdReply":
{
showAdAttribution: true,
title: judul,
body: isi,
mediaType: 1,
thumbnail: fs.readFileSync('./sticker/adreply.jpg'),
sourceUrl: 'https://github.com/dragneel1111/Simple-Selfbot'
}
}
},
{
sendEphemeral: true,
quoted: quo
})
}
const adReply2 = async (teks, judul, isi, quo) => {
conn.sendMessage(from, {
text: teks,
contextInfo: {
"externalAdReply":
{
showAdAttribution: true,
title: judul,
body: isi,
mediaType: 1,
renderLargerThumbnail: true,
thumbnail: fs.readFileSync('./sticker/menu.jpg'),
sourceUrl: 'https://github.com/dragneel1111/Simple-Selfbot'
}
}
},
{
sendEphemeral: true,
quoted: quo
})
}
const fstatus = {
key: {
fromMe: false,
participant: `0@s.whatsapp.net`,
...(from ? { remoteJid: "status@broadcast" } : {}),
},
message: {
imageMessage: {
url: "https://mmg.whatsapp.net/d/f/At0x7ZdIvuicfjlf9oWS6A3AR9XPh0P-hZIVPLsI70nM.enc",
mimetype: "image/jpeg",
caption: setting.wm,
fileSha256: "+Ia+Dwib70Y1CWRMAP9QLJKjIJt54fKycOfB2OEZbTU=",
fileLength: "28777",
height: 1080,
width: 1079,
mediaKey: "vXmRR7ZUeDWjXy5iQk17TrowBzuwRya0errAFnXxbGc=",
fileEncSha256: "sR9D2RS5JSifw49HeBADguI23fWDz1aZu4faWG/CyRY=",
directPath:
"/v/t62.7118-24/21427642_840952686474581_572788076332761430_n.enc?oh=3f57c1ba2fcab95f2c0bb475d72720ba&oe=602F3D69",
mediaKeyTimestamp: "1610993486",
jpegThumbnail: fs.readFileSync("./sticker/thumb.jpg"),
scansSidecar:
"1W0XhfaAcDwc7xh1R8lca6Qg/1bB4naFCSngM2LKO2NoP5RI7K+zLw==",
},
},
}
if (!isCmd && isGroup && isAlreadyResponList(from, chats, db_respon_list)) {
var get_data_respon = getDataResponList(from, chats, db_respon_list)
if (get_data_respon.isImage === false) {
adReply(sendResponList(from, chats, db_respon_list), groupName, tanggal, msg)
} else {
conn.sendMessage(from, { image: await getBuffer(get_data_respon.image_url), caption: get_data_respon.response }, {
quoted: msg
})
}
}
const sendContact = (jid, numbers, name, quoted, mn) => {
let number = numbers.replace(/[^0-9]/g, '')
const vcard = 'BEGIN:VCARD\n'
+ 'VERSION:3.0\n'
+ 'FN:' + name + '\n'
+ 'ORG:;\n'
+ 'TEL;type=CELL;type=VOICE;waid=' + number + ':+' + number + '\n'
+ 'END:VCARD'
return conn.sendMessage(from, { contacts: { displayName: name, contacts: [{ vcard }] }, mentions: mn ? mn : [] }, { quoted: quoted })
}
// presence update
// await conn.sendPresenceUpdate('unavailable', from)
// Logs cmd
if (isCmd && fromMe) {
var txt = color('──────────────────> COMMAND') + "\n"
txt += `• Time : ` + color(moment(msg.messageTimestamp * 1000).format('DD/MM/YYYY HH:mm:ss'), 'white') + "\n"
txt += `• From : ` + color(sender) + " as " + color(pushname) + "\n"
txt += `• In : ` + color(from) + "\n"
txt += `• Cmd : ` + color(`${command} [${args.length}]`) + "\n"
txt += color('────────────────────────────>') + "\n"
console.log(txt)
}
// Logs chats
if (!isGroup && chats && !isSticker && !isMedia) {
var txt = color('──────────────────> Personal Chat', 'red') + "\n"
txt += `• Time : ` + color(moment(msg.messageTimestamp * 1000).format('DD/MM/YYYY HH:mm:ss'), 'white') + "\n"
txt += `• From : ` + color(sender) + " as " + color(pushname) + "\n"
txt += `• Text : ` + color(`${chats}`, 'yellow') + "\n"
txt += color('─────────────────────────────────>', 'red') + "\n"
console.log(txt)
}
if (isGroup && chats && !isSticker && !isMedia) {
var txt = "\n" + color('──────────────────> GROUP CHAT', 'yellow') + "\n"
txt += `• Time : ` + color(moment(msg.messageTimestamp * 1000).format('DD/MM/YYYY HH:mm:ss'), 'white') + "\n"
txt += `• From : ` + color(sender) + " as " + color(pushname) + "\n"
txt += `• Group : ` + color(from) + " as " + color(groupName) + "\n"
txt += `• Text : ` + color(`${chats}`, 'yellow') + "\n"
txt += color('──────────────────────────────>', 'yellow') + "\n"
console.log(txt)
}
if (!fromMe) return
// Eval
if (chats.startsWith("x ")) {
console.log(color('[EVAL]'), color(moment(msg.messageTimestamp * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`From Owner`))
try {
let evaled = await eval(chats.slice(1))
if (typeof evaled !== 'string') evaled = require("util").inspect(evaled)
reply(`${evaled}`)
} catch (err) {
reply(err)
}
}
if (chats.startsWith("> ")) {
console.log(color('[EVAL]'), color(moment(msg.messageTimestamp * 1000).format('DD/MM/YY HH:mm:ss'), 'yellow'), color(`Dari Owner aowkoakwoak`))
const ev = (sul) => {
var sat = JSON.stringify(sul, null, 2)
var bang = util.format(sat)
if (sat == undefined) {
bang = util.format(sul)
}
return reply(bang)
}
try {
reply(util.format(eval(`;(async () => { ${chats.slice(1)} })()`)))
} catch (e) {
reply(util.format(e))
}
}
if (chats.startsWith("Test")) {
adReply(`*SELFBOT ONLINE* ✅
• Botname : ${setting.botName}
• Library : Baileys
• Prefix : ${prefix}
• Creator : ${setting.ownerName}
• Runtime : ${runtime(process.uptime())}
• Source Code :
https://github.com/dragneel1111/Simple-Selfbot
`,
`${tanggal}`, `${jam}`)
console.log(color(`[ SELFBOT ONLINE || RUNTIME: ${runtime(process.uptime())} ] ${tanggal}`, 'cyan'))
}
switch (command) {
case 'menu': case 'help':
if (!q) {
var cptn = `*Just Simple Selfbot*\n${readmore}\n`
cptn += `_Convert_\n`
cptn += `• ${prefix}sticker\n`
cptn += `• ${prefix}toimg\n`
cptn += `• ${prefix}tovideo\n`
cptn += `• ${prefix}toaudio\n`
cptn += `• ${prefix}tourl\n`
cptn += `• ${prefix}take\n`
cptn += `• ${prefix}stickermeme\n\n`
cptn += `_Downloader_\n`
cptn += `• ${prefix}play\n`
cptn += `• ${prefix}ytsearch\n`
cptn += `• ${prefix}ytmp3\n`
cptn += `• ${prefix}ytmp4\n`
cptn += `• ${prefix}facebook\n`
cptn += `• ${prefix}instagram\n`
cptn += `• ${prefix}tiktok\n`
cptn += `• ${prefix}mediafire\n`
cptn += `• ${prefix}mega\n\n`
cptn += `_Tools_\n`
cptn += `• ${prefix}creator\n`
cptn += `• ${prefix}setppbot\n`
cptn += `• ${prefix}setppbot\n`
cptn += `• ${prefix}infogroup\n`
cptn += `• ${prefix}reply\n`
cptn += `• ${prefix}readmore\n`
cptn += `• ${prefix}hidetag\n\n`
cptn += `${setting.wm}\n_Create by @Rafly͘~_\n_Since 01-12-2020_`
adReply2(cptn, setting.wm, setting.botName)
} else if (q.includes('owner')) {
var cptn = `_Owner Tools_\n`
cptn += `• ${prefix}setprefix\n`
cptn += `• ${prefix}setmenu\n`
cptn += `• ${prefix}setadreply\n`
cptn += `• ${prefix}setthumb\n`
cptn += `• ${prefix}error\n`
cptn += `• ${prefix}clear\n`
cptn += `• ${prefix}sendsesi\n`
cptn += `• ${prefix}addrespon\n`
cptn += `• ${prefix}delrespon\n`
adReply(cptn, tanggal, jam)
}
break
// DOWNLOADER
case 'mega':
if (!q) return reply(`example:\n${prefix + command} https://mega.nz/file/0FUA2bzb#vSu3Ud9Ft_HDz6zPvfIg_y62vE1qF8EmoYT3kY16zxo`)
var file = File.fromURL(q)
await file.loadAttributes()
if (file.size >= 300000000) return adReply('Minimum Size: 300MB', 'Error: file size is too large ')
adReply(`*_Please wait a few minutes..._*`, file.name, 'downloading...')
var data = await file.downloadBuffer()
if (/mp4/.test(data)) {
await conn.sendMessage(from, { document: data, mimetype: "video/mp4", fileName: `${file.name}.mp4` }, { quoted: msg })
} else if (/pdf/.test(data)) {
await conn.sendMessage(from, { document: data, mimetype: "application/pdf", fileName: `${file.name}.pdf` }, { quoted: msg })
}
break
case 'facebook':
case 'fbdl':
case 'fb':
if (!q) return reply(`example:\n${prefix + command} https://www.facebook.com/groups/1821107578248933/permalink/1951979891828367/`)
var data = await facebook.v1(q)
try {
var hasil = await getBuffer(data.urls[0].hd)
await conn.sendMessage(from, {
video: hasil,
}, { quoted: msg })
} catch (err) {
var hasil = await getBuffer(data.urls[1].sd)
await conn.sendMessage(from, {
video: hasil,
}, { quoted: msg })
}
break
case 'instagram':
case 'igdl':
case 'ig':
if (!q) return reply(`example:\n${prefix + command} https://www.instagram.com/p/C036XZdvBI2/?igsh=MzRlODBiNWFlZA==`)
var data = await snapsave(q)
var hasil = await getBuffer(data[0].url)
await conn.sendMessage(from, {
[(/mp4/.test(hasil)) ? "video" : "image"]: hasil,
}, { quoted: msg })
break
case 'play':
case 'ytplay':
if (!q) return reply(`example:\n${prefix + command} kokoronashi`)
var ytplay = await youtube.search(q)
var data = await youtubedl(ytplay[6].url)
var url = await data.audio['128kbps'].download()
var hasil = await getBuffer(url)
await conn.sendMessage(from, {
document: hasil,
mimetype: "audio/mp4",
fileName: `${data.title}.mp3`,
jpegThumbnail: fs.readFileSync('./sticker/thumb.jpg'),
}, { quoted: msg })
await conn.sendMessage(from, { audio: hasil, mimetype: "audio/mp4" }, { quoted: msg })
break
case 'ytmp3':
case 'mp3':
if (!q) return reply(`example\n${prefix + command} https://youtu.be/Pp2p4WABjos`)
var data = await youtubedl(q)
var url = await data.audio['128kbps'].download()
var hasil = await getBuffer(url)
await conn.sendMessage(from, {
document: hasil,
mimetype: "audio/mp4",
fileName: `${data.title}.mp3`,
jpegThumbnail: fs.readFileSync('./sticker/thumb.jpg'),
}, { quoted: msg })
await sleep(500)
await conn.sendMessage(from, { audio: hasil, mimetype: "audio/mp4" }, { quoted: msg })
break
case 'ytmp4':
case 'mp4':
if (!q) return reply(`example\n${prefix + command} https://youtu.be/Pp2p4WABjos`)
var data = await youtubedl(q)
var url = await data.video['auto'].download()
var hasil = await getBuffer(url)
await conn.sendMessage(from, {
video: hasil,
caption: data.title,
}, { quoted: msg })
break
case 'ytsearch':
case 'yts':
if (!q) return reply(`example:\n${prefix + command} Tekotok`)
var data = await youtube.search(q)
var cptn = `_*Result of ${q}*_\n\n`
for (let y of data) {
cptn += `• title: ${y.title}\n`
cptn += `• duration: ${y.duration}\n`
cptn += `• uploaded: ${y.uploaded}\n`
cptn += `• views: ${y.views}\n`
cptn += `• url: ${y.url}\n\n`
}
adReply(cptn, q, 'Youtube Search', msg)
break
case 'tiktok':
case 'tt':
if (!q) return reply(`example :\n${prefix + command} https://vt.tiktok.com/ZSN7Lf1dg/`)
var data = await fetchJson(`https://www.tikwm.com/api/?url=${q}?hd=1`)
hasil = data.data
try {
var url = data.data.images
var cptn = `*Id:* ${hasil.author.unique_id}\n`
cptn += `*Nickname:* ${hasil.author.nickname}\n`
cptn += `*Play Count:* ${hasil.play_count}\n`
cptn += `*Comment Count:* ${hasil.comment_count}\n`
cptn += `*Download Count:* ${hasil.download_count}\n`
cptn += `*Images Count:* ${url.length}\n`
cptn += `\n${hasil.title}`
await adReply(cptn, "Uploading Media...", "Tiktok Downloader", msg)
await sleep(500)
for (let o = 0; o < url.length; o++) {
await conn.sendMessage(from, {
[(/mp4/.test(url[o])) ? "video" : "image"]: { url: url[o] }
},
{ quoted: msg })
await sleep(200)
}
} catch (err) {
var url = data.data.play
var cptn = `*Id:* ${hasil.author.unique_id}\n`
cptn += `*Nickname:* ${hasil.author.nickname}\n`
cptn += `*Play Count:* ${hasil.play_count}\n`
cptn += `*Comment Count:* ${hasil.comment_count}\n`
cptn += `*Download Count:* ${hasil.download_count}\n`
cptn += `\n${hasil.title}`
await conn.sendMessage(from, {
video: { url: url },
caption: cptn,
},
{ quoted: msg })
}
break
case 'mediafire':
if (!q) return reply('*example:*\n#mediafire https://www.mediafire.com/file/451l493otr6zca4/V4.zip/file')
let isLinks = q.match(/(?:https?:\/{2})?(?:w{3}\.)?mediafire(?:com)?\.(?:com|be)(?:\/www\?v=|\/)([^\s&]+)/)
if (!isLinks) return reply('Invalid Link')
let baby1 = await mediafireDl(`${isLinks}`)
if (baby1[0].size.split('MB')[0] >= 1500) return reply('File Melebihi Batas ' + util.format(baby1))
let result4 = `*MEDIAFIRE DOWNLOADER*
*Name* : ${baby1[0].nama}
*Size* : ${baby1[0].size}
*Type* : ${baby1[0].mime}
_Wait Mengirim file..._
`
adReply(result4, `${baby1[0].nama}`, ``)
conn.sendMessage(from, { document: { url: baby1[0].link }, fileName: baby1[0].nama, mimetype: baby1[0].mime }, { quoted: msg }).catch((err) => adReply('*Failed to uploading media*', 'ERROR'))
break
// Owner tools
case 'setmenu':
if (isImage || isQuotedImage) {
await conn.downloadAndSaveMediaMessage(msg, 'image', `./sticker/menu.jpg`)
}
reply('Done')
break
case 'setthumb':
if (isImage || isQuotedImage) {
await conn.downloadAndSaveMediaMessage(msg, 'image', `./sticker/thumb.jpg`)
}
reply('Done')
break
case 'setadreply':
if (isImage || isQuotedImage) {
await conn.downloadAndSaveMediaMessage(msg, 'image', `./sticker/adreply.jpg`)
}
reply('Done')
break
case 'setppbot':
case 'setpp':
case 'spb':
if (isImage && isQuotedImage) return
await conn.downloadAndSaveMediaMessage(msg, "image", `./sticker/${sender.split('@')[0]}.jpg`)
var media = `./sticker/${sender.split('@')[0]}.jpg`
var { img } = await conn.generateProfilePicture(media)
await conn.query({
tag: 'iq',
attrs: {
to: botNumber,
type: 'set',
xmlns: 'w:profile:picture'
},
content: [
{
tag: 'picture',
attrs: { type: 'image' },
content: img
}
]
})
await sleep(2000)
fs.unlinkSync(media)
break
case 'setprefix':
setting.prefix = args[0]
fs.writeFileSync('./config.json', JSON.stringify(setting, null, 2))
reply('done')
break
case 'mysesi': case 'sendsesi': case 'session': {
reply('please wait..')
await sleep(3000)
// Read Database
var sesi_bot = fs.readFileSync(`./sessions/creds.json`)
// Sending Document
conn.sendMessage(from, { document: sesi_bot, mimetype: 'document/application', fileName: 'session.json' }, { quoted: msg })
}
break
case 'clear':
case 'clearer':
case 'clearerr': {
server_eror.splice('[]')
fs.writeFileSync('./database/func_error.json', JSON.stringify(server_eror))
reply('Done')
}
break
case 'error': {
var teks = `*ERROR SERVER*\n_Error total_ : ${server_eror.length}\n\n`
var NO = 1
for (let i of server_eror) {
teks += `=> *ERROR (${NO++})*\n${i.error}\n\n`
}
adReply(teks, "List Error", "")
}
break
case 'addrespon':
var args1 = q.split("|")[0]
var args2 = q.split("|")[1]
if (!q.includes("|")) return reply(`use ${prefix + command} *key|response*\n\n_example_\n\n#${command} tes|apa`)
if (isAlreadyResponList(from, args1, db_respon_list)) return reply(`Response key : *${args1}* already added in this group`)
addResponList(from, args1, args2, false, '-', db_respon_list)
reply(`Success add key: *${args1}*`)
break
case 'delrespon':
if (db_respon_list.length === 0) return reply(`not found`)
if (!q) return reply(`use: ${prefix + command} *key*\n\n_example_\n\n${command} hello`)
if (!isAlreadyResponList(from, q, db_respon_list)) return reply(`List response key: *${q}* not found in database!`)
delResponList(from, q, db_respon_list)
reply(`Success delete key: *${q}*`)
break
case 'fitnah':
case 'reply':
if (!isGroup) return
if (!q) return reply(`example *${prefix + command}* @tag|targetmessage|botmessage`)
var org = q.split("|")[0]
var target = q.split("|")[1]
var bot = q.split("|")[2]
if (!org.startsWith('@')) return reply('Tag someone')
if (!target) return reply(`add target message`)
if (!bot) return reply(`add bot message`)
var mens = parseMention(target)
var msg1 = { key: { fromMe: false, participant: `${parseMention(org)}`, remoteJid: from ? from : '' }, message: { extemdedTextMessage: { text: `${target}`, contextInfo: { mentionedJid: mens } } } }
var msg2 = { key: { fromMe: false, participant: `${parseMention(org)}`, remoteJid: from ? from : '' }, message: { conversation: `${target}` } }
conn.sendMessage(from, { text: bot, mentions: mentioned }, { quoted: mens.length > 2 ? msg1 : msg2 })
break
case 'setppgrup':
case 'setppgc':
case 'spgc':
if (!isGroup) return
if (isImage && isQuotedImage) return reply(`Kirim gambar dengan caption *#bukti* atau reply gambar yang sudah dikirim dengan caption *#bukti*`)
await conn.downloadAndSaveMediaMessage(msg, "image", `./sticker/${sender.split('@')[0]}.jpg`)
var media = `./sticker/${sender.split('@')[0]}.jpg`
var { img } = await conn.generateProfilePicture(media)
await conn.query({
tag: 'iq',
attrs: {
to: from,
type: 'set',
xmlns: 'w:profile:picture'
},
content: [
{
tag: 'picture',
attrs: { type: 'image' },
content: img
}
]
})
await sleep(2000)
fs.unlinkSync(media)
break
case 'tagall':
if (!q) return reply(`Teks?`)
let teks_tagall = `══✪〘 *👥 Tag All* 〙✪══\n\n${q ? q : ''}\n\n`
for (let mem of participants) {
teks_tagall += `➲ @${mem.id.split('@')[0]}\n`
}
conn.sendMessage(from, { text: teks_tagall, mentions: participants.map(a => a.id) }, { quoted: msg })
break
case 'hidetag':
case 'h':
if (!isGroup) return
let mem = [];
groupMembers.map(i => mem.push(i.id))
conn.sendMessage(from, { text: q ? q : '', mentions: mem })
break
case 'infogc':
case 'infogrup':
case 'infogroup':
if (!isGroup) return
var ppgc = await conn.profilePictureUrl(from, 'image')
let cekgcnya = `*INFO GROUP*
• *ID:* ${from}
• *Name:* ${groupName}
• *Member:* ${groupMembers.length}
• *Total Admin:* ${groupAdmins.length}
• *Description:*\n ${groupMetadata.desc}
`
await conn.sendMessage(from, {
image: { url: ppgc },
caption: cekgcnya
})
break
//TOOLS
case 'tourl': case 'upload':
if (isVideo || isQuotedVideo) {
await conn.downloadAndSaveMediaMessage(msg, 'video', `./sticker/${sender.split("@")[0]}.mp4`)
let buffer_up = fs.readFileSync(`./sticker/${sender.split("@")[0]}.mp4`)
var rand2 = 'sticker/' + getRandom('.mp4')
fs.writeFileSync(`./${rand2}`, buffer_up)
var text = await TelegraPh(rand2)
reply(text)
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.mp4`)
fs.unlinkSync(rand2)
} else if (isImage || isQuotedImage) {
var mediany = await conn.downloadAndSaveMediaMessage(msg, 'image', `./sticker/${sender.split("@")[0]}.jpg`)
let buffer_up = fs.readFileSync(mediany)
var rand2 = 'sticker/' + getRandom('.png')
fs.writeFileSync(`./${rand2}`, buffer_up)
var text = await TelegraPh(rand2)
reply(text)
fs.unlinkSync(mediany)
fs.unlinkSync(rand2)
}
break
case 'readmore':
var txt1 = q.split('|')[0]
var txt2 = q.split('|')[1]
await conn.sendMessage(from, { text: `${txt1}${readmore}${txt2}` })
break
// CONVERT
case 'toimg': case 'toimage':
if (isSticker || isQuotedSticker) {
await conn.downloadAndSaveMediaMessage(msg, "sticker", `./sticker/${sender.split("@")[0]}.webp`)
let buffer = fs.readFileSync(`./sticker/${sender.split("@")[0]}.webp`)
var rand1 = 'sticker/' + getRandom('.webp')
var rand2 = 'sticker/' + getRandom('.png')
fs.writeFileSync(`./${rand1}`, buffer)
exec(`ffmpeg -i ./${rand1} ./${rand2}`, (err) => {
fs.unlinkSync(`./${rand1}`)
if (err) return reply('*ERROR*')
conn.sendMessage(from, { image: fs.readFileSync(`./${rand2}`), jpegThumbnail: fs.readFileSync('./sticker/thumb.jpg'), fileLength: 99999999999999 }, { quoted: msg })
fs.unlinkSync(`./${rand2}`)
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.webp`)
})
} else {
reply(`Tag/reply picture with caption ${prefix + command}`)
}
break
case 'tomp4': case 'tovideo':
if (isSticker || isQuotedSticker) {
await conn.downloadAndSaveMediaMessage(msg, "sticker", `./sticker/${sender.split("@")[0]}.webp`)
let buffer = `./sticker/${sender.split("@")[0]}.webp`
let webpToMp4 = await webp2mp4File(buffer)
conn.sendMessage(from, { video: { url: webpToMp4.result }, caption: 'Convert Webp To Video', jpegThumbnail: fs.readFileSync('./sticker/thumb.jpg') }, { quoted: msg })
fs.unlinkSync(buffer)
} else {
reply(`Tag/reply picture with caption ${prefix + command}`)
}
break
case 'tomp3': case 'toaudio':
if (isVideo || isQuotedVideo) {
await conn.downloadAndSaveMediaMessage(msg, 'video', `./sticker/${sender.split("@")[0]}.mp4`)
let buffer_up = fs.readFileSync(`./sticker/${sender.split("@")[0]}.mp4`)
var rand2 = 'sticker/' + getRandom('.mp4')
fs.writeFileSync(`./${rand2}`, buffer_up)
exec(`ffmpeg -i ${media} ${rand2}`, (err) => {
var buffer453 = fs.readFileSync(rand2);
conn.sendMessage(from, {
audio: buffer453,
mimetype: "audio/mp4",
quoted: msg,
});
fs.unlinkSync(rand2);
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.mp4`)
})
}
break
case 'smeme':
case 'stikermeme':
case 'stickermeme':
case 'memestiker':
case 'stcmeme':
anu = q.split("|");
var atas = anu[0] !== "" ? anu[0] : " ";
var bawah = q.split('|')[1]
if (!q) return reply(`Kirim gambar dengan caption ${prefix + command} text_atas|text_bawah atau balas gambar yang sudah dikirim`)
if (isImage || isQuotedImage) {
var media = await conn.downloadAndSaveMediaMessage(msg, 'image', `./sticker/${sender.split('@')[0]}.jpg`)
var media_url = await TelegraPh(media)
var meme_url = `https://api.memegen.link/images/custom/${encodeURIComponent(atas)}/${encodeURIComponent(bawah)}.png?background=${media_url}`
let stcmeme = new Sticker(meme_url, {
pack: '', // The pack name
author: setting.wm, // 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: 'transparent' // The sticker background color (only for full stickers)
})
var buffer = await stcmeme.toBuffer()
conn.sendMessage(from, { sticker: buffer, fileLength: 1000000000000 }, { quoted: msg })
fs.unlinkSync(media)
}
break
case 'swm':
case 'stikerwm':
case 'stickerwm':
case 'takesticker':
case 'take':
var anu = q.split("|");
var pname = anu[0] !== "" ? anu[0] : ``;
var athor = q.split('|')[1]
if (isSticker || isQuotedSticker) {
await conn.downloadAndSaveMediaMessage(msg, "sticker", `./sticker/${sender.split("@")[0]}.webp`)
var media = fs.readFileSync(`./sticker/${sender.split("@")[0]}.webp`)
let stc = new Sticker(media, {
pack: `${pname}`, // The pack name
author: `${athor}`, // 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: 'transparent' // The sticker background color (only for full stickers)
})
var buffer = await stc.toBuffer()
conn.sendMessage(from, { sticker: buffer, fileLength: 1000000000000 }, { quoted: msg })
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.webp`)
} else {
reply(`reply dengan caption ${prefix + command} packname|author atau balas video/foto yang sudah dikirim`)
}
break
case 'sticker': case 's': case 'stiker': case 'stc':
if (isImage || isQuotedImage) {
await conn.downloadAndSaveMediaMessage(msg, "image", `./sticker/${sender.split("@")[0]}.jpeg`)
let stci = fs.readFileSync(`./sticker/${sender.split("@")[0]}.jpeg`)
let stc = new Sticker(stci, {
pack: '', // The pack name
author: setting.wm, // The author name
type: StickerTypes.FULL, // The sticker type
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 75, // The quality of the output file
background: 'transparent' // The sticker background color (only for full stickers)
})
var buffer = await stc.toBuffer()
conn.sendMessage(from, { sticker: buffer, fileLength: 99999999 }, { quoted: msg })
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.jpeg`)
} else if (isVideo && msg.message.videoMessage.seconds < 10 || isQuotedVideo && quotedMsg.videoMessage.seconds < 10) {
await conn.downloadAndSaveMediaMessage(msg, "video", `./sticker/${sender.split("@")[0]}.mp4`)
let stcg = fs.readFileSync(`./sticker/${sender.split("@")[0]}.mp4`)
let sticker = new Sticker(stcg, {
pack: '', // The pack name
author: setting.wm, // The author name
type: StickerTypes.FULL, // The sticker type
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 20, // The quality of the output file
background: 'transparent' // The sticker background color (only for full stickers)
})
const stikk = await sticker.toBuffer()
conn.sendMessage(from, { sticker: stikk, fileLength: 99999999 }, { quoted: msg })
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.mp4`)
}
break
case 'stickercrop': case 'scrop': case 'stikercrop':
if (isImage || isQuotedImage) {
await conn.downloadAndSaveMediaMessage(msg, "image", `./sticker/${sender.split("@")[0]}.jpeg`)
let stci = fs.readFileSync(`./sticker/${sender.split("@")[0]}.jpeg`)
let stc = new Sticker(stci, {
pack: '', // The pack name
author: setting.wm, // The author name
type: StickerTypes.CROPPED, // The sticker type
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 75, // The quality of the output file
background: 'transparent' // The sticker background color (only for full stickers)
})
var buffer = await stc.toBuffer()
conn.sendMessage(from, { sticker: buffer, fileLength: 99999999 }, { quoted: msg })
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.jpeg`)
} else if (isVideo && msg.message.videoMessage.seconds < 10 || isQuotedVideo && quotedMsg.videoMessage.seconds < 10) {
await conn.downloadAndSaveMediaMessage(msg, "video", `./sticker/${sender.split("@")[0]}.mp4`)
let stcg = fs.readFileSync(`./sticker/${sender.split("@")[0]}.mp4`)
let sticker = new Sticker(stcg, {
pack: '', // The pack name
author: setting.wm, // The author name
type: StickerTypes.CROPPED, // The sticker type
categories: ['🤩', '🎉'], // The sticker category
id: '12345', // The sticker id
quality: 20, // The quality of the output file
background: 'transparent' // The sticker background color (only for full stickers)
})
const stikk = await sticker.toBuffer()
conn.sendMessage(from, { sticker: stikk, fileLength: 99999999 }, { quoted: msg })
fs.unlinkSync(`./sticker/${sender.split("@")[0]}.mp4`)
}
break
default:
}
} catch (err) {
console.log(color('[ERROR]', 'red'), err)
server_eror.push({ "error": `${err}` })
fs.writeFileSync('./database/func_error.json', JSON.stringify(server_eror))
}
}