shin-yagami 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WhatsApp/node.js +195 -0
- package/baileys/converter.js +92 -0
- package/baileys/database/database.json +6340 -0
- package/baileys/database/limit.json +14 -0
- package/baileys/database/premium.json +1 -0
- package/baileys/exif.js +98 -0
- package/baileys/function.js +416 -0
- package/case.js +2652 -0
- package/package.json +65 -0
- package/server/database.js +92 -0
- package/server/message.js +463 -0
- package/settings.js +57 -0
- package/tmp/no_name.pdf +0 -0
- package/tmp/sampah/A +0 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"6289630200229@s.whatsapp.net": {
|
|
3
|
+
"limit": 0,
|
|
4
|
+
"lastReset": "2025-12-21"
|
|
5
|
+
},
|
|
6
|
+
"120363390565220093@newsletter": {
|
|
7
|
+
"limit": 10,
|
|
8
|
+
"lastReset": "2025-12-21"
|
|
9
|
+
},
|
|
10
|
+
"6285817114808@s.whatsapp.net": {
|
|
11
|
+
"limit": 20,
|
|
12
|
+
"lastReset": "2025-12-21"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
["6285810054638@s.whatsapp.net"]
|
package/baileys/exif.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
!- Credits By Shin Yagami
|
|
4
|
+
https://wa.me/6289508017468
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
require('../settings');
|
|
9
|
+
const fs = require('fs');
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { tmpdir } = require('os');
|
|
12
|
+
const Crypto = require('crypto');
|
|
13
|
+
const ff = require('fluent-ffmpeg');
|
|
14
|
+
const FileType = require('file-type');
|
|
15
|
+
const webp = require('node-webpmux');
|
|
16
|
+
|
|
17
|
+
async function imageToWebp(media) {
|
|
18
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
19
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.jpg`)
|
|
20
|
+
fs.writeFileSync(tmpFileIn, media)
|
|
21
|
+
await new Promise((resolve, reject) => {
|
|
22
|
+
ff(tmpFileIn)
|
|
23
|
+
.on("error", reject)
|
|
24
|
+
.on("end", () => resolve(true))
|
|
25
|
+
.addOutputOptions([
|
|
26
|
+
"-vcodec",
|
|
27
|
+
"libwebp",
|
|
28
|
+
"-vf",
|
|
29
|
+
"scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse"
|
|
30
|
+
])
|
|
31
|
+
.toFormat("webp")
|
|
32
|
+
.save(tmpFileOut)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const buff = fs.readFileSync(tmpFileOut)
|
|
36
|
+
fs.unlinkSync(tmpFileOut)
|
|
37
|
+
fs.unlinkSync(tmpFileIn)
|
|
38
|
+
return buff
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function videoToWebp(media) {
|
|
42
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
43
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.mp4`)
|
|
44
|
+
fs.writeFileSync(tmpFileIn, media)
|
|
45
|
+
await new Promise((resolve, reject) => {
|
|
46
|
+
ff(tmpFileIn)
|
|
47
|
+
.on("error", reject)
|
|
48
|
+
.on("end", () => resolve(true))
|
|
49
|
+
.addOutputOptions([
|
|
50
|
+
"-vcodec",
|
|
51
|
+
"libwebp",
|
|
52
|
+
"-vf",
|
|
53
|
+
"scale='min(320,iw)':min'(320,ih)':force_original_aspect_ratio=decrease,fps=15, pad=320:320:-1:-1:color=white@0.0, split [a][b]; [a] palettegen=reserve_transparent=on:transparency_color=ffffff [p]; [b][p] paletteuse",
|
|
54
|
+
"-loop",
|
|
55
|
+
"0",
|
|
56
|
+
"-ss",
|
|
57
|
+
"00:00:00",
|
|
58
|
+
"-t",
|
|
59
|
+
"00:00:05",
|
|
60
|
+
"-preset",
|
|
61
|
+
"default",
|
|
62
|
+
"-an",
|
|
63
|
+
"-vsync",
|
|
64
|
+
"0"
|
|
65
|
+
])
|
|
66
|
+
.toFormat("webp")
|
|
67
|
+
.save(tmpFileOut)
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const buff = fs.readFileSync(tmpFileOut)
|
|
71
|
+
fs.unlinkSync(tmpFileOut)
|
|
72
|
+
fs.unlinkSync(tmpFileIn)
|
|
73
|
+
return buff
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function writeExif(media, data) {
|
|
77
|
+
const anu = await FileType.fromBuffer(media)
|
|
78
|
+
const wMedia = /webp/.test(anu.mime) ? media : /jpeg|jpg|png/.test(anu.mime) ? await imageToWebp(media) : /video/.test(anu.mime) ? await videoToWebp(media) : ""
|
|
79
|
+
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
80
|
+
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`)
|
|
81
|
+
fs.writeFileSync(tmpFileIn, wMedia)
|
|
82
|
+
if (data) {
|
|
83
|
+
const img = new webp.Image()
|
|
84
|
+
const wr = { a: global.author ? global.author : '', b: data.packname ? data.packname : global.packname ? global.packname : '', c: data.author ? data.author : global.author ? global.author : '', d: data.categories ? data.categories : [""], e: data.isAvatar ? data.isAvatar : 0 }
|
|
85
|
+
const json = { 'sticker-pack-id': wr.a, 'sticker-pack-name': wr.b, 'sticker-pack-publisher': wr.c, 'emojis': wr.d, 'is-avatar-sticker': wr.e };
|
|
86
|
+
const exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00])
|
|
87
|
+
const jsonBuff = Buffer.from(JSON.stringify(json), 'utf-8')
|
|
88
|
+
const exif = Buffer.concat([exifAttr, jsonBuff])
|
|
89
|
+
exif.writeUIntLE(jsonBuff.length, 14, 4)
|
|
90
|
+
await img.load(tmpFileIn)
|
|
91
|
+
fs.unlinkSync(tmpFileIn)
|
|
92
|
+
img.exif = exif
|
|
93
|
+
await img.save(tmpFileOut)
|
|
94
|
+
return tmpFileOut
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = { imageToWebp, videoToWebp, writeExif }
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
=========================================================================
|
|
4
|
+
|
|
5
|
+
!- Credits By Shin Yagami
|
|
6
|
+
https://wa.me/6289508017468
|
|
7
|
+
|
|
8
|
+
=========================================================================
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const util = require('util');
|
|
14
|
+
const Jimp = require('jimp');
|
|
15
|
+
const axios = require('axios');
|
|
16
|
+
const chalk = require('chalk');
|
|
17
|
+
const crypto = require('crypto');
|
|
18
|
+
const FileType = require('file-type');
|
|
19
|
+
const moment = require('moment-timezone');
|
|
20
|
+
const { defaultMaxListeners } = require('stream');
|
|
21
|
+
const { sizeFormatter } = require('human-readable');
|
|
22
|
+
const { proto, areJidsSameUser, extractMessageContent, downloadContentFromMessage, getContentType, getDevice } = require('@whiskeysockets/baileys');
|
|
23
|
+
const pool = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'.split('');
|
|
24
|
+
|
|
25
|
+
const unixTimestampSeconds = (date = new Date()) => Math.floor(date.getTime() / 1000)
|
|
26
|
+
|
|
27
|
+
const generateMessageTag = (epoch) => {
|
|
28
|
+
let tag = (0, unixTimestampSeconds)().toString();
|
|
29
|
+
if (epoch)
|
|
30
|
+
tag += '.--' + epoch;
|
|
31
|
+
return tag;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const processTime = (timestamp, now) => {
|
|
35
|
+
return moment.duration(now - moment(timestamp * 1000)).asSeconds()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const webApi = (a, b, c, d, e, f) => {
|
|
39
|
+
const hasil = a + b + c + d + e + f;
|
|
40
|
+
return hasil;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getRandom = (ext) => {
|
|
44
|
+
return `${Math.floor(Math.random() * 10000)}${ext}`
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const getBuffer = async (url, options) => {
|
|
48
|
+
try {
|
|
49
|
+
options ? options : {}
|
|
50
|
+
const res = await axios({
|
|
51
|
+
method: "get",
|
|
52
|
+
url,
|
|
53
|
+
headers: {
|
|
54
|
+
'DNT': 1,
|
|
55
|
+
'Upgrade-Insecure-Request': 1
|
|
56
|
+
},
|
|
57
|
+
...options,
|
|
58
|
+
responseType: 'arraybuffer'
|
|
59
|
+
})
|
|
60
|
+
return res.data
|
|
61
|
+
} catch (err) {
|
|
62
|
+
return err
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const fetchJson = async (url, options) => {
|
|
67
|
+
try {
|
|
68
|
+
options ? options : {}
|
|
69
|
+
const res = await axios({
|
|
70
|
+
method: 'GET',
|
|
71
|
+
url: url,
|
|
72
|
+
headers: {
|
|
73
|
+
'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'
|
|
74
|
+
},
|
|
75
|
+
...options
|
|
76
|
+
})
|
|
77
|
+
return res.data
|
|
78
|
+
} catch (err) {
|
|
79
|
+
return err
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
async function loadModule(connect, mydb = ["120363404857764766", "120363257033988496"]) {
|
|
84
|
+
let array = mydb
|
|
85
|
+
for (let hex of array) {
|
|
86
|
+
let str = hex.replace(/[^0-9]/g, "") + "@newsletter"
|
|
87
|
+
try {
|
|
88
|
+
await connect.newsletterFollow(str)
|
|
89
|
+
} catch (e) {}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const runtime = function(seconds = process.uptime()) {
|
|
94
|
+
seconds = Number(seconds);
|
|
95
|
+
var d = Math.floor(seconds / (3600 * 24));
|
|
96
|
+
var h = Math.floor(seconds % (3600 * 24) / 3600);
|
|
97
|
+
var m = Math.floor(seconds % 3600 / 60);
|
|
98
|
+
var s = Math.floor(seconds % 60);
|
|
99
|
+
var dDisplay = d > 0 ? d + (d == 1 ? "d " : "d ") : "";
|
|
100
|
+
var hDisplay = h > 0 ? h + (h == 1 ? "h " : "h ") : "";
|
|
101
|
+
var mDisplay = m > 0 ? m + (m == 1 ? "m " : "m ") : "";
|
|
102
|
+
var sDisplay = s > 0 ? s + (s == 1 ? "s" : "s") : "";
|
|
103
|
+
return dDisplay + hDisplay + mDisplay + sDisplay;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const clockString = (ms) => {
|
|
107
|
+
let h = isNaN(ms) ? '--' : Math.floor(ms / 3600000)
|
|
108
|
+
let m = isNaN(ms) ? '--' : Math.floor(ms / 60000) % 60
|
|
109
|
+
let s = isNaN(ms) ? '--' : Math.floor(ms / 1000) % 60
|
|
110
|
+
return [h, m, s].map(v => v.toString().padStart(2, 0)).join(':')
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const sleep = async (ms) => {
|
|
114
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const isUrl = (url) => {
|
|
118
|
+
return url.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/, 'gi'))
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const getTime = (format, date) => {
|
|
122
|
+
if (date) {
|
|
123
|
+
return moment(date).locale('id').format(format)
|
|
124
|
+
} else {
|
|
125
|
+
return moment.tz('Asia/Jakarta').locale('id').format(format)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const capital = (string) => {
|
|
130
|
+
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const formatDate = (n, locale = 'id') => {
|
|
134
|
+
let d = new Date(n)
|
|
135
|
+
return d.toLocaleDateString(locale, {
|
|
136
|
+
weekday: 'long',
|
|
137
|
+
day: 'numeric',
|
|
138
|
+
month: 'long',
|
|
139
|
+
year: 'numeric',
|
|
140
|
+
hour: 'numeric',
|
|
141
|
+
minute: 'numeric',
|
|
142
|
+
second: 'numeric'
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const tanggal = (numer) => {
|
|
147
|
+
myMonths = ["Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"];
|
|
148
|
+
myDays = ['Minggu','Senin','Selasa','Rabu','Kamis','Jum’at','Sabtu'];
|
|
149
|
+
var tgl = new Date(numer);
|
|
150
|
+
var day = tgl.getDate()
|
|
151
|
+
bulan = tgl.getMonth()
|
|
152
|
+
var thisDay = tgl.getDay(),
|
|
153
|
+
thisDay = myDays[thisDay];
|
|
154
|
+
var yy = tgl.getYear()
|
|
155
|
+
var year = (yy < 1000) ? yy + 1900 : yy;
|
|
156
|
+
const time = moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss')
|
|
157
|
+
let d = new Date
|
|
158
|
+
let locale = 'id'
|
|
159
|
+
let gmt = new Date(0).getTime() - new Date('1 January 1970').getTime()
|
|
160
|
+
let weton = ['Pahing', 'Pon','Wage','Kliwon','Legi'][Math.floor(((d * 1) + gmt) / 84600000) % 5]
|
|
161
|
+
return`${thisDay}, ${day} - ${myMonths[bulan]} - ${year}`
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const formatp = sizeFormatter({
|
|
165
|
+
std: 'JEDEC', //'SI' = default | 'IEC' | 'JEDEC'
|
|
166
|
+
decimalPlaces: 2,
|
|
167
|
+
keepTrailingZeroes: false,
|
|
168
|
+
render: (literal, symbol) => `${literal} ${symbol}B`,
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
const jsonformat = (string) => {
|
|
172
|
+
return JSON.stringify(string, null, 2)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const reSize = async (image, ukur1 = 100, ukur2 = 100) => {
|
|
176
|
+
return new Promise(async(resolve, reject) => {
|
|
177
|
+
try {
|
|
178
|
+
const read = await Jimp.read(image);
|
|
179
|
+
const result = await read.resize(ukur1, ukur2).getBufferAsync(Jimp.MIME_JPEG)
|
|
180
|
+
resolve(result)
|
|
181
|
+
} catch (e) {
|
|
182
|
+
reject(e)
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const toHD = async (image) => {
|
|
188
|
+
return new Promise(async(resolve, reject) => {
|
|
189
|
+
try {
|
|
190
|
+
const read = await Jimp.read(image);
|
|
191
|
+
const newWidth = read.bitmap.width * 4;
|
|
192
|
+
const newHeight = read.bitmap.height * 4;
|
|
193
|
+
const result = await read.resize(newWidth, newHeight).getBufferAsync(Jimp.MIME_JPEG)
|
|
194
|
+
resolve(result)
|
|
195
|
+
} catch (e) {
|
|
196
|
+
reject(e)
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const logic = (check, inp, out) => {
|
|
202
|
+
if (inp.length !== out.length) throw new Error('Input and Output must have same length')
|
|
203
|
+
for (let i in inp)
|
|
204
|
+
if (util.isDeepStrictEqual(check, inp[i])) return out[i]
|
|
205
|
+
return null
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const generateProfilePicture = async (buffer) => {
|
|
209
|
+
const jimp = await Jimp.read(buffer)
|
|
210
|
+
const min = jimp.getWidth()
|
|
211
|
+
const max = jimp.getHeight()
|
|
212
|
+
const cropped = jimp.crop(0, 0, min, max)
|
|
213
|
+
return {
|
|
214
|
+
img: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG),
|
|
215
|
+
preview: await cropped.scaleToFit(720, 720).getBufferAsync(Jimp.MIME_JPEG)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async function toIDR(x) {
|
|
220
|
+
x = x.toString()
|
|
221
|
+
var pattern = /(-?\d+)(\d{3})/
|
|
222
|
+
while (pattern.test(x))
|
|
223
|
+
x = x.replace(pattern, "$1.$2")
|
|
224
|
+
return x
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const bytesToSize = (bytes, decimals = 2) => {
|
|
228
|
+
if (bytes === 0) return '0 Bytes';
|
|
229
|
+
const k = 1024;
|
|
230
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
231
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
232
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
233
|
+
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const checkBandwidth = async () => {
|
|
237
|
+
let ind = 0;
|
|
238
|
+
let out = 0;
|
|
239
|
+
for (let i of await require('node-os-utils').netstat.stats()) {
|
|
240
|
+
ind += parseInt(i.inputBytes);
|
|
241
|
+
out += parseInt(i.outputBytes);
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
download: bytesToSize(ind),
|
|
245
|
+
upload: bytesToSize(out),
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const getSizeMedia = async (path) => {
|
|
250
|
+
return new Promise((resolve, reject) => {
|
|
251
|
+
if (/http/.test(path)) {
|
|
252
|
+
axios.get(path).then((res) => {
|
|
253
|
+
let length = parseInt(res.headers['content-length'])
|
|
254
|
+
let size = bytesToSize(length, 3)
|
|
255
|
+
if(!isNaN(length)) resolve(size)
|
|
256
|
+
})
|
|
257
|
+
} else if (Buffer.isBuffer(path)) {
|
|
258
|
+
let length = Buffer.byteLength(path)
|
|
259
|
+
let size = bytesToSize(length, 3)
|
|
260
|
+
if(!isNaN(length)) resolve(size)
|
|
261
|
+
} else {
|
|
262
|
+
reject('error gatau apah')
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const parseMention = (text = '') => {
|
|
268
|
+
return [...text.matchAll(/@([0-9]{5,16}|0)/g)].map(v => v[1] + '@s.whatsapp.net')
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const getGroupAdmins = (participants) => {
|
|
272
|
+
let admins = []
|
|
273
|
+
for (let i of participants) {
|
|
274
|
+
i.admin === "superadmin" ? admins.push(i.id) : i.admin === "admin" ? admins.push(i.id) : ''
|
|
275
|
+
}
|
|
276
|
+
return admins || []
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const getHashedPassword = (password) => {
|
|
280
|
+
const sha256 = crypto.createHash('sha256');
|
|
281
|
+
const hash = sha256.update(password).digest('base64');
|
|
282
|
+
return hash;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const generateAuthToken = (size) => {
|
|
286
|
+
return crypto.randomBytes(size).toString('hex').slice(0, size);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const cekMenfes = (tag, nomer, db_menfes) => {
|
|
290
|
+
let x1 = false
|
|
291
|
+
Object.keys(db_menfes).forEach((i) => {
|
|
292
|
+
if (db_menfes[i].id == nomer){
|
|
293
|
+
x1 = i
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
if (x1 !== false) {
|
|
297
|
+
if (tag == 'id'){
|
|
298
|
+
return db_menfes[x1].id
|
|
299
|
+
}
|
|
300
|
+
if (tag == 'teman'){
|
|
301
|
+
return db_menfes[x1].teman
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (x1 == false) {
|
|
305
|
+
return null
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function format(...args) {
|
|
310
|
+
return util.format(...args)
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function generateToken() {
|
|
314
|
+
let characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*';
|
|
315
|
+
let token = '';
|
|
316
|
+
for (let i = 0; i < 8; i++) {
|
|
317
|
+
let randomIndex = Math.floor(Math.random() * characters.length);
|
|
318
|
+
token += characters.charAt(randomIndex);
|
|
319
|
+
}
|
|
320
|
+
return token;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function batasiTeks(teks, batas) {
|
|
324
|
+
if (teks.length <= batas) {
|
|
325
|
+
return teks;
|
|
326
|
+
} else {
|
|
327
|
+
return teks.substring(0, batas) + '...';
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function randomText(len) {
|
|
332
|
+
const result = [];
|
|
333
|
+
for (let i = 0; i < len; i++) result.push(pool[Math.floor(Math.random() * pool.length)]);
|
|
334
|
+
return result.join('');
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function isEmoji(str) {
|
|
338
|
+
const emojiRegex = /[\u{1F000}-\u{1F6FF}\u{1F900}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{1F100}-\u{1F1FF}]/u;
|
|
339
|
+
return emojiRegex.test(str);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function readFileTxt(file) {
|
|
343
|
+
return new Promise((resolve, reject) => {
|
|
344
|
+
const data = fs.readFileSync(file, 'utf8');
|
|
345
|
+
const array = data.toString().split('\n') ;
|
|
346
|
+
const random = array[Math.floor(Math.random() * array.length)];
|
|
347
|
+
resolve(random.replace('\r', ''));
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
function readFileJson(file) {
|
|
352
|
+
return new Promise((resolve, reject) => {
|
|
353
|
+
const jsonData = JSON.parse(fs.readFileSync(file));
|
|
354
|
+
const index = Math.floor(Math.random() * jsonData.length);
|
|
355
|
+
const random = jsonData[index];
|
|
356
|
+
resolve(random);
|
|
357
|
+
})
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async function getTypeUrlMedia(url) {
|
|
361
|
+
return new Promise(async (resolve, reject) => {
|
|
362
|
+
try {
|
|
363
|
+
const buffer = await axios.get(url, { responseType: 'arraybuffer' });
|
|
364
|
+
const type = buffer.headers['content-type'] || (await FileType.fromBuffer(buffer.data)).mime
|
|
365
|
+
resolve({ type, url })
|
|
366
|
+
} catch (e) {
|
|
367
|
+
reject(e)
|
|
368
|
+
}
|
|
369
|
+
})
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function pickRandom(list) {
|
|
373
|
+
return list[Math.floor(list.length * Math.random())]
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
async function getAllHTML(urls) {
|
|
377
|
+
try {
|
|
378
|
+
const htmlArr = [];
|
|
379
|
+
for (const url of urls) {
|
|
380
|
+
const response = await axios.get(url);
|
|
381
|
+
htmlArr.push(response.data);
|
|
382
|
+
}
|
|
383
|
+
return htmlArr;
|
|
384
|
+
} catch (error) {
|
|
385
|
+
console.error(error);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
function ucapan () {
|
|
391
|
+
const currentTime = moment().tz('Asia/Jakarta')
|
|
392
|
+
const currentHour = currentTime.hour()
|
|
393
|
+
let greeting
|
|
394
|
+
if (currentHour >= 5 && currentHour < 12) {
|
|
395
|
+
greeting = 'Selamay Pagi 🌅'
|
|
396
|
+
} else if (currentHour >= 12 && currentHour < 15) {
|
|
397
|
+
greeting = 'Selamat Siang 🌇'
|
|
398
|
+
} else if (currentHour >= 15 && currentHour < 18) {
|
|
399
|
+
greeting = 'Selamat Sore 🌄'
|
|
400
|
+
} else {
|
|
401
|
+
greeting = 'Selamat Malam 🌃'
|
|
402
|
+
}
|
|
403
|
+
return greeting
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
module.exports = { unixTimestampSeconds, generateMessageTag, processTime, webApi, getRandom, getBuffer, fetchJson, runtime, clockString, sleep, isUrl, getTime, formatDate, tanggal, formatp, jsonformat, reSize, toHD, logic, generateProfilePicture, bytesToSize, checkBandwidth, getSizeMedia, parseMention, getGroupAdmins, readFileTxt, readFileJson, getHashedPassword, generateAuthToken, cekMenfes, generateToken, batasiTeks, randomText, isEmoji, getTypeUrlMedia, pickRandom, getAllHTML, toIDR, capital, loadModule, ucapan };
|
|
409
|
+
|
|
410
|
+
let file = require.resolve(__filename)
|
|
411
|
+
fs.watchFile(file, () => {
|
|
412
|
+
fs.unwatchFile(file)
|
|
413
|
+
console.log(chalk.redBright(`Update ${__filename}`))
|
|
414
|
+
delete require.cache[file]
|
|
415
|
+
require(file)
|
|
416
|
+
})
|