From 6f265989ea49beb6ba31b0433c29847e59503c6f Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Sun, 27 Nov 2022 14:08:31 +0700 Subject: [PATCH] fix: captchaKey --- src/client/Client.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index 397acba..ea60974 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -1014,8 +1014,18 @@ class Client extends BaseClient { if (options && options.captchaService && !captchaServices.includes(options.captchaService)) { throw new TypeError('CLIENT_INVALID_OPTION', 'captchaService', captchaServices.join(', ')); } - if (options && captchaServices.includes(options.captchaService) && typeof options.captchaKey !== 'string') { - throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a string'); + // Parse captcha key + if (options && captchaServices.includes(options.captchaService)) { + if (typeof options.captchaKey !== 'string') { + throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a string'); + } + switch (options.captchaService) { + case '2captcha': + if (options.captchaKey.length !== 32) { + throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 32 character string'); + } + break; + } } if (options && typeof options.DMSync !== 'boolean') { throw new TypeError('CLIENT_INVALID_OPTION', 'DMSync', 'a boolean');