feat: new captcha solver service
This commit is contained in:
@@ -1025,6 +1025,9 @@ class Client extends BaseClient {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 32 character string');
|
||||
}
|
||||
break;
|
||||
case 'nopecha': {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (options && typeof options.DMSync !== 'boolean') {
|
||||
|
@@ -5,6 +5,9 @@ module.exports = class CaptchaSolver {
|
||||
this.solver = undefined;
|
||||
this._setup(service, key);
|
||||
}
|
||||
_missingModule(name) {
|
||||
return new Error(`${name} module not found, please install it with \`npm i ${name}\``);
|
||||
}
|
||||
_setup(service, key) {
|
||||
switch (service) {
|
||||
case '2captcha': {
|
||||
@@ -24,7 +27,34 @@ module.exports = class CaptchaSolver {
|
||||
});
|
||||
break;
|
||||
} catch (e) {
|
||||
throw new Error('2captcha module not found, please install it with `npm i 2captcha`');
|
||||
throw this._missingModule('2captcha');
|
||||
}
|
||||
}
|
||||
case 'nopecha': {
|
||||
if (!key || typeof key !== 'string') throw new Error('2captcha key is not provided');
|
||||
try {
|
||||
const { Configuration, NopeCHAApi } = require('nopecha');
|
||||
const configuration = new Configuration({
|
||||
apiKey: key,
|
||||
});
|
||||
this.service = 'nopecha';
|
||||
this.solver = new NopeCHAApi(configuration);
|
||||
this.solve = siteKey =>
|
||||
new Promise((resolve, reject) => {
|
||||
this.solver
|
||||
.solveToken({
|
||||
type: 'hcaptcha',
|
||||
sitekey: siteKey,
|
||||
url: 'https://discord.com',
|
||||
})
|
||||
.then(res => {
|
||||
resolve(res);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
break;
|
||||
} catch (e) {
|
||||
throw this._missingModule('nopecha');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -39,9 +39,10 @@ exports.MaxBulkDeletableMessageAge = 1_209_600_000;
|
||||
/**
|
||||
* API captcha solver
|
||||
* * `2captcha` - 2captcha.com
|
||||
* * `nopecha` - nopecha.com
|
||||
* @typedef {string[]} captchaServices
|
||||
*/
|
||||
exports.captchaServices = ['2captcha'];
|
||||
exports.captchaServices = ['2captcha', 'nopecha'];
|
||||
|
||||
/**
|
||||
* Automatically scan and delete direct messages you receive that contain explicit media content.
|
||||
|
Reference in New Issue
Block a user