diff --git a/README.md b/README.md index 0359da7..5aea93f 100644 --- a/README.md +++ b/README.md @@ -306,7 +306,7 @@ await conn.sendMessage( ### Notes - `id` is the WhatsApp ID of the person or group you're sending the message to. - - It must be in the format ```[country code][phone number]@s.whatsapp.net```, for example ```+19999999999@s.whatsapp.net``` for people. For groups, it must be in the format ``` 123456789-123345@g.us ```. + - It must be in the format ```[country code without +][phone number]@s.whatsapp.net```, for example ```19999999999@s.whatsapp.net``` for people. For groups, it must be in the format ``` 123456789-123345@g.us ```. - For broadcast lists it's `[timestamp of creation]@broadcast`. - For stories, the ID is `status@broadcast`. - For media messages, the thumbnail can be generated automatically for images & stickers. Thumbnails for videos can also be generated automatically, though, you need to have `ffmpeg` installed on your system. diff --git a/src/WAConnection/5.User.ts b/src/WAConnection/5.User.ts index 9d04c4f..5509ac2 100644 --- a/src/WAConnection/5.User.ts +++ b/src/WAConnection/5.User.ts @@ -19,33 +19,9 @@ export class WAConnection extends Base { * @returns undefined if the number doesn't exists, otherwise the correctly formatted jid */ isOnWhatsApp = async (str: string) => { - if (this.state !== 'open') { - return this.isOnWhatsAppNoConn(str) - } const { status, jid, biz } = await this.query({json: ['query', 'exist', str], requiresPhoneConnection: false}) if (status === 200) return { exists: true, jid: whatsappID(jid), isBusiness: biz as boolean} } - /** - * Query whether a given number is registered on WhatsApp, without needing to open a WS connection - * @param str phone number/jid you want to check for - * @returns undefined if the number doesn't exists, otherwise the correctly formatted jid - */ - isOnWhatsAppNoConn = async (str: string) => { - let phone = str.split('@')[0] - const url = `https://wa.me/${phone}` - const response = await this.fetchRequest(url, 'GET', undefined, undefined, undefined, false) - const loc = response.headers.location as string - if (!loc) { - this.logger.warn({ url, status: response.statusCode }, 'did not get location from request') - return - } - const locUrl = new URL('', loc) - if (!locUrl.pathname.endsWith('send/')) { - return - } - phone = locUrl.searchParams.get('phone') - return { exists: true, jid: `${phone}@s.whatsapp.net` } - } /** * Tell someone about your presence -- online, typing, offline etc. * @param jid the ID of the person/group who you are updating