|
|
@@ -195,11 +195,7 @@ async function doDragonBet(drawIssue, planStr, betAmount) {
|
|
|
|
|
|
|
|
|
async function tryReLogin() {
|
|
|
- let captchaRet = await doGenerateCaptcha();
|
|
|
- if (!captchaRet || captchaRet.statusCode != 200) {
|
|
|
- return;
|
|
|
- }
|
|
|
- let recognizeRet = await tryAutoRecognizeCaptcha('ddddocr', captchaRet.result);
|
|
|
+ let recognizeRet = await tryGenerateCaptchaAndRecognize(3);
|
|
|
if (!recognizeRet) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -225,6 +221,24 @@ async function tryReLogin() {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+async function tryGenerateCaptchaAndRecognize(tryCount = 1) {
|
|
|
+ let captchaRet = null;
|
|
|
+ let recognizeRet = null;
|
|
|
+ for(let i = i; i < tryCount; i++) {
|
|
|
+ captchaRet = await doGenerateCaptcha();
|
|
|
+ if (!captchaRet || captchaRet.statusCode != 200) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ recognizeRet = await tryAutoRecognizeCaptcha('ddddocr', captchaRet.result);
|
|
|
+ if (!recognizeRet) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return recognizeRet;
|
|
|
+}
|
|
|
+
|
|
|
async function doLogin(username, password, code, cryptograph) {
|
|
|
const url = `https://${gCaiLeHost}/rest/login`;
|
|
|
let reqData = {
|
|
|
@@ -313,7 +327,10 @@ async function recognizeCaptchaByDdddocr(captchaInfo) {
|
|
|
});
|
|
|
if (result && result.code == 1) {
|
|
|
let targetInfo = result.result.target;
|
|
|
- result.positionX = targetInfo[0];
|
|
|
+ if (Math.abs(targetInfo[1] - positionY) > 4){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ result.positionX = targetInfo[0] + randomFloat(0, 0.5);
|
|
|
result.positionY = positionY;
|
|
|
result.uuid = uuid;
|
|
|
return result;
|
|
|
@@ -321,6 +338,10 @@ async function recognizeCaptchaByDdddocr(captchaInfo) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+function randomFloat(min, max) {
|
|
|
+ return Math.random() * (max - min) + min;
|
|
|
+}
|
|
|
+
|
|
|
function generateRandString(length) {
|
|
|
let result = '';
|
|
|
let characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|