whatsapp-pi 1.0.4 → 1.0.5
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
CHANGED
|
@@ -85,6 +85,11 @@ export class SessionManager {
|
|
|
85
85
|
return this.ignoredNumbers;
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
async removeIgnoredNumber(number: string) {
|
|
89
|
+
this.ignoredNumbers = this.ignoredNumbers.filter(c => c.number !== number);
|
|
90
|
+
await this.saveConfig();
|
|
91
|
+
}
|
|
92
|
+
|
|
88
93
|
async addNumber(number: any, name?: string) {
|
|
89
94
|
// Handle potential nested objects from legacy bugs
|
|
90
95
|
let cleanNumber = number;
|
|
@@ -127,7 +127,7 @@ export class WhatsAppService {
|
|
|
127
127
|
public async handleIncomingMessages(m: any) {
|
|
128
128
|
if (this.sessionManager.getStatus() !== 'connected') return;
|
|
129
129
|
const msg = m.messages[0];
|
|
130
|
-
if (!msg || !msg.key.remoteJid) return;
|
|
130
|
+
if (!msg || !msg.key.remoteJid || msg.key.fromMe) return;
|
|
131
131
|
|
|
132
132
|
// Ignore messages sent by Pi (marked with π)
|
|
133
133
|
const text = msg.message?.conversation || msg.message?.extendedTextMessage?.text || "";
|
package/src/ui/menu.handler.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class MenuHandler {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
private async manageBlockList(ctx: ExtensionCommandContext) {
|
|
94
|
-
const list = this.sessionManager.
|
|
94
|
+
const list = this.sessionManager.getIgnoredNumbers();
|
|
95
95
|
|
|
96
96
|
if (list.length === 0) {
|
|
97
97
|
ctx.ui.notify('No blocked numbers', 'info');
|
|
@@ -115,19 +115,21 @@ export class MenuHandler {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
private async manageBlockedNumber(ctx: ExtensionCommandContext, number: string) {
|
|
118
|
-
const action = await ctx.ui.select(`Manage ${number}`, ['
|
|
118
|
+
const action = await ctx.ui.select(`Manage ${number}`, ['Allow', 'Delete', 'Back']);
|
|
119
119
|
|
|
120
|
-
if (action === '
|
|
121
|
-
const ok = await ctx.ui.confirm('
|
|
120
|
+
if (action === 'Allow') {
|
|
121
|
+
const ok = await ctx.ui.confirm('Allow', `Move ${number} to Allowed Numbers?`);
|
|
122
122
|
if (ok) {
|
|
123
|
-
|
|
123
|
+
const list = this.sessionManager.getIgnoredNumbers();
|
|
124
|
+
const contact = list.find(c => c.number === number);
|
|
125
|
+
await this.sessionManager.addNumber(number, contact?.name);
|
|
124
126
|
ctx.ui.notify(`${number} moved to Allowed List`, 'info');
|
|
125
127
|
}
|
|
126
128
|
await this.manageBlockList(ctx);
|
|
127
129
|
} else if (action === 'Delete') {
|
|
128
130
|
const ok = await ctx.ui.confirm('Delete', `Remove ${number} from Block List?`);
|
|
129
131
|
if (ok) {
|
|
130
|
-
await this.sessionManager.
|
|
132
|
+
await this.sessionManager.removeIgnoredNumber(number);
|
|
131
133
|
ctx.ui.notify(`${number} removed from Block List`, 'info');
|
|
132
134
|
}
|
|
133
135
|
await this.manageBlockList(ctx);
|