mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Added within chat search + updated readme
This commit is contained in:
@@ -70,10 +70,11 @@ export default class WhatsAppWebMessages extends WhatsAppWebBase {
|
||||
/**
|
||||
* Search WhatsApp messages with a given text string
|
||||
* @param txt the search string
|
||||
* @param inJid the ID of the chat to search in, set to null to search all chats
|
||||
* @param count number of results to return
|
||||
* @param page page number of results
|
||||
* @param page page number of results (starts from 1)
|
||||
*/
|
||||
async searchMessages(txt: string, count: number, page: number) {
|
||||
async searchMessages(txt: string, inJid: string | null, count: number, page: number) {
|
||||
const json = [
|
||||
'query',
|
||||
{
|
||||
@@ -81,7 +82,8 @@ export default class WhatsAppWebMessages extends WhatsAppWebBase {
|
||||
type: 'search',
|
||||
search: txt,
|
||||
count: count.toString(),
|
||||
page: page.toString()
|
||||
page: page.toString(),
|
||||
jid: inJid
|
||||
},
|
||||
null,
|
||||
]
|
||||
|
||||
@@ -131,9 +131,12 @@ WAClientTest('Misc', (client) => {
|
||||
await client.modifyChat (testJid, ChatModification.unmute, {stamp: mutedate})
|
||||
})
|
||||
it('should return search results', async () => {
|
||||
const response = await client.searchMessages('Adh', 25, 0)
|
||||
assert.ok (response.messages)
|
||||
assert.ok (response.messages.length >= 0)
|
||||
const jids = [null, testJid]
|
||||
for (let i in jids) {
|
||||
const response = await client.searchMessages('Hello', jids[i], 25, 1)
|
||||
assert.ok (response.messages)
|
||||
assert.ok (response.messages.length >= 0)
|
||||
}
|
||||
})
|
||||
})
|
||||
WAClientTest('Groups', (client) => {
|
||||
|
||||
Reference in New Issue
Block a user