@k4la/library 1.0.0
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/data/asahotak.json +1142 -0
- package/data/family100.json +73589 -0
- package/data/susunkata.json +3008 -0
- package/data/tebakbendera.json +346 -0
- package/data/tebakgambar.json +6002 -0
- package/data/tebakkata.json +1512 -0
- package/data/tebakkimia.json +502 -0
- package/index.js +29 -0
- package/lib/blackjack.js +219 -0
- package/lib/converter.js +105 -0
- package/lib/exif.js +205 -0
- package/lib/function.js +13 -0
- package/lib/game.js +58 -0
- package/lib/tictactoe.js +164 -0
- package/lib/ulartangga.js +181 -0
- package/lib/uno.js +250 -0
- package/lib/uploader.js +136 -0
- package/lib/werewolf.js +1208 -0
- package/package.json +23 -0
package/lib/uploader.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file lib/uploader.js
|
|
3
|
+
* @description Utilities to upload files to temporary storage servers
|
|
4
|
+
* @author K4lameety
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const axios = require('axios')
|
|
8
|
+
const BodyForm = require('form-data')
|
|
9
|
+
const fs = require('fs')
|
|
10
|
+
const cheerio = require('cheerio')
|
|
11
|
+
|
|
12
|
+
const getFileType = async (buffer) => {
|
|
13
|
+
const { fileTypeFromBuffer } = await import('file-type');
|
|
14
|
+
return await fileTypeFromBuffer(buffer);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function CatBox(filePath) {
|
|
18
|
+
try {
|
|
19
|
+
const fileStream = fs.createReadStream(filePath);
|
|
20
|
+
const formData = new BodyForm();
|
|
21
|
+
formData.append('fileToUpload', fileStream);
|
|
22
|
+
formData.append('reqtype', 'fileupload');
|
|
23
|
+
formData.append('userhash', '');
|
|
24
|
+
|
|
25
|
+
const response = await axios.post('https://catbox.moe/user/api.php', formData, {
|
|
26
|
+
headers: {
|
|
27
|
+
...formData.getHeaders(),
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return response.data;
|
|
32
|
+
} catch (error) {
|
|
33
|
+
throw new Error("An error occurred while uploading to Catbox.");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function TelegraPh(Path) {
|
|
38
|
+
return new Promise(async (resolve, reject) => {
|
|
39
|
+
if (!fs.existsSync(Path)) return reject(new Error("File not Found"))
|
|
40
|
+
try {
|
|
41
|
+
const form = new BodyForm();
|
|
42
|
+
form.append("file", fs.createReadStream(Path))
|
|
43
|
+
const data = await axios({
|
|
44
|
+
url: "https://telegra.ph/upload",
|
|
45
|
+
method: "POST",
|
|
46
|
+
headers: {
|
|
47
|
+
...form.getHeaders()
|
|
48
|
+
},
|
|
49
|
+
data: form
|
|
50
|
+
})
|
|
51
|
+
return resolve("https://telegra.ph" + data.data[0].src)
|
|
52
|
+
} catch (err) {
|
|
53
|
+
return reject(new Error(String(err)))
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function UploadFileUgu(input) {
|
|
59
|
+
return new Promise(async (resolve, reject) => {
|
|
60
|
+
const form = new BodyForm();
|
|
61
|
+
form.append("files[]", fs.createReadStream(input))
|
|
62
|
+
await axios({
|
|
63
|
+
url: "https://uguu.se/upload.php",
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: {
|
|
66
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36",
|
|
67
|
+
...form.getHeaders()
|
|
68
|
+
},
|
|
69
|
+
data: form
|
|
70
|
+
}).then((data) => {
|
|
71
|
+
resolve(data.data.files[0])
|
|
72
|
+
}).catch((err) => reject(err))
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function webp2mp4File(path) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const form = new BodyForm()
|
|
79
|
+
form.append('new-image-url', '')
|
|
80
|
+
form.append('new-image', fs.createReadStream(path))
|
|
81
|
+
axios({
|
|
82
|
+
method: 'post',
|
|
83
|
+
url: 'https://s6.ezgif.com/webp-to-mp4',
|
|
84
|
+
data: form,
|
|
85
|
+
headers: {
|
|
86
|
+
'Content-Type': `multipart/form-data; boundary=${form._boundary}`
|
|
87
|
+
}
|
|
88
|
+
}).then(({ data }) => {
|
|
89
|
+
const bodyFormThen = new BodyForm()
|
|
90
|
+
const $ = cheerio.load(data)
|
|
91
|
+
const file = $('input[name="file"]').attr('value')
|
|
92
|
+
bodyFormThen.append('file', file)
|
|
93
|
+
bodyFormThen.append('convert', "Convert WebP to MP4!")
|
|
94
|
+
axios({
|
|
95
|
+
method: 'post',
|
|
96
|
+
url: 'https://ezgif.com/webp-to-mp4/' + file,
|
|
97
|
+
data: bodyFormThen,
|
|
98
|
+
headers: {
|
|
99
|
+
'Content-Type': `multipart/form-data; boundary=${bodyFormThen._boundary}`
|
|
100
|
+
}
|
|
101
|
+
}).then(({ data }) => {
|
|
102
|
+
const $ = cheerio.load(data)
|
|
103
|
+
const result = 'https:' + $('div#output > p.outfile > video > source').attr('src')
|
|
104
|
+
resolve({
|
|
105
|
+
status: true,
|
|
106
|
+
message: "Created By MRHRTZ",
|
|
107
|
+
result: result
|
|
108
|
+
})
|
|
109
|
+
}).catch(reject)
|
|
110
|
+
}).catch(reject)
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function floNime(medianya, options = {}) {
|
|
115
|
+
const type = await getFileType(medianya) || { ext: options.ext }
|
|
116
|
+
var form = new BodyForm()
|
|
117
|
+
form.append('file', medianya, 'tmp.' + type.ext)
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
const { data } = await axios.post('https://flonime.my.id/upload', form, {
|
|
121
|
+
headers: form.getHeaders()
|
|
122
|
+
})
|
|
123
|
+
return data
|
|
124
|
+
} catch (err) {
|
|
125
|
+
throw new Error(err.message)
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = {
|
|
130
|
+
CatBox,
|
|
131
|
+
TelegraPh,
|
|
132
|
+
uptotelegra: TelegraPh,
|
|
133
|
+
UploadFileUgu,
|
|
134
|
+
webp2mp4File,
|
|
135
|
+
floNime
|
|
136
|
+
}
|