mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: implement product message sending
This commit is contained in:
@@ -79,27 +79,29 @@ export type AnyMediaMessageContent = (
|
|||||||
image: WAMediaUpload
|
image: WAMediaUpload
|
||||||
caption?: string
|
caption?: string
|
||||||
jpegThumbnail?: string
|
jpegThumbnail?: string
|
||||||
} & Mentionable & Buttonable & Templatable & WithDimensions) |
|
} & Mentionable & Buttonable & Templatable & WithDimensions)
|
||||||
({
|
| ({
|
||||||
video: WAMediaUpload
|
video: WAMediaUpload
|
||||||
caption?: string
|
caption?: string
|
||||||
gifPlayback?: boolean
|
gifPlayback?: boolean
|
||||||
jpegThumbnail?: string
|
jpegThumbnail?: string
|
||||||
} & Mentionable & Buttonable & Templatable & WithDimensions) | {
|
} & Mentionable & Buttonable & Templatable & WithDimensions)
|
||||||
|
| {
|
||||||
audio: WAMediaUpload
|
audio: WAMediaUpload
|
||||||
/** if set to true, will send as a `voice note` */
|
/** if set to true, will send as a `voice note` */
|
||||||
ptt?: boolean
|
ptt?: boolean
|
||||||
/** optionally tell the duration of the audio */
|
/** optionally tell the duration of the audio */
|
||||||
seconds?: number
|
seconds?: number
|
||||||
} | ({
|
}
|
||||||
|
| ({
|
||||||
sticker: WAMediaUpload
|
sticker: WAMediaUpload
|
||||||
isAnimated?: boolean
|
isAnimated?: boolean
|
||||||
} & WithDimensions) | ({
|
} & WithDimensions) | ({
|
||||||
document: WAMediaUpload
|
document: WAMediaUpload
|
||||||
mimetype: string
|
mimetype: string
|
||||||
fileName?: string
|
fileName?: string
|
||||||
} & Buttonable & Templatable)) &
|
} & Buttonable & Templatable))
|
||||||
{ mimetype?: string }
|
| { mimetype?: string }
|
||||||
|
|
||||||
export type ButtonReplyInfo = {
|
export type ButtonReplyInfo = {
|
||||||
displayText: string
|
displayText: string
|
||||||
@@ -107,27 +109,37 @@ export type ButtonReplyInfo = {
|
|||||||
index: number
|
index: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
||||||
|
productImage: WAMediaUpload
|
||||||
|
}
|
||||||
|
|
||||||
export type AnyRegularMessageContent = (
|
export type AnyRegularMessageContent = (
|
||||||
({
|
({
|
||||||
text: string
|
text: string
|
||||||
linkPreview?: WAUrlInfo | null
|
linkPreview?: WAUrlInfo | null
|
||||||
}
|
}
|
||||||
& Mentionable & Buttonable & Templatable & Listable) |
|
& Mentionable & Buttonable & Templatable & Listable)
|
||||||
AnyMediaMessageContent |
|
| AnyMediaMessageContent
|
||||||
{
|
| {
|
||||||
contacts: {
|
contacts: {
|
||||||
displayName?: string
|
displayName?: string
|
||||||
contacts: proto.Message.IContactMessage[]
|
contacts: proto.Message.IContactMessage[]
|
||||||
}
|
}
|
||||||
} |
|
}
|
||||||
{
|
| {
|
||||||
location: WALocationMessage
|
location: WALocationMessage
|
||||||
} | {
|
}
|
||||||
react: proto.Message.IReactionMessage
|
| { react: proto.Message.IReactionMessage }
|
||||||
} | {
|
| {
|
||||||
buttonReply: ButtonReplyInfo
|
buttonReply: ButtonReplyInfo
|
||||||
type: 'template' | 'plain'
|
type: 'template' | 'plain'
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
product: WASendableProduct,
|
||||||
|
businessOwnerJid?: string
|
||||||
|
body?: string
|
||||||
|
footer?: string
|
||||||
|
}
|
||||||
) & ViewOnce
|
) & ViewOnce
|
||||||
|
|
||||||
export type AnyMessageContent = AnyRegularMessageContent | {
|
export type AnyMessageContent = AnyRegularMessageContent | {
|
||||||
|
|||||||
@@ -340,6 +340,18 @@ export const generateWAMessageContent = async(
|
|||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
} else if('product' in message) {
|
||||||
|
const { imageMessage } = await prepareWAMessageMedia(
|
||||||
|
{ image: message.product.productImage },
|
||||||
|
options
|
||||||
|
)
|
||||||
|
m.productMessage = WAProto.Message.ProductMessage.fromObject({
|
||||||
|
...message,
|
||||||
|
product: {
|
||||||
|
...message.product,
|
||||||
|
productImage: imageMessage,
|
||||||
|
}
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
m = await prepareWAMessageMedia(
|
m = await prepareWAMessageMedia(
|
||||||
message,
|
message,
|
||||||
|
|||||||
Reference in New Issue
Block a user