waengine 1.1.0 → 1.1.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/README.md +24 -9
- package/package.json +4 -1
- package/src/easy-bot.js +123 -9
- package/src/message.js +19 -0
package/README.md
CHANGED
|
@@ -137,22 +137,32 @@ quickBot()
|
|
|
137
137
|
.start();
|
|
138
138
|
```
|
|
139
139
|
|
|
140
|
-
###
|
|
141
|
-
Chain multiple actions elegantly:
|
|
142
|
-
|
|
140
|
+
### **🆕 Enhanced Action Chaining v1.1.0**
|
|
143
141
|
```javascript
|
|
144
|
-
import { createBot } from "waengine";
|
|
145
|
-
|
|
146
142
|
createBot()
|
|
147
|
-
.when("
|
|
148
|
-
.react("
|
|
143
|
+
.when("demo")
|
|
144
|
+
.react("🎬")
|
|
149
145
|
.type(2)
|
|
150
|
-
.reply("
|
|
151
|
-
.
|
|
146
|
+
.reply("Starting demo...")
|
|
147
|
+
.wait(1000)
|
|
148
|
+
.sendImage("demo.jpg", "Demo image")
|
|
149
|
+
.slowTypeWithMention("Hello @user! This is for you! 🎉")
|
|
150
|
+
.aiReply("Explain this demo")
|
|
151
|
+
.saveData("demos", "count", 1)
|
|
152
152
|
.done()
|
|
153
153
|
.start();
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
+
### **🆕 New Mention Actions**
|
|
157
|
+
```javascript
|
|
158
|
+
bot
|
|
159
|
+
.when("hello").slowTypeWithMention("Hello @user! 👋")
|
|
160
|
+
.when("quick").quickTypeWithMention("Hey @user! ⚡")
|
|
161
|
+
.when("normal").normalTypeWithMention("Hi @user! 😊")
|
|
162
|
+
.when("mention").mentionSender("Thanks @user!")
|
|
163
|
+
.when("all").mentionAll("Hello everyone! 👥");
|
|
164
|
+
```
|
|
165
|
+
|
|
156
166
|
### **EasyBot Features**
|
|
157
167
|
```javascript
|
|
158
168
|
const bot = createBot()
|
|
@@ -449,6 +459,11 @@ await msg.replyWithMention("Hello @user!", userJid)
|
|
|
449
459
|
// Mention all in group
|
|
450
460
|
await msg.mentionAll("Hello everyone!")
|
|
451
461
|
|
|
462
|
+
// NEW in v1.1.0: Mention with Typing
|
|
463
|
+
await msg.slowTypeWithMention("Hello @user! How are you?", userJid)
|
|
464
|
+
await msg.quickTypeWithMention("Hey @user! 👋", userJid)
|
|
465
|
+
await msg.normalTypeWithMention("Hi @user, nice to see you!", userJid)
|
|
466
|
+
|
|
452
467
|
// Get mentions from message
|
|
453
468
|
const mentions = msg.getMentions()
|
|
454
469
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waengine",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "🚀 WAEngine - The most powerful WhatsApp Bot Library with Multi-Device Support & EasyBot API",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"example:easy": "node examples/easy-bot-examples.js vollständig"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
|
+
"mention",
|
|
16
|
+
"waengine",
|
|
17
|
+
"hidetag",
|
|
15
18
|
"whatsapp",
|
|
16
19
|
"bot",
|
|
17
20
|
"baileys",
|
package/src/easy-bot.js
CHANGED
|
@@ -455,21 +455,29 @@ export class EasyBot {
|
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
async sendReply(msg, text) {
|
|
458
|
+
async sendReply(msg, text, mentions = []) {
|
|
459
459
|
try {
|
|
460
460
|
if (this.isMultiDevice) {
|
|
461
461
|
const client = this.multiClient.getNextDevice();
|
|
462
462
|
if (client && client.socket) {
|
|
463
|
-
|
|
463
|
+
const messageObj = { text: String(text) };
|
|
464
|
+
if (mentions.length > 0) {
|
|
465
|
+
messageObj.mentions = mentions;
|
|
466
|
+
}
|
|
467
|
+
await client.socket.sendMessage(msg.from, messageObj);
|
|
464
468
|
} else {
|
|
465
469
|
throw new Error('Kein verfügbarer Multi-Device Client');
|
|
466
470
|
}
|
|
467
471
|
} else {
|
|
468
472
|
if (msg.reply && typeof msg.reply === 'function') {
|
|
469
|
-
await msg.reply(String(text));
|
|
473
|
+
await msg.reply(String(text), mentions);
|
|
470
474
|
} else {
|
|
471
475
|
// Fallback: Direct client call
|
|
472
|
-
|
|
476
|
+
const messageObj = { text: String(text) };
|
|
477
|
+
if (mentions.length > 0) {
|
|
478
|
+
messageObj.mentions = mentions;
|
|
479
|
+
}
|
|
480
|
+
await this.client.socket.sendMessage(msg.from, messageObj);
|
|
473
481
|
}
|
|
474
482
|
}
|
|
475
483
|
} catch (error) {
|
|
@@ -477,7 +485,11 @@ export class EasyBot {
|
|
|
477
485
|
// Fallback attempt
|
|
478
486
|
try {
|
|
479
487
|
if (this.client && this.client.socket) {
|
|
480
|
-
|
|
488
|
+
const messageObj = { text: String(text) };
|
|
489
|
+
if (mentions.length > 0) {
|
|
490
|
+
messageObj.mentions = mentions;
|
|
491
|
+
}
|
|
492
|
+
await this.client.socket.sendMessage(msg.from, messageObj);
|
|
481
493
|
}
|
|
482
494
|
} catch (fallbackError) {
|
|
483
495
|
console.error("❌ Auch Fallback fehlgeschlagen:", fallbackError.message);
|
|
@@ -771,6 +783,22 @@ class EasyRule {
|
|
|
771
783
|
return this;
|
|
772
784
|
}
|
|
773
785
|
|
|
786
|
+
// Neue Mention + Typing Kombinationen
|
|
787
|
+
slowTypeWithMention(text) {
|
|
788
|
+
this.actions.push({ type: 'slowTypeWithMention', value: text });
|
|
789
|
+
return this;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
quickTypeWithMention(text) {
|
|
793
|
+
this.actions.push({ type: 'quickTypeWithMention', value: text });
|
|
794
|
+
return this;
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
normalTypeWithMention(text) {
|
|
798
|
+
this.actions.push({ type: 'normalTypeWithMention', value: text });
|
|
799
|
+
return this;
|
|
800
|
+
}
|
|
801
|
+
|
|
774
802
|
// Delete actions
|
|
775
803
|
deleteMessage() {
|
|
776
804
|
this.actions.push({ type: 'delete' });
|
|
@@ -1046,13 +1074,99 @@ class EasyRule {
|
|
|
1046
1074
|
break;
|
|
1047
1075
|
|
|
1048
1076
|
case 'mentionSender':
|
|
1049
|
-
// Implementierung für mentionSender
|
|
1050
|
-
|
|
1077
|
+
// Verbesserte Implementierung für mentionSender
|
|
1078
|
+
try {
|
|
1079
|
+
if (msg.replyWithMention && typeof msg.replyWithMention === 'function') {
|
|
1080
|
+
await msg.replyWithMention(action.value, msg.getSender());
|
|
1081
|
+
} else {
|
|
1082
|
+
// Fallback
|
|
1083
|
+
const senderName = msg.getSender().split('@')[0];
|
|
1084
|
+
const mentionText = action.value.replace('@user', `@${senderName}`);
|
|
1085
|
+
await this.bot.sendReply(msg, mentionText, [msg.getSender()]);
|
|
1086
|
+
}
|
|
1087
|
+
} catch (error) {
|
|
1088
|
+
console.error('❌ Fehler bei mentionSender:', error.message);
|
|
1089
|
+
await this.bot.sendReply(msg, action.value);
|
|
1090
|
+
}
|
|
1051
1091
|
break;
|
|
1052
1092
|
|
|
1053
1093
|
case 'mentionAll':
|
|
1054
|
-
// Implementierung für mentionAll
|
|
1055
|
-
|
|
1094
|
+
// Verbesserte Implementierung für mentionAll
|
|
1095
|
+
try {
|
|
1096
|
+
if (msg.mentionAll && typeof msg.mentionAll === 'function') {
|
|
1097
|
+
await msg.mentionAll(action.value);
|
|
1098
|
+
} else {
|
|
1099
|
+
await this.bot.sendReply(msg, action.value);
|
|
1100
|
+
}
|
|
1101
|
+
} catch (error) {
|
|
1102
|
+
console.error('❌ Fehler bei mentionAll:', error.message);
|
|
1103
|
+
await this.bot.sendReply(msg, action.value);
|
|
1104
|
+
}
|
|
1105
|
+
break;
|
|
1106
|
+
|
|
1107
|
+
case 'mentionUser':
|
|
1108
|
+
// Implementierung für mentionUser
|
|
1109
|
+
try {
|
|
1110
|
+
if (msg.replyWithMention && typeof msg.replyWithMention === 'function') {
|
|
1111
|
+
await msg.replyWithMention(action.value.text, action.value.userJid);
|
|
1112
|
+
} else {
|
|
1113
|
+
await this.bot.sendReply(msg, action.value.text);
|
|
1114
|
+
}
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
console.error('❌ Fehler bei mentionUser:', error.message);
|
|
1117
|
+
await this.bot.sendReply(msg, action.value.text);
|
|
1118
|
+
}
|
|
1119
|
+
break;
|
|
1120
|
+
|
|
1121
|
+
case 'slowTypeWithMention':
|
|
1122
|
+
// Neue Funktion: Slow Type mit Mention
|
|
1123
|
+
try {
|
|
1124
|
+
if (msg.slowTypeWithMention && typeof msg.slowTypeWithMention === 'function') {
|
|
1125
|
+
await msg.slowTypeWithMention(action.value, msg.getSender());
|
|
1126
|
+
} else {
|
|
1127
|
+
// Fallback
|
|
1128
|
+
const senderName = msg.getSender().split('@')[0];
|
|
1129
|
+
const mentionText = action.value.replace('@user', `@${senderName}`);
|
|
1130
|
+
await this.bot.typeMessage(msg, 4000);
|
|
1131
|
+
await this.bot.sendReply(msg, mentionText, [msg.getSender()]);
|
|
1132
|
+
}
|
|
1133
|
+
} catch (error) {
|
|
1134
|
+
console.error('❌ Fehler bei slowTypeWithMention:', error.message);
|
|
1135
|
+
}
|
|
1136
|
+
break;
|
|
1137
|
+
|
|
1138
|
+
case 'quickTypeWithMention':
|
|
1139
|
+
// Neue Funktion: Quick Type mit Mention
|
|
1140
|
+
try {
|
|
1141
|
+
if (msg.quickTypeWithMention && typeof msg.quickTypeWithMention === 'function') {
|
|
1142
|
+
await msg.quickTypeWithMention(action.value, msg.getSender());
|
|
1143
|
+
} else {
|
|
1144
|
+
// Fallback
|
|
1145
|
+
const senderName = msg.getSender().split('@')[0];
|
|
1146
|
+
const mentionText = action.value.replace('@user', `@${senderName}`);
|
|
1147
|
+
await this.bot.typeMessage(msg, 1000);
|
|
1148
|
+
await this.bot.sendReply(msg, mentionText, [msg.getSender()]);
|
|
1149
|
+
}
|
|
1150
|
+
} catch (error) {
|
|
1151
|
+
console.error('❌ Fehler bei quickTypeWithMention:', error.message);
|
|
1152
|
+
}
|
|
1153
|
+
break;
|
|
1154
|
+
|
|
1155
|
+
case 'normalTypeWithMention':
|
|
1156
|
+
// Neue Funktion: Normal Type mit Mention
|
|
1157
|
+
try {
|
|
1158
|
+
if (msg.normalTypeWithMention && typeof msg.normalTypeWithMention === 'function') {
|
|
1159
|
+
await msg.normalTypeWithMention(action.value, msg.getSender());
|
|
1160
|
+
} else {
|
|
1161
|
+
// Fallback
|
|
1162
|
+
const senderName = msg.getSender().split('@')[0];
|
|
1163
|
+
const mentionText = action.value.replace('@user', `@${senderName}`);
|
|
1164
|
+
await this.bot.typeMessage(msg, 2000);
|
|
1165
|
+
await this.bot.sendReply(msg, mentionText, [msg.getSender()]);
|
|
1166
|
+
}
|
|
1167
|
+
} catch (error) {
|
|
1168
|
+
console.error('❌ Fehler bei normalTypeWithMention:', error.message);
|
|
1169
|
+
}
|
|
1056
1170
|
break;
|
|
1057
1171
|
|
|
1058
1172
|
case 'mentionUser':
|
package/src/message.js
CHANGED
|
@@ -301,6 +301,25 @@ export class Message {
|
|
|
301
301
|
return await this.reply(mentionText, allMembers);
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
+
// Mention mit Typing - Neue Funktion für bessere UX
|
|
305
|
+
async slowTypeWithMention(text, userJid) {
|
|
306
|
+
const senderName = userJid.split('@')[0];
|
|
307
|
+
const mentionText = text.replace('@user', `@${senderName}`);
|
|
308
|
+
return await this.slowType(mentionText, [userJid]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
async quickTypeWithMention(text, userJid) {
|
|
312
|
+
const senderName = userJid.split('@')[0];
|
|
313
|
+
const mentionText = text.replace('@user', `@${senderName}`);
|
|
314
|
+
return await this.quickType(mentionText, [userJid]);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
async normalTypeWithMention(text, userJid) {
|
|
318
|
+
const senderName = userJid.split('@')[0];
|
|
319
|
+
const mentionText = text.replace('@user', `@${senderName}`);
|
|
320
|
+
return await this.normalType(mentionText, [userJid]);
|
|
321
|
+
}
|
|
322
|
+
|
|
304
323
|
// ===== PERMISSION SYSTEM =====
|
|
305
324
|
|
|
306
325
|
async isAdmin() {
|