fca-chat-zach 0.0.1-security → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fca-chat-zach might be problematic. Click here for more details.
- package/.gitattributes +2 -0
- package/Extra/Database/index.js +469 -0
- package/Extra/ExtraAddons.js +82 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +340 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +119 -0
- package/Extra/Html/Classic/style.css +8 -0
- package/Extra/Security/Index.js +173 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +67 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +81 -0
- package/Extra/Src/Release_Memory.js +41 -0
- package/Extra/Src/Websocket.js +213 -0
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/uuid.js +137 -0
- package/Func/AcceptAgreement.js +31 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/LICENSE +21 -0
- package/Language/index.json +217 -0
- package/Main.js +1192 -0
- package/README.md +132 -3
- package/SECURITY.md +18 -0
- package/broadcast.js +40 -0
- package/index.js +383 -0
- package/logger.js +66 -0
- package/package.json +91 -3
- package/src/Dev_Horizon_Data.js +125 -0
- package/src/Premium.js +25 -0
- package/src/Screenshot.js +83 -0
- package/src/addExternalModule.js +16 -0
- package/src/addUserToGroup.js +79 -0
- package/src/changeAdminStatus.js +79 -0
- package/src/changeArchivedStatus.js +41 -0
- package/src/changeAvt.js +85 -0
- package/src/changeBio.js +65 -0
- package/src/changeBlockedStatus.js +36 -0
- package/src/changeGroupImage.js +106 -0
- package/src/changeNickname.js +45 -0
- package/src/changeThreadColor.js +62 -0
- package/src/changeThreadEmoji.js +42 -0
- package/src/createNewGroup.js +70 -0
- package/src/createPoll.js +60 -0
- package/src/deleteMessage.js +45 -0
- package/src/deleteThread.js +43 -0
- package/src/forwardAttachment.js +48 -0
- package/src/getAccessToken.js +28 -0
- package/src/getCurrentUserID.js +7 -0
- package/src/getEmojiUrl.js +27 -0
- package/src/getFriendsList.js +73 -0
- package/src/getMessage.js +80 -0
- package/src/getThreadHistory.js +537 -0
- package/src/getThreadInfo.js +425 -0
- package/src/getThreadList.js +213 -0
- package/src/getThreadMain.js +220 -0
- package/src/getThreadPictures.js +59 -0
- package/src/getUID.js +59 -0
- package/src/getUserID.js +62 -0
- package/src/getUserInfo.js +113 -0
- package/src/getUserInfoMain.js +65 -0
- package/src/getUserInfoV2.js +32 -0
- package/src/getUserInfoV3.js +63 -0
- package/src/getUserInfoV4.js +55 -0
- package/src/getUserInfoV5.js +61 -0
- package/src/handleFriendRequest.js +46 -0
- package/src/handleMessageRequest.js +49 -0
- package/src/httpGet.js +49 -0
- package/src/httpPost.js +48 -0
- package/src/httpPostFormData.js +41 -0
- package/src/listenMqtt.js +787 -0
- package/src/logout.js +68 -0
- package/src/markAsDelivered.js +48 -0
- package/src/markAsRead.js +70 -0
- package/src/markAsReadAll.js +43 -0
- package/src/markAsSeen.js +51 -0
- package/src/muteThread.js +47 -0
- package/src/removeUserFromGroup.js +49 -0
- package/src/resolvePhotoUrl.js +37 -0
- package/src/searchForThread.js +43 -0
- package/src/sendMessage.js +379 -0
- package/src/sendTypingIndicator.js +80 -0
- package/src/setMessageReaction.js +109 -0
- package/src/setPostReaction.js +102 -0
- package/src/setTitle.js +74 -0
- package/src/threadColors.js +39 -0
- package/src/unfriend.js +43 -0
- package/src/unsendMessage.js +40 -0
- package/test/Database_Test.js +4 -0
- package/test/Db2.js +530 -0
- package/test/Horizon_Database/A_README.md +1 -0
- package/test/Horizon_Database/Database.db +0 -0
- package/test/Zach_Database/A_README.md +1 -0
- package/test/Zach_Database/Database.db +0 -0
- package/test/data/shareAttach.js +146 -0
- package/test/data/something.mov +0 -0
- package/test/data/test.png +0 -0
- package/test/data/test.txt +7 -0
- package/test/env/.env +0 -0
- package/test/example-config.json +18 -0
- package/test/example-db.db +0 -0
- package/test/memoryleak.js +18 -0
- package/test/test-page.js +140 -0
- package/test/test.js +385 -0
- package/test/testv2.js +18 -0
- package/utils.js +1684 -0
package/test/Db2.js
ADDED
@@ -0,0 +1,530 @@
|
|
1
|
+
/* eslint-disable no-self-assign */
|
2
|
+
/* eslint-disable linebreak-style */
|
3
|
+
const get = require('lodash/get');
|
4
|
+
const set = require('lodash/set');
|
5
|
+
const sqlite3 = require('sqlite3');
|
6
|
+
const fs = require('fs-extra');
|
7
|
+
const request = require('request');
|
8
|
+
const deasync = require('deasync');
|
9
|
+
|
10
|
+
if (!fs.existsSync(process.cwd() + '/Zach_Database')) {
|
11
|
+
fs.mkdirSync(process.cwd() + '/Zach_Database');
|
12
|
+
fs.writeFileSync(process.cwd() + '/Zach_Database/A_README.md', 'This folder is used by ChernobyL(NANI =)) ) to store data. Do not delete this folder or any of the files in it.', 'utf8');
|
13
|
+
}
|
14
|
+
var Database = new sqlite3.Database(process.cwd() + "/Zach_Database/SyntheticDatabase.sqlite");
|
15
|
+
|
16
|
+
Database.serialize(function() {
|
17
|
+
Database.run("CREATE TABLE IF NOT EXISTS json (ID TEXT, json TEXT)");
|
18
|
+
});
|
19
|
+
|
20
|
+
function Lset(key, value) {
|
21
|
+
try {
|
22
|
+
//check if key is exists if yes then update it
|
23
|
+
if (Lhas(key)) {
|
24
|
+
var done = false;
|
25
|
+
Database.run(`UPDATE json SET json = (?) WHERE ID = (?)`, [JSON.stringify(value), key], function(err) {
|
26
|
+
done = true;
|
27
|
+
});
|
28
|
+
deasync.loopWhile(function(){
|
29
|
+
return !done;
|
30
|
+
});
|
31
|
+
return;
|
32
|
+
}
|
33
|
+
else {
|
34
|
+
var done = false;
|
35
|
+
Database.run(`INSERT INTO json(ID, json) VALUES(?, ?)`, [key, JSON.stringify(value)], function(err) {
|
36
|
+
done = true;
|
37
|
+
});
|
38
|
+
deasync.loopWhile(function(){
|
39
|
+
return !done;
|
40
|
+
});
|
41
|
+
return;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
catch (e) {
|
45
|
+
console.log(e);
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
function Lget(key) {
|
51
|
+
try {
|
52
|
+
var done = false;
|
53
|
+
var Data = undefined;
|
54
|
+
Database.get(`SELECT * FROM json WHERE ID = (?)`, [key], function(err, row) {
|
55
|
+
Data = row;
|
56
|
+
done = true;
|
57
|
+
});
|
58
|
+
deasync.loopWhile(function(){
|
59
|
+
return !done;
|
60
|
+
});
|
61
|
+
if (Data === undefined) return undefined;
|
62
|
+
return JSON.parse(Data.json);
|
63
|
+
}
|
64
|
+
catch (e) {
|
65
|
+
console.log(e);
|
66
|
+
return false;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
function Lhas(key) {
|
71
|
+
try {
|
72
|
+
var done = false;
|
73
|
+
var Data = undefined;
|
74
|
+
Database.get(`SELECT * FROM json WHERE ID = (?)`, [key], function(err, row) {
|
75
|
+
Data = row;
|
76
|
+
done = true;
|
77
|
+
});
|
78
|
+
deasync.loopWhile(function(){
|
79
|
+
return !done;
|
80
|
+
});
|
81
|
+
if (Data === undefined) return false;
|
82
|
+
return true;
|
83
|
+
}
|
84
|
+
catch (e) {
|
85
|
+
console.log(e);
|
86
|
+
return false;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
|
90
|
+
function Lremove(key) {
|
91
|
+
try {
|
92
|
+
var done = false;
|
93
|
+
Database.run(`DELETE FROM json WHERE ID = (?)`, [key], function(err) {
|
94
|
+
done = true;
|
95
|
+
});
|
96
|
+
deasync.loopWhile(function(){
|
97
|
+
return !done;
|
98
|
+
});
|
99
|
+
return;
|
100
|
+
}
|
101
|
+
catch (e) {
|
102
|
+
console.log(e);
|
103
|
+
return false;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
function LremoveMultiple(keys) {
|
108
|
+
try {
|
109
|
+
for (const key of keys) {
|
110
|
+
Database.run(`DELETE FROM json WHERE ID = (?)`, [key], function(err) {});
|
111
|
+
}
|
112
|
+
return true;
|
113
|
+
}
|
114
|
+
catch (e) {
|
115
|
+
console.log(e);
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
|
120
|
+
function Llist() {
|
121
|
+
var done = false;
|
122
|
+
var Data = undefined;
|
123
|
+
Database.all(`SELECT * FROM json`,[], function(err, rows) {
|
124
|
+
Data = rows;
|
125
|
+
done = true;
|
126
|
+
});
|
127
|
+
deasync.loopWhile(function(){
|
128
|
+
return !done;
|
129
|
+
});
|
130
|
+
return Data;
|
131
|
+
}
|
132
|
+
|
133
|
+
function Replit_Set(key, value) {
|
134
|
+
try {
|
135
|
+
var done = false;
|
136
|
+
|
137
|
+
request({
|
138
|
+
url: process.env.REPLIT_DB_URL,
|
139
|
+
method: "POST",
|
140
|
+
headers: {
|
141
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
142
|
+
},
|
143
|
+
body: `${encodeURIComponent(key)}=${encodeURIComponent(JSON.stringify(value))}`
|
144
|
+
|
145
|
+
}, function (error, response, body) {
|
146
|
+
done = true;
|
147
|
+
});
|
148
|
+
|
149
|
+
deasync.loopWhile(function(){
|
150
|
+
return !done;
|
151
|
+
});
|
152
|
+
|
153
|
+
return;
|
154
|
+
|
155
|
+
}
|
156
|
+
catch (e) {
|
157
|
+
console.log(e);
|
158
|
+
return false;
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
function Replit_Get(key) {
|
163
|
+
try {
|
164
|
+
var done = false;
|
165
|
+
var response = null;
|
166
|
+
|
167
|
+
request(process.env.REPLIT_DB_URL + "/" + key, function (error, res, body) {
|
168
|
+
if (!error && res.statusCode == 200) {
|
169
|
+
response = body;
|
170
|
+
}
|
171
|
+
done = true;
|
172
|
+
});
|
173
|
+
|
174
|
+
deasync.loopWhile(function(){
|
175
|
+
return !done;
|
176
|
+
});
|
177
|
+
|
178
|
+
return JSON.parse(response);
|
179
|
+
}
|
180
|
+
catch (e) {
|
181
|
+
console.log(e);
|
182
|
+
return false;
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
function Replit_Has(key) {
|
187
|
+
try {
|
188
|
+
var done = false;
|
189
|
+
var response = null;
|
190
|
+
|
191
|
+
request(process.env.REPLIT_DB_URL + "/" + key, function (error, res, body) {
|
192
|
+
if (!error && res.statusCode == 200) {
|
193
|
+
response = body;
|
194
|
+
}
|
195
|
+
done = true;
|
196
|
+
});
|
197
|
+
|
198
|
+
deasync.loopWhile(function(){
|
199
|
+
return !done;
|
200
|
+
});
|
201
|
+
|
202
|
+
return response != null;
|
203
|
+
}
|
204
|
+
catch (e) {
|
205
|
+
console.log(e);
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
|
210
|
+
function Replit_Remove(key) {
|
211
|
+
try {
|
212
|
+
var done = false;
|
213
|
+
request.delete(process.env.REPLIT_DB_URL + "/" + key , function (error, response, body) {
|
214
|
+
done = true;
|
215
|
+
});
|
216
|
+
|
217
|
+
deasync.loopWhile(function(){
|
218
|
+
return !done;
|
219
|
+
});
|
220
|
+
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
catch (e) {
|
224
|
+
console.log(e);
|
225
|
+
return false;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
function Replit_RemoveMultiple(keys) {
|
229
|
+
try {
|
230
|
+
for (const key of keys) {
|
231
|
+
request.delete(process.env.REPLIT_DB_URL + "/" + key , function (error, response, body) {});
|
232
|
+
}
|
233
|
+
return true;
|
234
|
+
}
|
235
|
+
catch (e) {
|
236
|
+
console.log(e);
|
237
|
+
return false;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
|
241
|
+
function Replit_List() {
|
242
|
+
var done = false;
|
243
|
+
var response = null;
|
244
|
+
|
245
|
+
request(process.env.REPLIT_DB_URL + "?encode=true" + `&prefix=${encodeURIComponent("")}`, function (error, res, body) {
|
246
|
+
if (!error && res.statusCode == 200) {
|
247
|
+
response = body;
|
248
|
+
}
|
249
|
+
done = true;
|
250
|
+
|
251
|
+
});
|
252
|
+
|
253
|
+
deasync.loopWhile(function(){
|
254
|
+
return !done;
|
255
|
+
});
|
256
|
+
|
257
|
+
if (response.length === 0) {
|
258
|
+
return [];
|
259
|
+
}
|
260
|
+
return response.split("\n").map(decodeURIComponent);
|
261
|
+
}
|
262
|
+
|
263
|
+
|
264
|
+
var methods = {
|
265
|
+
fetch: function(db, params, options) {
|
266
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
267
|
+
if (!fetched) return null;
|
268
|
+
try {
|
269
|
+
fetched = JSON.parse(fetched.json);
|
270
|
+
} catch (e) {
|
271
|
+
fetched = fetched.json;
|
272
|
+
}
|
273
|
+
if (params.ops.target) fetched = get(fetched, params.ops.target);
|
274
|
+
return fetched;
|
275
|
+
},
|
276
|
+
set: function(db, params, options) {
|
277
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
278
|
+
if (!fetched) {
|
279
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
280
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
281
|
+
}
|
282
|
+
try {
|
283
|
+
fetched = JSON.parse(fetched);
|
284
|
+
} catch (e) {
|
285
|
+
fetched = fetched;
|
286
|
+
}
|
287
|
+
if (typeof fetched === 'object' && params.ops.target) {
|
288
|
+
params.data = JSON.parse(params.data);
|
289
|
+
params.data = set(fetched, params.ops.target, params.data);
|
290
|
+
}
|
291
|
+
else if (params.ops.target) throw new TypeError('Cannot target a non-object.');
|
292
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(JSON.stringify(params.data), params.id);
|
293
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
294
|
+
if (newData === '{}') return null;
|
295
|
+
else {
|
296
|
+
try { newData = JSON.parse(newData);
|
297
|
+
}
|
298
|
+
catch (e) {
|
299
|
+
newData = newData;
|
300
|
+
}
|
301
|
+
return newData;
|
302
|
+
}
|
303
|
+
},
|
304
|
+
add: function addDB(db, params, options) {
|
305
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
306
|
+
if (!fetched) {
|
307
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
308
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
309
|
+
}
|
310
|
+
if (params.ops.target) {
|
311
|
+
try {
|
312
|
+
fetched = JSON.parse(fetched);
|
313
|
+
}
|
314
|
+
catch (e) {
|
315
|
+
fetched = fetched;
|
316
|
+
}
|
317
|
+
let oldValue = get(fetched, params.ops.target);
|
318
|
+
if (oldValue === undefined) oldValue = 0;
|
319
|
+
else if (isNaN(oldValue)) throw new Error(`Data @ ID: "${params.id}" IS NOT A number.\nFOUND: ${fetched}\nEXPECTED: number`);
|
320
|
+
params.data = set(fetched, params.ops.target, oldValue + JSON.parse(params.data));
|
321
|
+
}
|
322
|
+
else {
|
323
|
+
if (fetched.json === '{}') fetched.json = 0;
|
324
|
+
try {
|
325
|
+
fetched.json = JSON.parse(fetched);
|
326
|
+
} catch (e) {
|
327
|
+
fetched.json = fetched.json;
|
328
|
+
}
|
329
|
+
if (isNaN(fetched.json)) throw new Error(`Data @ ID: "${params.id}" IS NOT A number.\nFOUND: ${fetched.json}\nEXPECTED: number`);
|
330
|
+
params.data = parseInt(fetched.json, 10) + parseInt(params.data, 10);
|
331
|
+
}
|
332
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(JSON.stringify(params.data), params.id);
|
333
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
334
|
+
if (newData === '{}') return null;
|
335
|
+
else {
|
336
|
+
try {
|
337
|
+
newData = JSON.parse(newData);
|
338
|
+
}
|
339
|
+
catch (e) {
|
340
|
+
newData = newData;
|
341
|
+
}
|
342
|
+
return newData;
|
343
|
+
}
|
344
|
+
},
|
345
|
+
subtract: function subtractDB(db, params, options) {
|
346
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
347
|
+
if (!fetched) {
|
348
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
349
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
350
|
+
}
|
351
|
+
if (params.ops.target) {
|
352
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
353
|
+
params.data = JSON.parse(params.data);
|
354
|
+
let oldValue = get(fetched, params.ops.target);
|
355
|
+
if (oldValue === undefined) oldValue = 0;
|
356
|
+
else if (isNaN(oldValue)) throw new Error('Target is not a number.');
|
357
|
+
params.data = set(fetched, params.ops.target, oldValue - params.data);
|
358
|
+
} else {
|
359
|
+
if (fetched.json === '{}') fetched.json = 0;
|
360
|
+
else fetched.json = JSON.parse(fetched.json);
|
361
|
+
try { fetched.json = JSON.parse(fetched); } catch (e) {}
|
362
|
+
if (isNaN(fetched.json)) throw new Error('Target is not a number.');
|
363
|
+
params.data = parseInt(fetched.json, 10) - parseInt(params.data, 10);
|
364
|
+
}
|
365
|
+
params.data = JSON.stringify(params.data);
|
366
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(params.data, params.id);
|
367
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
368
|
+
if (newData === '{}') return null;
|
369
|
+
else {
|
370
|
+
try { newData = JSON.parse(newData); } catch (e) {}
|
371
|
+
return newData;
|
372
|
+
}
|
373
|
+
},
|
374
|
+
push: function pushDB(db, params, options) {
|
375
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
376
|
+
if (!fetched) {
|
377
|
+
db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
|
378
|
+
fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
379
|
+
}
|
380
|
+
if (params.ops.target) {
|
381
|
+
fetched = JSON.parse(fetched.json);
|
382
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
383
|
+
params.data = JSON.parse(params.data);
|
384
|
+
if (typeof fetched !== 'object') throw new TypeError('Cannot push into a non-object.');
|
385
|
+
let oldArray = get(fetched, params.ops.target);
|
386
|
+
if (oldArray === undefined) oldArray = [];
|
387
|
+
else if (!Array.isArray(oldArray)) throw new TypeError('Target is not an array.');
|
388
|
+
oldArray.push(params.data);
|
389
|
+
params.data = set(fetched, params.ops.target, oldArray);
|
390
|
+
} else {
|
391
|
+
if (fetched.json === '{}') fetched.json = [];
|
392
|
+
else fetched.json = JSON.parse(fetched.json);
|
393
|
+
try { fetched.json = JSON.parse(fetched.json); } catch (e) {}
|
394
|
+
params.data = JSON.parse(params.data);
|
395
|
+
if (!Array.isArray(fetched.json)) throw new TypeError('Target is not an array.');
|
396
|
+
fetched.json.push(params.data);
|
397
|
+
params.data = fetched.json;
|
398
|
+
}
|
399
|
+
params.data = JSON.stringify(params.data);
|
400
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(params.data, params.id);
|
401
|
+
let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
|
402
|
+
if (newData === '{}') return null;
|
403
|
+
else {
|
404
|
+
newData = JSON.parse(newData);
|
405
|
+
try { newData = JSON.parse(newData); } catch (e) {}
|
406
|
+
return newData;
|
407
|
+
}
|
408
|
+
},
|
409
|
+
delete: function deleteDB(db, params, options) {
|
410
|
+
const unset = require('lodash/unset');
|
411
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
412
|
+
if (!fetched) return false;
|
413
|
+
else fetched = JSON.parse(fetched.json);
|
414
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
415
|
+
if (typeof fetched === 'object' && params.ops.target) {
|
416
|
+
unset(fetched, params.ops.target);
|
417
|
+
fetched = JSON.stringify(fetched);
|
418
|
+
db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(fetched, params.id);
|
419
|
+
return true;
|
420
|
+
}
|
421
|
+
else if (params.ops.target) throw new TypeError('Target is not an object.');
|
422
|
+
else db.prepare(`DELETE FROM ${options.table} WHERE ID = (?)`).run(params.id);
|
423
|
+
return true;
|
424
|
+
},
|
425
|
+
has: function hasDB(db, params, options) {
|
426
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
427
|
+
if (!fetched) return false;
|
428
|
+
else fetched = JSON.parse(fetched.json);
|
429
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
430
|
+
if (params.ops.target) fetched = get(fetched, params.ops.target);
|
431
|
+
return (typeof fetched != 'undefined');
|
432
|
+
},
|
433
|
+
all: function allDB(db, params, options) {
|
434
|
+
var stmt = db.prepare(`SELECT * FROM ${options.table} WHERE ID IS NOT NULL`);
|
435
|
+
let resp = [];
|
436
|
+
for (var row of stmt.iterate()) {
|
437
|
+
try {
|
438
|
+
resp.push({
|
439
|
+
ID: row.ID,
|
440
|
+
data: JSON.parse(row.json)
|
441
|
+
});
|
442
|
+
}
|
443
|
+
catch (e) {
|
444
|
+
return [];
|
445
|
+
}
|
446
|
+
}
|
447
|
+
return resp;
|
448
|
+
},
|
449
|
+
type: function typeDB(db, params, options) {
|
450
|
+
let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
|
451
|
+
if (!fetched) return null; // If empty, return null
|
452
|
+
fetched = JSON.parse(fetched.json);
|
453
|
+
try { fetched = JSON.parse(fetched); } catch (e) {}
|
454
|
+
if (params.ops.target) fetched = get(fetched, params.ops.target); // Get prop using dot notation
|
455
|
+
return typeof fetched;
|
456
|
+
},
|
457
|
+
clear: function clearDB(db, params, options) {
|
458
|
+
let fetched = db.prepare(`DELETE FROM ${options.table}`).run();
|
459
|
+
if(!fetched) return null;
|
460
|
+
return fetched.changes;
|
461
|
+
|
462
|
+
}
|
463
|
+
};
|
464
|
+
|
465
|
+
|
466
|
+
function arbitrate(method, params) {
|
467
|
+
let options = {table: "json"};
|
468
|
+
db.prepare(`CREATE TABLE IF NOT EXISTS ${options.table} (ID TEXT, json TEXT)`).run();
|
469
|
+
if (params.ops.target && params.ops.target[0] === ".") params.ops.target = params.ops.target.slice(1); // Remove prefix if necessary
|
470
|
+
if (params.data && params.data === Infinity) throw new TypeError(`You cannot set Infinity into the database @ ID: ${params.id}`);
|
471
|
+
if (params.id && typeof params.id == "string" && params.id.includes(".")) {
|
472
|
+
let unparsed = params.id.split(".");
|
473
|
+
params.id = unparsed.shift();
|
474
|
+
params.ops.target = unparsed.join(".");
|
475
|
+
}
|
476
|
+
return methods[method](db, params, options);
|
477
|
+
}
|
478
|
+
|
479
|
+
|
480
|
+
module.exports = function ChernobyL(Local) {
|
481
|
+
if (Local && process.env["REPL_ID"]) {
|
482
|
+
return {
|
483
|
+
set: Lset,
|
484
|
+
get: Lget,
|
485
|
+
has: Lhas,
|
486
|
+
delete: Lremove,
|
487
|
+
deleteMultiple: LremoveMultiple,
|
488
|
+
list: Llist
|
489
|
+
};
|
490
|
+
} else if (!Local && process.env["REPL_ID"]) {
|
491
|
+
return {
|
492
|
+
set: Replit_Set,
|
493
|
+
get: Replit_Get,
|
494
|
+
has: Replit_Has,
|
495
|
+
delete: Replit_Remove,
|
496
|
+
deleteMultiple: Replit_RemoveMultiple,
|
497
|
+
list: Replit_List
|
498
|
+
};
|
499
|
+
}
|
500
|
+
else if (Local && !process.env["REPL_ID"]) {
|
501
|
+
return {
|
502
|
+
set: Lset,
|
503
|
+
get: Lget,
|
504
|
+
has: Lhas,
|
505
|
+
delete: Lremove,
|
506
|
+
deleteMultiple: LremoveMultiple,
|
507
|
+
list: Llist
|
508
|
+
};
|
509
|
+
}
|
510
|
+
else if (!Local && !process.env["REPL_ID"]) {
|
511
|
+
return {
|
512
|
+
set: Lset,
|
513
|
+
get: Lget,
|
514
|
+
has: Lhas,
|
515
|
+
delete: Lremove,
|
516
|
+
deleteMultiple: LremoveMultiple,
|
517
|
+
list: Llist
|
518
|
+
};
|
519
|
+
}
|
520
|
+
else {
|
521
|
+
return {
|
522
|
+
set: Lset,
|
523
|
+
get: Lget,
|
524
|
+
has: Lhas,
|
525
|
+
delete: Lremove,
|
526
|
+
deleteMultiple: LremoveMultiple,
|
527
|
+
list: Llist
|
528
|
+
};
|
529
|
+
}
|
530
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
This folder is used by ChernobyL(NANI =)) ) to store data. Do not delete this folder or any of the files in it.
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
This folder is used by ChernobyL(NANI =)) ) to store data. Do not delete this folder or any of the files in it.
|
Binary file
|
@@ -0,0 +1,146 @@
|
|
1
|
+
module.exports = {
|
2
|
+
"delta": {
|
3
|
+
"attachments": [
|
4
|
+
{
|
5
|
+
"fbid": "1522004821162174",
|
6
|
+
"id": "1522004821162174",
|
7
|
+
"mercury": {
|
8
|
+
"app_attribution": null,
|
9
|
+
"attach_type": "share",
|
10
|
+
"name": null,
|
11
|
+
"url": null,
|
12
|
+
"rel": null,
|
13
|
+
"preview_url": null,
|
14
|
+
"preview_width": null,
|
15
|
+
"preview_height": null,
|
16
|
+
"large_preview_url": null,
|
17
|
+
"large_preview_width": null,
|
18
|
+
"large_preview_height": null,
|
19
|
+
"icon_type": null,
|
20
|
+
"metadata": null,
|
21
|
+
"thumbnail_url": null,
|
22
|
+
"share": {
|
23
|
+
"description": null,
|
24
|
+
"media": {
|
25
|
+
"animated_image": null,
|
26
|
+
"animated_image_size": {
|
27
|
+
"height": null,
|
28
|
+
"width": null
|
29
|
+
},
|
30
|
+
"image": null,
|
31
|
+
"image_size": {
|
32
|
+
"height": null,
|
33
|
+
"width": null
|
34
|
+
},
|
35
|
+
"duration": null,
|
36
|
+
"playable": null,
|
37
|
+
"source": null
|
38
|
+
},
|
39
|
+
"source": "Dimon - testing",
|
40
|
+
"style_list": [
|
41
|
+
"business_message_items", "fallback"
|
42
|
+
],
|
43
|
+
"title": "search engines",
|
44
|
+
"properties": null,
|
45
|
+
"uri": null,
|
46
|
+
"subattachments": [],
|
47
|
+
"deduplication_key": "abcde",
|
48
|
+
"action_links": [],
|
49
|
+
"share_id": "1522004821162174",
|
50
|
+
"target": {
|
51
|
+
"call_to_actions": [],
|
52
|
+
"items": [
|
53
|
+
{
|
54
|
+
"id": "629934437209008",
|
55
|
+
"name": "search engines",
|
56
|
+
"desc": "",
|
57
|
+
"thumb_url": null,
|
58
|
+
"item_url": null,
|
59
|
+
"title": "search engines",
|
60
|
+
"text": "",
|
61
|
+
"source": null,
|
62
|
+
"metalines": {
|
63
|
+
"metaline_1": "click to get redirected",
|
64
|
+
"metaline_2": null,
|
65
|
+
"metaline_3": null
|
66
|
+
},
|
67
|
+
"location": 12314,
|
68
|
+
"category": 69,
|
69
|
+
"call_to_actions": [
|
70
|
+
{
|
71
|
+
"action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fgoogle.com%2F&h=ATNziCq_-6I3ZPYwwLluFdCrWMEwLLKvokFlXdEdS4LD2Lzsv2cR2SJYffJcDYBfB092Xeq8oRdftJk4husEYVduH24RnlP3HvVQOkOrciXDs2M7TkWYyNLBelvJ2Fc-mw8pbGy5NslGf_fkZ_A",
|
72
|
+
"action_type": 2,
|
73
|
+
"id": "FFD=",
|
74
|
+
"title": "Google",
|
75
|
+
"link_target_ids": [629934437209008],
|
76
|
+
"is_mutable_by_server": false,
|
77
|
+
"should_show_user_confirmation": false,
|
78
|
+
"confirmation_title": null,
|
79
|
+
"confirmation_message": null,
|
80
|
+
"confirmation_continue_label": null,
|
81
|
+
"confirmation_cancel_label": null,
|
82
|
+
"payment_metadata": {
|
83
|
+
"total_price": null,
|
84
|
+
"payment_module_config": null
|
85
|
+
},
|
86
|
+
"is_disabled": false
|
87
|
+
}, {
|
88
|
+
"action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fyahoo.com%2F&h=ATNIuTf7iDGP5xXTWOAdhaGhRFfDf4eS09t_G9CrR0MDiBKpqtCDzPf_9y5Bq7TXMgmo6RttztsgeO0ReSc0PDvJDTa1fLMMK2CjrpkqC91_m-yaMXfeQ4aI6MbhZrOPnK3YFnQP4XvRx3N1udE",
|
89
|
+
"action_type": 2,
|
90
|
+
"id": "CDE=",
|
91
|
+
"title": "Yahoo",
|
92
|
+
"link_target_ids": [629934437209008],
|
93
|
+
"is_mutable_by_server": false,
|
94
|
+
"should_show_user_confirmation": false,
|
95
|
+
"confirmation_title": null,
|
96
|
+
"confirmation_message": null,
|
97
|
+
"confirmation_continue_label": null,
|
98
|
+
"confirmation_cancel_label": null,
|
99
|
+
"payment_metadata": {
|
100
|
+
"total_price": null,
|
101
|
+
"payment_module_config": null
|
102
|
+
},
|
103
|
+
"is_disabled": false
|
104
|
+
}, {
|
105
|
+
"action_link": "http://l.facebook.com/l.php?u=http%3A%2F%2Fbing.com%2F&h=ATMoMijAt6Da6WWIQ679DhZyZizWdxAViWwyl-RjKobFUG_x8GmB8LD6pPa3KP5K1-QTL9vuaFwjqB0itaMFWk4VwQ9uh56JgnbFnAo4qM_CrQufgLeHwwCnWSCnZt8IzYT4y6YULLLFA5bL1H4",
|
106
|
+
"action_type": 2,
|
107
|
+
"id": "ABC=",
|
108
|
+
"title": "Bing",
|
109
|
+
"link_target_ids": [629934437209008],
|
110
|
+
"is_mutable_by_server": false,
|
111
|
+
"should_show_user_confirmation": false,
|
112
|
+
"confirmation_title": null,
|
113
|
+
"confirmation_message": null,
|
114
|
+
"confirmation_continue_label": null,
|
115
|
+
"confirmation_cancel_label": null,
|
116
|
+
"payment_metadata": {
|
117
|
+
"total_price": null,
|
118
|
+
"payment_module_config": null
|
119
|
+
},
|
120
|
+
"is_disabled": false
|
121
|
+
}
|
122
|
+
]
|
123
|
+
}
|
124
|
+
],
|
125
|
+
"location": 132145,
|
126
|
+
"category": 69,
|
127
|
+
"message": "Aaa: search engines"
|
128
|
+
}
|
129
|
+
}
|
130
|
+
},
|
131
|
+
"otherUserFbIds": ["1521994257829897"],
|
132
|
+
"titanType": 1
|
133
|
+
}
|
134
|
+
],
|
135
|
+
"messageMetadata": {
|
136
|
+
"actorFbId": "1345",
|
137
|
+
"messageId": "mid.12345:asdv",
|
138
|
+
"offlineThreadingId": "1345v1345",
|
139
|
+
"tags": ["source:messenger:commerce"],
|
140
|
+
"threadKey": {
|
141
|
+
"otherUserFbId": "13451345"
|
142
|
+
},
|
143
|
+
"timestamp": "1487078180265"
|
144
|
+
}
|
145
|
+
}
|
146
|
+
};
|
Binary file
|
Binary file
|