Skip to content

Commit

Permalink
feat(whatsapp): location message
Browse files Browse the repository at this point in the history
  • Loading branch information
XxLittleCxX committed Aug 12, 2023
1 parent 45b5755 commit 28414e9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 9 additions & 1 deletion adapters/whatsapp/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,15 @@ export interface MessageBodySticker extends MessageBodyBase {
sticker?: ReceivedMedia
}

export type MessageBody = MessageBodyText | MessageBodyMedia | MessageBodySticker
export interface MessageBodyLocation extends MessageBodyBase {
type: 'location'
location: {
latitude: number
longitude: number
}
}

export type MessageBody = MessageBodyText | MessageBodyMedia | MessageBodySticker | MessageBodyLocation

export interface SendMessageBase {
messaging_product: 'whatsapp'
Expand Down
5 changes: 5 additions & 0 deletions adapters/whatsapp/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ export async function decodeMessage(bot: WhatsAppBot, entry: Entry) {
}, [
h.image(`${bot.ctx.root.config.selfUrl}/whatsapp/assets/${bot.selfId}/${message.sticker.id}`),
])]
} else if (message.type === 'location') {
session.elements = [h('whatsapp:location', {
latitude: message.location.latitude,
longitude: message.location.longitude,
})]
} else {
continue
}
Expand Down

0 comments on commit 28414e9

Please sign in to comment.