Skip to content

Commit 14b6314

Browse files
committed
client,connector: Support external whatsmeow event handlers
1 parent f7fa9fe commit 14b6314

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

pkg/connector/client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ func (wa *WhatsAppConnector) LoadUserLogin(ctx context.Context, login *bridgev2.
7373
log := w.UserLogin.Log.With().Str("component", "whatsmeow").Logger()
7474
w.Client = whatsmeow.NewClient(w.Device, waLog.Zerolog(log))
7575
w.Client.AddEventHandlerWithSuccessStatus(w.handleWAEvent)
76+
if wa.ExternalEventHandler != nil {
77+
w.Client.AddEventHandler(wa.ExternalEventHandler)
78+
}
7679
w.Client.SynchronousAck = true
7780
if bridgev2.PortalEventBuffer == 0 {
7881
w.Client.EnableDecryptedEventBuffer = true

pkg/connector/connector.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ type WhatsAppConnector struct {
5757
mediaEditCache MediaEditCache
5858
mediaEditCacheLock sync.RWMutex
5959
stopMediaEditCacheLoop atomic.Pointer[context.CancelFunc]
60+
61+
ExternalEventHandler func(rawEvt any)
6062
}
6163

6264
func init() {

0 commit comments

Comments
 (0)