summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/Rhymen/go-whatsapp/message.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2019-08-26 23:22:34 +0200
committerGitHub <noreply@github.com>2019-08-26 23:22:34 +0200
commitd525f1c9e4ac39b74575052b61c4de72de794b4e (patch)
tree90f444dd4046c7d29ed08c005648c573deb484b2 /vendor/github.com/Rhymen/go-whatsapp/message.go
parent921f2dfcdf1a6263220b55eb55716e497373dfcf (diff)
downloadmatterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.tar.gz
matterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.tar.bz2
matterbridge-msglm-d525f1c9e4ac39b74575052b61c4de72de794b4e.zip
Update Rhymen/go-whatsapp vendor (#876)
Diffstat (limited to 'vendor/github.com/Rhymen/go-whatsapp/message.go')
-rw-r--r--vendor/github.com/Rhymen/go-whatsapp/message.go107
1 files changed, 106 insertions, 1 deletions
diff --git a/vendor/github.com/Rhymen/go-whatsapp/message.go b/vendor/github.com/Rhymen/go-whatsapp/message.go
index 9d44fb1e..84ef15fd 100644
--- a/vendor/github.com/Rhymen/go-whatsapp/message.go
+++ b/vendor/github.com/Rhymen/go-whatsapp/message.go
@@ -68,6 +68,14 @@ func (wac *Conn) Send(msg interface{}) (string, error) {
msgProto = getAudioProto(m)
msgInfo = getMessageInfo(msgProto)
ch, err = wac.sendProto(msgProto)
+ case LocationMessage:
+ msgProto = GetLocationProto(m)
+ msgInfo = getMessageInfo(msgProto)
+ ch, err = wac.sendProto(msgProto)
+ case LiveLocationMessage:
+ msgProto = GetLiveLocationProto(m)
+ msgInfo = getMessageInfo(msgProto)
+ ch, err = wac.sendProto(msgProto)
default:
return "ERROR", fmt.Errorf("cannot match type %T, use message types declared in the package", msg)
}
@@ -269,6 +277,7 @@ type VideoMessage struct {
Length uint32
Type string
Content io.Reader
+ GifPlayback bool
url string
mediaKey []byte
fileEncSha256 []byte
@@ -282,6 +291,7 @@ func getVideoMessage(msg *proto.WebMessageInfo) VideoMessage {
Info: getMessageInfo(msg),
Caption: vid.GetCaption(),
Thumbnail: vid.GetJpegThumbnail(),
+ GifPlayback: vid.GetGifPlayback(),
url: vid.GetUrl(),
mediaKey: vid.GetMediaKey(),
Length: vid.GetSeconds(),
@@ -299,6 +309,7 @@ func getVideoProto(msg VideoMessage) *proto.WebMessageInfo {
Caption: &msg.Caption,
JpegThumbnail: msg.Thumbnail,
Url: &msg.url,
+ GifPlayback: &msg.GifPlayback,
MediaKey: msg.mediaKey,
Seconds: &msg.Length,
FileEncSha256: msg.fileEncSha256,
@@ -431,7 +442,95 @@ func (m *DocumentMessage) Download() ([]byte, error) {
return Download(m.url, m.mediaKey, MediaDocument, int(m.fileLength))
}
-func parseProtoMessage(msg *proto.WebMessageInfo) interface{} {
+/*
+LocationMessage represents a location message
+*/
+type LocationMessage struct {
+ Info MessageInfo
+ DegreesLatitude float64
+ DegreesLongitude float64
+ Name string
+ Address string
+ Url string
+ JpegThumbnail []byte
+}
+
+func GetLocationMessage(msg *proto.WebMessageInfo) LocationMessage {
+ loc := msg.GetMessage().GetLocationMessage()
+ return LocationMessage{
+ Info: getMessageInfo(msg),
+ DegreesLatitude: loc.GetDegreesLatitude(),
+ DegreesLongitude: loc.GetDegreesLongitude(),
+ Name: loc.GetName(),
+ Address: loc.GetAddress(),
+ Url: loc.GetUrl(),
+ JpegThumbnail: loc.GetJpegThumbnail(),
+ }
+}
+
+func GetLocationProto(msg LocationMessage) *proto.WebMessageInfo {
+ p := getInfoProto(&msg.Info)
+ p.Message = &proto.Message{
+ LocationMessage: &proto.LocationMessage{
+ DegreesLatitude: &msg.DegreesLatitude,
+ DegreesLongitude: &msg.DegreesLongitude,
+ Name: &msg.Name,
+ Address: &msg.Address,
+ Url: &msg.Url,
+ JpegThumbnail: msg.JpegThumbnail,
+ },
+ }
+ return p
+}
+
+/*
+LiveLocationMessage represents a live location message
+*/
+type LiveLocationMessage struct {
+ Info MessageInfo
+ DegreesLatitude float64
+ DegreesLongitude float64
+ AccuracyInMeters uint32
+ SpeedInMps float32
+ DegreesClockwiseFromMagneticNorth uint32
+ Caption string
+ SequenceNumber int64
+ JpegThumbnail []byte
+}
+
+func GetLiveLocationMessage(msg *proto.WebMessageInfo) LiveLocationMessage {
+ loc := msg.GetMessage().GetLiveLocationMessage()
+ return LiveLocationMessage{
+ Info: getMessageInfo(msg),
+ DegreesLatitude: loc.GetDegreesLatitude(),
+ DegreesLongitude: loc.GetDegreesLongitude(),
+ AccuracyInMeters: loc.GetAccuracyInMeters(),
+ SpeedInMps: loc.GetSpeedInMps(),
+ DegreesClockwiseFromMagneticNorth: loc.GetDegreesClockwiseFromMagneticNorth(),
+ Caption: loc.GetCaption(),
+ SequenceNumber: loc.GetSequenceNumber(),
+ JpegThumbnail: loc.GetJpegThumbnail(),
+ }
+}
+
+func GetLiveLocationProto(msg LiveLocationMessage) *proto.WebMessageInfo {
+ p := getInfoProto(&msg.Info)
+ p.Message = &proto.Message{
+ LiveLocationMessage: &proto.LiveLocationMessage{
+ DegreesLatitude: &msg.DegreesLatitude,
+ DegreesLongitude: &msg.DegreesLongitude,
+ AccuracyInMeters: &msg.AccuracyInMeters,
+ SpeedInMps: &msg.SpeedInMps,
+ DegreesClockwiseFromMagneticNorth: &msg.DegreesClockwiseFromMagneticNorth,
+ Caption: &msg.Caption,
+ SequenceNumber: &msg.SequenceNumber,
+ JpegThumbnail: msg.JpegThumbnail,
+ },
+ }
+ return p
+}
+
+func ParseProtoMessage(msg *proto.WebMessageInfo) interface{} {
switch {
case msg.GetMessage().GetAudioMessage() != nil:
@@ -452,6 +551,12 @@ func parseProtoMessage(msg *proto.WebMessageInfo) interface{} {
case msg.GetMessage().GetExtendedTextMessage() != nil:
return getTextMessage(msg)
+ case msg.GetMessage().GetLocationMessage() != nil:
+ return GetLocationMessage(msg)
+
+ case msg.GetMessage().GetLiveLocationMessage() != nil:
+ return GetLiveLocationMessage(msg)
+
default:
//cannot match message
}