Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
whats.js
Advanced tools
Readme
Whats.js is simple package that allow you to use whatsapp-web as nodejs client. Using @adiwajshing/baileys ( Modifed )
npm i whats.js@latest
Simple Source To Start Your Bot
const whatsapp = require("whats.js");
const client = new whatsapp();
Simple Ready Event Listener
const whatsapp = require("whats.js");
const client = new whatsapp();
client.once("ready",async client=>{
console.log(`Account Is Ready , Number : ${client.user.number} , Name : ${client.user.name}`);
})
Simple Message Event Listener
const whatsapp = require("whats.js");
const client = new whatsapp();
client.on("message",async message=>{
if(message.content =="Hi"){
await message.markAsRead(); // Mark The Message As Read
message.reply("Hello World"); // Reply In Same Channel "Group/UserDM"
message.reply("Don't Tell AnyOne But Im a bot ...",true); // Reply In DM.
}
})
PROPERTIES | METHODS | EVENTS |
---|---|---|
login | ready | |
message | ||
messageUpdate | ||
messageDelete | ||
reactionCreate |
Emitted when the client becomes ready to start working.
PARAMETER | TYPE | DESCRIPTION |
---|---|---|
client | User | The Client Data |
Emitted whenever a message is created.
PARAMETER | TYPE | DESCRIPTION |
---|---|---|
message | Message | The Created Message Data |
* Event Still Not Ready Yet.
* Event Still Not Ready Yet.
* Event Still Not Ready Yet.
Call This Function To Login The Client To WA-WEB Socket Server Required *
client.login();
An Object For User's Data.
PROPERTIES | METHODS |
---|---|
id | send |
Number | startActivity |
name |
.id
Current Client's ID As String
.
.number
Current Client's Number As String
.
.name
Current Client's Name As String
.
.send(MessageTypes)
Send A Message To User With Parameter MessageTypes
or String
Required *, Return MessageClass
Of New Message Sent By Client (Cause Circular Class Error Deprecated).
await user.send(`Hi There Using Whats.js 💜.`); // Content OR MessageType Object.
.startActivity(activity)
Start Activity In Current User's DM Such As Typing,Recording,...etc String
.
await user.startActivity(`recording`); // Client Will Show Recording Status At The User's Dm
An Object of Message instanse.
PROPERTIES | METHODS |
---|---|
content | reply |
id | markAsRead |
Author | react |
channel | unReact |
media | forward |
isMediaMessage | |
isButtonResponse | |
isListResponse |
.content
Returns Message Content As String
.
.id
Returns Message ID As String
.
.reply(MessageTypes,Dm)
Reply To Message With Parameters MessageTypes
or String
Required * And Reply In Dm Boolean
, Return MessageClass
Of New Message Sent By Client.
await message.reply(`Hi There Using Whats.js 💜.`,true); // First Content OR MessageType Object, Then Boolean True Or False (Default).
.markAsRead()
Mark A Message As Read (Two blue Ticks), No Parameters.
await message.markAsRead();
.react(Emoji)
React To A Message With An Emoji, Parameters String
Emoji Default : 👀.
await message.react("🍟"); // Fries Are The Best.
.unReact()
UnReact To Previous Reacted Message.
await message.unReact();
.forward(User)
Forward Message To Another User Parameter Must Be User
Required * .
await message.forward(myOtherAccount);
.isMediaMessage()
Returns True
When Its Media Message.
Returns True
When Its Button Response.
.isListResponse()
Returns True
When Its List Response.
PROPERTIES | METHODS |
---|---|
id | send |
startActivity | |
awaitMessages |
Returns Channel ID As String
.
.send(MessageTypes)
Send A Message In Channel With Parameter MessageTypes
or String
Required *, Return MessageClass
Of New Message Sent By Client (Cause Circular Class Error Deprecated).
await channel.send(`Hi There Using Whats.js 💜.`); // Content OR MessageType Object.
.startActivity(activity)
Start Activity In Current Channel Such As Typing,Recording,...etc String
.
await user.startActivity(`recording`); // Client Will Show Recording Status At The Channel
.awaitMessages(filter,maxResults,time)
Create A Message Collector With Filter And Max Results And Time. Parameters Function
Of Messages Filter, Number
Max Number Of Results Collected, Time To Stop Collecting Messages.
let filter = message=> !isNaN(message.content);
let collected = await channel.awaitMessages(filter,1,10000); // Collect Only One Number Content Message In 10,000ms = 10s;
console.log(collected);
PROPERTIES | METHODS |
---|---|
name | isAudio |
format | isImage |
isVideo | |
buffer | |
saveFile |
.name
Returns Media File Name As String
.
.format
Returns Media File Format As String
.
.isAudio()
Returns True
If Media File Is An Audio File.
.isImage()
Returns True
If Media File Is An Image File.
.isVideo()
Returns True
If Media File Is A Video File.
.buffer()
Async Function That Returns Buffer
Of The Media File.
await media.buffer(); // returns Buffer.
.saveFile(fileName,path)
Save File In Certain Path And Name Parameters FileName String
, Path String
Default : fileName = Media.name, path = Root Project Path.
await media.saveFile("Video.mp4","./videos");
unavailable
, available
, composing
, recording
, paused
This Class Can Be Used To Send A File With .send(MessageTypes)
/.send(MessageTypes)
/.reply(MessageTypes)
const attachment = new client.MessageAttachment(path,fileName);
message.reply(Attachment);
This Type Of Messages Doesn't Show Up For Other WA User Anymore So Its Deprecated *
This is A contact Card Message, Users Can Add Any Contact Quickly Using This Type Of Message.
const contact = new client.MessageContact().setContactName("WA.js Developer").addContact("ASTA","967778117520","X Design Co."); // Parameters Can Be Used Within Class Constructor
message.reply(contact);
This is A Location On Map Message, You Can Send A Location Using The Latitude,Longitude.
const location = new client.MessageLocation(48.05,12.85); // Latitude,Longitude
channel.send(location);
// Markdowns Will Be More Detailed Soon I Want To Sleep Now LoL
FAQs
a simple whatsapp package interface same as discord.js
The npm package whats.js receives a total of 361 weekly downloads. As such, whats.js popularity was classified as not popular.
We found that whats.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.