Skip to content

Commit

Permalink
feat(PluginSystem): Add steamGuardQrCode event
Browse files Browse the repository at this point in the history
  • Loading branch information
3urobeat committed May 1, 2024
1 parent ae45535 commit fdd1e5d
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
8 changes: 8 additions & 0 deletions src/controller/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions src/controller/events/steamGuardQrCode.js
Original file line number Diff line number Diff line change
@@ -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 <https://github.com/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 <https://www.gnu.org/licenses/>.
*/


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);

};
13 changes: 9 additions & 4 deletions src/data/fileStructure.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/pluginSystem/loadPlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/3urobeat>
Expand All @@ -24,6 +24,7 @@ const PLUGIN_EVENTS = {
READY: "ready",
STATUS_UPDATE: "statusUpdate",
steamGuardInput: "steamGuardInput",
steamGuardQrCode: "steamGuardQrCode"
};


Expand Down
5 changes: 3 additions & 2 deletions src/pluginSystem/pluginSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/3urobeat>
Expand All @@ -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
*/


Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/sessions/helpers/handle2FA.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <https://github.com/3urobeat>
Expand Down Expand Up @@ -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);

};

0 comments on commit fdd1e5d

Please sign in to comment.