whatsapp-pi 1.0.25 → 1.0.27
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/package.json +1 -1
- package/src/ui/menu.handler.ts +11 -10
package/package.json
CHANGED
package/src/ui/menu.handler.ts
CHANGED
|
@@ -18,24 +18,24 @@ export class MenuHandler {
|
|
|
18
18
|
const options: string[] = [];
|
|
19
19
|
|
|
20
20
|
if (status === 'connected') {
|
|
21
|
+
options.push('Recents');
|
|
22
|
+
options.push('Allowed Numbers');
|
|
23
|
+
options.push('Blocked Numbers');
|
|
21
24
|
options.push('Disconnect WhatsApp');
|
|
22
25
|
} else {
|
|
23
|
-
options.push('Connect
|
|
26
|
+
options.push('Connect WhatsApp');
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
if (registered) {
|
|
27
30
|
options.push('Logoff (Delete Session)');
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
options.push('Allowed Numbers');
|
|
31
|
-
options.push('Blocked Numbers');
|
|
32
|
-
options.push('Recents');
|
|
33
33
|
options.push('Back');
|
|
34
34
|
|
|
35
35
|
const choice = await ctx.ui.select(`WhatsApp (Status: ${status})`, options);
|
|
36
36
|
|
|
37
37
|
switch (choice) {
|
|
38
|
-
case 'Connect
|
|
38
|
+
case 'Connect WhatsApp':
|
|
39
39
|
if (status === 'connected') {
|
|
40
40
|
ctx.ui.notify('WhatsApp is already connected', 'info');
|
|
41
41
|
break;
|
|
@@ -332,21 +332,22 @@ export class MenuHandler {
|
|
|
332
332
|
private async sendMessageToAllowedNumber(ctx: ExtensionCommandContext, contact: Contact) {
|
|
333
333
|
const displayName = contact.name ? `${contact.name} (${contact.number})` : contact.number;
|
|
334
334
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
335
|
-
const
|
|
336
|
-
const trimmed = text?.trim() || '';
|
|
335
|
+
const inputText = (await ctx.ui.input(`Send a message to ${displayName}:`))?.trim() || '';
|
|
337
336
|
|
|
338
|
-
if (!
|
|
337
|
+
if (!inputText) {
|
|
339
338
|
ctx.ui.notify('Please enter a message before sending.', 'error');
|
|
340
339
|
continue;
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
const
|
|
342
|
+
const inputTextWithPiSuffix = inputText + ' π';
|
|
343
|
+
|
|
344
|
+
const result = await this.whatsappService.sendMenuMessage(this.toJid(contact.number), inputTextWithPiSuffix);
|
|
344
345
|
if (result.success) {
|
|
345
346
|
await this.recentsService.recordMessage({
|
|
346
347
|
messageId: result.messageId ?? `${Date.now()}`,
|
|
347
348
|
senderNumber: contact.number,
|
|
348
349
|
senderName: contact.name,
|
|
349
|
-
text:
|
|
350
|
+
text: inputTextWithPiSuffix,
|
|
350
351
|
direction: 'outgoing',
|
|
351
352
|
timestamp: Date.now()
|
|
352
353
|
});
|