yandev 3.0.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of yandev might be problematic. Click here for more details.

Files changed (101) hide show
  1. package/.cache/replit/__replit_disk_meta.json +1 -0
  2. package/.cache/replit/nix/env.json +1 -0
  3. package/.config/configstore/update-notifier-npm.json +4 -0
  4. package/.config/configstore/update-notifier-npm.json.1735545094 +4 -0
  5. package/.gitattributes +2 -0
  6. package/.replit +93 -0
  7. package/.upm/store.json +1 -0
  8. package/ConfigFca.json +38 -0
  9. package/Extra/Database/index.js +469 -0
  10. package/Extra/ExtraAddons.js +82 -0
  11. package/Extra/ExtraFindUID.js +62 -0
  12. package/Extra/ExtraGetThread.js +340 -0
  13. package/Extra/ExtraScreenShot.js +430 -0
  14. package/Extra/ExtraUptimeRobot.js +38 -0
  15. package/Extra/Html/Classic/script.js +833 -0
  16. package/Extra/Html/Classic/style.css +1222 -0
  17. package/Extra/Security/Index.js +173 -0
  18. package/Extra/Security/Step_1.js +6 -0
  19. package/Extra/Security/Step_2.js +22 -0
  20. package/Extra/Security/Step_3.js +22 -0
  21. package/Extra/Src/Change_Environment.js +24 -0
  22. package/Extra/Src/Check_Update.js +66 -0
  23. package/Extra/Src/History.js +115 -0
  24. package/Extra/Src/Instant_Update.js +64 -0
  25. package/Extra/Src/Last-Run.js +65 -0
  26. package/Extra/Src/Release_Memory.js +41 -0
  27. package/Extra/Src/image/checkmate.jpg +0 -0
  28. package/Extra/Src/uuid.js +137 -0
  29. package/Func/AcceptAgreement.js +31 -0
  30. package/Func/ClearCache.js +64 -0
  31. package/Func/ReportV1.js +54 -0
  32. package/Index.js +378 -0
  33. package/LICENSE +21 -0
  34. package/Language/index.json +224 -0
  35. package/Main.js +1110 -0
  36. package/README.md +142 -0
  37. package/broadcast.js +40 -0
  38. package/logger.js +66 -0
  39. package/package.json +102 -0
  40. package/replit.nix +8 -0
  41. package/src/Dev_Horizon_Data.js +125 -0
  42. package/src/Premium.js +25 -0
  43. package/src/Screenshot.js +83 -0
  44. package/src/addExternalModule.js +16 -0
  45. package/src/addUserToGroup.js +79 -0
  46. package/src/changeAdminStatus.js +79 -0
  47. package/src/changeArchivedStatus.js +41 -0
  48. package/src/changeAvt.js +85 -0
  49. package/src/changeBio.js +65 -0
  50. package/src/changeBlockedStatus.js +36 -0
  51. package/src/changeGroupImage.js +106 -0
  52. package/src/changeNickname.js +45 -0
  53. package/src/changeThreadColor.js +62 -0
  54. package/src/changeThreadEmoji.js +42 -0
  55. package/src/createNewGroup.js +70 -0
  56. package/src/createPoll.js +60 -0
  57. package/src/deleteMessage.js +45 -0
  58. package/src/deleteThread.js +43 -0
  59. package/src/forwardAttachment.js +48 -0
  60. package/src/getAccessToken.js +28 -0
  61. package/src/getCurrentUserID.js +7 -0
  62. package/src/getEmojiUrl.js +27 -0
  63. package/src/getFriendsList.js +73 -0
  64. package/src/getMessage.js +80 -0
  65. package/src/getThreadHistory.js +537 -0
  66. package/src/getThreadInfo.js +425 -0
  67. package/src/getThreadList.js +213 -0
  68. package/src/getThreadMain.js +220 -0
  69. package/src/getThreadPictures.js +59 -0
  70. package/src/getUID.js +59 -0
  71. package/src/getUserID.js +62 -0
  72. package/src/getUserInfo.js +113 -0
  73. package/src/getUserInfoMain.js +65 -0
  74. package/src/getUserInfoV2.js +32 -0
  75. package/src/getUserInfoV3.js +63 -0
  76. package/src/getUserInfoV4.js +55 -0
  77. package/src/getUserInfoV5.js +61 -0
  78. package/src/handleFriendRequest.js +46 -0
  79. package/src/handleMessageRequest.js +49 -0
  80. package/src/httpGet.js +49 -0
  81. package/src/httpPost.js +48 -0
  82. package/src/httpPostFormData.js +41 -0
  83. package/src/listenMqtt.js +786 -0
  84. package/src/logout.js +68 -0
  85. package/src/markAsDelivered.js +48 -0
  86. package/src/markAsRead.js +70 -0
  87. package/src/markAsReadAll.js +43 -0
  88. package/src/markAsSeen.js +51 -0
  89. package/src/muteThread.js +47 -0
  90. package/src/removeUserFromGroup.js +49 -0
  91. package/src/resolvePhotoUrl.js +37 -0
  92. package/src/searchForThread.js +43 -0
  93. package/src/sendMessage.js +379 -0
  94. package/src/sendTypingIndicator.js +80 -0
  95. package/src/setMessageReaction.js +109 -0
  96. package/src/setPostReaction.js +102 -0
  97. package/src/setTitle.js +74 -0
  98. package/src/threadColors.js +39 -0
  99. package/src/unfriend.js +43 -0
  100. package/src/unsendMessage.js +40 -0
  101. package/utils.js +1684 -0
