(sock: any, message: any, args: any, context: BotContext)
| 296 | adminOnly: true, |
| 297 | |
| 298 | async handler(sock: any, message: any, args: any, context: BotContext) { |
| 299 | const chatId = context.chatId || message.key.remoteJid; |
| 300 | const match = args.join(' ').toLowerCase(); |
| 301 | |
| 302 | if (!match) { |
| 303 | await showTyping(sock, chatId); |
| 304 | return sock.sendMessage(chatId, { |
| 305 | text: `*🤖 CHATBOT SETUP*\n\n` + |
| 306 | `*Storage:* ${HAS_DB ? 'Database' : 'File System'}\n` + |
| 307 | `*APIs:* ${API_ENDPOINTS.length} endpoints with fallback\n\n` + |
| 308 | `*Commands:*\n` + |
| 309 | `• \`.chatbot on\` - Enable chatbot\n` + |
| 310 | `• \`.chatbot off\` - Disable chatbot\n\n` + |
| 311 | `*How it works:*\n` + |
| 312 | `When enabled, bot responds when mentioned or replied to.\n\n` + |
| 313 | `*Features:*\n` + |
| 314 | `• Natural English conversations\n` + |
| 315 | `• Remembers context\n` + |
| 316 | `• Personality-based replies\n` + |
| 317 | `• Auto fallback if API fails`, |
| 318 | quoted: message |
| 319 | }); |
| 320 | } |
| 321 | |
| 322 | const data = await loadUserGroupData(); |
| 323 | |
| 324 | if (match === 'on') { |
| 325 | await showTyping(sock, chatId); |
| 326 | if (data.chatbot[chatId]) { |
| 327 | return sock.sendMessage(chatId, { |
| 328 | text: '⚠️ *Chatbot is already enabled for this group*', |
| 329 | quoted: message |
| 330 | }); |
| 331 | } |
| 332 | data.chatbot[chatId] = true; |
| 333 | await saveUserGroupData(data); |
| 334 | return sock.sendMessage(chatId, { |
| 335 | text: '✅ *Chatbot enabled!*\n\nMention me or reply to my messages to chat.', |
| 336 | quoted: message |
| 337 | }); |
| 338 | } |
| 339 | |
| 340 | if (match === 'off') { |
| 341 | await showTyping(sock, chatId); |
| 342 | if (!data.chatbot[chatId]) { |
| 343 | return sock.sendMessage(chatId, { |
| 344 | text: '⚠️ *Chatbot is already disabled for this group*', |
| 345 | quoted: message |
| 346 | }); |
| 347 | } |
| 348 | delete data.chatbot[chatId]; |
| 349 | await saveUserGroupData(data); |
| 350 | return sock.sendMessage(chatId, { |
| 351 | text: '❌ *Chatbot disabled!*\n\nI will no longer respond to mentions.', |
| 352 | quoted: message |
| 353 | }); |
| 354 | } |
| 355 |
nothing calls this directly
no test coverage detected