MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / handler

Function handler

plugins/stealth.js:9–55  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

7 usage: '.stealth <on|off>',
8 ownerOnly: true,
9 async handler(sock, message, args, context) {
10 const { chatId } = context;
11 const action = args[0]?.toLowerCase();
12 if (!action || !['on', 'off'].includes(action)) {
13 const currentState = await store.getSetting('global', 'stealthMode');
14 const status = currentState?.enabled ? 'ON' : 'OFF';
15 let autotypingWarning = '';
16 try {
17 const autotypingState = await store.getSetting('global', 'autotyping');
18 if (autotypingState?.enabled && currentState?.enabled) {
19 autotypingWarning = '\n\n⚠️ *Autotyping is enabled* but will be blocked by stealth mode.';
20 }
21 }
22 catch (e) { }
23 let autoreadWarning = '';
24 try {
25 const autoreadState = await store.getSetting('global', 'autoread');
26 if (autoreadState?.enabled && currentState?.enabled) {
27 autoreadWarning = '\n⚠️ *Autoread is enabled* but will be blocked by stealth mode.';
28 }
29 }
30 catch (e) { }
31 return await sock.sendMessage(chatId, {
32 text: `👻 *Stealth Mode Status:* ${status}\n\n*Usage:* .stealth <on|off>\n\n*What it does:*\n• Blocks all presence updates (typing, online, last seen)\n• Makes the bot completely invisible\n\n*When enabled:*\n✓ No "typing..." indicator\n✓ No "online" status\n✓ Complete stealth mode${autotypingWarning}${autoreadWarning}`
33 }, { quoted: message });
34 }
35 const enabled = action === 'on';
36 await store.saveSetting('global', 'stealthMode', { enabled });
37 let warnings = '';
38 if (enabled) {
39 try {
40 const autotypingState = await store.getSetting('global', 'autotyping');
41 const autoreadState = await store.getSetting('global', 'autoread');
42 if (autotypingState?.enabled || autoreadState?.enabled) {
43 warnings = '\n\n*⚠️ Note:*\n';
44 if (autotypingState?.enabled)
45 warnings += '• Autotyping is enabled but will be blocked\n';
46 if (autoreadState?.enabled)
47 warnings += '• Autoread is enabled but will be blocked\n';
48 }
49 }
50 catch (e) { }
51 }
52 await sock.sendMessage(chatId, {
53 text: `👻 Stealth mode has been turned *${enabled ? 'ON' : 'OFF'}*\n\n${enabled ? '✓ Bot is now in complete stealth mode\n✓ No presence updates\n✓ No typing indicators' : '✓ Presence updates enabled\n✓ Typing indicators enabled (if autotyping is on)'}${warnings}`
54 }, { quoted: message });
55 }
56};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected