feat: bring back nopecha #599
This commit is contained in:
parent
6d8efc6e00
commit
00d6a6a88a
@ -1038,6 +1038,12 @@ class Client extends BaseClient {
|
|||||||
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 32 character string');
|
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 32 character string');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'nopecha': {
|
||||||
|
if (options.captchaKey.length !== 16) {
|
||||||
|
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 16 character string');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof options.captchaRetryLimit !== 'number' || isNaN(options.captchaRetryLimit)) {
|
if (typeof options.captchaRetryLimit !== 'number' || isNaN(options.captchaRetryLimit)) {
|
||||||
|
@ -91,6 +91,33 @@ module.exports = class CaptchaSolver {
|
|||||||
});
|
});
|
||||||
break;
|
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: {
|
default: {
|
||||||
this.solve = this.defaultCaptchaSolver;
|
this.solve = this.defaultCaptchaSolver;
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,10 @@ exports.MaxBulkDeletableMessageAge = 1_209_600_000;
|
|||||||
* API captcha solver
|
* API captcha solver
|
||||||
* * `2captcha` - 2captcha.com
|
* * `2captcha` - 2captcha.com
|
||||||
* * `capmonster` - capmonster.cloud
|
* * `capmonster` - capmonster.cloud
|
||||||
|
* * `nopecha` - nopecha.com
|
||||||
* @typedef {string[]} captchaServices
|
* @typedef {string[]} captchaServices
|
||||||
*/
|
*/
|
||||||
exports.captchaServices = ['2captcha', 'capmonster', 'custom'];
|
exports.captchaServices = ['2captcha', 'capmonster', 'nopecha', 'custom'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Automatically scan and delete direct messages you receive that contain explicit media content.
|
* Automatically scan and delete direct messages you receive that contain explicit media content.
|
||||||
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@ -5057,7 +5057,7 @@ export interface ClientOptions {
|
|||||||
usingNewAttachmentAPI?: boolean;
|
usingNewAttachmentAPI?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type captchaServices = '2captcha' | 'capmonster';
|
export type captchaServices = '2captcha' | 'capmonster' | 'nopecha';
|
||||||
|
|
||||||
// end copy
|
// end copy
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user