From a8644ca1c504792fe610293a0458dee407edab09 Mon Sep 17 00:00:00 2001 From: Aditya Kalro Date: Thu, 26 Feb 2026 22:35:20 -0800 Subject: [PATCH] Refactor whatsapp native channel based on the new channel interface --- pkg/channels/manager.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pkg/channels/manager.go b/pkg/channels/manager.go index dfc4fd9f9..7fae0d060 100644 --- a/pkg/channels/manager.go +++ b/pkg/channels/manager.go @@ -220,14 +220,19 @@ func (m *Manager) initChannels() error { if storePath == "" { storePath = filepath.Join(m.config.WorkspacePath(), "whatsapp") } - ch, err := NewWhatsAppNativeChannel(waCfg, m.bus, storePath) - if err != nil { - logger.ErrorCF("channels", "Failed to initialize WhatsApp native channel", map[string]any{ - "error": err.Error(), - }) + newNative := getWhatsAppNativeFactory() + if newNative == nil { + logger.ErrorCF("channels", "WhatsApp native not linked; import _ github.com/sipeed/picoclaw/pkg/channels/whatsapp or build with -tags whatsapp_native", nil) } else { - m.channels["whatsapp"] = ch - logger.InfoC("channels", "WhatsApp native channel enabled successfully") + ch, err := newNative(waCfg, m.bus, storePath) + if err != nil { + logger.ErrorCF("channels", "Failed to initialize WhatsApp native channel", map[string]any{ + "error": err.Error(), + }) + } else { + m.channels["whatsapp"] = ch + logger.InfoC("channels", "WhatsApp native channel enabled successfully") + } } } else if waCfg.BridgeURL != "" { m.initChannel("whatsapp", "WhatsApp")