𝗗𝗔𝗥𝗥𝗘𝗟𝗟 𝗠𝗨𝗖𝗛𝗘𝗥𝗜 ⚡ commited on
Commit
3d8e544
·
unverified ·
1 Parent(s): b38d64c

Subzero MD

Browse files
Files changed (3) hide show
  1. lib/functions.js +113 -0
  2. lib/msg.js +145 -0
  3. lib/shannzCdn.js +43 -0
lib/functions.js ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺
2
+ ⭐PROJECT NAME:
3
+ SUBZERO WHATSAPP MD BOT
4
+
5
+ ⭐DEVELOPER
6
+ MR FRANK
7
+
8
+ ⭐ MY TEAM
9
+ XERO CODERS
10
+
11
+ ⭐ OUR WEBSITE
12
+ https://github.com/ZwSyntax/SUBZERO-MD
13
+
14
+ © TRY DECRYPTING IF YOU CAN⚠
15
+
16
+ ╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺*/
17
+
18
+
19
+
20
+ const axios = require('axios')
21
+
22
+ const getBuffer = async(url, options) => {
23
+ try {
24
+ options ? options : {}
25
+ var res = await axios({
26
+ method: 'get',
27
+ url,
28
+ headers: {
29
+ 'DNT': 1,
30
+ 'Upgrade-Insecure-Request': 1
31
+ },
32
+ ...options,
33
+ responseType: 'arraybuffer'
34
+ })
35
+ return res.data
36
+ } catch (e) {
37
+ console.log(e)
38
+ }
39
+ }
40
+
41
+ const getGroupAdmins = (participants) => {
42
+ var admins = []
43
+ for (let i of participants) {
44
+ i.admin !== null ? admins.push(i.id) : ''
45
+ }
46
+ return admins
47
+ }
48
+
49
+ const getRandom = (ext) => {
50
+ return `${Math.floor(Math.random() * 10000)}${ext}`
51
+ }
52
+
53
+ const h2k = (eco) => {
54
+ var lyrik = ['', 'K', 'M', 'B', 'T', 'P', 'E']
55
+ var ma = Math.log10(Math.abs(eco)) / 3 | 0
56
+ if (ma == 0) return eco
57
+ var ppo = lyrik[ma]
58
+ var scale = Math.pow(10, ma * 3)
59
+ var scaled = eco / scale
60
+ var formatt = scaled.toFixed(1)
61
+ if (/\.0$/.test(formatt))
62
+ formatt = formatt.substr(0, formatt.length - 2)
63
+ return formatt + ppo
64
+ }
65
+
66
+ const isUrl = (url) => {
67
+ return url.match(
68
+ new RegExp(
69
+ /https?:\/\/(www\.)?[-a-zA-Z0-9@:%.+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%+.~#?&/=]*)/,
70
+ 'gi'
71
+ )
72
+ )
73
+ }
74
+
75
+ const Json = (string) => {
76
+ return JSON.stringify(string, null, 2)
77
+ }
78
+
79
+ const runtime = (seconds) => {
80
+ seconds = Number(seconds)
81
+ var d = Math.floor(seconds / (3600 * 24))
82
+ var h = Math.floor(seconds % (3600 * 24) / 3600)
83
+ var m = Math.floor(seconds % 3600 / 60)
84
+ var s = Math.floor(seconds % 60)
85
+ var dDisplay = d > 0 ? d + (d == 1 ? ' day, ' : ' days, ') : ''
86
+ var hDisplay = h > 0 ? h + (h == 1 ? ' hour, ' : ' hours, ') : ''
87
+ var mDisplay = m > 0 ? m + (m == 1 ? ' minute, ' : ' minutes, ') : ''
88
+ var sDisplay = s > 0 ? s + (s == 1 ? ' second' : ' seconds') : ''
89
+ return dDisplay + hDisplay + mDisplay + sDisplay;
90
+ }
91
+
92
+ const sleep = async(ms) => {
93
+ return new Promise(resolve => setTimeout(resolve, ms))
94
+ }
95
+
96
+ const fetchJson = async (url, options) => {
97
+ try {
98
+ options ? options : {}
99
+ const res = await axios({
100
+ method: 'GET',
101
+ url: url,
102
+ headers: {
103
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
104
+ },
105
+ ...options
106
+ })
107
+ return res.data
108
+ } catch (err) {
109
+ return err
110
+ }
111
+ }
112
+
113
+ module.exports = { getBuffer, getGroupAdmins, getRandom, h2k, isUrl, Json, runtime, sleep , fetchJson}
lib/msg.js ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺
2
+ ⭐PROJECT NAME:
3
+ SUBZERO WHATSAPP MD BOT
4
+
5
+ ⭐DEVELOPER
6
+ MR FRANK
7
+
8
+ ⭐ MY TEAM
9
+ XERO CODERS
10
+
11
+ ⭐ OUR WEBSITE
12
+ https://github.com/ZwSyntax/SUBZERO-MD
13
+
14
+ © TRY DECRYPTING IF YOU CAN⚠
15
+
16
+ ╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺*/
17
+
18
+
19
+
20
+
21
+ const { proto, downloadContentFromMessage, getContentType } = require('@whiskeysockets/baileys')
22
+ const fs = require('fs')
23
+
24
+ const downloadMediaMessage = async(m, filename) => {
25
+ if (m.type === 'viewOnceMessage') {
26
+ m.type = m.msg.type
27
+ }
28
+ if (m.type === 'imageMessage') {
29
+ var nameJpg = filename ? filename + '.jpg' : 'undefined.jpg'
30
+ const stream = await downloadContentFromMessage(m.msg, 'image')
31
+ let buffer = Buffer.from([])
32
+ for await (const chunk of stream) {
33
+ buffer = Buffer.concat([buffer, chunk])
34
+ }
35
+ fs.writeFileSync(nameJpg, buffer)
36
+ return fs.readFileSync(nameJpg)
37
+ } else if (m.type === 'videoMessage') {
38
+ var nameMp4 = filename ? filename + '.mp4' : 'undefined.mp4'
39
+ const stream = await downloadContentFromMessage(m.msg, 'video')
40
+ let buffer = Buffer.from([])
41
+ for await (const chunk of stream) {
42
+ buffer = Buffer.concat([buffer, chunk])
43
+ }
44
+ fs.writeFileSync(nameMp4, buffer)
45
+ return fs.readFileSync(nameMp4)
46
+ } else if (m.type === 'audioMessage') {
47
+ var nameMp3 = filename ? filename + '.mp3' : 'undefined.mp3'
48
+ const stream = await downloadContentFromMessage(m.msg, 'audio')
49
+ let buffer = Buffer.from([])
50
+ for await (const chunk of stream) {
51
+ buffer = Buffer.concat([buffer, chunk])
52
+ }
53
+ fs.writeFileSync(nameMp3, buffer)
54
+ return fs.readFileSync(nameMp3)
55
+ } else if (m.type === 'stickerMessage') {
56
+ var nameWebp = filename ? filename + '.webp' : 'undefined.webp'
57
+ const stream = await downloadContentFromMessage(m.msg, 'sticker')
58
+ let buffer = Buffer.from([])
59
+ for await (const chunk of stream) {
60
+ buffer = Buffer.concat([buffer, chunk])
61
+ }
62
+ fs.writeFileSync(nameWebp, buffer)
63
+ return fs.readFileSync(nameWebp)
64
+ } else if (m.type === 'documentMessage') {
65
+ var ext = m.msg.fileName.split('.')[1].toLowerCase().replace('jpeg', 'jpg').replace('png', 'jpg').replace('m4a', 'mp3')
66
+ var nameDoc = filename ? filename + '.' + ext : 'undefined.' + ext
67
+ const stream = await downloadContentFromMessage(m.msg, 'document')
68
+ let buffer = Buffer.from([])
69
+ for await (const chunk of stream) {
70
+ buffer = Buffer.concat([buffer, chunk])
71
+ }
72
+ fs.writeFileSync(nameDoc, buffer)
73
+ return fs.readFileSync(nameDoc)
74
+ }
75
+ }
76
+
77
+ const sms = (conn, m) => {
78
+ if (m.key) {
79
+ m.id = m.key.id
80
+ m.chat = m.key.remoteJid
81
+ m.fromMe = m.key.fromMe
82
+ m.isGroup = m.chat.endsWith('@g.us')
83
+ m.sender = m.fromMe ? conn.user.id.split(':')[0]+'@s.whatsapp.net' : m.isGroup ? m.key.participant : m.key.remoteJid
84
+ }
85
+ if (m.message) {
86
+ m.type = getContentType(m.message)
87
+ m.msg = (m.type === 'viewOnceMessage') ? m.message[m.type].message[getContentType(m.message[m.type].message)] : m.message[m.type]
88
+ if (m.msg) {
89
+ if (m.type === 'viewOnceMessage') {
90
+ m.msg.type = getContentType(m.message[m.type].message)
91
+ }
92
+ var quotedMention = m.msg.contextInfo != null ? m.msg.contextInfo.participant : ''
93
+ var tagMention = m.msg.contextInfo != null ? m.msg.contextInfo.mentionedJid : []
94
+ var mention = typeof(tagMention) == 'string' ? [tagMention] : tagMention
95
+ mention != undefined ? mention.push(quotedMention) : []
96
+ m.mentionUser = mention != undefined ? mention.filter(x => x) : []
97
+ m.body = (m.type === 'conversation') ? m.msg : (m.type === 'extendedTextMessage') ? m.msg.text : (m.type == 'imageMessage') && m.msg.caption ? m.msg.caption : (m.type == 'videoMessage') && m.msg.caption ? m.msg.caption : (m.type == 'templateButtonReplyMessage') && m.msg.selectedId ? m.msg.selectedId : (m.type == 'buttonsResponseMessage') && m.msg.selectedButtonId ? m.msg.selectedButtonId : ''
98
+ m.quoted = m.msg.contextInfo != undefined ? m.msg.contextInfo.quotedMessage : null
99
+ if (m.quoted) {
100
+ m.quoted.type = getContentType(m.quoted)
101
+ m.quoted.id = m.msg.contextInfo.stanzaId
102
+ m.quoted.sender = m.msg.contextInfo.participant
103
+ m.quoted.fromMe = m.quoted.sender.split('@')[0].includes(conn.user.id.split(':')[0])
104
+ m.quoted.msg = (m.quoted.type === 'viewOnceMessage') ? m.quoted[m.quoted.type].message[getContentType(m.quoted[m.quoted.type].message)] : m.quoted[m.quoted.type]
105
+ if (m.quoted.type === 'viewOnceMessage') {
106
+ m.quoted.msg.type = getContentType(m.quoted[m.quoted.type].message)
107
+ }
108
+ var quoted_quotedMention = m.quoted.msg.contextInfo != null ? m.quoted.msg.contextInfo.participant : ''
109
+ var quoted_tagMention = m.quoted.msg.contextInfo != null ? m.quoted.msg.contextInfo.mentionedJid : []
110
+ var quoted_mention = typeof(quoted_tagMention) == 'string' ? [quoted_tagMention] : quoted_tagMention
111
+ quoted_mention != undefined ? quoted_mention.push(quoted_quotedMention) : []
112
+ m.quoted.mentionUser = quoted_mention != undefined ? quoted_mention.filter(x => x) : []
113
+ m.quoted.fakeObj = proto.WebMessageInfo.fromObject({
114
+ key: {
115
+ remoteJid: m.chat,
116
+ fromMe: m.quoted.fromMe,
117
+ id: m.quoted.id,
118
+ participant: m.quoted.sender
119
+ },
120
+ message: m.quoted
121
+ })
122
+ m.quoted.download = (filename) => downloadMediaMessage(m.quoted, filename)
123
+ m.quoted.delete = () => conn.sendMessage(m.chat, { delete: m.quoted.fakeObj.key })
124
+ m.quoted.react = (emoji) => conn.sendMessage(m.chat, { react: { text: emoji, key: m.quoted.fakeObj.key } })
125
+ }
126
+ }
127
+ m.download = (filename) => downloadMediaMessage(m, filename)
128
+ }
129
+
130
+ m.reply = (teks, id = m.chat, option = { mentions: [m.sender] }) => conn.sendMessage(id, { text: teks, contextInfo: { mentionedJid: option.mentions } }, { quoted: m })
131
+ m.replyS = (stik, id = m.chat, option = { mentions: [m.sender] }) => conn.sendMessage(id, { sticker: stik, contextInfo: { mentionedJid: option.mentions } }, { quoted: m })
132
+ m.replyImg = (img, teks, id = m.chat, option = { mentions: [m.sender] }) => conn.sendMessage(id, { image: img, caption: teks, contextInfo: { mentionedJid: option.mentions } }, { quoted: m })
133
+ m.replyVid = (vid, teks, id = m.chat, option = { mentions: [m.sender], gif: false }) => conn.sendMessage(id, { video: vid, caption: teks, gifPlayback: option.gif, contextInfo: { mentionedJid: option.mentions } }, { quoted: m })
134
+ m.replyAud = (aud, id = m.chat, option = { mentions: [m.sender], ptt: false }) => conn.sendMessage(id, { audio: aud, ptt: option.ptt, mimetype: 'audio/mpeg', contextInfo: { mentionedJid: option.mentions } }, { quoted: m })
135
+ m.replyDoc = (doc, id = m.chat, option = { mentions: [m.sender], filename: 'undefined.pdf', mimetype: 'application/pdf' }) => conn.sendMessage(id, { document: doc, mimetype: option.mimetype, fileName: option.filename, contextInfo: { mentionedJid: option.mentions } }, { quoted: m })
136
+ m.replyContact = (name, info, number) => {
137
+ var vcard = 'BEGIN:VCARD\n' + 'VERSION:3.0\n' + 'FN:' + name + '\n' + 'ORG:' + info + ';\n' + 'TEL;type=CELL;type=VOICE;waid=' + number + ':+' + number + '\n' + 'END:VCARD'
138
+ conn.sendMessage(m.chat, { contacts: { displayName: name, contacts: [{ vcard }] } }, { quoted: m })
139
+ }
140
+ m.react = (emoji) => conn.sendMessage(m.chat, { react: { text: emoji, key: m.key } })
141
+
142
+ return m
143
+ }
144
+
145
+ module.exports = { sms,downloadMediaMessage }
lib/shannzCdn.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺
2
+ ⭐PROJECT NAME:
3
+ SUBZERO WHATSAPP MD BOT
4
+
5
+ ⭐DEVELOPER
6
+ MR FRANK
7
+
8
+ ⭐ MY TEAM
9
+ XERO CODERS
10
+
11
+ ⭐ OUR WEBSITE
12
+ https://github.com/ZwSyntax/SUBZERO-MD
13
+
14
+ © TRY DECRYPTING IF YOU CAN⚠
15
+
16
+ ╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺╺*/
17
+
18
+
19
+
20
+ const axios = require("axios");
21
+ const fs = require("fs");
22
+ const FormData = require("form-data");
23
+
24
+ async function shannzCdn(path) {
25
+ const form = new FormData();
26
+
27
+ const fileStream = fs.createReadStream(path);
28
+ form.append("file", fileStream);
29
+
30
+ try {
31
+ const response = await axios.post("https://endpoint.web.id/server/upload", form, {
32
+ headers: {
33
+ ...form.getHeaders(),
34
+ },
35
+ });
36
+
37
+ return response.data
38
+ } catch (error) {
39
+ return error.message
40
+ }
41
+ }
42
+
43
+ module.exports = { shannzCdn }