Skip to content

Commit a869d38

Browse files
committed
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
2 parents 547f981 + 7bf7c96 commit a869d38

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/whatsapp/services/chatwoot.service.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,10 +1021,12 @@ export class ChatwootService {
10211021
body.conversation.meta.sender?.phone_number?.replace('+', '') || body.conversation.meta.sender?.identifier;
10221022
// Chatwoot to Whatsapp
10231023
const messageReceived = body.content
1024-
.replaceAll(/(?<!\*)\*((?!\s)([^\n*]+?)(?<!\s))\*(?!\*)/g, '_$1_') // Substitui * por _
1025-
.replaceAll(/\*{2}((?!\s)([^\n*]+?)(?<!\s))\*{2}/g, '*$1*') // Substitui ** por *
1026-
.replaceAll(/~{2}((?!\s)([^\n*]+?)(?<!\s))~{2}/g, '~$1~') // Substitui ~~ por ~
1027-
.replaceAll(/(?<!`)`((?!\s)([^`*]+?)(?<!\s))`(?!`)/g, '```$1```'); // Substitui ` por ```
1024+
? body.content
1025+
.replaceAll(/(?<!\*)\*((?!\s)([^\n*]+?)(?<!\s))\*(?!\*)/g, '_$1_') // Substitui * por _
1026+
.replaceAll(/\*{2}((?!\s)([^\n*]+?)(?<!\s))\*{2}/g, '*$1*') // Substitui ** por *
1027+
.replaceAll(/~{2}((?!\s)([^\n*]+?)(?<!\s))~{2}/g, '~$1~') // Substitui ~~ por ~
1028+
.replaceAll(/(?<!`)`((?!\s)([^`*]+?)(?<!\s))`(?!`)/g, '```$1```') // Substitui ` por ```
1029+
: body.content;
10281030

10291031
const senderName = body?.sender?.name;
10301032
const waInstance = this.waMonitor.waInstances[instance.instanceName];
@@ -1484,10 +1486,13 @@ export class ChatwootService {
14841486
this.logger.verbose('get conversation message');
14851487

14861488
// Whatsapp to Chatwoot
1487-
const bodyMessage = await this.getConversationMessage(body.message)
1488-
.replaceAll(/\*((?!\s)([^\n*]+?)(?<!\s))\*/g, '**$1**')
1489-
.replaceAll(/_((?!\s)([^\n_]+?)(?<!\s))_/g, '*$1*')
1490-
.replaceAll(/~((?!\s)([^\n~]+?)(?<!\s))~/g, '~~$1~~');
1489+
const originalMessage = await this.getConversationMessage(body.message);
1490+
const bodyMessage = originalMessage
1491+
? originalMessage
1492+
.replaceAll(/\*((?!\s)([^\n*]+?)(?<!\s))\*/g, '**$1**')
1493+
.replaceAll(/_((?!\s)([^\n_]+?)(?<!\s))_/g, '*$1*')
1494+
.replaceAll(/~((?!\s)([^\n~]+?)(?<!\s))~/g, '~~$1~~')
1495+
: originalMessage;
14911496

14921497
this.logger.verbose('body message: ' + bodyMessage);
14931498

src/whatsapp/services/whatsapp.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,10 +1233,14 @@ export class WAStartupService {
12331233
this.logger.verbose('Connection opened');
12341234
this.instance.wuid = this.client.user.id.replace(/:\d+/, '');
12351235
this.instance.profilePictureUrl = (await this.profilePicture(this.instance.wuid)).profilePictureUrl;
1236+
const formattedWuid = this.instance.wuid.split('@')[0].padEnd(30, ' ');
1237+
const formattedName = this.instance.name.split('@')[0].padEnd(30, ' ');
12361238
this.logger.info(
12371239
`
12381240
┌──────────────────────────────┐
12391241
│ CONNECTED TO WHATSAPP │
1242+
${formattedWuid}
1243+
${formattedName}
12401244
└──────────────────────────────┘`.replace(/^ +/gm, ' '),
12411245
);
12421246

0 commit comments

Comments
 (0)