@vielhuber/wahelper 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WhatsApp.js +10 -4
- package/package.json +1 -1
package/WhatsApp.js
CHANGED
|
@@ -381,10 +381,14 @@ export default class WhatsApp {
|
|
|
381
381
|
message = message.replace(/ /g, ' ');
|
|
382
382
|
// replace <br> with real line breaks
|
|
383
383
|
message = message.replace(/<br\s*\/?>/gis, '\n');
|
|
384
|
-
// replace " </x>" with "</x> "
|
|
385
|
-
message = message.replace(/ (\<\/[a-z]+\>)/gis, '$1 ');
|
|
386
|
-
|
|
387
|
-
message = message.replace(/(
|
|
384
|
+
// replace " </x>" with "</x> " (multiple times)
|
|
385
|
+
message = message.replace(/ +(\<\/[a-z]+\>)/gis, '$1 ');
|
|
386
|
+
message = message.replace(/ +(\<\/[a-z]+\>)/gis, '$1 ');
|
|
387
|
+
message = message.replace(/ +(\<\/[a-z]+\>)/gis, '$1 ');
|
|
388
|
+
// replace "<x> " with " <x>" (multiple times)
|
|
389
|
+
message = message.replace(/(\<[a-z]+(?:\s[^>]*)?\>) +/gis, ' $1');
|
|
390
|
+
message = message.replace(/(\<[a-z]+(?:\s[^>]*)?\>) +/gis, ' $1');
|
|
391
|
+
message = message.replace(/(\<[a-z]+(?:\s[^>]*)?\>) +/gis, ' $1');
|
|
388
392
|
// replace " \n" with "\n"
|
|
389
393
|
message = message.replace(/ \n/gis, '\n');
|
|
390
394
|
// remove "<x> </x>"
|
|
@@ -437,7 +441,9 @@ export default class WhatsApp {
|
|
|
437
441
|
async sendMessageToUser(number = null, message = null, attachments = null) {
|
|
438
442
|
let jid = this.formatNumber(number) + '@s.whatsapp.net',
|
|
439
443
|
msgResponse = [];
|
|
444
|
+
this.log('begin send message to user ' + jid);
|
|
440
445
|
msgResponse.push(await this.sock.sendMessage(jid, { text: this.formatMessage(message) }));
|
|
446
|
+
this.log('end send message to user ' + jid);
|
|
441
447
|
//this.log(attachments);
|
|
442
448
|
if (attachments !== null && attachments.length > 0) {
|
|
443
449
|
for (let attachments__value of attachments) {
|