-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile.js
28 lines (25 loc) · 786 Bytes
/
file.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const puppeteer = require('puppeteer');
const fs = require('fs');
const readline = require('readline');
const { loginToWhatsApp, sendMessage } = require('./whatsapp');
const { delay, getRandomTimeout } = require('./utils');
async function readCSVFile(page,filePath) {
const fileStream = fs.createReadStream(filePath);
const rl = readline.createInterface({
input: fileStream,
crlfDelay: Infinity,
});
for await (const group of rl) {
var flag=0
// Process each line here
console.log(group+"................................");
try {
await sendMessage(page, group, 'hello');
flag=1;
} catch (error) {
console.log(`Error occurred at ${group}: ${error.message}`);
continue;
}
}
}
module.exports={readCSVFile};