feat: add button reply

This commit is contained in:
Adhiraj Singh
2022-06-13 16:22:28 +05:30
parent 7b3fd7c3c5
commit 32fadda86a
2 changed files with 26 additions and 0 deletions

View File

@@ -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

View File

@@ -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,