12 Commits

Author SHA1 Message Date
panleicim 703ca3d694 change include mode 2024-12-04 10:59:45 +01:00
panleicim 7cc4f87e0b stop when need to refresh captcha 2024-11-15 22:20:03 +01:00
panleicim 5a2b88139e add appointment mode 2024-11-12 00:22:51 +01:00
panleicim 6ce3a56ce2 support Mi note 10 2024-11-06 14:06:37 +01:00
panleicim f3a7188b31 Merge branch 'master' of bitbucket.org:panleicim/puppeteerjs 2024-10-11 09:33:06 +02:00
panleicim 24f95842ba add shuffle before booking 2024-10-11 09:32:22 +02:00
panleicim 9657007a5b Merge branch 'feature/list_according_serail' 2024-10-05 16:49:15 +02:00
panleicim 9d70bf7097 do not need to bind contact list with mobiles 2024-10-05 16:48:25 +02:00
Lei PAN 9cfa650b31 correction for moto 2024-10-05 08:35:18 +02:00
Lei PAN 87eca37d8b Merge branch 'feature/custom_adb' into feature/list_according_serail 2024-10-01 23:29:00 +02:00
Lei PAN a04ec8373d support moto 2024-10-01 23:28:09 +02:00
panleicim 842f87c784 bind contact list with phone serial 2024-10-01 22:58:32 +02:00
6 changed files with 53 additions and 34 deletions
+39 -22
View File
@@ -8,18 +8,18 @@ const {Sender} = require("./queue/Sender");
const {devices} = require("./android/adb");
const mongoManager = new MongoManager();
const SEVEN_DAYS_IN_S = 3600 * 24 * 7;
// const NINETY_DAYS_IN_S = 3600 * 24 * 30 * 3;
const NINETY_DAYS_IN_S = 30 * 3;
let excelUtil = new ExcelUtil();
let collectionName = formatDate(new Date())
let excludeMode = DeviceExcludeMode.ZERO
let includeMode = DeviceExcludeMode.ZERO
// let includeMode = DeviceExcludeMode.APPOINTMENT
let three_to_excludes = []
let four_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
let three_to_include = []
let four_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518"]
let seven_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "fuljaueqguugf6pn", "EPHUT20825001518"]
let six_to_excludes = ["4e8ca027", "hi7ljr5xduyt9pfi", "EPHUT20825001518", "bec11752", "07fbd156", "NFD669QK8XNFSCNN", "6X494TTWQGFALB79", "71a0371d", "YP6HVKLFE67T598L"]
let nine_to_excludes = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
let for_scrpay = ["07fbd156", "47e7e36b", "4f55c3d4", "5ac879a2", "69db59f0", "71a0371d", "774687ff", "7b71fb20", "8f76f9e7", "99cyfiaebqcy6poj", "EPHUT20825001518", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "ai9xv8hy599hvkee", "b41c1b72", "bec11752", "becb6e99", "c3ba032e", "d54e946", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "fy65eqs4wkvcpf9h", "hi7ljr5xduyt9pfi", "njzxojhim7gedyvw", "p7d6nbw8cu7duous"]
// let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fuljaueqguugf6pn", "fmiz5pa6rsx4u4ts"]
let appointment_to_include = ["ai9xv8hy599hvkee", "07fbd156", "71a0371d", "J4AXB761H2322WJ", "W8GMFELRHIKZS84T", "fy65eqs4wkvcpf9h", "p7d6nbw8cu7duous", "fmiz5pa6rsx4u4ts"]
let nine_to_include = ["bec11752", "4e8ca027", "hi7ljr5xduyt9pfi", "47e7e36b", "p7d6nbw8cu7duous", "njzxojhim7gedyvw", "fmiz5pa6rsx4u4ts", "fuljaueqguugf6pn", "EPHUT20825001518"]
attributedPorts = []
const device_port_info = new Map();
startPort = 9000
@@ -118,9 +118,17 @@ function shuffle(array) {
return array;
}
function getContactListForDevice(device, allContactList) {
let contactList = [];
allContactList.forEach((contact) => {
if (contact.serial === device.serial) {
contactList.push(contact)
}
})
return contactList;
}
async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathToExcelFile = '/Users/lpan/Desktop/contact_all.xlsx', audioAnalyse = true, alertBeep = false) {
console.log("startBookWithNumbers() called, with alertBeep:" + alertBeep)
console.log("startBookWithNumbers() called, with audioAnalyse:" + audioAnalyse)
let allContactList = excelUtil.readContacts(pathToExcelFile);
let contactList;
if (endNumber <= allContactList.length) {
@@ -170,28 +178,37 @@ async function startBookWithNumbers(startNumber, endNumber, selectedStore, pathT
alert("未找到连接的设备");
return
}
let device_to_excludes = three_to_excludes;
if (excludeMode === DeviceExcludeMode.FOUR) {
device_to_excludes = four_to_excludes;
} else if (excludeMode === DeviceExcludeMode.THREE) {
device_to_excludes = three_to_excludes;
} else if (excludeMode === DeviceExcludeMode.NINE) {
device_to_excludes = nine_to_excludes;
} else if (excludeMode === DeviceExcludeMode.SEVEN) {
let device_to_excludes = three_to_include;
if (includeMode === DeviceExcludeMode.FOUR) {
device_to_excludes = four_to_include;
} else if (includeMode === DeviceExcludeMode.THREE) {
device_to_excludes = three_to_include;
} else if (includeMode === DeviceExcludeMode.NINE) {
device_to_excludes = nine_to_include;
} else if (includeMode === DeviceExcludeMode.SEVEN) {
device_to_excludes = seven_to_excludes
} else if (excludeMode === DeviceExcludeMode.SIX) {
device_to_excludes = six_to_excludes
} else if (excludeMode === DeviceExcludeMode.ZERO) {
} else if (includeMode === DeviceExcludeMode.APPOINTMENT) {
device_to_excludes = appointment_to_include
} else if (includeMode === DeviceExcludeMode.ZERO) {
device_to_excludes = []
}
filteredDeviceList = devices.filter(device => !device_to_excludes.includes(device.serial))
let filteredDeviceList;
if (includeMode === DeviceExcludeMode.ZERO) {
filteredDeviceList = devices
} else {
filteredDeviceList = devices.filter(device => device_to_excludes.includes(device.serial))
}
let segmentNumber = listWithoutBlackContact.length / filteredDeviceList.length;
console.log("connected device number:" + filteredDeviceList.length)
console.log("segmentNumber:" + segmentNumber)
listWithoutBlackContact = shuffle(listWithoutBlackContact)
for (let i = 0; i < filteredDeviceList.length; i++) {
let device = filteredDeviceList[i];
let port = startForwordingForDevice(device)
startWithList(listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1)), device, sender, selectedStore, audioAnalyse, alertBeep, port);
let _contactList = listWithoutBlackContact.slice(i * segmentNumber, segmentNumber * (i + 1))
// let _contactList = getContactListForDevice(device, listWithoutBlackContact)
console.log("contactList: for device:" + device.serial + " has " + _contactList.length)
startWithList(_contactList, device, sender, selectedStore, audioAnalyse, alertBeep, port);
}
})
+3 -2
View File
@@ -19,11 +19,12 @@ class ExcelUtil {
if (store === undefined || store.length === 0) {
store = "random"
}
let ipCountry = info[5];
let serial = info[5];
let ipCountry = info[6];
if (ipCountry === undefined || ipCountry.length === 0) {
ipCountry = "FR"
}
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry);
let newContact = new ContactPojo(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry, serial);
contactList.push(newContact);
}
}
+2 -1
View File
@@ -1,6 +1,6 @@
class ContactPojo {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry) {
constructor(phoneNumber, passportNumber, lastName, firstName, mail, store, ipCountry, serial) {
this.phoneNumber = phoneNumber;
this.passportNumber = passportNumber;
this.lastName = lastName;
@@ -8,6 +8,7 @@ class ContactPojo {
this.mail = mail;
this.store = store;
this.ipCountry = ipCountry;
this.serial = serial;
}
}
+3 -2
View File
@@ -1,9 +1,10 @@
const DeviceExcludeMode = {
const DeviceIncludeMode = {
ZERO: Symbol("ZERO"),
NINE: Symbol("NINE"),
THREE: Symbol("THREE"),
SIX: Symbol("SIX"),
SEVEN: Symbol("SEVEN"),
APPOINTMENT: Symbol("APPOINTMENT"),
FOUR: Symbol("FOUR")
}
module.exports = DeviceExcludeMode
module.exports = DeviceIncludeMode
+6 -4
View File
@@ -886,7 +886,7 @@ class CommandorPage {
this.isTerminated = true;
break;
case OCRResult.SLIDING_CAPTCHA_REFRESH:
await this.connect_to_browser(checkResult)
this.isTerminated = true;
break;
case OCRResult.SLIDING_CAPTCHA:
logWithDevice("will call this.slidingCaptcha()", this.device)
@@ -1354,8 +1354,8 @@ class CommandorPage {
this.device.shell("input tap " + 925 + " " + 1325)
} else if (this.device.model === "22041219PG") {
this.device.shell("input tap " + 925 + " " + 1430)
} else if (this.device.model === "moto g51 5G") {
await this.tapForDevice(this.device, 950, 1434)
} else if (this.device.model === "moto_g51_5G") {
this.device.shell("input tap " + 950 + " " + 1434)
} else
this.device.shell("input tap " + 933 + " " + 1538)
await delay(2000);
@@ -1417,7 +1417,7 @@ class CommandorPage {
this.device.shell("input tap " + 818 + " " + 2140)
await delay(1000);
} else if (model === "moto_g51_5G") {
await this.tapForDevice(this.device, 800, 2215)
this.device.shell("input tap " + 806 + " " + 2230)
await delay(2000);
this.device.shell("input tap " + 800 + " " + 2215)
await delay(1000);
@@ -1465,6 +1465,8 @@ class CommandorPage {
this.device.shell("input tap " + 510 + " " + 1975)
} else if (model === "MI_5s") {
this.device.shell("input tap " + 510 + " " + 1615)
} else if (model === "Mi_Note_10") {
await this.tapForDevice(this.device, 498, 1910)
} else
this.device.shell("input tap " + 385 + " " + 2050)
await delay(1000);
-3
View File
@@ -148,9 +148,6 @@ class OCRChecker {
} else {
await this.deleteFile(fileName)
}
// await this.deleteFile(screenShot)
// if (result.includes("rac"))
// return OCRResult.SLIDING_CAPTCHA_REFRESH
return OCRResult.SLIDING_CAPTCHA
} else if (result.includes(SLIDING_CAPTCHA_RETRY_FR)
) {