mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
Added method to update the profile name
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as QR from 'qrcode-terminal'
|
||||
import { WAConnection as Base } from './3.Connect'
|
||||
import { WAMessageStatusUpdate, WAMessage, WAContact, WAChat, WAMessageProto, WA_MESSAGE_STUB_TYPE, WA_MESSAGE_STATUS_TYPE, PresenceUpdate, BaileysEvent, DisconnectReason, WAOpenResult, Presence, AuthenticationCredentials, WAParticipantAction, WAGroupMetadata, WAUser, WANode, WAPresenceData, WAChatUpdate, BlocklistUpdate } from './Constants'
|
||||
import { WAMessageStatusUpdate, WAMessage, WAContact, WAChat, WAMessageProto, WA_MESSAGE_STUB_TYPE, WA_MESSAGE_STATUS_TYPE, PresenceUpdate, BaileysEvent, DisconnectReason, WAOpenResult, Presence, AuthenticationCredentials, WAParticipantAction, WAGroupMetadata, WAUser, WANode, WAPresenceData, WAChatUpdate, BlocklistUpdate, WAContactUpdate } from './Constants'
|
||||
import { whatsappID, unixTimestampSeconds, isGroupID, GET_MESSAGE_ID, WA_MESSAGE_ID, waMessageKey, newMessagesDB, shallowChanges, toNumber } from './Utils'
|
||||
import KeyedDB from '@adiwajshing/keyed-db'
|
||||
import { Mutex } from './Mutex'
|
||||
@@ -298,10 +298,21 @@ export class WAConnection extends Base {
|
||||
}
|
||||
})
|
||||
// status updates
|
||||
this.on('CB:Status', async json => {
|
||||
this.on('CB:Status,status', async json => {
|
||||
const jid = whatsappID(json[1].id)
|
||||
this.emit ('contact-update', { jid, status: json[1].status })
|
||||
|
||||
// emit deprecated
|
||||
this.emit ('user-status-update', { jid, status: json[1].status })
|
||||
})
|
||||
// User Profile Name Updates
|
||||
this.on ('CB:Conn,pushname', json => {
|
||||
if (this.user) {
|
||||
const name = json[1].pushname
|
||||
this.user.name = name // update on client too
|
||||
this.emit ('contact-update', { jid: this.user.jid, name })
|
||||
}
|
||||
})
|
||||
// read updates
|
||||
this.on ('CB:action,,read', async json => {
|
||||
const update = json[2][0][1]
|
||||
@@ -351,7 +362,6 @@ export class WAConnection extends Base {
|
||||
|
||||
// blocklist updates
|
||||
this.on('CB:Blocklist', json => {
|
||||
if (!json) return
|
||||
json = json[1]
|
||||
const initial = this.blocklist
|
||||
this.blocklist = json.blocklist
|
||||
@@ -632,8 +642,13 @@ export class WAConnection extends Base {
|
||||
* @deprecated use `chat-update`
|
||||
* */
|
||||
on (event: 'user-presence-update', listener: (update: PresenceUpdate) => void): this
|
||||
/** when a user's status is updated */
|
||||
/**
|
||||
* when a user's status is updated
|
||||
* @deprecated use `contact-update`
|
||||
*/
|
||||
on (event: 'user-status-update', listener: (update: {jid: string, status?: string}) => void): this
|
||||
/** when a user's status is updated */
|
||||
on (event: 'contact-update', listener: (update: WAContactUpdate) => void): this
|
||||
/** when a new chat is added */
|
||||
on (event: 'chat-new', listener: (chat: WAChat) => void): this
|
||||
/** when contacts are sent by WA */
|
||||
|
||||
Reference in New Issue
Block a user