Skip to content

Commit 8d04198

Browse files
fix: monospace and bold
1 parent 5aa89d8 commit 8d04198

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/whatsapp/services/chatwoot.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,12 @@ export class ChatwootService {
10191019
this.logger.verbose('check if is group');
10201020
const chatId =
10211021
body.conversation.meta.sender?.phone_number?.replace('+', '') || body.conversation.meta.sender?.identifier;
1022+
// Chatwoot to Whatsapp
10221023
const messageReceived = body.content
1023-
.replaceAll(/\*((?!\s)([^\n*]+?)(?<!\s))\*/g, '_$1_') // Substitui * por _
1024+
.replaceAll(/(?<!\*)\*((?!\s)([^\n*]+?)(?<!\s))\*(?!\*)/g, '_$1_') // Substitui * por _
10241025
.replaceAll(/\*{2}((?!\s)([^\n*]+?)(?<!\s))\*{2}/g, '*$1*') // Substitui ** por *
1025-
.replace(/~{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 ```
10261028

10271029
const senderName = body?.sender?.name;
10281030
const waInstance = this.waMonitor.waInstances[instance.instanceName];
@@ -1481,6 +1483,7 @@ export class ChatwootService {
14811483

14821484
this.logger.verbose('get conversation message');
14831485

1486+
// Whatsapp to Chatwoot
14841487
const bodyMessage = await this.getConversationMessage(body.message)
14851488
.replaceAll(/\*((?!\s)([^\n*]+?)(?<!\s))\*/g, '**$1**')
14861489
.replaceAll(/_((?!\s)([^\n_]+?)(?<!\s))_/g, '*$1*')

0 commit comments

Comments
 (0)