whatsapp-pi 1.0.11 → 1.0.14

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.
Files changed (3) hide show
  1. package/README.md +20 -2
  2. package/package.json +1 -1
  3. package/whatsapp-pi.ts +20 -11
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
- - **Allow Numbers**: Manage contacts that can interact with Pi
66
- - **Blocked Numbers**: View ignored numbers (not in allow list) and add them to allow list
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatsapp-pi",
3
- "version": "1.0.11",
3
+ "version": "1.0.14",
4
4
  "type": "module",
5
5
  "description": "WhatsApp integration extension for Pi",
6
6
  "main": "whatsapp-pi.ts",
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 lastCommandCtx: ExtensionCommandContext | undefined;
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
 
@@ -58,11 +60,11 @@ export default function (pi: ExtensionAPI) {
58
60
  }
59
61
 
60
62
  // Check whatsapp flag
61
- const isWhatsappPiOff = process.argv.includes("--whatsapp-pi-off");
63
+ const isWhatsappPiOn = process.argv.includes("--whatsapp-pi-online");
62
64
 
63
65
  // Auto-connect removed to avoid socket conflicts
64
66
  if (await sessionManager.isRegistered()) {
65
- const shouldConnect = !isWhatsappPiOff;
67
+ const shouldConnect = isWhatsappPiOn;
66
68
 
67
69
  if (shouldConnect) {
68
70
  ctx.ui.setStatus('whatsapp', '| WhatsApp: Auto-connecting...');
@@ -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('/new')) {
140
- console.log(`[WhatsApp-Pi] Session reset requested by ${pushName}. Clearing context...`);
141
+ if (text.trim().toLowerCase().startsWith('/compact')) {
142
+ console.log(`[WhatsApp-Pi] Session compact requested by ${pushName}.`);
141
143
 
142
- if (lastCommandCtx) {
143
- await lastCommandCtx.newSession();
144
- await whatsappService.sendMessage(remoteJid!, "Sessão iniciada com sucesso! ✅");
145
- } else {
146
- pi.sendUserMessage("Use /whatsapp no Pi TUI para ativar o comando /new no whatsapp.", { deliverAs: "followUp" });
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
- lastCommandCtx = ctx;
168
+ _ctx = ctx;
160
169
  await menuHandler.handleCommand(ctx);
161
170
 
162
171
  // Persist state after changes