mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
urlInfo fix
This commit is contained in:
@@ -272,19 +272,24 @@ const makeMessagesSocket = (config: SocketConfig) => {
|
|||||||
|
|
||||||
/** Query a string to check if it has a url, if it does, return WAUrlInfo */
|
/** Query a string to check if it has a url, if it does, return WAUrlInfo */
|
||||||
const generateUrlInfo = async(text: string) => {
|
const generateUrlInfo = async(text: string) => {
|
||||||
const response = await query({
|
const response: BinaryNode = await query({
|
||||||
json: new BinaryNode(
|
json: new BinaryNode(
|
||||||
'query',
|
'query',
|
||||||
{type: 'url', url: text, epoch: currentEpoch().toString()}
|
{
|
||||||
|
type: 'url',
|
||||||
|
url: text,
|
||||||
|
epoch: currentEpoch().toString()
|
||||||
|
}
|
||||||
),
|
),
|
||||||
binaryTag: [26, WAFlag.ignore],
|
binaryTag: [26, WAFlag.ignore],
|
||||||
expect200: true,
|
expect200: true,
|
||||||
requiresPhoneConnection: false
|
requiresPhoneConnection: false
|
||||||
})
|
})
|
||||||
if(response[1]) {
|
const urlInfo = { ...response.attributes } as any as WAUrlInfo
|
||||||
response[1].jpegThumbnail = response[2]
|
if(response && response.data) {
|
||||||
|
urlInfo.jpegThumbnail = response.data as Buffer
|
||||||
}
|
}
|
||||||
return response[1] as WAUrlInfo
|
return urlInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Relay (send) a WAMessage; more advanced functionality to send a built WA Message, you may want to stick with sendMessage() */
|
/** Relay (send) a WAMessage; more advanced functionality to send a built WA Message, you may want to stick with sendMessage() */
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ export const generateWAMessageContent = async(
|
|||||||
extContent.title = data.title
|
extContent.title = data.title
|
||||||
extContent.previewType = 0
|
extContent.previewType = 0
|
||||||
} catch (error) { // ignore if fails
|
} catch (error) { // ignore if fails
|
||||||
|
options.logger?.warn({ trace: error.stack }, 'url generation failed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m.extendedTextMessage = extContent
|
m.extendedTextMessage = extContent
|
||||||
|
|||||||
Reference in New Issue
Block a user