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

Function handler

plugins/antitag.js:84–170  ·  view source on GitHub ↗
(sock, message, args, context)

Source from the content-addressed store, hash-verified

82 groupOnly: true,
83 adminOnly: true,
84 async handler(sock, message, args, context) {
85 const chatId = context.chatId || message.key.remoteJid;
86 const action = args[0]?.toLowerCase();
87 if (!action) {
88 const config = await getAntitag(chatId, 'on');
89 await sock.sendMessage(chatId, {
90 text: `*🏷️ ANTITAG SETUP*\n\n` +
91 `*Current Status:* ${config?.enabled ? '✅ Enabled' : '❌ Disabled'}\n` +
92 `*Current Action:* ${config?.action || 'Not set'}\n\n` +
93 `*Commands:*\n` +
94 `• \`.antitag on\` - Enable\n` +
95 `• \`.antitag off\` - Disable\n` +
96 `• \`.antitag set delete\` - Delete tagall messages\n` +
97 `• \`.antitag set kick\` - Kick users who tagall\n\n` +
98 `*Detection:*\n` +
99 `• Detects mentions of 50%+ members\n` +
100 `• Catches bot tagall patterns\n` +
101 `• Protects against spam tagging`
102 }, { quoted: message });
103 return;
104 }
105 switch (action) {
106 case 'on':
107 const existingConfig = await getAntitag(chatId, 'on');
108 if (existingConfig?.enabled) {
109 await sock.sendMessage(chatId, {
110 text: '⚠️ *Antitag is already enabled*'
111 }, { quoted: message });
112 return;
113 }
114 const result = await setAntitag(chatId, 'on', 'delete');
115 await sock.sendMessage(chatId, {
116 text: result
117 ? '✅ *Antitag enabled successfully!*\n\nDefault action: Delete tagall messages'
118 : '❌ *Failed to enable antitag*'
119 }, { quoted: message });
120 break;
121 case 'off':
122 await removeAntitag(chatId, 'on');
123 await sock.sendMessage(chatId, {
124 text: '❌ *Antitag disabled*\n\nUsers can now tag all members.'
125 }, { quoted: message });
126 break;
127 case 'set':
128 if (args.length < 2) {
129 await sock.sendMessage(chatId, {
130 text: '❌ *Please specify an action*\n\nUsage: `.antitag set delete | kick`'
131 }, { quoted: message });
132 return;
133 }
134 const setAction = args[1].toLowerCase();
135 if (!['delete', 'kick'].includes(setAction)) {
136 await sock.sendMessage(chatId, {
137 text: '❌ *Invalid action*\n\nChoose: delete or kick'
138 }, { quoted: message });
139 return;
140 }
141 const setResult = await setAntitag(chatId, 'on', setAction);

Callers

nothing calls this directly

Calls 3

getAntitagFunction · 0.90
setAntitagFunction · 0.90
removeAntitagFunction · 0.90

Tested by

no test coverage detected