@@ -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