diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index b2ed2312..974ac825 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -47,7 +47,7 @@ import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js'; import qrcode from 'qrcode-terminal'; import express from 'express'; import { GBSSR } from '../../core.gbapp/services/GBSSR.js'; -import pkg from 'whatsapp-web.js'; +import pkg, { WAState } from 'whatsapp-web.js'; import { DialogKeywords } from '../../basic.gblib/services/DialogKeywords.js'; import { ChatServices } from '../../gpt.gblib/services/ChatServices.js'; import { GBAdminService } from '../../admin.gbapp/services/GBAdminService.js'; @@ -908,7 +908,14 @@ export class WhatsappDirectLine extends GBService { to = to + '@c.us'; } } - await this.customClient.sendMessage(to, msg); + if (await this.customClient.getState() === WAState.CONNECTED) + { + await this.customClient.sendMessage(to, msg); + } + else + { + GBLog.info(`WhatsApp OFFLINE ${to}: ${msg}`); + } break;