vasani-arpit / WBOT

A simple Web based BOT for WhatsApp™ in NodeJS 😜. Working as of 📅 Feb 4th, 2024
Other
986 stars 314 forks source link

Checking Validity of a Whatsapp Number #206

Closed tradename closed 3 years ago

tradename commented 3 years ago

have made a small modification to : WAPI.sendMessage2(message.chatId._serialized, itemResponse.text);

to: WAPI.sendMessage2(itemResponse.to, itemResponse.text);

Now How can i check if itemResponse.to is a valid whatsapp number before i execute WAPI.sendMessage2(itemResponse.to, itemResponse.text);

vasani-arpit commented 3 years ago

AFAIK you can not check it without sending a message. I suggest you to send a test message and if the function returns with false then it is not a WhatsApp number and if it returns with true then it is a WhatsApp number. but be cautious about this. if you query for so many numbers like this then there is a high amount of chances that your number might get banned.

tradename commented 3 years ago

Its not then sending a message if the number is not saved and or never had a chat with the number, sendMessage and sendMessage2 won't send to non contacts, any other way i can go about it?

vasani-arpit commented 3 years ago

I have seen people using sendMessage2 for that use case. haven't tried myself but it works for others.

tradename commented 3 years ago

okay thanks, thoush i have tried sendMessage2 to a valid whatsapp number number@c.us but wont send unless i save it first

vasani-arpit commented 3 years ago

In that case use https://contacts.google.com/ to save the phone number remotely.

vasani-arpit commented 3 years ago

a new version has a function now to check the number.

WAPI.checkNumberStatus("XXXXXXXXXX@c.us",function(){console.log(arguments[0])})
vasani-arpit commented 3 years ago

@tradename

tradename commented 3 years ago

Thanks so much. working perfect

ChinkyPrinceCarey commented 3 years ago

@vasani-arpit

Firstly, thanks a lot for this WBOT!

Do I have to be cautious when using checkNumberStatus method? I thought that method works if I have valid contact saved on my mobile, but it seems like even if I don't have a contact saved on my mobile, it checks and giving the correct output.

Could you tell me, how checkNumberStatus method actually works?

vasani-arpit commented 3 years ago

@ChinkyPrinceCarey checkNumbStatus checked for the number in WA database and returns if the number is WA number or not.

yes be cautious with this make sure you don't send too much requests. WA might be checking how many requests are coming from which number if it exceeds certain threshold and time then it might ban your number. less then 900 in 12 hour would be an idle number. I am just guessing based on what people have reported.