whatsapp-pi 1.0.11 → 1.0.12
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 +20 -2
- package/package.json +1 -1
- package/whatsapp-pi.ts +18 -9
package/README.md
CHANGED
|
@@ -62,8 +62,26 @@ pi -e whatsapp-pi.ts --verbose
|
|
|
62
62
|
## Commands
|
|
63
63
|
|
|
64
64
|
- `/whatsapp` - Open the WhatsApp management menu
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
### Main Menu Options
|
|
67
|
+
- **Connect WhatsApp** - Start WhatsApp connection (shows QR code for first-time setup)
|
|
68
|
+
- **Disconnect WhatsApp** - Stop WhatsApp connection
|
|
69
|
+
- **Logoff (Delete Session)** - Remove all credentials and session data
|
|
70
|
+
- **Reset Conversation** - Clear all conversation history
|
|
71
|
+
- **Allowed Numbers** - Manage contacts that can interact with Pi
|
|
72
|
+
- **Blocked Numbers** - View ignored numbers and manage them
|
|
73
|
+
|
|
74
|
+
### Allowed Numbers Management
|
|
75
|
+
- **Add Number** - Add a new contact to the allow list (format: +5511999999999)
|
|
76
|
+
- **Remove [Number]** - Remove a specific contact from the allow list
|
|
77
|
+
- **Clear All** - Remove all allowed numbers
|
|
78
|
+
- **Back** - Return to main menu
|
|
79
|
+
|
|
80
|
+
### Blocked Numbers Management
|
|
81
|
+
- **View List** - See all numbers that have been ignored (not in allow list)
|
|
82
|
+
- **Allow** - Move a blocked number to the allowed list
|
|
83
|
+
- **Delete** - Remove a number from the blocked list
|
|
84
|
+
- **Back** - Return to main menu
|
|
67
85
|
|
|
68
86
|
## Project Structure
|
|
69
87
|
|
package/package.json
CHANGED
package/whatsapp-pi.ts
CHANGED
|
@@ -23,10 +23,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
23
23
|
const whatsappService = new WhatsAppService(sessionManager);
|
|
24
24
|
const audioService = new AudioService();
|
|
25
25
|
const menuHandler = new MenuHandler(whatsappService, sessionManager);
|
|
26
|
-
let
|
|
26
|
+
let _ctx: ExtensionContext | undefined;
|
|
27
|
+
|
|
27
28
|
|
|
28
29
|
// Initial status setup
|
|
29
30
|
pi.on("session_start", async (_event, ctx) => {
|
|
31
|
+
_ctx = ctx;
|
|
30
32
|
// Check verbose mode
|
|
31
33
|
const isVerboseFlagSet = process.argv.includes("--verbose");
|
|
32
34
|
|
|
@@ -136,14 +138,21 @@ export default function (pi: ExtensionAPI) {
|
|
|
136
138
|
console.log(`[WhatsApp-Pi] ${pushName} (+${sender}): ${text}`);
|
|
137
139
|
|
|
138
140
|
// Handle commands
|
|
139
|
-
if (text.trim().toLowerCase().startsWith('/
|
|
140
|
-
console.log(`[WhatsApp-Pi] Session
|
|
141
|
+
if (text.trim().toLowerCase().startsWith('/compact')) {
|
|
142
|
+
console.log(`[WhatsApp-Pi] Session compact requested by ${pushName}.`);
|
|
141
143
|
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
await whatsappService.sendMessage(remoteJid!, "Sessão
|
|
145
|
-
}
|
|
146
|
-
|
|
144
|
+
if (_ctx) {
|
|
145
|
+
_ctx.compact();
|
|
146
|
+
await whatsappService.sendMessage(remoteJid!, "Sessão compactada com sucesso! ✅");
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (text.trim().toLowerCase().startsWith('/abort')) {
|
|
152
|
+
console.log(`[WhatsApp-Pi] Abort requested by ${pushName}.`);
|
|
153
|
+
if (_ctx) {
|
|
154
|
+
_ctx.abort();
|
|
155
|
+
await whatsappService.sendMessage(remoteJid!, "Abortado! ✅");
|
|
147
156
|
}
|
|
148
157
|
return;
|
|
149
158
|
}
|
|
@@ -156,7 +165,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
156
165
|
pi.registerCommand("whatsapp", {
|
|
157
166
|
description: "Manage WhatsApp integration",
|
|
158
167
|
handler: async (args, ctx) => {
|
|
159
|
-
|
|
168
|
+
_ctx = ctx;
|
|
160
169
|
await menuHandler.handleCommand(ctx);
|
|
161
170
|
|
|
162
171
|
// Persist state after changes
|