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

Function handler

plugins/stealth.ts:12–62  ·  view source on GitHub ↗
(sock: any, message: any, args: any, context: BotContext)

Source from the content-addressed store, hash-verified

10 ownerOnly: true,
11
12 async handler(sock: any, message: any, args: any, context: BotContext) {
13 const { chatId } = context;
14
15 const action = args[0]?.toLowerCase();
16
17 if (!action || !['on', 'off'].includes(action)) {
18 const currentState = await store.getSetting('global', 'stealthMode');
19 const status = currentState?.enabled ? 'ON' : 'OFF';
20
21 let autotypingWarning = '';
22 try {
23 const autotypingState = await store.getSetting('global', 'autotyping');
24 if (autotypingState?.enabled && currentState?.enabled) {
25 autotypingWarning = '\n\n⚠️ *Autotyping is enabled* but will be blocked by stealth mode.';
26 }
27 } catch(e: any) {}
28
29 let autoreadWarning = '';
30 try {
31 const autoreadState = await store.getSetting('global', 'autoread');
32 if (autoreadState?.enabled && currentState?.enabled) {
33 autoreadWarning = '\n⚠️ *Autoread is enabled* but will be blocked by stealth mode.';
34 }
35 } catch(e: any) {}
36
37 return await sock.sendMessage(chatId, {
38 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}`
39 }, { quoted: message });
40 }
41
42 const enabled = action === 'on';
43 await store.saveSetting('global', 'stealthMode', { enabled });
44
45 let warnings = '';
46 if (enabled) {
47 try {
48 const autotypingState = await store.getSetting('global', 'autotyping');
49 const autoreadState = await store.getSetting('global', 'autoread');
50
51 if (autotypingState?.enabled || autoreadState?.enabled) {
52 warnings = '\n\n*⚠️ Note:*\n';
53 if (autotypingState?.enabled) warnings += '• Autotyping is enabled but will be blocked\n';
54 if (autoreadState?.enabled) warnings += '• Autoread is enabled but will be blocked\n';
55 }
56 } catch(e: any) {}
57 }
58
59 await sock.sendMessage(chatId, {
60 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}`
61 }, { quoted: message });
62 }
63};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected