mirror of
https://github.com/FranP-code/Baileys.git
synced 2025-10-13 00:32:22 +00:00
feat: add button reply
This commit is contained in:
@@ -100,6 +100,12 @@ export type AnyMediaMessageContent = (
|
||||
} & Buttonable & Templatable)) &
|
||||
{ mimetype?: string }
|
||||
|
||||
export type ButtonReplyInfo = {
|
||||
displayText: string
|
||||
id: string
|
||||
index: number
|
||||
}
|
||||
|
||||
export type AnyRegularMessageContent = (
|
||||
({
|
||||
text: string
|
||||
@@ -117,6 +123,9 @@ export type AnyRegularMessageContent = (
|
||||
location: WALocationMessage
|
||||
} | {
|
||||
react: proto.IReactionMessage
|
||||
} | {
|
||||
buttonReply: ButtonReplyInfo
|
||||
type: 'template' | 'plain'
|
||||
}
|
||||
) & ViewOnce
|
||||
|
||||
|
||||
@@ -307,6 +307,23 @@ export const generateWAMessageContent = async(
|
||||
(message.disappearingMessagesInChat ? WA_DEFAULT_EPHEMERAL : 0) :
|
||||
message.disappearingMessagesInChat
|
||||
m = prepareDisappearingMessageSettingContent(exp)
|
||||
} else if('buttonReply' in message) {
|
||||
switch (message.type) {
|
||||
case 'template':
|
||||
m.templateButtonReplyMessage = {
|
||||
selectedDisplayText: message.buttonReply.displayText,
|
||||
selectedId: message.buttonReply.id,
|
||||
selectedIndex: message.buttonReply.index,
|
||||
}
|
||||
break
|
||||
case 'plain':
|
||||
m.buttonsResponseMessage = {
|
||||
selectedButtonId: message.buttonReply.id,
|
||||
selectedDisplayText: message.buttonReply.displayText,
|
||||
type: proto.ButtonsResponseMessage.ButtonsResponseMessageType.DISPLAY_TEXT,
|
||||
}
|
||||
break
|
||||
}
|
||||
} else {
|
||||
m = await prepareWAMessageMedia(
|
||||
message,
|
||||
|
||||
Reference in New Issue
Block a user