Refactor whatsapp native channel based on the new channel interface
This commit is contained in:
parent
49612adf8a
commit
a8644ca1c5
1 changed files with 12 additions and 7 deletions
|
|
@ -220,14 +220,19 @@ func (m *Manager) initChannels() error {
|
||||||
if storePath == "" {
|
if storePath == "" {
|
||||||
storePath = filepath.Join(m.config.WorkspacePath(), "whatsapp")
|
storePath = filepath.Join(m.config.WorkspacePath(), "whatsapp")
|
||||||
}
|
}
|
||||||
ch, err := NewWhatsAppNativeChannel(waCfg, m.bus, storePath)
|
newNative := getWhatsAppNativeFactory()
|
||||||
if err != nil {
|
if newNative == nil {
|
||||||
logger.ErrorCF("channels", "Failed to initialize WhatsApp native channel", map[string]any{
|
logger.ErrorCF("channels", "WhatsApp native not linked; import _ github.com/sipeed/picoclaw/pkg/channels/whatsapp or build with -tags whatsapp_native", nil)
|
||||||
"error": err.Error(),
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
m.channels["whatsapp"] = ch
|
ch, err := newNative(waCfg, m.bus, storePath)
|
||||||
logger.InfoC("channels", "WhatsApp native channel enabled successfully")
|
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 != "" {
|
} else if waCfg.BridgeURL != "" {
|
||||||
m.initChannel("whatsapp", "WhatsApp")
|
m.initChannel("whatsapp", "WhatsApp")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue