mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
667fc85d54
add new field type to Channel struct config.channels refactor to channel_list update config version to 3 update the docs
33 lines
757 B
Go
33 lines
757 B
Go
package teamswebhook
|
|
|
|
import (
|
|
"github.com/sipeed/picoclaw/pkg/bus"
|
|
"github.com/sipeed/picoclaw/pkg/channels"
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
func init() {
|
|
channels.RegisterFactory(
|
|
config.ChannelTeamsWebHook,
|
|
func(channelName, channelType string, cfg *config.Config, b *bus.MessageBus) (channels.Channel, error) {
|
|
bc := cfg.Channels[channelName]
|
|
decoded, err := bc.GetDecoded()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
c, ok := decoded.(*config.TeamsWebhookSettings)
|
|
if !ok {
|
|
return nil, channels.ErrSendFailed
|
|
}
|
|
ch, err := NewTeamsWebhookChannel(bc, c, b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if channelName != config.ChannelTeamsWebHook {
|
|
ch.SetName(channelName)
|
|
}
|
|
return ch, nil
|
|
},
|
|
)
|
|
}
|