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');
|
throw new TypeError('CLIENT_INVALID_OPTION', 'captchaKey', 'a 32 character string');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'capmonster':
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (typeof options.captchaRetryLimit !== 'number' || isNaN(options.captchaRetryLimit)) {
|
if (typeof options.captchaRetryLimit !== 'number' || isNaN(options.captchaRetryLimit)) {
|
||||||
|
@ -46,6 +46,7 @@ class APIRequest {
|
|||||||
let headers = {
|
let headers = {
|
||||||
...this.client.options.http.headers,
|
...this.client.options.http.headers,
|
||||||
Accept: '*/*',
|
Accept: '*/*',
|
||||||
|
origin: 'https://discord.com',
|
||||||
'Accept-Language': 'en-US',
|
'Accept-Language': 'en-US',
|
||||||
'Sec-Fetch-Dest': 'empty',
|
'Sec-Fetch-Dest': 'empty',
|
||||||
'Sec-Fetch-Mode': 'cors',
|
'Sec-Fetch-Mode': 'cors',
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
const { setTimeout } = require('node:timers');
|
||||||
|
const axios = require('axios');
|
||||||
module.exports = class CaptchaSolver {
|
module.exports = class CaptchaSolver {
|
||||||
constructor(service, key, defaultCaptchaSolver) {
|
constructor(service, key, defaultCaptchaSolver) {
|
||||||
this.service = 'custom';
|
this.service = 'custom';
|
||||||
this.solver = undefined;
|
this.solver = undefined;
|
||||||
this.defaultCaptchaSolver = defaultCaptchaSolver;
|
this.defaultCaptchaSolver = defaultCaptchaSolver;
|
||||||
|
this.key = null;
|
||||||
this._setup(service, key);
|
this._setup(service, key);
|
||||||
}
|
}
|
||||||
_missingModule(name) {
|
_missingModule(name) {
|
||||||
@ -16,6 +19,7 @@ module.exports = class CaptchaSolver {
|
|||||||
try {
|
try {
|
||||||
const lib = require('2captcha');
|
const lib = require('2captcha');
|
||||||
this.service = '2captcha';
|
this.service = '2captcha';
|
||||||
|
this.key = key;
|
||||||
this.solver = new lib.Solver(key);
|
this.solver = new lib.Solver(key);
|
||||||
this.solve = (data, userAgent) =>
|
this.solve = (data, userAgent) =>
|
||||||
new Promise((resolve, reject) => {
|
new Promise((resolve, reject) => {
|
||||||
@ -38,6 +42,42 @@ module.exports = class CaptchaSolver {
|
|||||||
throw this._missingModule('2captcha');
|
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: {
|
default: {
|
||||||
this.solve = this.defaultCaptchaSolver;
|
this.solve = this.defaultCaptchaSolver;
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,10 @@ exports.MaxBulkDeletableMessageAge = 1_209_600_000;
|
|||||||
/**
|
/**
|
||||||
* API captcha solver
|
* API captcha solver
|
||||||
* * `2captcha` - 2captcha.com
|
* * `2captcha` - 2captcha.com
|
||||||
|
* * `capmonster` - capmonster.cloud
|
||||||
* @typedef {string[]} captchaServices
|
* @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.
|
* 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_version: '10.0.22621',
|
||||||
os_arch: 'x64',
|
os_arch: 'x64',
|
||||||
system_locale: 'en-US',
|
system_locale: 'en-US',
|
||||||
client_build_number: 177662,
|
client_build_number: 178590,
|
||||||
native_build_number: 29584,
|
native_build_number: 29584,
|
||||||
client_event_source: null,
|
client_event_source: null,
|
||||||
design_id: 0,
|
design_id: 0,
|
||||||
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@ -5044,7 +5044,7 @@ export interface ClientOptions {
|
|||||||
usingNewAttachmentAPI?: boolean;
|
usingNewAttachmentAPI?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type captchaServices = '2captcha';
|
export type captchaServices = '2captcha' | 'capmonster';
|
||||||
|
|
||||||
// end copy
|
// end copy
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user