From fafad59dce7bb74bec29c6c210d04f93fd1c0d41 Mon Sep 17 00:00:00 2001 From: 3urobeat <35304405+HerrEurobeat@users.noreply.github.com> Date: Sun, 9 May 2021 15:08:36 +0200 Subject: [PATCH] Version 2.10.5 (read commit description) Added custom relog function to fix not all accounts relogging after loosing connection (#93). Fixed error when not confirming/declining update on startup whith disabled auto-update. Fixed updater not updating to/from BETA versions when branch was switched from beta-testing to master. Minor other changes. --- README.md | 4 +- package-lock.json | 144 +++++++++++++++++++++---------------------- src/bot.js | 94 +++++++++++++++++++++++++--- src/controller.js | 17 ++--- src/data.json | 6 +- src/defaultlang.json | 1 + src/updater.js | 13 +++- start.js | 2 + 8 files changed, 186 insertions(+), 95 deletions(-) diff --git a/README.md b/README.md index 229918f8..aed4a57d 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Additional information
-![Showcase](https://drive.google.com/uc?export=view&id=1FAzvJBbYys9tGePCD8Gc2VEjg3gHIT7y) +![Showcase](https://drive.google.com/uc?export=view&id=1FAzvJBbYys9tGePCD8Gc2VEjg3gHIT7y) ## **Introduction** @@ -118,6 +118,8 @@ As the **license** already stated: If you want to use code from this repository If you are using this bot as a whole: You are allowed to change bot messages (for translation). You are **not** allowed to remove any credit to myself. #### **Credits** +Thank you [DoctorMcKay](https://github.com/DoctorMcKay) for creating the [steam-user](https://github.com/DoctorMcKay/node-steam-user) and [steamcommunity](https://github.com/DoctorMcKay/node-steamcommunity) libraries! + Special thanks to [KNO7](https://steamcommunity.com/id/KN07Gaming/) for testing early beta versions, providing many ideas behind this project and donating 5€! I also want to thank [Stiefel](https://steamcommunity.com/id/Stiefel1234) for finding weird bugs I wouldn't have found alone, being a cool dude and for hosting the bot with 9 unlimited accounts. Another thank you goes out to [effex1337](https://github.com/effex1337) for donating $5 via bitcoin, helping in issues and for supporting the project! diff --git a/package-lock.json b/package-lock.json index 3ca15e2d..2e19eecf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -111,9 +111,9 @@ "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" }, "node_modules/@types/node": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.1.tgz", - "integrity": "sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==" + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz", + "integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==" }, "node_modules/accepts": { "version": "1.3.7", @@ -1012,19 +1012,19 @@ } }, "node_modules/is-bigint": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.1.tgz", - "integrity": "sha512-J0ELF4yHFxHy0cmSxZuheDOz2luOdVvqjwmEcj8H/L1JHeuEDSDbeRP+Dk9kFVk5RTFzbucJ2Kb9F7ixY2QaCg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.2.tgz", + "integrity": "sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA==", "funding": { "url": "https://github.com/sponsors/ljharb" } }, "node_modules/is-boolean-object": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.0.tgz", - "integrity": "sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.1.tgz", + "integrity": "sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng==", "dependencies": { - "call-bind": "^1.0.0" + "call-bind": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -1045,9 +1045,9 @@ } }, "node_modules/is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.4.tgz", + "integrity": "sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A==", "engines": { "node": ">= 0.4" }, @@ -1056,9 +1056,9 @@ } }, "node_modules/is-generator-function": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.8.tgz", - "integrity": "sha512-2Omr/twNtufVZFr1GhxjOMFPAj2sjc/dKaIqBhvo4qciXfJmITGH6ZGd8eZYNHza8t1y0e01AuqRhJwfWp26WQ==", + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.9.tgz", + "integrity": "sha512-ZJ34p1uvIfptHCN7sFTjGibB9/oBg17sHqzDLfuwhvmN/qLVvIQXRQ8licZQ35WJ8KuEQt/etnnzQFI9C9Ue/A==", "engines": { "node": ">= 0.4" }, @@ -1078,9 +1078,9 @@ } }, "node_modules/is-number-object": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", - "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==", + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.5.tgz", + "integrity": "sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw==", "engines": { "node": ">= 0.4" }, @@ -1089,12 +1089,12 @@ } }, "node_modules/is-regex": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz", - "integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.3.tgz", + "integrity": "sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==", "dependencies": { "call-bind": "^1.0.2", - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -1104,9 +1104,9 @@ } }, "node_modules/is-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", - "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.6.tgz", + "integrity": "sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w==", "engines": { "node": ">= 0.4" }, @@ -1115,11 +1115,11 @@ } }, "node_modules/is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", "dependencies": { - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.2" }, "engines": { "node": ">= 0.4" @@ -1404,9 +1404,9 @@ } }, "node_modules/object-inspect": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.2.tgz", - "integrity": "sha512-gz58rdPpadwztRrPjZE9DZLOABUpTGdcANUgOwBFO1C+HZZhePoP83M65WGDmbpwFYJSWqavbl4SgDn4k8RYTA==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", + "integrity": "sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==", "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -1739,9 +1739,9 @@ } }, "node_modules/steam-user": { - "version": "4.19.4", - "resolved": "https://registry.npmjs.org/steam-user/-/steam-user-4.19.4.tgz", - "integrity": "sha512-mqWuymix+Uzru8Um1lq1nq0TMRMGZJT9wAX/0Q1YgcQ7W/t36E6mSCrydbsIGl0cUkUNo98RhcL/SirnEN77bg==", + "version": "4.19.5", + "resolved": "https://registry.npmjs.org/steam-user/-/steam-user-4.19.5.tgz", + "integrity": "sha512-yrfrjM5IcPUG2AZw2jLoUtM/Hv/sadHosaernSAply0F8F1jhj0H+IBDrAMRFuOb8hhvQur+BOdRc7xVkFZI6g==", "dependencies": { "@bbob/parser": "^2.2.0", "@doctormckay/stdlib": "^1.11.1", @@ -2169,9 +2169,9 @@ "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" }, "@types/node": { - "version": "15.0.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.1.tgz", - "integrity": "sha512-TMkXt0Ck1y0KKsGr9gJtWGjttxlZnnvDtphxUOSd0bfaR6Q1jle+sPvrzNR1urqYTWMinoKvjKfXUGsumaO1PA==" + "version": "15.0.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-15.0.2.tgz", + "integrity": "sha512-p68+a+KoxpoB47015IeYZYRrdqMUcpbK8re/zpFB8Ld46LHC1lPEbp3EXgkEhAYEcPvjJF6ZO+869SQ0aH1dcA==" }, "accepts": { "version": "1.3.7", @@ -2889,16 +2889,16 @@ } }, "is-bigint": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.1.tgz", - "integrity": "sha512-J0ELF4yHFxHy0cmSxZuheDOz2luOdVvqjwmEcj8H/L1JHeuEDSDbeRP+Dk9kFVk5RTFzbucJ2Kb9F7ixY2QaCg==" + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.2.tgz", + "integrity": "sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA==" }, "is-boolean-object": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.0.tgz", - "integrity": "sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.1.tgz", + "integrity": "sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng==", "requires": { - "call-bind": "^1.0.0" + "call-bind": "^1.0.2" } }, "is-callable": { @@ -2907,14 +2907,14 @@ "integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==" }, "is-date-object": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.2.tgz", - "integrity": "sha512-USlDT524woQ08aoZFzh3/Z6ch9Y/EWXEHQ/AaRN0SkKq4t2Jw2R2339tSXmwuVoY7LLlBCbOIlx2myP/L5zk0g==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.4.tgz", + "integrity": "sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A==" }, "is-generator-function": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.8.tgz", - "integrity": "sha512-2Omr/twNtufVZFr1GhxjOMFPAj2sjc/dKaIqBhvo4qciXfJmITGH6ZGd8eZYNHza8t1y0e01AuqRhJwfWp26WQ==" + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.9.tgz", + "integrity": "sha512-ZJ34p1uvIfptHCN7sFTjGibB9/oBg17sHqzDLfuwhvmN/qLVvIQXRQ8licZQ35WJ8KuEQt/etnnzQFI9C9Ue/A==" }, "is-negative-zero": { "version": "2.0.1", @@ -2922,30 +2922,30 @@ "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==" }, "is-number-object": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", - "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.5.tgz", + "integrity": "sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw==" }, "is-regex": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.2.tgz", - "integrity": "sha512-axvdhb5pdhEVThqJzYXwMlVuZwC+FF2DpcOhTS+y/8jVq4trxyPgfcwIxIKiyeuLlSQYKkmUaPQJ8ZE4yNKXDg==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.3.tgz", + "integrity": "sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==", "requires": { "call-bind": "^1.0.2", - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.2" } }, "is-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", - "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==" + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.6.tgz", + "integrity": "sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w==" }, "is-symbol": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", - "integrity": "sha512-OwijhaRSgqvhm/0ZdAcXNZt9lYdKFpcRDT5ULUuYXPoT794UNOdU+gpT6Rzo7b4V2HUl/op6GqY894AZwv9faQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", "requires": { - "has-symbols": "^1.0.1" + "has-symbols": "^1.0.2" } }, "is-typed-array": { @@ -3179,9 +3179,9 @@ "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==" }, "object-inspect": { - "version": "1.10.2", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.2.tgz", - "integrity": "sha512-gz58rdPpadwztRrPjZE9DZLOABUpTGdcANUgOwBFO1C+HZZhePoP83M65WGDmbpwFYJSWqavbl4SgDn4k8RYTA==" + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", + "integrity": "sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==" }, "object-keys": { "version": "1.1.1", @@ -3446,9 +3446,9 @@ "integrity": "sha512-d+tjnr3wwDkbrKFxjYZ0uK4CSF09oJwCmlGH8SdOlTDkbtBPuNhPKY0XzZxQVltZF6/JkEYj+uz+kBr6UrY7BQ==" }, "steam-user": { - "version": "4.19.4", - "resolved": "https://registry.npmjs.org/steam-user/-/steam-user-4.19.4.tgz", - "integrity": "sha512-mqWuymix+Uzru8Um1lq1nq0TMRMGZJT9wAX/0Q1YgcQ7W/t36E6mSCrydbsIGl0cUkUNo98RhcL/SirnEN77bg==", + "version": "4.19.5", + "resolved": "https://registry.npmjs.org/steam-user/-/steam-user-4.19.5.tgz", + "integrity": "sha512-yrfrjM5IcPUG2AZw2jLoUtM/Hv/sadHosaernSAply0F8F1jhj0H+IBDrAMRFuOb8hhvQur+BOdRc7xVkFZI6g==", "requires": { "@bbob/parser": "^2.2.0", "@doctormckay/stdlib": "^1.11.1", diff --git a/src/bot.js b/src/bot.js index 905a7844..91237c63 100644 --- a/src/bot.js +++ b/src/bot.js @@ -17,6 +17,9 @@ module.exports.run = async (logOnOptions, loginindex) => { var extdata = require('./data.json'); var cachefile = require('./cache.json'); + var enabledebugmode = false; //if enabled debug and debug-verbose events from the steam-user library will be logged (will absolutely spam your output.txt file!) + var disablecommentcmd = false; //disables the comment and resetcooldown command and responds with maintenance message + var commandcooldown = 12000 //The bot won't respond if a user sends more than 5 messages in this time frame var maxLogOnRetries = 1 //How often a failed logOn will be retried var lastWebSessionRefresh = Date.now(); //Track when the last refresh was to avoid spamming webLogOn() on sessionExpired @@ -37,9 +40,19 @@ module.exports.run = async (logOnOptions, loginindex) => { var thisproxy = controller.proxies[controller.proxyShift] controller.proxyShift++ //switch to next proxy - const bot = new SteamUser({ httpProxy: thisproxy }); + const bot = new SteamUser({ autoRelogin: false, httpProxy: thisproxy }); const community = new SteamCommunity(); + if (enabledebugmode) { + bot.on("debug", (msg) => { + logger("debug: " + msg, false, true) + }) + + bot.on("debug-verbose", (msg) => { + logger("debug-verbose: " + msg, false, true) + }) + } + //Make chat message method shorter function chatmsg(steamID, txt) { bot.chat.sendFriendMessage(steamID, txt) } @@ -153,6 +166,26 @@ module.exports.run = async (logOnOptions, loginindex) => { } }, 250) } + + function relogAccount() { //Function to regulate automatic relogging and delay it to + if (!controller.relogQueue.includes(loginindex)) controller.relogQueue.push(loginindex) + logger(`[${thisbot}] Queueing for a relog. ${controller.relogQueue.length - 1} other accounts are waiting...`, false, true) + + var relogInterval = setInterval(() => { + if (controller.relogQueue.indexOf(loginindex) != 0) return; //not our turn? stop and retry in the next iteration + + clearInterval(relogInterval) //prevent any retries + bot.logOff() + + logger(`[${thisbot}] It is now my turn. Waiting ${controller.relogdelay / 1000} seconds before attempting to relog...`, false, true) + setTimeout(() => { + if (thisproxy == null) logger(`[${thisbot}] Trying to relog without proxy...`, false, true) + else logger(`[${thisbot}] Trying to relog with proxy ${controller.proxyShift - 1}...`, false, true) + + bot.logOn(logOnOptions) + }, controller.relogdelay); + }, 1000); + } logOnAccount(); @@ -162,9 +195,24 @@ module.exports.run = async (logOnOptions, loginindex) => { if (loginindex == 0) { logger(`\x1b[31mAccount is bot0. Aborting...\x1b[0m`, true); process.exit(0) } return; } + + if (err.eresult == 3) { //NoConnection will be thrown here when autoRelogin is false instead of the disconnected event + if (!controller.relogQueue.includes(loginindex)) logger(`\x1b[31m[${thisbot}] Lost connection to Steam. Reason: NoConnection\x1b[0m`) + + if (!controller.relogQueue.includes(loginindex) && !controller.skippednow.includes(loginindex) && controller.relogAfterDisconnect) { //bot.logOff() also calls this event with NoConnection. To ensure the relog function doesn't call itself again here we better check if the account is already being relogged + logger(`[${thisbot}] Initiating a relog in 30 seconds.`, false, true) //Announce relog + setTimeout(() => { + relogAccount() + }, 30000); + } + + return; + } + + //Actual error handling: let blockedEnumsForRetries = [5, 12, 13, 17, 18] //Enums: https://github.com/DoctorMcKay/node-steam-user/blob/master/enums/EResult.js - if (logOnTries > maxLogOnRetries || blockedEnumsForRetries.includes(err.eresult)) { + if ((logOnTries > maxLogOnRetries || blockedEnumsForRetries.includes(err.eresult)) && !controller.relogQueue.includes(loginindex)) { logger(`\nCouldn't log in bot${loginindex} after ${logOnTries} attempt(s). Error ${err.eresult}: ${err}`, true) if (err.eresult == 5) logger(`Note: The error "InvalidPassword" (${err.eresult}) can also be caused by a wrong Username or shared_secret!\n Try leaving the shared_secret field empty and check the username & password of bot${loginindex}.`, true) if (thisproxy != null) logger(`Is your proxy ${controller.proxyShift} offline or blocked by Steam?`, true) @@ -179,10 +227,12 @@ module.exports.run = async (logOnOptions, loginindex) => { controller.skippednow.push(loginindex) } } else { - //Got retries left... + //Got retries left or it is a relog... logger(`Error ${err.eresult} while trying to log in bot${loginindex}. Retrying in 5 seconds...`) setTimeout(() => { - logOnAccount(); + //Call either relogAccount or logOnAccount function to continue where we started at + if (controller.relogQueue.includes(loginindex)) relogAccount(); + else logOnAccount(); }, 5000) } }) @@ -214,11 +264,11 @@ module.exports.run = async (logOnOptions, loginindex) => { }, 500); } else { logger(`[${thisbot}] steamGuard input empty, skipping account...`, false, true) - bot.logOff() //Seems to prevent the steamGuard lastCodeWrong check from requesting again every few seconds - controller.accisloggedin = true; //set to true to log next account in updater.skippedaccounts.push(loginindex) controller.skippednow.push(loginindex) + + bot.logOff() //Seems to prevent the steamGuard lastCodeWrong check from requesting again every few seconds } } else { //code provided @@ -234,11 +284,11 @@ module.exports.run = async (logOnOptions, loginindex) => { if (config.skipSteamGuard) { if (loginindex > 0) { logger(`[${thisbot}] Skipping account because skipSteamGuard is enabled...`, false, true) - bot.logOff() //Seems to prevent the steamGuard lastCodeWrong check from requesting again every few seconds - controller.accisloggedin = true; //set to true to log next account in updater.skippedaccounts.push(loginindex) controller.skippednow.push(loginindex) + + bot.logOff() //Seems to prevent the steamGuard lastCodeWrong check from requesting again every few seconds return; } else { logger("Even with skipSteamGuard enabled, the first account always has to be logged in.", true) @@ -283,10 +333,11 @@ module.exports.run = async (logOnOptions, loginindex) => { } + //If the loginindex is already included then this is a restart controller.communityobject[loginindex] = community //export this community instance to the communityobject to access it from controller.js controller.botobject[loginindex] = bot //export this bot instance to the botobject to access it from controller.js - if (loginindex == 0) { + if (loginindex == 0 && !Object.keys(controller.botobject[0]).includes(commentcmd)) { Object.keys(controller.botobject[0]).push(commentcmd) controller.botobject[0].commentcmd = commentcmd } @@ -300,6 +351,13 @@ module.exports.run = async (logOnOptions, loginindex) => { //Accept offline group & friend invites logger(`[${thisbot}] Got websession and set cookies.`, false, true) + + //If this is a relog then remove this account from the queue and let the next account be able to relog + if (controller.relogQueue.includes(loginindex)) { + logger(`[${thisbot}] Relog successful.`) + controller.relogQueue = controller.relogQueue.slice(1) //remove first element from the queue + } + logger(`[${thisbot}] Accepting offline friend & group invites...`, false, true) //Friends: @@ -413,6 +471,7 @@ module.exports.run = async (logOnOptions, loginindex) => { if (loginindex === 0) { //check if this is the main bot //Check if bot is not fully started yet and block cmd usage if that is the case to prevent errors if (controller.readyafter == 0) return chatmsg(steamID, lang.botnotready) + if (controller.relogQueue.length > 0) return chatmsg(steamID, lang.botnotready) var lastcommentsteamID = steam64id var notownerresponse = (() => { return chatmsg(steamID, lang.commandowneronly) }) @@ -483,6 +542,8 @@ module.exports.run = async (logOnOptions, loginindex) => { break; case '!comment': + if (disablecommentcmd) return chatmsg(steamID, lang.botmaintenance) + commentcmd(steamID, args) //Just call the function like normal when the command was used break; @@ -552,6 +613,8 @@ module.exports.run = async (logOnOptions, loginindex) => { case '!rc': case '!resetcooldown': if (!ownercheck) return notownerresponse(); + if (disablecommentcmd) return chatmsg(steamID, lang.botmaintenance) + if (config.commentcooldown === 0) return chatmsg(steamID, lang.resetcooldowncmdcooldowndisabled) //is the cooldown enabled? if (args[0]) { @@ -931,7 +994,18 @@ module.exports.run = async (logOnOptions, loginindex) => { //Display message when connection was lost to Steam bot.on("disconnected", (eresult, msg) => { - logger(`\x1b[31m[${thisbot}] Lost connection to Steam. Bot should relog automatically. Message: ${msg} | Check: https://steamstat.us\x1b[0m`) + if (controller.relogQueue.includes(loginindex)) return; //disconnect is already handled + + logger(`\x1b[31m[${thisbot}] Lost connection to Steam. Bot should relog automatically. Message: ${msg} | Check: https://steamstat.us\x1b[0m`) + + if (!controller.skippednow.includes(loginindex) && controller.relogAfterDisconnect) { //bot.logOff() also calls this event with NoConnection. To ensure the relog function doesn't call itself again here we better check if the account is already being relogged + logger(`[${thisbot}] Initiating a relog in 30 seconds.`, false, true) //Announce relog + setTimeout(() => { + relogAccount() + }, 30000); + } else { + logger(`[${thisbot}] I won't queue myself for a relog because this account is either already being relogged, was skipped or this is an intended logOff.`, false, true) + } }) //Get new websession as sometimes the bot would relog after a lost connection but wouldn't get a websession. Read more about cookies & expiration: https://dev.doctormckay.com/topic/365-cookies/ diff --git a/src/controller.js b/src/controller.js index 398361a7..982f210e 100644 --- a/src/controller.js +++ b/src/controller.js @@ -7,11 +7,6 @@ const fs = require('fs'); const https = require('https') const readline = require("readline") -if (!fs.existsSync('./node_modules/steam-user') || !fs.existsSync('./node_modules/steamcommunity')) { //Quickly check if user forgot to run npm install and display custom error message - console.log(`\n\n\x1b[31mIt seems like you haven't installed the needed npm packages yet.\nPlease run the following command in this terminal once: "npm install"\nAborting...\x1b[0m\n`) - process.exit(0) -} - const SteamID = require('steamid'); const SteamTotp = require('steam-totp'); const xml2js = require('xml2js') @@ -31,7 +26,11 @@ var bootstart = 0 var bootstart = new Date(); var steamGuardInputTime = 0 var readyafter = 0 -var logindelay = 2500 +var logindelay = 2500 //time to wait between logins +var relogdelay = 10000 //time to wait between relog attempts (for example after loosing connection to Steam) +var relogQueue = [] +var relogAfterDisconnect = true; //allows to prevent accounts from relogging when calling bot.logOff() +var lastRelogTime = 0; var proxyShift = 0 var skippednow = [] //array to track which accounts have been skipped var stoplogin = false; @@ -328,6 +327,10 @@ module.exports={ steamGuardInputTimeFunc, steamGuardInputTime, readyafter, + relogdelay, + relogQueue, + relogAfterDisconnect, + lastRelogTime, logger, communityobject, botobject, @@ -343,7 +346,7 @@ module.exports={ proxies, proxyShift, logininfo, - lang + lang } diff --git a/src/data.json b/src/data.json index ad18f1e4..ef12fcfe 100644 --- a/src/data.json +++ b/src/data.json @@ -1,6 +1,6 @@ { - "version": "2104", - "versionstr": "2.10.4", + "version": "2105", + "versionstr": "2.10.5", "branch": "master", "filetostart": "./src/updater.js", "filetostarturl": "https://raw.githubusercontent.com/HerrEurobeat/steam-comment-service-bot/master/src/updater.js", @@ -9,7 +9,7 @@ "aboutstr": "This bot was created by 3urobeat.\nGitHub: https://github.com/HerrEurobeat/steam-comment-service-bot \nSteam: https://steamcommunity.com/id/3urobeat \nIf you like my work, any donation would be appreciated! https://paypal.me/3urobeat", "firststart": true, "compatibilityfeaturedone": false, - "whatsnew": "Replaced repeatedComments with maxComments in config. Added potential fix for no websession after reconnect. Fixed limited & not friend check not using randomizeAccounts order. Fixed comment cmd not refreshing config changes. Other changes listed on GitHub.", + "whatsnew": "Fixed not all accounts relogging after disconnect. Fixed error when not confirming/declining update on startup whith disabled auto-update. Fixed bot not updating from BETA version when branch is master. Minor other changes.", "urlrequestsecretkey": "", "timesloggedin": 0, "totallogintime": 0 diff --git a/src/defaultlang.json b/src/defaultlang.json index fc8f0a57..fe23dde1 100644 --- a/src/defaultlang.json +++ b/src/defaultlang.json @@ -30,6 +30,7 @@ "userspamblock": "/me You have been blocked for 60 seconds for spamming.", "usernotfriend": "/me Please add me before using a command!", "botnotready": "/me The bot is not completely started yet. Please wait a moment before using a command.", + "botmaintenance": "/me The comment command is currently unavailable for maintenance. Please wait a bit.", "commandowneronly": "This command is only available for the botowner.\nIf you are the botowner, make sure you added your ownerid to the config.json.", "invalidprofileid": "This is not a valid profileid! A profile id must look like this: 76561198260031749", diff --git a/src/updater.js b/src/updater.js index d26df09c..e8fbf381 100644 --- a/src/updater.js +++ b/src/updater.js @@ -6,6 +6,13 @@ const fs = require('fs') const https = require("https") const readline = require("readline") + +//Quickly check if user forgot to run npm install and display custom error message +if (!fs.existsSync('./node_modules/steam-user') || !fs.existsSync('./node_modules/steamcommunity')) { + console.log(`\n\n\x1b[31mIt seems like you haven't installed the needed npm packages yet.\nPlease run the following command in this terminal once: 'npm install'\nAborting...\x1b[0m\n`) + process.exit(0) +} + var oldconfig = {} //obj that can get populated by restart data to keep config through restarts var skippedaccounts = [] //array to save which accounts have been skipped to skip them automatically when restarting var botisloggedin = false @@ -143,7 +150,7 @@ var checkforupdate = (forceupdate, responseSteamID, compatibilityfeaturedone) => module.exports.onlinemestr = JSON.parse(chunk).mestr //get mestr and aboutstr from GitHub to check for modification module.exports.onlineaboutstr = JSON.parse(chunk).aboutstr - if (onlineversion > Number(extdata.version) || forceupdate == true || releasemode == "beta-testing" && !onlineversionstr.includes("BETA") && extdata.versionstr.includes("BETA") || releasemode == "beta-testing" && onlineversionstr.includes("BETA") && !extdata.versionstr.includes("BETA")) { //version number greater or forceupdate is true? + if (onlineversion > Number(extdata.version) || forceupdate == true || !onlineversionstr.includes("BETA") && extdata.versionstr.includes("BETA") || onlineversionstr.includes("BETA") && !extdata.versionstr.includes("BETA")) { //version number greater, forceupdate is true, release or beta version available? logger("", true) logger(`\x1b[32mUpdate available!\x1b[0m Your version: \x1b[31m${extdata.versionstr}\x1b[0m | New version: \x1b[32m${onlineversionstr}\x1b[0m`, true) logger("", true) @@ -172,7 +179,7 @@ var checkforupdate = (forceupdate, responseSteamID, compatibilityfeaturedone) => let noresponsetimeout = setTimeout(() => { //skip update after 7.5 sec if the user doesn't respond updatestdin.pause() - process.stdout.write("\x1b[31mX\n\x1b[93mStarting the bot since you haven't replied in 7.5 seconds...\x1b[0m\n\n", true) + process.stdout.write("\x1b[31mX\n\x1b[93mStarting the bot since you haven't replied in 7.5 seconds...\x1b[0m\n\n") require('./controller.js') botisloggedin = true @@ -209,6 +216,8 @@ var checkforupdate = (forceupdate, responseSteamID, compatibilityfeaturedone) => if (bot.activecommentprocess.length == 0) { //start logging off accounts when no comment request is being processed anymore logger("Active comment process finished. Starting to update...", true) + controller.relogAfterDisconnect = false; //Prevents disconnect event (which will be called by logOff) to relog accounts + Object.keys(controller.botobject).forEach((e) => { logger(`Logging off bot${e}...`, false, true) controller.botobject[e].logOff() //logging off each account diff --git a/start.js b/start.js index 83a2f460..dd9fddab 100644 --- a/start.js +++ b/start.js @@ -27,6 +27,8 @@ var restart = (args, nologOff) => { //Restart the application controller.server.close() } + controller.relogAfterDisconnect = false; //Prevents disconnect event (which will be called by logOff) to relog accounts + Object.keys(controller.botobject).forEach((e) => { //log out all bots controller.botobject[e].logOff() })