From c69a4b327da9f6151ca89390a8c169d4a13e5c77 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:00:03 +0700 Subject: [PATCH] Update CaptchaSolver.js --- src/rest/CaptchaSolver.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/rest/CaptchaSolver.js b/src/rest/CaptchaSolver.js index eef0538..263833c 100644 --- a/src/rest/CaptchaSolver.js +++ b/src/rest/CaptchaSolver.js @@ -34,18 +34,6 @@ const proxyParser = proxy => { return proxyConfig; }; -function findStringWithRegex(obj, regex) { - const matchingKeys = []; - for (const key in obj) { - if (obj[key] && typeof obj[key] === 'object') { - matchingKeys.push(...findStringWithRegex(obj[key], regex)); - } else if (typeof obj[key] === 'string' && regex.test(obj[key])) { - matchingKeys.push(key); - } - } - return matchingKeys; -} - module.exports = class CaptchaSolver { constructor(service, key, defaultCaptchaSolver, proxyString = '') { this.service = 'custom'; @@ -92,9 +80,11 @@ module.exports = class CaptchaSolver { this.solver .hcaptcha(siteKey, 'discord.com', postD) .then(res => { - let result = findStringWithRegex(res.data, /^P\d_\w+/)[0]; - if (!result) throw new Error('Invalid captcha response'); - resolve(result); + if (typeof res.data == 'string') { + resolve(res.data); + } else { + reject(new Error('Unknown Response')); + } }) .catch(reject); });