webfast 0.1.20 → 0.1.24
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/index.js +227 -224
- package/modules/bots/applications/telegram.js +10 -2
- package/package.json +1 -1
- /package/{app/content → content}/images/banner.png +0 -0
- /package/{app/content → content}/images/block.png +0 -0
- /package/{app/content → content}/js/jquery-3.7.1.min.js +0 -0
- /package/{app/content → content}/js/webfast.js +0 -0
package/index.js
CHANGED
@@ -1,244 +1,247 @@
|
|
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
|
-
let
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
module.exports = function () {
|
2
|
+
const { readdirSync } = require("fs");
|
3
|
+
|
4
|
+
console.log(`WebFast!! Program`);
|
5
|
+
let program = {
|
6
|
+
ts : Date.now(),
|
7
|
+
modules : {},
|
8
|
+
tmp : {},
|
9
|
+
set : {}
|
10
|
+
}
|
11
|
+
|
12
|
+
// Setup The Requirements
|
13
|
+
async function set(program) {
|
14
|
+
program.path = await require(`path`);
|
15
|
+
program.fs = await require(`fs`);
|
16
|
+
program.uuid = require(`uuid`);
|
17
|
+
program.fetch = require(`fetch`);
|
18
|
+
return program;
|
19
|
+
}
|
20
|
+
|
21
|
+
// Program Fetch
|
22
|
+
program.modules.dependOn = async function(reqFunc,program,name,callback) {
|
23
|
+
console.log(`Depend On Check`);
|
24
|
+
|
25
|
+
// Loop Through dependOn if its not true then check
|
26
|
+
for (let dependIndex in reqFunc.dependOn) {
|
27
|
+
const dependOn = reqFunc.dependOn[dependIndex];
|
28
|
+
// So we dependOn
|
29
|
+
// Check index
|
30
|
+
// If .
|
31
|
+
let split = dependOn.split(`.`);
|
32
|
+
// Now we should loop through array
|
33
|
+
let objectData = program;
|
34
|
+
let fullObjectPath = `program`;
|
35
|
+
let dependOnItem = ``;
|
36
|
+
for (let spl in split) {
|
37
|
+
// Grab object
|
38
|
+
let toCheck = split[spl];
|
39
|
+
if (objectData[toCheck] == undefined) {
|
40
|
+
if (program.modules[name] != undefined) {
|
41
|
+
return;
|
42
|
+
} else {
|
43
|
+
program.modules[name] = {
|
44
|
+
ts : Date.now()
|
45
|
+
}
|
46
|
+
await setTimeout(async function(){
|
47
|
+
await program.modules.dependOn(reqFunc,program,name,callback);
|
48
|
+
},200);
|
43
49
|
}
|
44
|
-
await setTimeout(async function(){
|
45
|
-
await program.modules.dependOn(reqFunc,program,name,callback);
|
46
|
-
},200);
|
47
|
-
}
|
48
|
-
} else {
|
49
|
-
// New object thing and og next
|
50
|
-
if (split.length-1 != spl) {
|
51
|
-
fullObjectPath = fullObjectPath + `.${toCheck}`
|
52
50
|
} else {
|
53
|
-
//
|
54
|
-
|
51
|
+
// New object thing and og next
|
52
|
+
if (split.length-1 != spl) {
|
53
|
+
fullObjectPath = fullObjectPath + `.${toCheck}`
|
54
|
+
} else {
|
55
|
+
// Depend on
|
56
|
+
dependOnItem = toCheck;
|
57
|
+
}
|
58
|
+
objectData = objectData[toCheck];
|
55
59
|
}
|
56
|
-
objectData = objectData[toCheck];
|
57
60
|
}
|
58
|
-
}
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
62
|
+
let progData = await eval(fullObjectPath);
|
63
|
+
const IndexCheck = Object.keys(progData).indexOf(dependOnItem);
|
64
|
+
if (IndexCheck == -1) {
|
65
|
+
// We need to wait and try again untill we can return
|
66
|
+
console.log(`DependOn Fail: ${dependOn}`);
|
67
|
+
await setTimeout(async function(){
|
68
|
+
await program.modules.dependOn(reqFunc,program);
|
69
|
+
},200);
|
70
|
+
} else if (program.modules[reqFunc.name] == undefined) {
|
71
|
+
console.log(`DependOn Succes: ${dependOn}`);
|
72
|
+
|
73
|
+
// Loop Through to find where data to set
|
74
|
+
const splitLoop = String(`${fullObjectPath}.${dependOnItem}`).split(`.`);
|
75
|
+
let object;
|
76
|
+
for (let s in splitLoop) {
|
77
|
+
let key = splitLoop[s];
|
78
|
+
try {
|
79
|
+
if (object == undefined) {
|
80
|
+
object = eval(key);
|
81
|
+
} else {
|
82
|
+
object = object[key];
|
83
|
+
}
|
84
|
+
if (s == splitLoop-1) {
|
85
|
+
// It's end
|
86
|
+
object = {
|
87
|
+
depend : dependOn,
|
88
|
+
state : true,
|
89
|
+
ts : Date.now()
|
90
|
+
}
|
91
|
+
}
|
92
|
+
} catch (err) {
|
93
|
+
console.error(err);
|
94
|
+
console.error(`errror boject eval set`);
|
95
|
+
return setTimeout(async function(){
|
96
|
+
await program.modules.dependOn(reqFunc,program,name,callback);
|
97
|
+
},200);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
/*
|
101
|
+
progData[dependOnItem] = {
|
102
|
+
depend : dependOn,
|
103
|
+
state : true,
|
104
|
+
ts : Date.now()
|
105
|
+
} */
|
106
|
+
|
107
|
+
// Now include this thing then
|
76
108
|
try {
|
77
|
-
|
78
|
-
|
109
|
+
program.modules[reqFunc.name] = await reqFunc.run(program,reqFunc.name);
|
110
|
+
if (callback != undefined) {
|
111
|
+
return callback(program,name)
|
79
112
|
} else {
|
80
|
-
|
113
|
+
return program;
|
81
114
|
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
depend : dependOn,
|
86
|
-
state : true,
|
87
|
-
ts : Date.now()
|
88
|
-
}
|
89
|
-
}
|
90
|
-
} catch (err) {
|
115
|
+
} catch(err) {
|
116
|
+
// When erro
|
117
|
+
console.error(`Error Program add depend on require`);
|
91
118
|
console.error(err);
|
92
|
-
console.error(`errror boject eval set`);
|
93
|
-
return setTimeout(async function(){
|
94
|
-
await program.modules.dependOn(reqFunc,program,name,callback);
|
95
|
-
},200);
|
96
119
|
}
|
97
120
|
}
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
//
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
program.modules.fetch = async function(folder,program) {
|
125
|
+
// TO Fetch folder modules
|
126
|
+
program = await set(program);
|
127
|
+
try {
|
128
|
+
// Loop through folder and run module if js
|
129
|
+
const readPath = program.path.join(__dirname,folder);
|
130
|
+
const readDir = program.fs.readdirSync(readPath);
|
131
|
+
// Check if folder or not
|
132
|
+
await readDir.forEach(async (item) => {
|
133
|
+
const itemPath = program.path.join(readPath, item);
|
134
|
+
// Get the filename with extension
|
135
|
+
const fileNameWithExtension = program.path.basename(itemPath);
|
136
|
+
|
137
|
+
// Get the filename without extension
|
138
|
+
const fileNameWithoutExtension = program.path.parse(fileNameWithExtension).name;
|
139
|
+
|
140
|
+
console.log('Filename without extension:', fileNameWithoutExtension);
|
141
|
+
|
142
|
+
const isDirectory = program.fs.statSync(itemPath).isDirectory();
|
143
|
+
|
144
|
+
if (!isDirectory) {
|
145
|
+
// So it's file
|
146
|
+
// Run the file to know what to do but change program with the return
|
147
|
+
//program = (require(itemPath)(program));
|
148
|
+
//console.log(`Set`,itemPath);
|
110
149
|
} else {
|
111
|
-
|
150
|
+
// It's directory so read the init file
|
151
|
+
const initPath = program.path.join(itemPath,`init.js`);
|
152
|
+
|
153
|
+
// Require first
|
154
|
+
const reqFunc = require(initPath);
|
155
|
+
const theType = typeof reqFunc;
|
156
|
+
switch (theType) {
|
157
|
+
case `object`:
|
158
|
+
// It's a object so check for dependend things etc.
|
159
|
+
console.log(`Depending object`);
|
160
|
+
return await program.modules.dependOn(reqFunc,program,fileNameWithoutExtension,function(program,name){
|
161
|
+
console.log(`Setup `,name)
|
162
|
+
});
|
163
|
+
break;
|
164
|
+
case `function`:
|
165
|
+
program = await (require(initPath)(program,fileNameWithExtension));
|
166
|
+
break;
|
167
|
+
default:
|
168
|
+
console.error(`Error Missing typeOf item`);
|
169
|
+
}
|
112
170
|
}
|
113
|
-
}
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
171
|
+
});
|
172
|
+
|
173
|
+
} catch(err) {
|
174
|
+
console.error(`Error Program Modules Fetch`);
|
175
|
+
console.error(err);
|
118
176
|
}
|
119
177
|
}
|
120
|
-
|
121
|
-
|
122
|
-
program.modules.
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
const
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
const
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
178
|
+
|
179
|
+
// Create tmp file path
|
180
|
+
program.modules.walkDirectory = async function (directoryPath, callback, forward, parentFileData) {
|
181
|
+
let allFiles = [];
|
182
|
+
try {
|
183
|
+
// Read the contents of the current directory
|
184
|
+
const files = await program.fs.readdirSync(directoryPath);
|
185
|
+
|
186
|
+
// Iterate through the files in the directory
|
187
|
+
for (const file of files) {
|
188
|
+
// Construct the full path of the current file or directory
|
189
|
+
const fullPath = program.path.join(directoryPath, file);
|
190
|
+
|
191
|
+
// Check if the current item is a directory
|
192
|
+
const pathSync = await program.fs.statSync(fullPath);
|
193
|
+
const isDirectoryPath = await pathSync.isDirectory();
|
194
|
+
const fileExtension = program.path.extname(fullPath);
|
195
|
+
|
196
|
+
// Get the filename without the extension
|
197
|
+
const fileName = program.path.basename(fullPath, fileExtension);
|
198
|
+
|
199
|
+
// Create a new fileData object for each file or directory
|
200
|
+
const currentFileData = {
|
201
|
+
extension: fileExtension,
|
202
|
+
name: fileName,
|
203
|
+
path: fullPath,
|
204
|
+
sub: [],
|
205
|
+
};
|
206
|
+
|
207
|
+
if (isDirectoryPath) {
|
208
|
+
// If it's a directory, recursively walk through it
|
209
|
+
let pushData = await program.modules.walkDirectory(fullPath, callback, fileName, currentFileData);
|
210
|
+
if (pushData.length !== 0) {
|
211
|
+
// Concatenate arrays instead of pushing an array
|
212
|
+
allFiles.push(currentFileData);
|
213
|
+
allFiles = allFiles.concat(pushData);
|
147
214
|
} else {
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
break;
|
162
|
-
case `function`:
|
163
|
-
program = await (require(initPath)(program,fileNameWithExtension));
|
164
|
-
break;
|
165
|
-
default:
|
166
|
-
console.error(`Error Missing typeOf item`);
|
167
|
-
}
|
215
|
+
allFiles.push(currentFileData);
|
216
|
+
}
|
217
|
+
} else {
|
218
|
+
// If it's a file, print the path
|
219
|
+
console.log('File Extension:', fileExtension);
|
220
|
+
console.log('File Name:', fileName);
|
221
|
+
|
222
|
+
if (forward !== undefined) {
|
223
|
+
// Push it to sub
|
224
|
+
parentFileData.sub.push(currentFileData);
|
225
|
+
} else {
|
226
|
+
allFiles.push(currentFileData);
|
227
|
+
}
|
168
228
|
}
|
169
|
-
});
|
170
|
-
|
171
|
-
} catch(err) {
|
172
|
-
console.error(`Error Program Modules Fetch`);
|
173
|
-
console.error(err);
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
// Create tmp file path
|
178
|
-
program.modules.walkDirectory = async function (directoryPath, callback, forward, parentFileData) {
|
179
|
-
let allFiles = [];
|
180
|
-
try {
|
181
|
-
// Read the contents of the current directory
|
182
|
-
const files = await program.fs.readdirSync(directoryPath);
|
183
|
-
|
184
|
-
// Iterate through the files in the directory
|
185
|
-
for (const file of files) {
|
186
|
-
// Construct the full path of the current file or directory
|
187
|
-
const fullPath = program.path.join(directoryPath, file);
|
188
|
-
|
189
|
-
// Check if the current item is a directory
|
190
|
-
const pathSync = await program.fs.statSync(fullPath);
|
191
|
-
const isDirectoryPath = await pathSync.isDirectory();
|
192
|
-
const fileExtension = program.path.extname(fullPath);
|
193
|
-
|
194
|
-
// Get the filename without the extension
|
195
|
-
const fileName = program.path.basename(fullPath, fileExtension);
|
196
|
-
|
197
|
-
// Create a new fileData object for each file or directory
|
198
|
-
const currentFileData = {
|
199
|
-
extension: fileExtension,
|
200
|
-
name: fileName,
|
201
|
-
path: fullPath,
|
202
|
-
sub: [],
|
203
|
-
};
|
204
|
-
|
205
|
-
if (isDirectoryPath) {
|
206
|
-
// If it's a directory, recursively walk through it
|
207
|
-
let pushData = await program.modules.walkDirectory(fullPath, callback, fileName, currentFileData);
|
208
|
-
if (pushData.length !== 0) {
|
209
|
-
// Concatenate arrays instead of pushing an array
|
210
|
-
allFiles.push(currentFileData);
|
211
|
-
allFiles = allFiles.concat(pushData);
|
212
|
-
} else {
|
213
|
-
allFiles.push(currentFileData);
|
214
|
-
}
|
215
|
-
} else {
|
216
|
-
// If it's a file, print the path
|
217
|
-
console.log('File Extension:', fileExtension);
|
218
|
-
console.log('File Name:', fileName);
|
219
|
-
|
220
|
-
if (forward !== undefined) {
|
221
|
-
// Push it to sub
|
222
|
-
parentFileData.sub.push(currentFileData);
|
223
|
-
} else {
|
224
|
-
allFiles.push(currentFileData);
|
225
|
-
}
|
226
229
|
}
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
}
|
237
|
-
|
238
|
-
|
230
|
+
|
231
|
+
if (callback && forward === undefined) {
|
232
|
+
await callback(allFiles);
|
233
|
+
}
|
234
|
+
|
235
|
+
return allFiles;
|
236
|
+
} catch (error) {
|
237
|
+
console.error('Error:', error.message);
|
238
|
+
}
|
239
|
+
};
|
240
|
+
|
239
241
|
|
240
|
-
|
241
|
-
|
242
|
+
|
243
|
+
|
242
244
|
|
243
|
-
// Run program fetch
|
244
|
-
program.modules.fetch(`modules`,program);
|
245
|
+
// Run program fetch
|
246
|
+
program.modules.fetch(`modules`,program);
|
247
|
+
}
|
@@ -264,7 +264,8 @@ module.exports = async function(program,folder) {
|
|
264
264
|
console.error(`Error Setting URL`);
|
265
265
|
}
|
266
266
|
|
267
|
-
|
267
|
+
let teleData = program.path.join(__dirname,`telegram`);
|
268
|
+
|
268
269
|
let moduleData = await program.modules.walkDirectory(teleData);
|
269
270
|
// Loop Through
|
270
271
|
let telegram = {
|
@@ -296,6 +297,10 @@ module.exports = async function(program,folder) {
|
|
296
297
|
}
|
297
298
|
|
298
299
|
let middleWareFolder = program.path.join(__dirname,`telegram`,`middleware`);
|
300
|
+
if (program.set.path != undefined) {
|
301
|
+
middleWareFolder = program.path.join(program.set.path,`bots`,`telegram`,`middleware`);
|
302
|
+
}
|
303
|
+
|
299
304
|
console.log(`MiddleWare:`,middleWareFolder);
|
300
305
|
|
301
306
|
let middleWareData = program.fs.readdirSync(middleWareFolder);
|
@@ -333,7 +338,10 @@ module.exports = async function(program,folder) {
|
|
333
338
|
telegram.middleware = middleWarFuncs;
|
334
339
|
|
335
340
|
// Process scripts
|
336
|
-
|
341
|
+
let scriptsPath = program.path.join(__dirname,`telegram`,`scripts`);
|
342
|
+
if (program.set.path != undefined) {
|
343
|
+
scriptsPath = program.path.join(program.set.path,`bots`,`telegram`,`scripts`);
|
344
|
+
}
|
337
345
|
|
338
346
|
// Loop Through scripts folder
|
339
347
|
let scriptsData = await program.modules.walkDirectory(scriptsPath);
|
package/package.json
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|