From 34fb1df241ed1fce8041f37f272a5ed74f09f49c Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 6 Apr 2023 19:29:25 +0700 Subject: [PATCH] feat: remove nopecha --- src/rest/APIRequest.js | 4 ++++ src/rest/CaptchaSolver.js | 27 --------------------------- src/util/Constants.js | 3 +-- src/util/Options.js | 2 +- typings/index.d.ts | 2 +- 5 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/rest/APIRequest.js b/src/rest/APIRequest.js index ff39678..0a5faf1 100644 --- a/src/rest/APIRequest.js +++ b/src/rest/APIRequest.js @@ -70,6 +70,10 @@ class APIRequest { if (this.options.auth !== false) headers.Authorization = this.rest.getAuth(); if (this.options.reason) headers['X-Audit-Log-Reason'] = encodeURIComponent(this.options.reason); if (this.options.headers) headers = Object.assign(headers, this.options.headers); + // Delete all headers if undefined + for (const [key, value] of Object.entries(headers)) { + if (value === undefined) delete headers[key]; + } if (this.options.webhook === true) { headers = { 'User-Agent': this.client.options.http.headers['User-Agent'], diff --git a/src/rest/CaptchaSolver.js b/src/rest/CaptchaSolver.js index 604dc44..169445e 100644 --- a/src/rest/CaptchaSolver.js +++ b/src/rest/CaptchaSolver.js @@ -91,33 +91,6 @@ module.exports = class CaptchaSolver { }); break; } - case 'nopecha': { - if (!key || typeof key !== 'string') throw new Error('nopecha key is not provided'); - try { - const { Configuration, NopeCHAApi } = require('nopecha'); - this.service = 'nopecha'; - this.key = key; - const configuration = new Configuration({ - apiKey: key, - }); - this.solver = new NopeCHAApi(configuration); - this.solve = (data, userAgent) => - new Promise((resolve, reject) => { - if (data.captcha_rqdata) reject(new Error('nopecha does not support invisible captcha')); - this.solver - .solveToken({ - type: 'hcaptcha', - sitekey: data.captcha_sitekey, - url: 'https://discord.com/channels/@me', - useragent: userAgent, - }) - .then(console.log); - }); - break; - } catch (e) { - throw this._missingModule('nopecha'); - } - } default: { this.solve = this.defaultCaptchaSolver; } diff --git a/src/util/Constants.js b/src/util/Constants.js index 5ae1aaa..183965c 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -18,10 +18,9 @@ exports.MaxBulkDeletableMessageAge = 1_209_600_000; * API captcha solver * * `2captcha` - 2captcha.com * * `capmonster` - capmonster.cloud - * * `nopecha` - nopecha.com * @typedef {string[]} captchaServices */ -exports.captchaServices = ['2captcha', 'capmonster', 'nopecha', 'custom']; +exports.captchaServices = ['2captcha', 'capmonster', 'custom']; /** * Automatically scan and delete direct messages you receive that contain explicit media content. diff --git a/src/util/Options.js b/src/util/Options.js index c627ffc..327bc13 100644 --- a/src/util/Options.js +++ b/src/util/Options.js @@ -201,7 +201,7 @@ class Options extends null { os_version: '10.0.22621', os_arch: 'x64', system_locale: 'en-US', - client_build_number: 99997, // 184787 (stable) but we don't want the captcha to be more difficult to solve + client_build_number: 184787, // 184787 (stable) but we don't want the captcha to be more difficult to solve native_build_number: 30921, client_event_source: null, design_id: 0, diff --git a/typings/index.d.ts b/typings/index.d.ts index ba84486..3075d20 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -5057,7 +5057,7 @@ export interface ClientOptions { usingNewAttachmentAPI?: boolean; } -export type captchaServices = '2captcha' | 'capmonster' | 'nopecha'; +export type captchaServices = '2captcha' | 'capmonster'; // end copy