🕷Venom Bot🕸
Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
🕷🕷 Functions Venom🕷🕷
Automatic QR Refresh | ✔ |
Send text, image, video, audio and docs | ✔ |
Get contacts, chats, groups, group members,Block List | ✔ |
Send contacts | ✔ |
Send stickers | ✔ |
Multiple Sessions | ✔ |
Forward Messages | ✔ |
Receive message | ✔ |
📍 Send location!! | ✔ |
🕸🕸 and much more | ✔ |
Installation
> npm i --save venom-bot
Getting started
// Supports ES6// import { create, Whatsapp } from 'venom-bot';const venom = ; venom; { client;}
create()
function, venom will create an instance of whatsapp web. If you are not logged in, it will print a QR code in the terminal. Scan it with your phone and you are ready to go!
After executing Venom will remember the session so there is no need to authenticate everytime.
create()
function:
Multiples sessions can be created at the same time by pasing a session name to // Init sales whatsapp botvenom; // Init support whatsapp botvenom;
Optional create parameters
Venom create()
method third parameter can have the following optional parameters:
;
Callback Status Session
Gets the return if the session is isLogged
or if it is notLogged
;
Exporting QR Code
By default QR code will appear on the terminal. If you need to pass the QR somewhere else heres how:
const fs = ; // Second create() parameter is the QR callbackvenom; // Writes QR in specified path { qrCode = qrCode; const imageBuffer = Buffer; // Creates 'marketing-qr.png' file fs;}
Downloading Files
Puppeteer takes care of the file downloading. The decryption is being done as fast as possible (outruns native methods). Supports big files!
;; client;
Basic Functions (usage)
Not every available function is listed, for further look, every function available can be found in here and here
Chatting
chatId
could be <phoneNumber>@c.us
or <phoneNumber>-<groupId>@c.us
Here, // Send basic textawait client; // Send imageawait client; // Send @tagged messageawait client; // Reply to a messageawait client; // Reply to a message with mentionawait client; // Send file (venom will take care of mime types, just need the path)await client; // Send gifawait client; // Send contact// contactId: 52155334634@c.usawait client; // Forwards messagesawait client; //Generates sticker from the provided animated gif image and sends it (Send image as animated sticker)//image path imageBase64 A valid gif image is required. You can also send via http/https (http://www.website.com/img.gif)await client; //Generates sticker from given image and sends it (Send Image As Sticker)// image path imageBase64 A valid png, jpg and webp image is required. You can also send via http/https (http://www.website.com/img.jpg)await client; // Send locationawait client; // Send seen ✔️✔️await client; // Start typing...await client; // Stop typingawait client; // Set chat state (0: Typing, 1: Recording, 2: Paused)await client;
Retrieving Data
// Calls your list of blocked contacts (returns an array)const getBlockList = await client; // Retrieve contactsconst contacts = await client; // Retrieve all messages in chatconst allMessages = await client; // Retrieve contact statusconst status = await client; // Retrieve user profileconst user = await client; // Retrieve all unread messageconst messages = await client; // Retrieve all chatsconst chats = await client; // Retrieve all groupsconst chats = await client; // Retrieve profile fic (as url)const url = await client; // Retrieve chat/conversationconst chat = await client;
Group Functions
// groupId or chatId: leaveGroup 52123123-323235@g.us // Leave groupawait client; // Get group membersawait client; // Get group members idsawait client; // Generate group invite url linkawait client; // Create group (title, participants to add)await client; // Remove participantawait client; // Add participantawait client; // Promote participant (Give admin privileges)await client; // Demote particiapnt (Revoke admin privileges)await client; // Get group adminsawait client; // Return the group status, jid, description from it's invite linkawait client; // Join a group using the group invite codeawait client;
Profile Functions
// set your present online or offline, online = true | offline = false await client; // Set client statusawait client; // Set client profile nameawait client; // Set client profile photoawait client;
Device Functions
// Get device infoawait client; // Get connection stateawait client; // Get battery levelawait client; // Is connectedawait client; // Get whatsapp web versionawait client;
Events
// Listen to messagesclient // Listen to state changesclient; // Listen to ack'sclient; // Listen to live location// chatId: 'phone@c.us'client; // chatId looks like this: '5518156745634-1516512045@g.us'// Event interface is in here: https://github.com/s2click/venom/blob/master/src/api/model/participant-event.tsclient; // Listen when client has been added to a groupclient;
Other
// Delete chatawait client; // Clear chat messagesawait client; // Delete message (last parameter: delete only locally)await client; // Mark chat as not seen (returns true if it works)await client; //blocks a user (returns true if it works)await client; //unlocks contacts (returns true if it works)await client; // Retrieve a number profile / check if contact is a valid whatsapp numberconst profile = await client;
Misc
There are some tricks for a better usage of venom.
Keep session alive:
// In case of being logged out of whatsapp web// Force it to keep the current session// State changeclient;
Send message to new contacts (non-added)
Also see Whatsapp links Be careful since this can pretty much could cause a ban from Whatsapp, always keep your contacts updated!
await client;
Multiple sessions
If you need to run multiple sessions at once just pass a session name to
create()
method, not use hyphen for name of sessions.
async { const marketingClient = await venom; const salesClient = await venom; const supportClient = await venom;};
Closing (saving) sessions
Close the session properly to ensure the session is saved for the next time you log in (So it wont ask for QR scan again). So instead of CTRL+C,
// Catch ctrl+Cprocess; // Try-catch closetry ... catch error client;
Auto closing unsynced sessions
The auto close is enabled by default and the timeout is setted to 60 sec. Receives the time in milliseconds to countdown until paired.
autoClose
enabled the "refreshQR" parameter is changed to 1000 (1 sec.)!
Important with Use "autoClose: false" to disable auto closing.
Debugging
Development
Building venom is really simple altough it contians 3 main projects inside
- Wapi project
> npm run build:wapi
- Middleeware
> npm run build:middleware> npm run build:jsQR
- Venom
> npm run build:venom
To build the entire project just run
> npm run build
Maintainers
Maintainers are needed, I cannot keep with all the updates by myself. If you are interested please open a Pull Request.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.