@@ -0,0 +1 @@
1
+ {"nonce":7412493518187109517,"last_updated":{"seconds":1695318515,"nanos":743785000}}
@@ -0,0 +1 @@
1
+ {"entries":{"replit.nix":{"env":{"AR":"ar","AS":"as","CC":"gcc","CONFIG_SHELL":"/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash","CXX":"g++","HOST_PATH":"/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin:/nix/store/w8q2bwi6rdhsa1dz9i8mqznddk5l7p26-typescript-language-server-3.3.2/bin:/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/bin:/nix/store/n1wjpwirjdkvkqyfjjg8qafgdhpr5w2m-jest-cli-23.6.0/bin:/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin:/nix/store/mydc6f4k2z73xlcz7ilif3v2lcaiqvza-findutils-4.9.0/bin:/nix/store/j9p3g8472iijd50vhdprx0nmk2fqn5gv-diffutils-3.8/bin:/nix/store/89zs7rms6x00xfq4dq6m7mjnhkr8a6r4-gnused-4.8/bin:/nix/store/86bp03jkmsl6f92w0yzg4s59g5mhxwmy-gnugrep-3.7/bin:/nix/store/hwcdqw4jrjnd37wxqgsd47hd0j8bnj09-gawk-5.1.1/bin:/nix/store/cfbhw8r8ags41vwqaz47r583d0p4h4a1-gnutar-1.34/bin:/nix/store/p3m1ndl1lapwrlh698bnb5lvvxh67378-gzip-1.12/bin:/nix/store/a8mhcagrsly7c7mpjrpsnaahk4aax056-bzip2-1.0.8-bin/bin:/nix/store/mblgz65m3zv9x548a3d5m96fj2pbwr09-gnumake-4.3/bin:/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin:/nix/store/v7ljksji50mg3w61dykaa3n3y79n6nil-patch-2.7.6/bin:/nix/store/zlcnmqq14jz5x9439jf937mvayyl63da-xz-5.2.7-bin/bin:/nix/store/y6aj732zm9m87c82fpvf103a1xb22blp-file-5.43/bin","LD":"ld","LOCALE_ARCHIVE":"/usr/lib/locale/locale-archive","NIX_BINTOOLS":"/nix/store/1d6ian3r8kdzspw8hacjhl3xkp40g1lj-binutils-wrapper-2.39","NIX_BINTOOLS_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_BUILD_CORES":"4","NIX_BUILD_TOP":"/tmp","NIX_CC":"/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0","NIX_CC_WRAPPER_TARGET_HOST_x86_64_unknown_linux_gnu":"1","NIX_CFLAGS_COMPILE":" -frandom-seed=w7rihbbvnp -isystem /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/include -isystem /nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/include","NIX_ENFORCE_NO_NATIVE":"1","NIX_HARDENING_ENABLE":"fortify stackprotector pic strictoverflow format relro bindnow","NIX_INDENT_MAKE":"1","NIX_LDFLAGS":"-rpath /nix/store/w7rihbbvnp89y3vqbkwy2z30wi3mwzhi-nix-shell/lib64 -rpath /nix/store/w7rihbbvnp89y3vqbkwy2z30wi3mwzhi-nix-shell/lib ","NIX_STORE":"/nix/store","NM":"nm","NODE_PATH":"/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/lib/node_modules:/nix/store/w8q2bwi6rdhsa1dz9i8mqznddk5l7p26-typescript-language-server-3.3.2/lib/node_modules:/nix/store/n1wjpwirjdkvkqyfjjg8qafgdhpr5w2m-jest-cli-23.6.0/lib/node_modules","OBJCOPY":"objcopy","OBJDUMP":"objdump","PATH":"/nix/store/bap4d0lpcrhpwmpb8ayjcgkmvfj62lnq-bash-interactive-5.1-p16/bin:/nix/store/pr5n59mb4jzmfx6kanwxly0l07p861fg-patchelf-0.15.0/bin:/nix/store/dq0xwmsk1g0i2ayg6pb7y87na2knzylh-gcc-wrapper-11.3.0/bin:/nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0/bin:/nix/store/57xv61c5zi8pphjbcwxxjlgc34p61ic9-glibc-2.35-163-bin/bin:/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin:/nix/store/1d6ian3r8kdzspw8hacjhl3xkp40g1lj-binutils-wrapper-2.39/bin:/nix/store/039g378vc3pc3dvi9dzdlrd0i4q93qwf-binutils-2.39/bin:/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1/bin:/nix/store/w8q2bwi6rdhsa1dz9i8mqznddk5l7p26-typescript-language-server-3.3.2/bin:/nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19/bin:/nix/store/n1wjpwirjdkvkqyfjjg8qafgdhpr5w2m-jest-cli-23.6.0/bin:/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin:/nix/store/mydc6f4k2z73xlcz7ilif3v2lcaiqvza-findutils-4.9.0/bin:/nix/store/j9p3g8472iijd50vhdprx0nmk2fqn5gv-diffutils-3.8/bin:/nix/store/89zs7rms6x00xfq4dq6m7mjnhkr8a6r4-gnused-4.8/bin:/nix/store/86bp03jkmsl6f92w0yzg4s59g5mhxwmy-gnugrep-3.7/bin:/nix/store/hwcdqw4jrjnd37wxqgsd47hd0j8bnj09-gawk-5.1.1/bin:/nix/store/cfbhw8r8ags41vwqaz47r583d0p4h4a1-gnutar-1.34/bin:/nix/store/p3m1ndl1lapwrlh698bnb5lvvxh67378-gzip-1.12/bin:/nix/store/a8mhcagrsly7c7mpjrpsnaahk4aax056-bzip2-1.0.8-bin/bin:/nix/store/mblgz65m3zv9x548a3d5m96fj2pbwr09-gnumake-4.3/bin:/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin:/nix/store/v7ljksji50mg3w61dykaa3n3y79n6nil-patch-2.7.6/bin:/nix/store/zlcnmqq14jz5x9439jf937mvayyl63da-xz-5.2.7-bin/bin:/nix/store/y6aj732zm9m87c82fpvf103a1xb22blp-file-5.43/bin","RANLIB":"ranlib","READELF":"readelf","SIZE":"size","SOURCE_DATE_EPOCH":"315532800","STRINGS":"strings","STRIP":"strip","XDG_DATA_DIRS":"/nix/store/pr5n59mb4jzmfx6kanwxly0l07p861fg-patchelf-0.15.0/share","_":"/nix/store/a7gvj343m05j2s32xcnwr35v31ynlypr-coreutils-9.1/bin/env","__ETC_PROFILE_SOURCED":"1","buildInputs":"/nix/store/dj805sw07vvpbxx39c8g67x8qddg0ikw-nodejs-18.12.1 /nix/store/w8q2bwi6rdhsa1dz9i8mqznddk5l7p26-typescript-language-server-3.3.2 /nix/store/zdcnqq55qi214j46zgw2qa1jp4dpdf2m-yarn-1.22.19 /nix/store/n1wjpwirjdkvkqyfjjg8qafgdhpr5w2m-jest-cli-23.6.0","buildPhase":"echo \"------------------------------------------------------------\" \u003e\u003e$out\necho \" WARNING: the existence of this path is not guaranteed.\" \u003e\u003e$out\necho \" It is an internal implementation detail for pkgs.mkShell.\" \u003e\u003e$out\necho \"------------------------------------------------------------\" \u003e\u003e$out\necho \u003e\u003e $out\n# Record all build inputs as runtime dependencies\nexport \u003e\u003e $out\n","builder":"/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash","cmakeFlags":"","configureFlags":"","depsBuildBuild":"","depsBuildBuildPropagated":"","depsBuildTarget":"","depsBuildTargetPropagated":"","depsHostHost":"","depsHostHostPropagated":"","depsTargetTarget":"","depsTargetTargetPropagated":"","doCheck":"","doInstallCheck":"","mesonFlags":"","name":"nix-shell","nativeBuildInputs":"","out":"/nix/store/w7rihbbvnp89y3vqbkwy2z30wi3mwzhi-nix-shell","outputs":"out","patches":"","phases":"buildPhase","propagatedBuildInputs":"","propagatedNativeBuildInputs":"","shell":"/nix/store/dsd5gz46hdbdk2rfdimqddhq6m8m8fqs-bash-5.1-p16/bin/bash","shellHook":"","stdenv":"/nix/store/kmfaajdpyyyg319vfqni5jm9wkxjmf73-stdenv-linux","strictDeps":"","system":"x86_64-linux"},"dependencies":[{"path":"replit.nix","mod_time":"2023-09-14T19:12:19.450788746Z"}],"channel":"stable-22_11","channel_nix_path":"/nix/store/g2zwsf4i26pngib77ask4m00n9pj2a03-nixpkgs-stable-22_11-22.11.tar.gz/nixpkgs-stable-22_11","production":null}}}
@@ -0,0 +1,4 @@
1
+ {
2
+ "optOut": false,
3
+ "lastUpdateCheck": 1695249987771
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "optOut": false,
3
+ "lastUpdateCheck": 1678825045705
4
+ }
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
package/.replit ADDED
@@ -0,0 +1,93 @@
1
+ entrypoint = "Index"
2
+
3
+ hidden = [".config", "package-lock.json"]
4
+
5
+ [interpreter]
6
+ command = [
7
+ "prybar-nodejs",
8
+ "-q",
9
+ "--ps1",
10
+ "\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
11
+ "-i"
12
+ ]
13
+
14
+ [[hints]]
15
+ regex = "Error \\[ERR_REQUIRE_ESM\\]"
16
+ message = "We see that you are using require(...) inside your code. We currently do not support this syntax. Please use 'import' instead when using external modules. (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)"
17
+
18
+ [nix]
19
+ channel = "stable-22_11"
20
+
21
+ [env]
22
+ XDG_CONFIG_HOME = "$REPL_HOME/.config"
23
+ PATH = "$REPL_HOME/.config/npm/node_global/bin:$REPL_HOME/node_modules/.bin"
24
+ npm_config_prefix = "$REPL_HOME/.config/npm/node_global"
25
+
26
+ [gitHubImport]
27
+ requiredFiles = [".replit", "replit.nix", ".config", "package.json", "package-lock.json"]
28
+
29
+ [packager]
30
+ language = "nodejs"
31
+
32
+ [packager.features]
33
+ packageSearch = true
34
+ guessImports = true
35
+ enabledForHosting = false
36
+
37
+ [unitTest]
38
+ language = "nodejs"
39
+
40
+ [debugger]
41
+ support = true
42
+
43
+ [debugger.interactive]
44
+ transport = "localhost:0"
45
+ startCommand = [ "dap-node" ]
46
+
47
+ [debugger.interactive.initializeMessage]
48
+ command = "initialize"
49
+ type = "request"
50
+
51
+ [debugger.interactive.initializeMessage.arguments]
52
+ clientID = "replit"
53
+ clientName = "replit.com"
54
+ columnsStartAt1 = true
55
+ linesStartAt1 = true
56
+ locale = "en-us"
57
+ pathFormat = "path"
58
+ supportsInvalidatedEvent = true
59
+ supportsProgressReporting = true
60
+ supportsRunInTerminalRequest = true
61
+ supportsVariablePaging = true
62
+ supportsVariableType = true
63
+
64
+ [debugger.interactive.launchMessage]
65
+ command = "launch"
66
+ type = "request"
67
+
68
+ [debugger.interactive.launchMessage.arguments]
69
+ args = []
70
+ console = "externalTerminal"
71
+ cwd = "."
72
+ environment = []
73
+ pauseForSourceMap = false
74
+ program = "./index.js"
75
+ request = "launch"
76
+ sourceMaps = true
77
+ stopOnEntry = false
78
+ type = "pwa-node"
79
+
80
+
81
+
82
+ [languages]
83
+
84
+ [languages.javascript]
85
+ pattern = "**/{*.js,*.jsx,*.ts,*.tsx,*.json}"
86
+
87
+ [languages.javascript.languageServer]
88
+ start = "typescript-language-server --stdio"
89
+
90
+ [deployment]
91
+ run = ["node", "index.js"]
92
+ deploymentTarget = "cloudrun"
93
+ ignorePorts = false
@@ -0,0 +1 @@
1
+ {"version":2,"languages":{"nodejs-npm":{"specfileHash":"ff9e5f0bf2d86edb0496c53e0172360e","lockfileHash":"4581018c545fbcd8463de85e11fa909a","guessedImports":["better-sqlite3","request","puppeteer","fs-extra","got","axios","is-hexcolor","mqtt","cheerio","aes-js","crypto-js","readable-stream","encode32","https-proxy-agent","bluebird","express","lodash","chalk","ws","totp-generator","tough-cookie","figlet","npmlog","deasync","duplexify","uuid","form-data","file-url","pretty-ms"],"guessedImportsHash":"13dbbd517c2db20c23c75062f27bb666"}}}
package/ConfigFca.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "Config_Version": "3.0.0",
3
+ "Language": "vi",
4
+ "AutoUpdate": true,
5
+ "MainColor": "#54C9F0",
6
+ "MainName": "[ KAIYOBOT ]",
7
+ "Uptime": false,
8
+ "Config": "default",
9
+ "DevMode": false,
10
+ "Login2Fa": false,
11
+ "AutoLogin": true,
12
+ "BroadCast": true,
13
+ "AuthString": "SD4S XQ32 O2JA WXB3 FUX2 OPJ7 Q7JZ 4R6Z",
14
+ "EncryptFeature": false,
15
+ "ResetDataLogin": false,
16
+ "AutoInstallNode": false,
17
+ "AntiSendAppState": false,
18
+ "AutoRestartMinutes": 0,
19
+ "RestartMQTT_Minutes": 0,
20
+ "HTML": {
21
+ "HTML": false,
22
+ "Port": "8888",
23
+ "Title": "FCA-KAIYOBOT",
24
+ "AvtLink": "https://i.imgur.com/SPTKasU.jpg",
25
+ "UserName": "Premium",
26
+ "Description": "I Am Dang Hoang An<33",
27
+ "FacebookLink": "https://m.me/dhannn.06"
28
+ },
29
+ "AntiGetInfo": {
30
+ "Database_Type": "default",
31
+ "AntiGetThreadInfo": true,
32
+ "AntiGetUserInfo": true
33
+ },
34
+ "Stable_Version": {
35
+ "Accept": false,
36
+ "Version": ""
37
+ }
38
+ }
@@ -0,0 +1,469 @@
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 BetterDB = require("better-sqlite3");
6
+ const fs = require('fs-extra');
7
+ const request = require('request');
8
+ const deasync = require('deasync');
9
+
10
+ if (!fs.existsSync(process.cwd() + '/Zeid_Database')) {
11
+ fs.mkdirSync(process.cwd() + '/Zeid_Database');
12
+ fs.writeFileSync(process.cwd() + '/Zeid_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 db = new BetterDB(process.cwd() + "/Zeid_Database/SyntheticDatabase.sqlite");
15
+
16
+ function Lset(key, value) {
17
+ if (!key)
18
+ throw new TypeError(
19
+ "No key specified."
20
+ );
21
+ return arbitrate("set",{
22
+ stringify: false,
23
+ id: key,
24
+ data: value,
25
+ ops: {},
26
+ });
27
+ }
28
+
29
+ function Lget(key) {
30
+ if (!key)
31
+ throw new TypeError(
32
+ "No key specified."
33
+ );
34
+ return arbitrate("fetch", { id: key, ops: {} || {} });
35
+ }
36
+
37
+ function Lhas(key) {
38
+ if (!key)
39
+ throw new TypeError(
40
+ "No key specified."
41
+ );
42
+ return arbitrate("has", { id: key, ops: {} });
43
+ }
44
+
45
+ function Lremove(key) {
46
+ if (!key)
47
+ throw new TypeError(
48
+ "No key specified."
49
+ );
50
+ return arbitrate("delete", { id: key, ops: {} });
51
+ }
52
+
53
+ function LremoveMultiple(key) {
54
+ if (!key)
55
+ throw new TypeError(
56
+ "No key specified."
57
+ );
58
+ try {
59
+ for (let i of key) {
60
+ arbitrate("delete", { id: i, ops: {} });
61
+ }
62
+ return true;
63
+ }
64
+ catch (err) {
65
+ return false;
66
+ }
67
+ }
68
+
69
+ function Llist() {
70
+ return arbitrate("all",{ ops: {} });
71
+ }
72
+
73
+ function Replit_Set(key, value) {
74
+ try {
75
+ var done = false;
76
+
77
+ request({
78
+ url: process.env.REPLIT_DB_URL,
79
+ method: "POST",
80
+ headers: {
81
+ 'Content-Type': 'application/x-www-form-urlencoded',
82
+ },
83
+ body: `${encodeURIComponent(key)}=${encodeURIComponent(JSON.stringify(value))}`
84
+
85
+ }, function (error, response, body) {
86
+ done = true;
87
+ });
88
+
89
+ deasync.loopWhile(function(){
90
+ return !done;
91
+ });
92
+
93
+ return;
94
+
95
+ }
96
+ catch (e) {
97
+ console.log(e);
98
+ return false;
99
+ }
100
+ }
101
+
102
+ function Replit_Get(key) {
103
+ try {
104
+ var done = false;
105
+ var response = null;
106
+
107
+ request(process.env.REPLIT_DB_URL + "/" + key, function (error, res, body) {
108
+ if (!error && res.statusCode == 200) {
109
+ response = body;
110
+ }
111
+ done = true;
112
+ });
113
+
114
+ deasync.loopWhile(function(){
115
+ return !done;
116
+ });
117
+
118
+ return JSON.parse(response);
119
+ }
120
+ catch (e) {
121
+ console.log(e);
122
+ return false;
123
+ }
124
+ }
125
+
126
+ function Replit_Has(key) {
127
+ try {
128
+ var done = false;
129
+ var response = null;
130
+
131
+ request(process.env.REPLIT_DB_URL + "/" + key, function (error, res, body) {
132
+ if (!error && res.statusCode == 200) {
133
+ response = body;
134
+ }
135
+ done = true;
136
+ });
137
+
138
+ deasync.loopWhile(function(){
139
+ return !done;
140
+ });
141
+
142
+ return response != null;
143
+ }
144
+ catch (e) {
145
+ console.log(e);
146
+ return false;
147
+ }
148
+ }
149
+
150
+ function Replit_Remove(key) {
151
+ try {
152
+ var done = false;
153
+ request.delete(process.env.REPLIT_DB_URL + "/" + key , function (error, response, body) {
154
+ done = true;
155
+ });
156
+
157
+ deasync.loopWhile(function(){
158
+ return !done;
159
+ });
160
+
161
+ return;
162
+ }
163
+ catch (e) {
164
+ console.log(e);
165
+ return false;
166
+ }
167
+ }
168
+ function Replit_RemoveMultiple(keys) {
169
+ try {
170
+ for (const key of keys) {
171
+ request.delete(process.env.REPLIT_DB_URL + "/" + key , function (error, response, body) {});
172
+ }
173
+ return true;
174
+ }
175
+ catch (e) {
176
+ console.log(e);
177
+ return false;
178
+ }
179
+ }
180
+
181
+ function Replit_List() {
182
+ var done = false;
183
+ var response = null;
184
+
185
+ request(process.env.REPLIT_DB_URL + "?encode=true" + `&prefix=${encodeURIComponent("")}`, function (error, res, body) {
186
+ if (!error && res.statusCode == 200) {
187
+ response = body;
188
+ }
189
+ done = true;
190
+
191
+ });
192
+
193
+ deasync.loopWhile(function(){
194
+ return !done;
195
+ });
196
+
197
+ if (response.length === 0) {
198
+ return [];
199
+ }
200
+ return response.split("\n").map(decodeURIComponent);
201
+ }
202
+
203
+
204
+ var methods = {
205
+ fetch: function(db, params, options) {
206
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
207
+ if (!fetched) return null;
208
+ try {
209
+ fetched = JSON.parse(fetched.json);
210
+ } catch (e) {
211
+ fetched = fetched.json;
212
+ }
213
+ return fetched;
214
+ },
215
+ set: function(db, params, options) {
216
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
217
+ if (!fetched) {
218
+ db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
219
+ fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
220
+ }
221
+ try {
222
+ fetched = JSON.parse(fetched);
223
+ } catch (e) {
224
+ fetched = fetched;
225
+ }
226
+ if (typeof fetched === 'object' && params.ops.target) {
227
+ params.data = JSON.parse(params.data);
228
+ params.data = set(fetched, params.ops.target, params.data);
229
+ }
230
+ else if (params.ops.target) throw new TypeError('Cannot target a non-object.');
231
+ db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(JSON.stringify(params.data), params.id);
232
+ let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
233
+ if (newData === '{}') return null;
234
+ else {
235
+ try { newData = JSON.parse(newData);
236
+ }
237
+ catch (e) {
238
+ newData = newData;
239
+ }
240
+ return newData;
241
+ }
242
+ },
243
+ add: function addDB(db, params, options) {
244
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
245
+ if (!fetched) {
246
+ db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
247
+ fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
248
+ }
249
+ if (params.ops.target) {
250
+ try {
251
+ fetched = JSON.parse(fetched);
252
+ }
253
+ catch (e) {
254
+ fetched = fetched;
255
+ }
256
+ let oldValue = get(fetched, params.ops.target);
257
+ if (oldValue === undefined) oldValue = 0;
258
+ else if (isNaN(oldValue)) throw new Error(`Data @ ID: "${params.id}" IS NOT A number.\nFOUND: ${fetched}\nEXPECTED: number`);
259
+ params.data = set(fetched, params.ops.target, oldValue + JSON.parse(params.data));
260
+ }
261
+ else {
262
+ if (fetched.json === '{}') fetched.json = 0;
263
+ try {
264
+ fetched.json = JSON.parse(fetched);
265
+ } catch (e) {
266
+ fetched.json = fetched.json;
267
+ }
268
+ if (isNaN(fetched.json)) throw new Error(`Data @ ID: "${params.id}" IS NOT A number.\nFOUND: ${fetched.json}\nEXPECTED: number`);
269
+ params.data = parseInt(fetched.json, 10) + parseInt(params.data, 10);
270
+ }
271
+ db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(JSON.stringify(params.data), params.id);
272
+ let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
273
+ if (newData === '{}') return null;
274
+ else {
275
+ try {
276
+ newData = JSON.parse(newData);
277
+ }
278
+ catch (e) {
279
+ newData = newData;
280
+ }
281
+ return newData;
282
+ }
283
+ },
284
+ subtract: function subtractDB(db, params, options) {
285
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
286
+ if (!fetched) {
287
+ db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
288
+ fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
289
+ }
290
+ if (params.ops.target) {
291
+ try { fetched = JSON.parse(fetched); } catch (e) {}
292
+ params.data = JSON.parse(params.data);
293
+ let oldValue = get(fetched, params.ops.target);
294
+ if (oldValue === undefined) oldValue = 0;
295
+ else if (isNaN(oldValue)) throw new Error('Target is not a number.');
296
+ params.data = set(fetched, params.ops.target, oldValue - params.data);
297
+ } else {
298
+ if (fetched.json === '{}') fetched.json = 0;
299
+ else fetched.json = JSON.parse(fetched.json);
300
+ try { fetched.json = JSON.parse(fetched); } catch (e) {}
301
+ if (isNaN(fetched.json)) throw new Error('Target is not a number.');
302
+ params.data = parseInt(fetched.json, 10) - parseInt(params.data, 10);
303
+ }
304
+ params.data = JSON.stringify(params.data);
305
+ db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(params.data, params.id);
306
+ let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
307
+ if (newData === '{}') return null;
308
+ else {
309
+ try { newData = JSON.parse(newData); } catch (e) {}
310
+ return newData;
311
+ }
312
+ },
313
+ push: function pushDB(db, params, options) {
314
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
315
+ if (!fetched) {
316
+ db.prepare(`INSERT INTO ${options.table} (ID,json) VALUES (?,?)`).run(params.id, '{}');
317
+ fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
318
+ }
319
+ if (params.ops.target) {
320
+ fetched = JSON.parse(fetched.json);
321
+ try { fetched = JSON.parse(fetched); } catch (e) {}
322
+ params.data = JSON.parse(params.data);
323
+ if (typeof fetched !== 'object') throw new TypeError('Cannot push into a non-object.');
324
+ let oldArray = get(fetched, params.ops.target);
325
+ if (oldArray === undefined) oldArray = [];
326
+ else if (!Array.isArray(oldArray)) throw new TypeError('Target is not an array.');
327
+ oldArray.push(params.data);
328
+ params.data = set(fetched, params.ops.target, oldArray);
329
+ } else {
330
+ if (fetched.json === '{}') fetched.json = [];
331
+ else fetched.json = JSON.parse(fetched.json);
332
+ try { fetched.json = JSON.parse(fetched.json); } catch (e) {}
333
+ params.data = JSON.parse(params.data);
334
+ if (!Array.isArray(fetched.json)) throw new TypeError('Target is not an array.');
335
+ fetched.json.push(params.data);
336
+ params.data = fetched.json;
337
+ }
338
+ params.data = JSON.stringify(params.data);
339
+ db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(params.data, params.id);
340
+ let newData = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id).json;
341
+ if (newData === '{}') return null;
342
+ else {
343
+ newData = JSON.parse(newData);
344
+ try { newData = JSON.parse(newData); } catch (e) {}
345
+ return newData;
346
+ }
347
+ },
348
+ delete: function deleteDB(db, params, options) {
349
+ const unset = require('lodash/unset');
350
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
351
+ if (!fetched) return false;
352
+ else fetched = JSON.parse(fetched.json);
353
+ try { fetched = JSON.parse(fetched); } catch (e) {}
354
+ if (typeof fetched === 'object' && params.ops.target) {
355
+ unset(fetched, params.ops.target);
356
+ fetched = JSON.stringify(fetched);
357
+ db.prepare(`UPDATE ${options.table} SET json = (?) WHERE ID = (?)`).run(fetched, params.id);
358
+ return true;
359
+ }
360
+ else if (params.ops.target) throw new TypeError('Target is not an object.');
361
+ else db.prepare(`DELETE FROM ${options.table} WHERE ID = (?)`).run(params.id);
362
+ return true;
363
+ },
364
+ has: function hasDB(db, params, options) {
365
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
366
+ if (!fetched) return false;
367
+ else fetched = JSON.parse(fetched.json);
368
+ try { fetched = JSON.parse(fetched); } catch (e) {}
369
+ if (params.ops.target) fetched = get(fetched, params.ops.target);
370
+ return (typeof fetched != 'undefined');
371
+ },
372
+ all: function allDB(db, params, options) {
373
+ var stmt = db.prepare(`SELECT * FROM ${options.table} WHERE ID IS NOT NULL`);
374
+ let resp = [];
375
+ for (var row of stmt.iterate()) {
376
+ try {
377
+ resp.push({
378
+ ID: row.ID,
379
+ data: JSON.parse(row.json)
380
+ });
381
+ }
382
+ catch (e) {
383
+ return [];
384
+ }
385
+ }
386
+ return resp;
387
+ },
388
+ type: function typeDB(db, params, options) {
389
+ let fetched = db.prepare(`SELECT * FROM ${options.table} WHERE ID = (?)`).get(params.id);
390
+ if (!fetched) return null; // If empty, return null
391
+ fetched = JSON.parse(fetched.json);
392
+ try { fetched = JSON.parse(fetched); } catch (e) {}
393
+ if (params.ops.target) fetched = get(fetched, params.ops.target); // Get prop using dot notation
394
+ return typeof fetched;
395
+ },
396
+ clear: function clearDB(db, params, options) {
397
+ let fetched = db.prepare(`DELETE FROM ${options.table}`).run();
398
+ if(!fetched) return null;
399
+ return fetched.changes;
400
+
401
+ }
402
+ };
403
+
404
+
405
+ function arbitrate(method, params) {
406
+ let options = {table: "json"};
407
+ db.prepare(`CREATE TABLE IF NOT EXISTS ${options.table} (ID TEXT, json TEXT)`).run();
408
+ if (params.ops.target && params.ops.target[0] === ".") params.ops.target = params.ops.target.slice(1); // Remove prefix if necessary
409
+ if (params.data && params.data === Infinity) throw new TypeError(`You cannot set Infinity into the database @ ID: ${params.id}`);
410
+ if (params.id && typeof params.id == "string" && params.id.includes(".")) {
411
+ let unparsed = params.id.split(".");
412
+ params.id = unparsed.shift();
413
+ params.ops.target = unparsed.join(".");
414
+ }
415
+ return methods[method](db, params, options);
416
+ }
417
+
418
+
419
+ module.exports = function ChernobyL(Local) {
420
+ if (Local && process.env["REPL_ID"]) {
421
+ return {
422
+ set: Lset,
423
+ get: Lget,
424
+ has: Lhas,
425
+ delete: Lremove,
426
+ deleteMultiple: LremoveMultiple,
427
+ list: Llist
428
+ };
429
+ } else if (!Local && process.env["REPL_ID"]) {
430
+ return {
431
+ set: Replit_Set,
432
+ get: Replit_Get,
433
+ has: Replit_Has,
434
+ delete: Replit_Remove,
435
+ deleteMultiple: Replit_RemoveMultiple,
436
+ list: Replit_List
437
+ };
438
+ }
439
+ else if (Local && !process.env["REPL_ID"]) {
440
+ return {
441
+ set: Lset,
442
+ get: Lget,
443
+ has: Lhas,
444
+ delete: Lremove,
445
+ deleteMultiple: LremoveMultiple,
446
+ list: Llist
447
+ };
448
+ }
449
+ else if (!Local && !process.env["REPL_ID"]) {
450
+ return {
451
+ set: Lset,
452
+ get: Lget,
453
+ has: Lhas,
454
+ delete: Lremove,
455
+ deleteMultiple: LremoveMultiple,
456
+ list: Llist
457
+ };
458
+ }
459
+ else {
460
+ return {
461
+ set: Lset,
462
+ get: Lget,
463
+ has: Lhas,
464
+ delete: Lremove,
465
+ deleteMultiple: LremoveMultiple,
466
+ list: Llist
467
+ };
468
+ }
469
+ };