mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
b12f03be2e
Add an output-only channel that sends messages to Slack via Incoming
Webhooks using Block Kit formatting.
Features:
- Multiple webhook targets with named routing (requires "default" target)
- Markdown to Slack mrkdwn conversion (bold, italic, strikethrough, links, lists)
- Code block handling with proper fence preservation across chunk splits
- Table rendering with aligned columns in code blocks
- Automatic text chunking at 3000 chars (Slack's text block limit)
- HTTPS-only webhook URL validation
Configuration example:
channels:
slack_webhook:
webhooks:
default:
webhook_url: "https://hooks.slack.com/services/..."
username: "PicoClaw"
icon_emoji: ":robot_face:"
Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
757 B
Go
33 lines
757 B
Go
package slackwebhook
|
|
|
|
import (
|
|
"github.com/sipeed/picoclaw/pkg/bus"
|
|
"github.com/sipeed/picoclaw/pkg/channels"
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
)
|
|
|
|
func init() {
|
|
channels.RegisterFactory(
|
|
config.ChannelSlackWebHook,
|
|
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.SlackWebhookSettings)
|
|
if !ok {
|
|
return nil, channels.ErrSendFailed
|
|
}
|
|
ch, err := NewSlackWebhookChannel(bc, c, b)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if channelName != config.ChannelSlackWebHook {
|
|
ch.SetName(channelName)
|
|
}
|
|
return ch, nil
|
|
},
|
|
)
|
|
}
|