cli-whatsapp 0.1.14 → 0.1.16
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/dist/cli/commands/read.js +12 -4
- package/dist/cli/commands/shell.js +1 -1
- package/dist/cli/index.js +2 -2
- package/dist/db/sqlite.js +10 -5
- package/package.json +1 -1
|
@@ -10,13 +10,21 @@ export function chats(opts) {
|
|
|
10
10
|
print(renderChatList(rows, cfg.preferences.time24h));
|
|
11
11
|
}
|
|
12
12
|
/** wa contacts [--limit N] */
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
/** wa contacts [starts] — list contacts; `starts` filters by name prefix
|
|
14
|
+
* (e.g. `wa contacts a` → names starting with "a"). */
|
|
15
|
+
export function contacts(starts, opts) {
|
|
16
|
+
// Show everyone by default; honor an explicit --limit if given.
|
|
17
|
+
const limit = opts.limit ? Math.max(1, parseInt(opts.limit, 10) || 100000) : 100000;
|
|
18
|
+
const filter = starts?.replace(/^-+/, '').trim() || undefined; // tolerate "-a"
|
|
19
|
+
const rows = listContacts(limit, filter);
|
|
16
20
|
if (rows.length === 0) {
|
|
17
|
-
print(c.dim(
|
|
21
|
+
print(c.dim(filter
|
|
22
|
+
? `No contacts starting with "${filter}".`
|
|
23
|
+
: 'No contacts cached yet. Run `wa sync`.'));
|
|
18
24
|
return;
|
|
19
25
|
}
|
|
26
|
+
if (filter)
|
|
27
|
+
print(c.dim(`Contacts starting with "${filter}":`));
|
|
20
28
|
const width = String(rows.length).length;
|
|
21
29
|
print(rows
|
|
22
30
|
.map((r, i) => {
|
|
@@ -528,7 +528,7 @@ async function handle(state, raw) {
|
|
|
528
528
|
recent({ limit: args[0] });
|
|
529
529
|
return;
|
|
530
530
|
case 'contacts':
|
|
531
|
-
contacts(
|
|
531
|
+
contacts(args[0], {});
|
|
532
532
|
return;
|
|
533
533
|
case 'history':
|
|
534
534
|
if (state.active && (!args[0] || /^\d+$/.test(args[0])))
|
package/dist/cli/index.js
CHANGED
|
@@ -80,8 +80,8 @@ program
|
|
|
80
80
|
.option('-n, --limit <n>', 'max chats to show')
|
|
81
81
|
.action(run(chats));
|
|
82
82
|
program
|
|
83
|
-
.command('contacts')
|
|
84
|
-
.description('List
|
|
83
|
+
.command('contacts [starts]')
|
|
84
|
+
.description('List contacts; pass a letter to filter (e.g. `wa contacts a`)')
|
|
85
85
|
.option('-n, --limit <n>', 'max contacts to show')
|
|
86
86
|
.action(run(contacts));
|
|
87
87
|
program
|
package/dist/db/sqlite.js
CHANGED
|
@@ -145,13 +145,18 @@ export function listChats(limit = 50, includeArchived = false) {
|
|
|
145
145
|
LIMIT ?`)
|
|
146
146
|
.all(limit);
|
|
147
147
|
}
|
|
148
|
-
export function listContacts(limit = 500) {
|
|
148
|
+
export function listContacts(limit = 500, startsWith) {
|
|
149
149
|
// Exclude WhatsApp privacy-masked placeholder names (e.g. "+91∙∙∙∙∙∙∙∙37").
|
|
150
|
+
const params = [];
|
|
151
|
+
let where = "name IS NOT NULL AND name NOT LIKE '%∙%'";
|
|
152
|
+
if (startsWith) {
|
|
153
|
+
where += " AND name LIKE ? ESCAPE '\\'";
|
|
154
|
+
params.push(escapeLike(startsWith) + '%');
|
|
155
|
+
}
|
|
156
|
+
params.push(limit);
|
|
150
157
|
return getDb()
|
|
151
|
-
.prepare(`SELECT * FROM contacts
|
|
152
|
-
|
|
153
|
-
ORDER BY name COLLATE NOCASE LIMIT ?`)
|
|
154
|
-
.all(limit);
|
|
158
|
+
.prepare(`SELECT * FROM contacts WHERE ${where} ORDER BY name COLLATE NOCASE LIMIT ?`)
|
|
159
|
+
.all(...params);
|
|
155
160
|
}
|
|
156
161
|
export function getMessages(chatJid, limit = 30) {
|
|
157
162
|
// Newest N, returned oldest-first for natural chat reading order.
|
package/package.json
CHANGED