mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-20 04:47:37 +08:00
feishu: harden channel action handling and align with manager capabilities
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -27,6 +28,15 @@ type FeishuChannel struct {
|
|||||||
runCancel cancelGuard
|
runCancel cancelGuard
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FeishuChannel) SupportsAction(action string) bool {
|
||||||
|
switch strings.ToLower(strings.TrimSpace(action)) {
|
||||||
|
case "", "send":
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChannel, error) {
|
func NewFeishuChannel(cfg config.FeishuConfig, bus *bus.MessageBus) (*FeishuChannel, error) {
|
||||||
base := NewBaseChannel("feishu", cfg, bus, cfg.AllowFrom)
|
base := NewBaseChannel("feishu", cfg, bus, cfg.AllowFrom)
|
||||||
|
|
||||||
@@ -94,6 +104,10 @@ func (c *FeishuChannel) Send(ctx context.Context, msg bus.OutboundMessage) error
|
|||||||
if msg.ChatID == "" {
|
if msg.ChatID == "" {
|
||||||
return fmt.Errorf("chat ID is empty")
|
return fmt.Errorf("chat ID is empty")
|
||||||
}
|
}
|
||||||
|
action := strings.ToLower(strings.TrimSpace(msg.Action))
|
||||||
|
if action != "" && action != "send" {
|
||||||
|
return fmt.Errorf("unsupported feishu action: %s", action)
|
||||||
|
}
|
||||||
|
|
||||||
payload, err := json.Marshal(map[string]string{"text": msg.Content})
|
payload, err := json.Marshal(map[string]string{"text": msg.Content})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user