Skip to content

Commit e3a529b

Browse files
committed
events: add cast helpers to FBMessage struct
1 parent bb5852f commit e3a529b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

types/events/events.go

+16
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import (
1515
waBinary "go.mau.fi/whatsmeow/binary"
1616
waProto "go.mau.fi/whatsmeow/binary/proto"
1717
armadillo "go.mau.fi/whatsmeow/proto"
18+
"go.mau.fi/whatsmeow/proto/waArmadilloApplication"
19+
"go.mau.fi/whatsmeow/proto/waConsumerApplication"
1820
"go.mau.fi/whatsmeow/proto/waMsgApplication"
1921
"go.mau.fi/whatsmeow/proto/waMsgTransport"
2022
"go.mau.fi/whatsmeow/types"
@@ -301,6 +303,20 @@ type FBMessage struct {
301303
Application *waMsgApplication.MessageApplication // The second level of wrapping the message was in
302304
}
303305

306+
func (evt *FBMessage) GetConsumerApplication() *waConsumerApplication.ConsumerApplication {
307+
if consumerApp, ok := evt.Message.(*waConsumerApplication.ConsumerApplication); ok {
308+
return consumerApp
309+
}
310+
return nil
311+
}
312+
313+
func (evt *FBMessage) GetArmadillo() *waArmadilloApplication.Armadillo {
314+
if armadillo, ok := evt.Message.(*waArmadilloApplication.Armadillo); ok {
315+
return armadillo
316+
}
317+
return nil
318+
}
319+
304320
// UnwrapRaw fills the Message, IsEphemeral and IsViewOnce fields based on the raw message in the RawMessage field.
305321
func (evt *Message) UnwrapRaw() *Message {
306322
evt.Message = evt.RawMessage

0 commit comments

Comments
 (0)