feat: capmonster
This commit is contained in:
parent
ee906b544e
commit
3d44ff54f7
@ -1033,6 +1033,8 @@ class Client extends BaseClient {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 32 character string');
|
||||
}
|
||||
break;
|
||||
case 'capmonster':
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (typeof options.captchaRetryLimit !== 'number' || isNaN(options.captchaRetryLimit)) {
|
||||
|
@ -46,6 +46,7 @@ class APIRequest {
|
||||
let headers = {
|
||||
...this.client.options.http.headers,
|
||||
Accept: '*/*',
|
||||
origin: 'https://discord.com',
|
||||
'Accept-Language': 'en-US',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
|
@ -1,9 +1,12 @@
|
||||
'use strict';
|
||||
const { setTimeout } = require('node:timers');
|
||||
const axios = require('axios');
|
||||
module.exports = class CaptchaSolver {
|
||||
constructor(service, key, defaultCaptchaSolver) {
|
||||
this.service = 'custom';
|
||||
this.solver = undefined;
|
||||
this.defaultCaptchaSolver = defaultCaptchaSolver;
|
||||
this.key = null;
|
||||
this._setup(service, key);
|
||||
}
|
||||
_missingModule(name) {
|
||||
@ -16,6 +19,7 @@ module.exports = class CaptchaSolver {
|
||||
try {
|
||||
const lib = require('2captcha');
|
||||
this.service = '2captcha';
|
||||
this.key = key;
|
||||
this.solver = new lib.Solver(key);
|
||||
this.solve = (data, userAgent) =>
|
||||
new Promise((resolve, reject) => {
|
||||
@ -38,6 +42,42 @@ module.exports = class CaptchaSolver {
|
||||
throw this._missingModule('2captcha');
|
||||
}
|
||||
}
|
||||
case 'capmonster': {
|
||||
if (!key || typeof key !== 'string') throw new Error('Capmonster key is not provided');
|
||||
this.service = 'capmonster';
|
||||
this.key = key;
|
||||
this.solve = async (captchaData, userAgent) => {
|
||||
// https://github.com/aiko-chan-ai/discord.js-selfbot-v13/issues/548#issuecomment-1452091328
|
||||
try {
|
||||
const createTaskResponse = await axios.post('https://api.capmonster.cloud/createTask', {
|
||||
clientKey: this.key,
|
||||
task: {
|
||||
type: 'HCaptchaTask',
|
||||
websiteURL: 'https://discord.com/channels/@me',
|
||||
websiteKey: captchaData.captcha_sitekey,
|
||||
data: captchaData.captcha_rqdata,
|
||||
isInvisible: !!captchaData.captcha_rqdata,
|
||||
userAgent: userAgent,
|
||||
},
|
||||
});
|
||||
const taskId = createTaskResponse.data.taskId;
|
||||
let getResults = { status: 'processing' };
|
||||
while (getResults.status === 'processing') {
|
||||
const getResultsResponse = await axios.post('https://api.capmonster.cloud/getTaskResult', {
|
||||
clientKey: this.key,
|
||||
taskId,
|
||||
});
|
||||
getResults = getResultsResponse.data;
|
||||
await new Promise(resolve => setTimeout(resolve, 1500).unref());
|
||||
}
|
||||
const solution = getResults.solution.gRecaptchaResponse;
|
||||
return await solution;
|
||||
} catch (e) {
|
||||
throw new Error('Capmonster API error', e);
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
this.solve = this.defaultCaptchaSolver;
|
||||
}
|
||||
|
@ -17,9 +17,10 @@ exports.MaxBulkDeletableMessageAge = 1_209_600_000;
|
||||
/**
|
||||
* API captcha solver
|
||||
* * `2captcha` - 2captcha.com
|
||||
* * `capmonster` - capmonster.cloud
|
||||
* @typedef {string[]} captchaServices
|
||||
*/
|
||||
exports.captchaServices = ['2captcha', 'custom'];
|
||||
exports.captchaServices = ['2captcha', 'capmonster', 'custom'];
|
||||
|
||||
/**
|
||||
* Automatically scan and delete direct messages you receive that contain explicit media content.
|
||||
|
@ -201,7 +201,7 @@ class Options extends null {
|
||||
os_version: '10.0.22621',
|
||||
os_arch: 'x64',
|
||||
system_locale: 'en-US',
|
||||
client_build_number: 177662,
|
||||
client_build_number: 178590,
|
||||
native_build_number: 29584,
|
||||
client_event_source: null,
|
||||
design_id: 0,
|
||||
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@ -5044,7 +5044,7 @@ export interface ClientOptions {
|
||||
usingNewAttachmentAPI?: boolean;
|
||||
}
|
||||
|
||||
export type captchaServices = '2captcha';
|
||||
export type captchaServices = '2captcha' | 'capmonster';
|
||||
|
||||
// end copy
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user