Skip to content

Commit

Permalink
[core] get engine info
Browse files Browse the repository at this point in the history
  • Loading branch information
allburov committed Mar 19, 2024
1 parent 9d489bd commit 4719cde
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/abc/session.abc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,10 @@ export abstract class WhatsappSession {
throw new NotImplementedByEngineError();
}

public async getEngineInfo(): Promise<any> {
return {};
}

/**
* END - Methods for API
*/
Expand Down
7 changes: 7 additions & 0 deletions src/core/engines/webjs/session.webjs.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/core/manager.core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
];
}
Expand Down
1 change: 1 addition & 0 deletions src/structures/sessions.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,5 @@ export class MeInfo {

export class SessionInfo extends SessionDTO {
me?: MeInfo;
engine?: any;
}

0 comments on commit 4719cde

Please sign in to comment.