|
@@ -12,14 +12,16 @@ function createWa(be, res) {
|
|
|
const wa = new WhasAppClient(be);
|
|
|
wa.client.on('qr', async qr => {
|
|
|
console.log(`be:${wa.clientId}:qr:${qr}`);
|
|
|
- if (res == null) {
|
|
|
- try {
|
|
|
- await wa.client.destroy();
|
|
|
- } catch (error) {
|
|
|
- console.log(error);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
+ // if (res == null) {
|
|
|
+ // try {
|
|
|
+ // await wa.client.destroy();
|
|
|
+ // fs.rm(`.wwebjs_auth/session-${wa.clientId}`, { recursive: true, force: true }, (error) => {
|
|
|
+ // });
|
|
|
+ // } catch (error) {
|
|
|
+ // console.log(error);
|
|
|
+ // }
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
if (!wa.isGenerateQr) {
|
|
|
if (res != null) res.json({ status: '00', be: wa.clientId, qr: qr });
|
|
|
}
|
|
@@ -101,11 +103,15 @@ app.post("/api/send/:be", async (req, res) => {
|
|
|
const data = req.body.message.data;
|
|
|
const caption = req.body.message.caption;
|
|
|
let messageMedia = new MessageMedia(media, data, fileName);
|
|
|
- await client.sendMessage(`${to}@c.us`, messageMedia, { caption: caption });
|
|
|
+ to.forEach( it => {
|
|
|
+ client.sendMessage(`${it}@c.us`, messageMedia, { caption: caption });
|
|
|
+ });
|
|
|
res.json({ status: '00', be: be });
|
|
|
return;
|
|
|
}
|
|
|
- await client.sendMessage(`${to}@c.us`, message);
|
|
|
+ to.forEach( it => {
|
|
|
+ client.sendMessage(`${it}@c.us`, messageMedia, { caption: caption });
|
|
|
+ });
|
|
|
res.json({ status: '00', be: be });
|
|
|
} catch (error) {
|
|
|
console.log(`error:${error}`);
|