mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
add high res picture fetch
This commit is contained in:
@@ -496,8 +496,11 @@ await conn.sendMessage(
|
||||
```
|
||||
- To get the display picture of some person/group
|
||||
``` ts
|
||||
// for low res picture
|
||||
const ppUrl = await conn.profilePictureUrl("xyz@g.us")
|
||||
console.log("download profile picture from: " + ppUrl)
|
||||
// for high res picture
|
||||
const ppUrl = await conn.profilePictureUrl("xyz@g.us", 'image')
|
||||
```
|
||||
- To change your display picture or a group's
|
||||
``` ts
|
||||
|
||||
@@ -11,8 +11,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
ev,
|
||||
ws,
|
||||
authState,
|
||||
processMessage,
|
||||
relayMessage,
|
||||
generateMessageTag,
|
||||
sendNode,
|
||||
query
|
||||
@@ -221,7 +219,12 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
)
|
||||
}
|
||||
|
||||
const profilePictureUrl = async(jid: string) => {
|
||||
/**
|
||||
* fetch the profile picture of a user/group
|
||||
* type = "preview" for a low res picture
|
||||
* type = "image for the high res picture"
|
||||
*/
|
||||
const profilePictureUrl = async(jid: string, type: 'preview' | 'image' = 'preview') => {
|
||||
jid = jidNormalizedUser(jid)
|
||||
const result = await query({
|
||||
tag: 'iq',
|
||||
@@ -231,7 +234,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
xmlns: 'w:profile:picture'
|
||||
},
|
||||
content: [
|
||||
{ tag: 'picture', attrs: { type: 'preview', query: 'url' } }
|
||||
{ tag: 'picture', attrs: { type, query: 'url' } }
|
||||
]
|
||||
})
|
||||
const child = getBinaryNodeChild(result, 'picture')
|
||||
|
||||
Reference in New Issue
Block a user