From 4719cded95aa62ad07adc8a56ed365ef685b29ce Mon Sep 17 00:00:00 2001 From: allburov Date: Tue, 19 Mar 2024 14:14:53 +0700 Subject: [PATCH] [core] get engine info --- src/core/abc/session.abc.ts | 4 ++++ src/core/engines/webjs/session.webjs.core.ts | 7 +++++++ src/core/manager.core.ts | 5 +++++ src/structures/sessions.dto.ts | 1 + 4 files changed, 17 insertions(+) diff --git a/src/core/abc/session.abc.ts b/src/core/abc/session.abc.ts index 179d641a..b4df333d 100644 --- a/src/core/abc/session.abc.ts +++ b/src/core/abc/session.abc.ts @@ -425,6 +425,10 @@ export abstract class WhatsappSession { throw new NotImplementedByEngineError(); } + public async getEngineInfo(): Promise { + return {}; + } + /** * END - Methods for API */ diff --git a/src/core/engines/webjs/session.webjs.core.ts b/src/core/engines/webjs/session.webjs.core.ts index 6fe61ea0..59b8bce8 100644 --- a/src/core/engines/webjs/session.webjs.core.ts +++ b/src/core/engines/webjs/session.webjs.core.ts @@ -622,6 +622,13 @@ export class WhatsappSessionWebJSCore extends WhatsappSession { }); } + public async getEngineInfo() { + return { + WWebVersion: await this.whatsapp?.getWWebVersion(), + state: await this.whatsapp?.getState(), + }; + } + protected toWAContact(contact: Contact) { // @ts-ignore contact.id = contact.id._serialized; diff --git a/src/core/manager.core.ts b/src/core/manager.core.ts index 47b2e8a3..565611fb 100644 --- a/src/core/manager.core.ts +++ b/src/core/manager.core.ts @@ -213,12 +213,17 @@ export class SessionManagerCore extends SessionManager { ]; } const me = await this.session.getSessionMeInfo().catch((err) => null); + const engine = { + engine: this.session?.engine, + ...(await this.session?.getEngineInfo().catch((err) => ({}))), + }; return [ { name: this.session.name, status: this.session.status, config: this.session.sessionConfig, me: me, + engine: engine, }, ]; } diff --git a/src/structures/sessions.dto.ts b/src/structures/sessions.dto.ts index 0ed48031..67837a72 100644 --- a/src/structures/sessions.dto.ts +++ b/src/structures/sessions.dto.ts @@ -79,4 +79,5 @@ export class MeInfo { export class SessionInfo extends SessionDTO { me?: MeInfo; + engine?: any; }