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
|
- To get the display picture of some person/group
|
||||||
``` ts
|
``` ts
|
||||||
|
// for low res picture
|
||||||
const ppUrl = await conn.profilePictureUrl("xyz@g.us")
|
const ppUrl = await conn.profilePictureUrl("xyz@g.us")
|
||||||
console.log("download profile picture from: " + ppUrl)
|
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
|
- To change your display picture or a group's
|
||||||
``` ts
|
``` ts
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
ev,
|
ev,
|
||||||
ws,
|
ws,
|
||||||
authState,
|
authState,
|
||||||
processMessage,
|
|
||||||
relayMessage,
|
|
||||||
generateMessageTag,
|
generateMessageTag,
|
||||||
sendNode,
|
sendNode,
|
||||||
query
|
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)
|
jid = jidNormalizedUser(jid)
|
||||||
const result = await query({
|
const result = await query({
|
||||||
tag: 'iq',
|
tag: 'iq',
|
||||||
@@ -231,7 +234,7 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
|||||||
xmlns: 'w:profile:picture'
|
xmlns: 'w:profile:picture'
|
||||||
},
|
},
|
||||||
content: [
|
content: [
|
||||||
{ tag: 'picture', attrs: { type: 'preview', query: 'url' } }
|
{ tag: 'picture', attrs: { type, query: 'url' } }
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
const child = getBinaryNodeChild(result, 'picture')
|
const child = getBinaryNodeChild(result, 'picture')
|
||||||
|
|||||||
Reference in New Issue
Block a user