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
|
||||
caption?: string
|
||||
jpegThumbnail?: string
|
||||
} & Mentionable & Buttonable & Templatable & WithDimensions) |
|
||||
({
|
||||
} & Mentionable & Buttonable & Templatable & WithDimensions)
|
||||
| ({
|
||||
video: WAMediaUpload
|
||||
caption?: string
|
||||
gifPlayback?: boolean
|
||||
jpegThumbnail?: string
|
||||
} & Mentionable & Buttonable & Templatable & WithDimensions) | {
|
||||
} & Mentionable & Buttonable & Templatable & WithDimensions)
|
||||
| {
|
||||
audio: WAMediaUpload
|
||||
/** if set to true, will send as a `voice note` */
|
||||
ptt?: boolean
|
||||
/** optionally tell the duration of the audio */
|
||||
seconds?: number
|
||||
} | ({
|
||||
}
|
||||
| ({
|
||||
sticker: WAMediaUpload
|
||||
isAnimated?: boolean
|
||||
} & WithDimensions) | ({
|
||||
document: WAMediaUpload
|
||||
mimetype: string
|
||||
fileName?: string
|
||||
} & Buttonable & Templatable)) &
|
||||
{ mimetype?: string }
|
||||
} & Buttonable & Templatable))
|
||||
| { mimetype?: string }
|
||||
|
||||
export type ButtonReplyInfo = {
|
||||
displayText: string
|
||||
@@ -107,27 +109,37 @@ export type ButtonReplyInfo = {
|
||||
index: number
|
||||
}
|
||||
|
||||
export type WASendableProduct = Omit<proto.Message.ProductMessage.IProductSnapshot, 'productImage'> & {
|
||||
productImage: WAMediaUpload
|
||||
}
|
||||
|
||||
export type AnyRegularMessageContent = (
|
||||
({
|
||||
text: string
|
||||
linkPreview?: WAUrlInfo | null
|
||||
}
|
||||
& Mentionable & Buttonable & Templatable & Listable) |
|
||||
AnyMediaMessageContent |
|
||||
{
|
||||
& Mentionable & Buttonable & Templatable & Listable)
|
||||
| AnyMediaMessageContent
|
||||
| {
|
||||
contacts: {
|
||||
displayName?: string
|
||||
contacts: proto.Message.IContactMessage[]
|
||||
}
|
||||
} |
|
||||
{
|
||||
}
|
||||
| {
|
||||
location: WALocationMessage
|
||||
} | {
|
||||
react: proto.Message.IReactionMessage
|
||||
} | {
|
||||
}
|
||||
| { react: proto.Message.IReactionMessage }
|
||||
| {
|
||||
buttonReply: ButtonReplyInfo
|
||||
type: 'template' | 'plain'
|
||||
}
|
||||
| {
|
||||
product: WASendableProduct,
|
||||
businessOwnerJid?: string
|
||||
body?: string
|
||||
footer?: string
|
||||
}
|
||||
) & ViewOnce
|
||||
|
||||
export type AnyMessageContent = AnyRegularMessageContent | {
|
||||
|
||||
@@ -340,6 +340,18 @@ export const generateWAMessageContent = async(
|
||||
}
|
||||
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 {
|
||||
m = await prepareWAMessageMedia(
|
||||
message,
|
||||
|
||||
Reference in New Issue
Block a user