diff --git a/src/controller/controller.js b/src/controller/controller.js index 252aae4f..c858b395 100644 --- a/src/controller/controller.js +++ b/src/controller/controller.js @@ -307,6 +307,7 @@ Controller.prototype._preLogin = async function() { require("./events/ready.js"); require("./events/statusUpdate.js"); require("./events/steamGuardInput.js"); + require("./events/steamGuardQrCode.js"); require("./helpers/friendlist.js"); require("./helpers/getBots.js"); require("./helpers/handleSteamIdResolving.js"); @@ -451,6 +452,13 @@ Controller.prototype._statusUpdateEvent = function(bot, newStatus) {}; // eslint */ Controller.prototype._steamGuardInputEvent = function(bot, submitCode) {}; // eslint-disable-line +/** + * Emits steamGuardQrCode event for bot & plugins + * @param {Bot} bot Bot instance of the affected account + * @param {string} challengeUrl The QrCode Challenge URL supplied by Steam. Display this value using a QR-Code parser and let a user scan it using their Steam Mobile App. + */ +Controller.prototype._steamGuardQrCodeEvent = function(bot, challengeUrl) {}; // eslint-disable-line + /** * Check if all friends are in lastcomment database * @param {Bot} bot Bot object of the account to check diff --git a/src/controller/events/steamGuardQrCode.js b/src/controller/events/steamGuardQrCode.js new file mode 100644 index 00000000..24d8a501 --- /dev/null +++ b/src/controller/events/steamGuardQrCode.js @@ -0,0 +1,35 @@ +/* + * File: steamGuardQrCode.js + * Project: steam-comment-service-bot + * Created Date: 2024-05-01 14:44:36 + * Author: 3urobeat + * + * Last Modified: 2024-05-01 14:48:33 + * Modified By: 3urobeat + * + * Copyright (c) 2024 3urobeat + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * You should have received a copy of the GNU General Public License along with this program. If not, see . + */ + + +const Bot = require("../../bot/bot.js"); // eslint-disable-line +const Controller = require("../controller"); + + +/** + * Emits steamGuardQrCode event for bot & plugins + * @param {Bot} bot Bot instance of the affected account + * @param {string} challengeUrl The QrCode Challenge URL supplied by Steam. Display this value using a QR-Code parser and let a user scan it using their Steam Mobile App. + */ +Controller.prototype._steamGuardQrCodeEvent = function(bot, challengeUrl) { + + // Log debug message + logger("debug", `Controller steamGuardQrCodeEvent: Emitting event for bot${bot.index} so plugins can display the QR-Code...`); + + // Emit event + this.events.emit("steamGuardQrCode", bot, challengeUrl); + +}; diff --git a/src/data/fileStructure.json b/src/data/fileStructure.json index 62c35022..ca60a531 100644 --- a/src/data/fileStructure.json +++ b/src/data/fileStructure.json @@ -493,7 +493,7 @@ { "path": "src/controller/controller.js", "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/controller.js", - "checksum": "031c4ada6d2ed4e366773d5af1da359b" + "checksum": "fd28817485832dadb454cef17b782c51" }, { "path": "src/controller/events/ready.js", @@ -510,6 +510,11 @@ "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/events/steamGuardInput.js", "checksum": "df33797c6bf867a52adb5d7e39315e73" }, + { + "path": "src/controller/events/steamGuardQrCode.js", + "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/events/steamGuardQrCode.js", + "checksum": "37910bd18328ada639373d8373c664a4" + }, { "path": "src/controller/helpers/friendlist.js", "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/controller/helpers/friendlist.js", @@ -708,12 +713,12 @@ { "path": "src/pluginSystem/loadPlugins.js", "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/pluginSystem/loadPlugins.js", - "checksum": "236e11079a89df528f4e609eb68e784e" + "checksum": "a2889cdf46fa8876a767ab272356b3f9" }, { "path": "src/pluginSystem/pluginSystem.js", "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/pluginSystem/pluginSystem.js", - "checksum": "15f035879c2247ab7372644e21398344" + "checksum": "577b44eae6d3c22fcbf40bde95b99fc1" }, { "path": "src/sessions/events/sessionEvents.js", @@ -723,7 +728,7 @@ { "path": "src/sessions/helpers/handle2FA.js", "url": "https://raw.githubusercontent.com/3urobeat/steam-comment-service-bot/beta-testing/src/sessions/helpers/handle2FA.js", - "checksum": "14641de1b2895cbea783b4264a7bd489" + "checksum": "60163e6e65c01443a28269937ed69261" }, { "path": "src/sessions/helpers/handleCredentialsLoginError.js", diff --git a/src/pluginSystem/loadPlugins.js b/src/pluginSystem/loadPlugins.js index 0e069c2f..2bc71bdc 100644 --- a/src/pluginSystem/loadPlugins.js +++ b/src/pluginSystem/loadPlugins.js @@ -4,7 +4,7 @@ * Created Date: 2023-06-04 15:37:17 * Author: DerDeathraven * - * Last Modified: 2024-03-08 18:19:31 + * Last Modified: 2024-05-01 14:54:49 * Modified By: 3urobeat * * Copyright (c) 2023 - 2024 3urobeat @@ -24,6 +24,7 @@ const PLUGIN_EVENTS = { READY: "ready", STATUS_UPDATE: "statusUpdate", steamGuardInput: "steamGuardInput", + steamGuardQrCode: "steamGuardQrCode" }; diff --git a/src/pluginSystem/pluginSystem.js b/src/pluginSystem/pluginSystem.js index 29a4ed3b..2e7a29df 100644 --- a/src/pluginSystem/pluginSystem.js +++ b/src/pluginSystem/pluginSystem.js @@ -4,7 +4,7 @@ * Created Date: 2023-03-19 13:34:27 * Author: 3urobeat * - * Last Modified: 2024-02-23 14:42:19 + * Last Modified: 2024-05-01 15:19:03 * Modified By: 3urobeat * * Copyright (c) 2023 - 2024 3urobeat @@ -29,6 +29,7 @@ const Bot = require("../bot/bot.js"); // eslint-disab * @property {function(): void} ready Controller ready event * @property {function(Bot, Bot.EStatus, Bot.EStatus): void} statusUpdate Controller statusUpdate event * @property {function(Bot, function(string): void): void} steamGuardInput Controller steamGuardInput event + * @property {function(Bot, string): void} steamGuardQrCode Controller steamGuardQrCode event */ @@ -114,7 +115,7 @@ PluginSystem.prototype.reloadPlugins = function () { /** * Internal: Loads all plugin npm packages and populates pluginList */ -PluginSystem.prototype._loadPlugins = function () {}; +PluginSystem.prototype._loadPlugins = async function () {}; /** * Internal: Checks a plugin, displays relevant warnings and decides whether the plugin is allowed to be loaded diff --git a/src/sessions/helpers/handle2FA.js b/src/sessions/helpers/handle2FA.js index 01bcc16f..a1842acf 100644 --- a/src/sessions/helpers/handle2FA.js +++ b/src/sessions/helpers/handle2FA.js @@ -4,7 +4,7 @@ * Created Date: 2022-10-09 12:59:31 * Author: 3urobeat * - * Last Modified: 2024-02-28 22:28:46 + * Last Modified: 2024-05-01 14:56:23 * Modified By: 3urobeat * * Copyright (c) 2022 - 2024 3urobeat @@ -181,4 +181,7 @@ SessionHandler.prototype._handleQRCode = function(res) { logger.readInput("", 90000, () => {}); }); + // Emit steamGuardQrCode event from our controller so that plugins can handle this event too + this.controller._steamGuardQrCodeEvent(this.bot, res.qrChallengeUrl); + };