{"id":14986977,"url":"https://github.com/hacxk/whatsappbottemplate","last_synced_at":"2025-06-14T23:04:16.359Z","repository":{"id":244182016,"uuid":"814502978","full_name":"hacxk/WhatsappBotTemplate","owner":"hacxk","description":"A simple WhatsApp user bot written in JavaScript using the Baileys library. This bot can interact with groups, channels, and normal messages. Also you can modify as your need!","archived":false,"fork":false,"pushed_at":"2024-10-09T07:05:12.000Z","size":252,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-14T00:02:51.380Z","etag":null,"topics":["automation","baileys-bot","baileys-md","hacxk","hacxkmd","javascript","md","multidevice","nodejs","ownbot","userbot","whatsapp","whatsapp-bot-md","whatsapp-web","whatsappbot"],"latest_commit_sha":null,"homepage":"https://whatsapp.com/channel/0029Vahkcya1SWt1EzYAg43I","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hacxk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-13T06:31:28.000Z","updated_at":"2024-10-09T07:05:15.000Z","dependencies_parsed_at":"2024-06-26T20:13:29.450Z","dependency_job_id":"391cc237-740b-4ba0-af0f-4458dbaca32d","html_url":"https://github.com/hacxk/WhatsappBotTemplate","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"85a6ccfc6976a58738ffb6abb0f7860ec0b418ce"},"previous_names":["hacxk/whatsappbottemplate"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacxk%2FWhatsappBotTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacxk%2FWhatsappBotTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacxk%2FWhatsappBotTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hacxk%2FWhatsappBotTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hacxk","download_url":"https://codeload.github.com/hacxk/WhatsappBotTemplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219850450,"owners_count":16556318,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","baileys-bot","baileys-md","hacxk","hacxkmd","javascript","md","multidevice","nodejs","ownbot","userbot","whatsapp","whatsapp-bot-md","whatsapp-web","whatsappbot"],"created_at":"2024-09-24T14:13:54.236Z","updated_at":"2024-10-14T00:02:59.096Z","avatar_url":"https://github.com/hacxk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# 🤖 WhatsAppBotTemplate\n\nA simple and elegant WhatsApp bot written in JavaScript using the Baileys library. This bot can interact with groups, channels, and normal messages. Customize it to your heart's content! 🌟✨\n\n## 🚀 Create Your Own WhatsApp Bot\n\n---\n\n\u003e [!CAUTION]\n\u003e\n\u003e First You Need to Install [NodeJS](https://nodejs.org/en) in your bot building environment.\n\n---\n\n### 🛠️ Setup Instructions\n\nFollow these magical steps to create and customize your very own WhatsApp bot:\n\n1. **🧙‍♂️ Clone the Repository**\n   ```bash\n   git clone https://github.com/hacxk/WhatsappBotTemplate.git\n   ```\n\n2. **📦 Install Dependencies**\n   ```bash\n   cd WhatsappBotTemplate\n   npm install\n   ```\n\n3. **⚙️ Configure the Bot**\n   - Open the `config.js` file and add your WhatsApp account details if needed.\n\n4. **🎉 Run the Bot**\n   ```bash\n   node index.js\n   ```\n\n### 🔮 Creating a Command\n\n\u003e [!NOTE]\n\u003e\n\u003e If you want more help join our whatsapp channel [HACXK MD 🙋‍♂️](https://whatsapp.com/channel/0029Vahkcya1SWt1EzYAg43I).\n\nTo create a new command, follow this enchanting structure. Each command is a module that exports an object with specific properties and an `execute` function. ✨\n\n\u003e 📝 To create a command, first create a `filename.js` in the Plugins folder.\n\n\u003e [!NOTE]\n\u003e\n\u003e Don't Need to Restart Whole NodeJS Process When Make Changes in Plugin Folder Commands (!Only Works New Update).\n\n```javascript\nmodule.exports = {\n    usage: ['Hi'], // 🎯 Command usage trigger\n    description: 'Say hello!', // 📜 Description of the command\n    emoji: '👋', // 🎨 Emoji associated with the command\n    isGroupOnly: false, // 👥 Set to true if the command should only work in groups\n    isChannelOnly: false, // 📢 Set to true if the command should only work in channels\n    isWorkAll: true, // 🌍 Set to true if the command should work all type\n    async execute(sock, m, args) {\n        // 🧠 The function to be executed when the command is called\n        await hacxk.reply('Hello! 👋', m);\n    }\n};\n```\n\n### 🔍 Explanation of Command Properties\n\n- **`usage`**: 🎯 An array of strings that represent the triggers for this command.\n- **`description`**: 📜 A brief description of what the command does.\n- **`emoji`**: 🎨 An emoji to visually represent the command.\n- **`isGroupOnly`**: 👥 A boolean indicating if the command should only work in group chats.\n- **`isChannelOnly`**: 📢 A boolean indicating if the command should only work in channels.\n- **`isWorkAll`**:👥 A boolean indicating if the command work in all mode (private/group/channels)\n- **`execute(sock, m, args)`**: The main function that gets executed when the command is called. It takes the following parameters:\n  - `sock`: The WhatsApp socket instance.\n  - `m`: The message object that triggered the command.\n  - `args`: An array of arguments passed to the command.\n\n---\n\n### 💬 Sending Messages\n\nYou can send different types of messages using the bot. Here are the supported types:\n\n1. **📝 Normal Text Messages**\n   ```javascript\n   await hacxk.reply(text, m);\n   ```\n\n      - `text`: The text message you want to send.\n   - `m`: The message you want to reply to.\n\n2. **😄 React to Messages**\n   ```javascript\n   await hacxk.react(emoji, m);\n   ```\n\n     - `emoji`: The emoji reaction.\n   - `m`: The message you want to react to.\n\n3. **🖼️ Image Messages**\n   ```javascript\n   await hacxk.Image(imageBuffer, m, caption);\n   ```\n\n      - `imageBuffer`: The image buffer you want to send.\n   - `m`: The message you want to reply to.\n   - `caption`: (Optional) A caption for the image.\n\n4. **🎵 Audio Messages**\n   ```javascript\n   await hacxk.Audio(audioBuffer, m);\n   ```\n\n      - `audioBuffer`: The audio buffer you want to send.\n   - `m`: The message you want to reply to.\n\n---\n\n# ✨ Event Listener: Your Baileys Bot ✨\n\n🚀 This module lets you listen for specific events and react with custom actions.\n\n🎉 **Why Use Event Listeners?**\n\n* 🎯 **Precision:** Respond only to the events you care about.\n* ⚡️ **Efficiency:** Your bot doesn't have to constantly check for things.\n* 🧠 **Flexibility:** Build complex interactions and workflows.\n\n# 📖 Event Handling with HacxK\n\nWelcome to the HacxK event handling guide! This guide will walk you through the process of setting up and using event listeners in your bot using the `HacxK` event emitter.\n\n## 💡 How It Works\n\n1. **Import HacxK:**  \n   The `HacxK` object is your gateway to event handling.\n   ```javascript\n   const { HacxK } = require('../Lib/EventsHandle/EventsHandle'); // Import the HacxK event emitter\n   ```\n\n2. **Choose Your Event:**  \n   We'll focus on the `hacxk.messages` event, which triggers when a new message is received.\n   ```javascript\n   HacxK.on('hacxk.messages', listener);\n   ```\n\n3. **Create a Listener:**  \n   Write a function to define how your bot should react when the event occurs.\n   ```javascript\n   // Example Function! You Can Also Write Your Own Function/Logic\n   // 👂 Listen for \"Hello!\" replies only once\n   const listener = async (message) =\u003e {\n       if (message.message \u0026\u0026 message.message.conversation \u0026\u0026 message.message.conversation.toLowerCase() === 'hello!') {\n           await sock.sendMessage(message.key.remoteJid, { text: 'Yo! How can I help you?' }, { quoted: message });\n           HacxK.off('hacxk.messages', listener); // Stop listening after responding\n       }\n   };\n\n   HacxK.on('hacxk.messages', listener);\n   ```\n\n4. **Attach the Listener:**  \n   Use `HacxK.on` to connect your function to the event.\n   ```javascript\n   HacxK.on('hacxk.messages', listener);\n   ```\n\n5. **(Optional) Remove the Listener:**  \n   For one-time actions, use `HacxK.off` to stop listening after you've reacted.\n   ```javascript\n   HacxK.off('hacxk.messages', listener); // Stop listening after responding\n   ```\n`\n\n## 🛠️ Example: A Friendly Greeting Bot\n\n```javascript\nconst { HacxK } = require('../Lib/EventsHandle/EventsHandle');\n\nmodule.exports = {\n    usage: ['Hi', 'Hello'],\n    description: 'Say hello!',\n    emoji: '👋',\n    isGroupOnly: true,\n    isChannelOnly: true,\n    isWorkAll: false,\n    async execute(sock, m, args) {\n        await sock.sendMessage(m.key.remoteJid, { text: 'Hello! 👋' }, { quoted: m });\n\n        // Listen for specific messages once and then stop listening\n        const listener = async (message) =\u003e {\n            if (message.message \u0026\u0026 message.message.conversation \u0026\u0026 message.message.conversation.toLowerCase() === 'Hello!') {\n                await sock.sendMessage(message.key.remoteJid, { text: 'Yo How Can I Help! You.' }, { quoted: message });\n                HacxK.off('hacxk.messages', listener); // Remove the listener\n            }\n        };\n\n        HacxK.on('hacxk.messages', listener);\n    }\n};\n\n```\n\n---\n\n## 💡 Example Commands\n\nHere's an example of a simple \"Hello\" command to get you started:\n\n```javascript\nconst { HacxK } = require('../Lib/EventsHandle/EventsHandle');\n\nmodule.exports = {\n    usage: ['Hi', 'Hello'],\n    description: 'Say hello!',\n    emoji: '👋',\n    isGroupOnly: true,\n    isChannelOnly: true,\n    isWorkAll: false,\n    async execute(sock, m, args) {\n        await sock.sendMessage(m.key.remoteJid, { text: 'Hello! 👋' }, { quoted: m });\n\n        // Listen for specific messages once and then stop listening\n        const listener = async (message) =\u003e {\n            if (message.message \u0026\u0026 message.message.conversation \u0026\u0026 message.message.conversation.toLowerCase() === 'Hello!') {\n                await sock.sendMessage(message.key.remoteJid, { text: 'Yo How Can I Help! You.' }, { quoted: message });\n                HacxK.off('hacxk.messages', listener); // Remove the listener\n            }\n        };\n\n        HacxK.on('hacxk.messages', listener);\n    }\n};\n\n```\n\nThis command will reply with \"Hello there! 👋 How can I assist you today?\" whenever someone types \"Hello\".\n\n---\n\n## 🤝 Contributing\n\nContributions are welcome! If you have ideas to improve this bot, feel free to open an issue or submit a pull request on GitHub. \n\n---\n\n## 📄 License\n\nThis project is licensed under the MIT License. See the LICENSE file for more details.\n\n---\n\nStay connected and have fun with your new WhatsApp bot! 🚀💬\n\n![WhatsApp Bot](https://example.com/your-image-link.jpg)\n\n---\n\n### 🛠️ Additional Helper Functions\n\nBelow is a utility to handle sending messages and updating presence status. It includes handling for sending text, image, audio, and reaction messages.\n\n```javascript\nconst delay = ms =\u003e new Promise(resolve =\u003e setTimeout(resolve, ms));\n\nasync function sendMessageHandle(sock) {\n    if (!sock) {\n        throw new Error(\"Socket not provided\");\n    }\n\n    try {\n        if (!global.hacxk) {\n            global.hacxk = {\n                reply: async (text, m) =\u003e {\n                    try {\n                        if (!m || !m.key) {\n                            throw new Error(\"Message object or key is not available\");\n                        }\n                        if (m.key.remoteJid.endsWith('@newsletter')) {\n                            await sock.sendMessage(m.key.remoteJid, { text: text });\n                        } else {\n                            await sock.readMessages([m.key]);\n                            await sock.sendPresenceUpdate('composing', m.key.remoteJid);\n                            await delay(500);\n                            const message = await sock.sendMessage(m.key.remoteJid, { text: text }, { quoted: m });\n                            await sock.sendPresenceUpdate('available', m.key.remoteJid);\n                            return message;\n                        }\n                    } catch (error) {\n                        console.error(\"Failed to send reply:\", error);\n                        throw error;\n                    }\n                },\n\n                react: async (emoji, m) =\u003e {\n                    try {\n                        if (!m || !m.key || !emoji) {\n                            throw new Error(\"Message object or key or Emoji is not available\");\n                        }\n                        await sock.readMessages([m.key]);\n                        await sock.sendPresenceUpdate('composing', m.key.remoteJid);\n                        await delay(500);\n                        const message = await sock.sendMessage(m.key.remoteJid, { react: { text: emoji, key: m.key } });\n                        await sock.sendPresenceUpdate('available', m.key.remoteJid);\n                        return message;\n                    } catch (error) {\n                        console.error(\"Failed to send Reaction:\", error);\n                        throw error;\n                    }\n                },\n\n                Image: async (imageBuffer, m, caption) =\u003e {\n                    try {\n                        if (!imageBuffer || !m || !m.key) {\n                            throw new Error(\"Image buffer, message object, or key is not available\");\n                        }\n\n                        await sock.readMessages([m.key]);\n                        await sock.sendPresenceUpdate('composing', m.key.remoteJid);\n                        await delay(500);\n                        const message = await sock.sendMessage(m.key.remoteJid, { image: imageBuffer, caption: caption }, { quoted: m });\n                        await sock.sendPresenceUpdate('available', m.key.remoteJid);\n                        return message;\n                    } catch (error) {\n                        console.error(\"Failed to send image:\", error);\n                        throw error;\n                    }\n                },\n\n                Audio: async (audioBuffer, m) =\u003e {\n                    try {\n                        if (!audioBuffer || !m || !m.key) {\n                            throw new Error(\"Audio buffer, message object, or key is not available\");\n                        }\n\n                        await sock.readMessages([m.key]);\n                        await sock.sendPresenceUpdate('recording', m.key.remoteJid);\n                        await delay(500);\n                        const message = await sock.sendMessage(m.key.remoteJid, { audio: audioBuffer, mimetype: 'audio/mp4' }, { quoted: m });\n                        await sock.sendPresenceUpdate('available', m.key.remoteJid);\n                        return message;\n                    } catch (error) {\n                        console.error(\"Failed to send audio:\", error);\n                        throw error;\n                    }\n                }\n            };\n        }\n    } catch (error) {\n        console.error(\"Error initializing global send object:\", error);\n        throw error;\n    }\n}\n\nmodule.exports = { sendMessageHandle };\n\n```\n\n---\n\n## 🌟 Features\n\n- 🔌 Easy to set up and use\n- 🛠️ Highly customizable\n- 👥 Works in groups, channels, and private chats\n- 🖼️ Supports text, image, and audio messages\n- 😄 React to messages with emojis\n- 🚀 Extendable command system\n\n---\n\n## 📚 Documentation\n\nFor more detailed information on how to use and extend this bot, check out our [Wiki](https://github.com/hacxk/WhatsappBotTemplate/wiki).\n\n---\n\n## 🐛 Bug Reports\n\nFound a bug? Please report it in the [Issues](https://github.com/hacxk/WhatsappBotTemplate/issues) section of our GitHub repository.\n\n---\n\n## 💖 Support the Project\n\nIf you find this project helpful, consider giving it a star ⭐ on GitHub!\n\n---\n\nHappy Botting! 🤖💬✨","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacxk%2Fwhatsappbottemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhacxk%2Fwhatsappbottemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhacxk%2Fwhatsappbottemplate/lists"}