From 7c793c4184af974729a71aa04be0eb0818ed2a79 Mon Sep 17 00:00:00 2001 From: Adhiraj Date: Sat, 13 Jun 2020 13:05:28 +0530 Subject: [PATCH 1/3] Update README.md --- README.md | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 388d6d3..93bf360 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,12 @@ If you require more functionality than provided, it'll super easy for you to write an extension (More on this at the end). ## Install - Create and cd to your NPM project directory and then in terminal, write: ``` npm install baileys ``` - Then import in your code using: - ``` javascript - const WhatsAppWeb = require('baileys') - ``` +Create and cd to your NPM project directory and then in terminal, write: ``` npm install baileys ``` +Then import in your code using: +``` javascript + const WhatsAppWeb = require('baileys') +``` + ## Connecting ``` javascript const client = new WhatsAppWeb() @@ -170,24 +171,25 @@ It's super simple ] ``` - Tested formats: png, jpeg, webp (sticker), mp4, ogg - `options` is a JSON object, providing some information about the message. It can have the following __optional__ values: - ``` javascript - info = { - caption: "hello there!", // (for media messages) the caption to send with the media (cannot be sent with stickers though) - thumbnail: "23GD#4/==", /* (for location & media messages) has to be a base 64 encoded JPEG if you want to send a custom thumb, - or set to null if you don't want to send a thumbnail. - Do not enter this field if you want to automatically generate a thumb + +The last parameter when sending messages is `info`, a JSON object, providing some information about the message. It can have the following __optional__ values: +``` javascript +info = { + caption: "hello there!", // (for media messages) the caption to send with the media (cannot be sent with stickers though) + thumbnail: "23GD#4/==", /* (for location & media messages) has to be a base 64 encoded JPEG if you want to send a custom thumb, + or set to null if you don't want to send a thumbnail. + Do not enter this field if you want to automatically generate a thumb + */ + mimetype: "application/pdf", /* (for media messages) specify the type of media (optional for all media types except documents), + for pdf files => set to "application/pdf", + for txt files => set to "application/txt" + etc. */ - mimetype: "application/pdf", /* (for media messages) specify the type of media (optional for all media types except documents), - for pdf files => set to "application/pdf", - for txt files => set to "application/txt" - etc. - */ - gif: true, // (for video messages) if the video should be treated as a GIF - quoted: quotedMessage, // the message you want to quote (can be used with sending all kinds of messages) - timestamp: Date() // optional, if you want to manually set the timestamp of the message - } - ``` + gif: true, // (for video messages) if the video should be treated as a GIF + quoted: quotedMessage, // the message you want to quote (can be used with sending all kinds of messages) + timestamp: Date() // optional, if you want to manually set the timestamp of the message +} +``` ``` id ``` is the WhatsApp id of the person or group you're sending the message to. From a109e321cbc4878137642cdce1325a5dfd9b3ea0 Mon Sep 17 00:00:00 2001 From: Adhiraj Singh Date: Sat, 13 Jun 2020 21:23:28 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 93bf360..c651df6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ Baileys has also been written from the ground up to be very extensible and simple to use. If you require more functionality than provided, it'll super easy for you to write an extension (More on this at the end). + + If you're interested in building a WhatsApp bot, you may wanna check out [WhatsAppInfoBot](https://github.com/adiwajshing/WhatsappInfoBot) and an actual bot built with it, [Messcat](https://github.com/adiwajshing/Messcat). ## Install Create and cd to your NPM project directory and then in terminal, write: ``` npm install baileys ``` From bc2889272fa5f2ee01d3eafbaae061c66eb789ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20de=20La=20Bourdonnaye?= Date: Sun, 14 Jun 2020 21:02:52 +0200 Subject: [PATCH 3/3] fix conversation result usage in loadEntireConversation In loadEntireConversation, json was an array of [result, request], now it only takes result into account --- WhatsAppWeb.Query.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WhatsAppWeb.Query.js b/WhatsAppWeb.Query.js index 850f5ff..14fdbff 100644 --- a/WhatsAppWeb.Query.js +++ b/WhatsAppWeb.Query.js @@ -102,7 +102,7 @@ module.exports = { const loadMessage = () => { return this.loadConversation(jid, chunkSize, offsetID, mostRecentFirst) - .then (json => { + .then (([json]) => { if (json[2]) { // callback with most recent message first (descending order of date) let lastMessage @@ -201,4 +201,4 @@ module.exports = { const json = ["query", "inviteCode", jid] return this.query (json).then (([json, _]) => json.code) } -} \ No newline at end of file +}