mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
added deleteChat
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
WAMetric,
|
||||
WAFlag,
|
||||
MessageLogLevel,
|
||||
WATag,
|
||||
} from '../WAConnection/Constants'
|
||||
|
||||
export default class WhatsAppWebBase extends WAConnection {
|
||||
@@ -75,8 +76,6 @@ export default class WhatsAppWebBase extends WAConnection {
|
||||
const response = await this.queryExpecting200(['query', 'ProfilePicThumb', jid || this.userMetaData.id])
|
||||
return response.eurl as string
|
||||
}
|
||||
/** Query broadcast list info */
|
||||
async getBroadcastListInfo(jid: string) { return this.queryExpecting200(['query', 'contact', jid]) as Promise<WABroadcastListInfo> }
|
||||
/** Get your contacts */
|
||||
async getContacts() {
|
||||
const json = ['query', { epoch: this.msgCount.toString(), type: 'contacts' }, null]
|
||||
@@ -103,6 +102,12 @@ export default class WhatsAppWebBase extends WAConnection {
|
||||
const json = ['query', { epoch: this.msgCount.toString(), type: 'chat' }, null]
|
||||
return this.query(json, [5, WAFlag.ignore]) // this has to be an encrypted query
|
||||
}
|
||||
/** Query broadcast list info */
|
||||
async getBroadcastListInfo(jid: string) { return this.queryExpecting200(['query', 'contact', jid]) as Promise<WABroadcastListInfo> }
|
||||
/** Delete the chat of a given ID */
|
||||
async deleteChat (jid: string) {
|
||||
return this.setQuery ([ ['chat', {type: 'delete', jid: jid}, null] ], [12, WAFlag.ignore]) as Promise<{status: number}>
|
||||
}
|
||||
/**
|
||||
* Check if your phone is connected
|
||||
* @param timeoutMs max time for the phone to respond
|
||||
@@ -181,8 +186,8 @@ export default class WhatsAppWebBase extends WAConnection {
|
||||
return loadMessage() as Promise<void>
|
||||
}
|
||||
/** Generic function for action, set queries */
|
||||
async setQuery (nodes: WANode[]) {
|
||||
async setQuery (nodes: WANode[], binaryTags: WATag = [WAMetric.group, WAFlag.ignore]) {
|
||||
const json = ['action', {epoch: this.msgCount.toString(), type: 'set'}, nodes]
|
||||
return this.queryExpecting200(json, [WAMetric.group, WAFlag.ignore]) as Promise<{status: number}>
|
||||
return this.queryExpecting200(json, binaryTags) as Promise<{status: number}>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,9 @@ WAClientTest('Groups', (client) => {
|
||||
it('should archive the group', async () => {
|
||||
await client.archiveChat(gid)
|
||||
})
|
||||
it('should delete the group', async () => {
|
||||
await client.deleteChat(gid)
|
||||
})
|
||||
})
|
||||
WAClientTest('Events', (client) => {
|
||||
it('should deliver a message', async () => {
|
||||
|
||||
Reference in New Issue
Block a user