beecork 1.4.5 → 1.4.6
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/index.js +38 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -163,17 +163,48 @@ program
|
|
|
163
163
|
});
|
|
164
164
|
program
|
|
165
165
|
.command('whatsapp')
|
|
166
|
-
.description('Set up
|
|
167
|
-
.
|
|
166
|
+
.description('Set up or disable WhatsApp')
|
|
167
|
+
.option('--disable', 'Disable WhatsApp and remove session')
|
|
168
|
+
.action(async (opts) => {
|
|
169
|
+
if (opts.disable) {
|
|
170
|
+
const { getConfig, saveConfig } = await import('./config.js');
|
|
171
|
+
const { getBeecorkHome } = await import('./util/paths.js');
|
|
172
|
+
const fs = await import('node:fs');
|
|
173
|
+
const config = getConfig();
|
|
174
|
+
if (config.whatsapp) {
|
|
175
|
+
config.whatsapp.enabled = false;
|
|
176
|
+
saveConfig(config);
|
|
177
|
+
}
|
|
178
|
+
// Remove session files
|
|
179
|
+
const sessionPath = `${getBeecorkHome()}/whatsapp-session`;
|
|
180
|
+
if (fs.existsSync(sessionPath)) {
|
|
181
|
+
fs.rmSync(sessionPath, { recursive: true, force: true });
|
|
182
|
+
}
|
|
183
|
+
console.log('✓ WhatsApp disabled and session removed.');
|
|
184
|
+
// Restart daemon if running
|
|
185
|
+
const { getDaemonPid } = await import('./cli/helpers.js');
|
|
186
|
+
if (getDaemonPid()) {
|
|
187
|
+
const { execSync } = await import('node:child_process');
|
|
188
|
+
try {
|
|
189
|
+
execSync('beecork stop', { stdio: 'ignore' });
|
|
190
|
+
execSync('beecork start', { stdio: 'ignore' });
|
|
191
|
+
console.log(' Daemon restarted.');
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
console.log(' Restart daemon: beecork stop && beecork start');
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
168
199
|
const readline = await import('node:readline');
|
|
169
200
|
const fs = await import('node:fs');
|
|
170
201
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
171
202
|
const ask = (q, def) => new Promise(r => rl.question(def ? `${q} [${def}]: ` : `${q}: `, a => r(a.trim() || def || '')));
|
|
172
203
|
console.log('\nWhatsApp Setup\n');
|
|
173
|
-
console.log('
|
|
174
|
-
console.log('
|
|
175
|
-
console.log('
|
|
176
|
-
const number = await ask('Your WhatsApp
|
|
204
|
+
console.log(' You need two WhatsApp accounts:');
|
|
205
|
+
console.log(' 1. A bot account (separate SIM) — will scan the QR code to pair');
|
|
206
|
+
console.log(' 2. Your personal number — allowed to message the bot\n');
|
|
207
|
+
const number = await ask('Your personal WhatsApp number (the one that will message the bot, e.g., 14155551234)');
|
|
177
208
|
if (!number) {
|
|
178
209
|
console.log('No number provided. Cancelled.');
|
|
179
210
|
rl.close();
|
|
@@ -212,7 +243,7 @@ program
|
|
|
212
243
|
try {
|
|
213
244
|
const qrcodeTerminal = await import('qrcode-terminal');
|
|
214
245
|
(qrcodeTerminal.default || qrcodeTerminal).generate(update.qr, { small: true });
|
|
215
|
-
console.log('Scan the
|
|
246
|
+
console.log('Scan with the BOT phone (WhatsApp → Linked Devices → Link a Device)\n');
|
|
216
247
|
}
|
|
217
248
|
catch {
|
|
218
249
|
console.log('QR data:', update.qr);
|