mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-28 02:37:28 +08:00
fix: allow enabling weixin before binding
This commit is contained in:
@@ -93,24 +93,17 @@ func (m *Manager) initChannels() error {
|
||||
}
|
||||
|
||||
if m.config.Channels.Weixin.Enabled {
|
||||
if len(m.config.Channels.Weixin.Accounts) == 0 && strings.TrimSpace(m.config.Channels.Weixin.BotToken) == "" {
|
||||
logger.WarnCF("channels", 0, map[string]interface{}{
|
||||
"channel": "weixin",
|
||||
"error": "missing accounts",
|
||||
weixin, err := NewWeixinChannel(m.config.Channels.Weixin, m.bus)
|
||||
if err != nil {
|
||||
logger.ErrorCF("channels", 0, map[string]interface{}{
|
||||
logger.FieldChannel: "weixin",
|
||||
logger.FieldError: err.Error(),
|
||||
})
|
||||
} else {
|
||||
weixin, err := NewWeixinChannel(m.config.Channels.Weixin, m.bus)
|
||||
if err != nil {
|
||||
logger.ErrorCF("channels", 0, map[string]interface{}{
|
||||
logger.FieldChannel: "weixin",
|
||||
logger.FieldError: err.Error(),
|
||||
})
|
||||
} else {
|
||||
m.channels["weixin"] = weixin
|
||||
logger.InfoCF("channels", 0, map[string]interface{}{
|
||||
logger.FieldChannel: "weixin",
|
||||
})
|
||||
}
|
||||
m.channels["weixin"] = weixin
|
||||
logger.InfoCF("channels", 0, map[string]interface{}{
|
||||
logger.FieldChannel: "weixin",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -187,9 +187,6 @@ func Validate(cfg *Config) []error {
|
||||
if cfg.Channels.OutboundDedupeWindowSeconds <= 0 {
|
||||
errs = append(errs, fmt.Errorf("channels.outbound_dedupe_window_seconds must be > 0"))
|
||||
}
|
||||
if cfg.Channels.Weixin.Enabled && len(cfg.Channels.Weixin.Accounts) == 0 && strings.TrimSpace(cfg.Channels.Weixin.BotToken) == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.weixin.accounts or channels.weixin.bot_token is required when channels.weixin.enabled=true"))
|
||||
}
|
||||
if cfg.Channels.Telegram.Enabled && cfg.Channels.Telegram.Token == "" {
|
||||
errs = append(errs, fmt.Errorf("channels.telegram.token is required when channels.telegram.enabled=true"))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user