refactor: remove Pico and MaixCAM channels
Remove pico, pico_client and maixcam adapters, configuration and migration support. Drop Pico-specific agent publishing while preserving shared IM streaming and MQTT. Clean up channel examples and localized documentation; move shared tests to Telegram. Validated with full Go tests, vet, lint, docs checks and a Linux amd64 build.
This commit is contained in:
1 parent
6159157e47
commit
996dfefffe
74 files changed
+243
-5862
No files matched your search
@@ -27,10 +27,6 @@ var rrCounter atomic.Uint64
|
||||
// CurrentVersion is the latest config schema version
|
||||
const CurrentVersion = 3
|
||||
|
||||
func init() {
|
||||
initChannel()
|
||||
}
|
||||
|
||||
// Config is the current config structure with version support.
|
||||
type Config struct {
|
||||
// Config schema version for migration.
|
||||
@@ -565,11 +561,6 @@ type DiscordSettings struct {
|
||||
MentionOnly bool `json:"mention_only" yaml:"-" env:"PICOCLAW_CHANNELS_DISCORD_MENTION_ONLY"`
|
||||
}
|
||||
|
||||
type MaixCamSettings struct {
|
||||
Host string `json:"host" yaml:"-" env:"PICOCLAW_CHANNELS_MAIXCAM_HOST"`
|
||||
Port int `json:"port" yaml:"-" env:"PICOCLAW_CHANNELS_MAIXCAM_PORT"`
|
||||
}
|
||||
|
||||
type QQSettings struct {
|
||||
AppID string `json:"app_id" yaml:"-" env:"PICOCLAW_CHANNELS_QQ_APP_ID"`
|
||||
AppSecret SecureString `json:"app_secret,omitzero" yaml:"app_secret,omitempty" env:"PICOCLAW_CHANNELS_QQ_APP_SECRET"`
|
||||
@@ -668,30 +659,6 @@ func (c *WeixinSettings) SetToken(token string) {
|
||||
c.Token = *NewSecureString(token)
|
||||
}
|
||||
|
||||
type PicoSettings struct {
|
||||
Token SecureString `json:"token,omitzero" yaml:"token,omitempty" env:"PICOCLAW_CHANNELS_PICO_TOKEN"`
|
||||
AllowTokenQuery bool `json:"allow_token_query,omitempty" yaml:"-"`
|
||||
AllowOrigins []string `json:"allow_origins,omitempty" yaml:"-"`
|
||||
Streaming StreamingConfig `json:"streaming,omitzero" yaml:"-"`
|
||||
PingInterval int `json:"ping_interval,omitempty" yaml:"-"`
|
||||
ReadTimeout int `json:"read_timeout,omitempty" yaml:"-"`
|
||||
WriteTimeout int `json:"write_timeout,omitempty" yaml:"-"`
|
||||
MaxConnections int `json:"max_connections,omitempty" yaml:"-"`
|
||||
}
|
||||
|
||||
// SetToken sets the Pico token and marks it as dirty for security saving
|
||||
func (c *PicoSettings) SetToken(token string) {
|
||||
c.Token = *NewSecureString(token)
|
||||
}
|
||||
|
||||
type PicoClientSettings struct {
|
||||
URL string `json:"url" yaml:"-" env:"PICOCLAW_CHANNELS_PICO_CLIENT_URL"`
|
||||
Token SecureString `json:"token,omitzero" yaml:"token,omitempty" env:"PICOCLAW_CHANNELS_PICO_CLIENT_TOKEN"`
|
||||
SessionID string `json:"session_id,omitempty" yaml:"-"`
|
||||
PingInterval int `json:"ping_interval,omitempty" yaml:"-"`
|
||||
ReadTimeout int `json:"read_timeout,omitempty" yaml:"-"`
|
||||
}
|
||||
|
||||
type IRCSettings struct {
|
||||
Server string `json:"server" yaml:"-" env:"PICOCLAW_CHANNELS_IRC_SERVER"`
|
||||
TLS bool `json:"tls" yaml:"-" env:"PICOCLAW_CHANNELS_IRC_TLS"`
|
||||
|
||||
@@ -17,8 +17,6 @@ import (
|
||||
|
||||
// Channel type constants — single source of truth for all channel type names.
|
||||
const (
|
||||
ChannelPico = "pico"
|
||||
ChannelPicoClient = "pico_client"
|
||||
ChannelTelegram = "telegram"
|
||||
ChannelDiscord = "discord"
|
||||
ChannelFeishu = "feishu"
|
||||
@@ -33,7 +31,6 @@ const (
|
||||
ChannelQQ = "qq"
|
||||
ChannelIRC = "irc"
|
||||
ChannelVK = "vk"
|
||||
ChannelMaixCam = "maixcam"
|
||||
ChannelWhatsApp = "whatsapp"
|
||||
ChannelWhatsAppNative = "whatsapp_native"
|
||||
ChannelTeamsWebHook = "teams_webhook"
|
||||
@@ -41,27 +38,6 @@ const (
|
||||
ChannelSlackWebHook = "slack_webhook"
|
||||
)
|
||||
|
||||
func initChannel() {
|
||||
registerSingletonChannel(ChannelPico)
|
||||
registerSingletonChannel(ChannelPicoClient)
|
||||
}
|
||||
|
||||
// singletonRegistry stores which channel types are singletons (only allow one instance).
|
||||
// Each channel type should call registerSingletonChannel in its init() if it's a singleton.
|
||||
var singletonRegistry = make(map[string]struct{})
|
||||
|
||||
// registerSingletonChannel marks a channel type as singleton (only one instance allowed).
|
||||
// Should be called from the channel type's init() function.
|
||||
func registerSingletonChannel(channelType string) {
|
||||
singletonRegistry[channelType] = struct{}{}
|
||||
}
|
||||
|
||||
// IsSingletonChannel returns true if the channel type only allows one instance.
|
||||
func IsSingletonChannel(channelType string) bool {
|
||||
_, ok := singletonRegistry[channelType]
|
||||
return ok
|
||||
}
|
||||
|
||||
// RawNode stores raw configuration data as JSON bytes, supporting both JSON and YAML.
|
||||
// Internally uses json.RawMessage, so Decode always uses json.Unmarshal
|
||||
// which correctly respects json struct tags.
|
||||
@@ -506,37 +482,6 @@ func (c ChannelsConfig) SetEnabled(name string, enabled bool) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// validateSingletonChannels checks that singleton channel types have at most
|
||||
// one enabled instance. Returns an error if a singleton type has multiple enabled channels.
|
||||
func validateSingletonChannels(channels ChannelsConfig) error {
|
||||
typeCount := make(map[string]int)
|
||||
typeNames := make(map[string][]string)
|
||||
for name, bc := range channels {
|
||||
if !bc.Enabled {
|
||||
continue
|
||||
}
|
||||
t := bc.Type
|
||||
if t == "" {
|
||||
t = name
|
||||
}
|
||||
if IsSingletonChannel(t) {
|
||||
typeCount[t]++
|
||||
typeNames[t] = append(typeNames[t], name)
|
||||
}
|
||||
}
|
||||
for t, count := range typeCount {
|
||||
if count > 1 {
|
||||
return fmt.Errorf(
|
||||
"channel type %q is singleton and does not support multiple instances, found %d enabled instances: %v",
|
||||
t,
|
||||
count,
|
||||
typeNames[t],
|
||||
)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// BaseFieldNames are JSON keys that belong to Channel, not to channel-specific settings.
|
||||
var BaseFieldNames = map[string]struct{}{
|
||||
"enabled": {},
|
||||
@@ -660,8 +605,6 @@ func filterSecureFields(r RawNode, secureFields map[string]struct{}) RawNode {
|
||||
var channelSettingsMu sync.RWMutex
|
||||
|
||||
var channelSettingsFactory = map[string]any{
|
||||
ChannelPico: (PicoSettings{}),
|
||||
ChannelPicoClient: (PicoClientSettings{}),
|
||||
ChannelTelegram: (TelegramSettings{}),
|
||||
ChannelDiscord: (DiscordSettings{}),
|
||||
ChannelFeishu: (FeishuSettings{}),
|
||||
@@ -676,7 +619,6 @@ var channelSettingsFactory = map[string]any{
|
||||
ChannelQQ: (QQSettings{}),
|
||||
ChannelIRC: (IRCSettings{}),
|
||||
ChannelVK: (VKSettings{}),
|
||||
ChannelMaixCam: (MaixCamSettings{}),
|
||||
ChannelWhatsApp: (WhatsAppSettings{}),
|
||||
ChannelWhatsAppNative: (WhatsAppSettings{}),
|
||||
ChannelTeamsWebHook: (TeamsWebhookSettings{}),
|
||||
@@ -717,16 +659,15 @@ func isValidChannelType(channelType string) bool {
|
||||
}
|
||||
|
||||
// InitChannelList validates and initializes all channels in the ChannelsConfig.
|
||||
// It performs three steps:
|
||||
// It performs two steps:
|
||||
// 1. Validates that each channel has a non-empty Type
|
||||
// 2. Validates singleton constraints
|
||||
// 3. Decodes Settings into the correct typed struct based on Type,
|
||||
// so that b.extend contains the actual settings (e.g., PicoSettings)
|
||||
// 2. Decodes Settings into the correct typed struct based on Type,
|
||||
// so that b.extend contains the actual settings (e.g., TelegramSettings)
|
||||
//
|
||||
// After calling this method, callers can safely use b.extend via Decode()
|
||||
// without re-parsing raw Settings.
|
||||
func InitChannelList(channels ChannelsConfig) error {
|
||||
// Step 1 & 3: validate type and decode into typed settings
|
||||
// Validate type and decode into typed settings.
|
||||
for name, bc := range channels {
|
||||
if bc == nil {
|
||||
delete(channels, name)
|
||||
@@ -757,11 +698,6 @@ func InitChannelList(channels ChannelsConfig) error {
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: validate singleton constraints
|
||||
if err := validateSingletonChannels(channels); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -791,8 +727,6 @@ func applyTelegramStreamingEnvCompat(target any) {
|
||||
func validateChannelStreamingConfig(channelName string, target any) error {
|
||||
var streaming StreamingConfig
|
||||
switch settings := target.(type) {
|
||||
case *PicoSettings:
|
||||
streaming = settings.Streaming
|
||||
case *TelegramSettings:
|
||||
streaming = settings.Streaming
|
||||
case *WeComSettings:
|
||||
|
||||
@@ -144,30 +144,6 @@ func TestStreamingConfig_IsChannelGeneric(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPicoSettings_StreamingConfig(t *testing.T) {
|
||||
raw := RawNode(`{
|
||||
"token": "test-token",
|
||||
"streaming": {
|
||||
"enabled": true,
|
||||
"throttle_seconds": 2,
|
||||
"min_growth_chars": 80
|
||||
}
|
||||
}`)
|
||||
ch := &Channel{
|
||||
Type: ChannelPico,
|
||||
Enabled: true,
|
||||
Settings: raw,
|
||||
}
|
||||
ch.SetName("pico")
|
||||
var picoCfg PicoSettings
|
||||
if err := ch.Decode(&picoCfg); err != nil {
|
||||
t.Fatalf("Decode() error = %v", err)
|
||||
}
|
||||
assert.True(t, picoCfg.Streaming.Enabled)
|
||||
assert.Equal(t, 2, picoCfg.Streaming.ThrottleSeconds)
|
||||
assert.Equal(t, 80, picoCfg.Streaming.MinGrowthChars)
|
||||
}
|
||||
|
||||
func TestWeComSettings_StreamingConfig(t *testing.T) {
|
||||
raw := RawNode(`{
|
||||
"bot_id": "bot-1",
|
||||
@@ -192,7 +168,7 @@ func TestWeComSettings_StreamingConfig(t *testing.T) {
|
||||
assert.Equal(t, 160, wecomCfg.Streaming.MinGrowthChars)
|
||||
}
|
||||
|
||||
func TestPicoStreamingConfig_Defaults(t *testing.T) {
|
||||
func TestStreamingConfig_Defaults(t *testing.T) {
|
||||
cfg := StreamingConfig{Enabled: true}
|
||||
got := cfg.WithDefaults(1, 40)
|
||||
assert.Equal(t, 1, got.ThrottleSeconds)
|
||||
@@ -220,10 +196,10 @@ func TestInitChannelList_TelegramStreamingEnvCompatibility(t *testing.T) {
|
||||
Enabled: true,
|
||||
Settings: RawNode(`{"token":"telegram-token"}`),
|
||||
},
|
||||
"pico": {
|
||||
Type: ChannelPico,
|
||||
"wecom": {
|
||||
Type: ChannelWeCom,
|
||||
Enabled: true,
|
||||
Settings: RawNode(`{"token":"pico-token"}`),
|
||||
Settings: RawNode(`{"bot_id":"bot-1"}`),
|
||||
},
|
||||
}
|
||||
if err := InitChannelList(channels); err != nil {
|
||||
@@ -239,14 +215,14 @@ func TestInitChannelList_TelegramStreamingEnvCompatibility(t *testing.T) {
|
||||
assert.Equal(t, 3, tgCfg.Streaming.ThrottleSeconds)
|
||||
assert.Equal(t, 120, tgCfg.Streaming.MinGrowthChars)
|
||||
|
||||
picoDecoded, err := channels["pico"].GetDecoded()
|
||||
wecomDecoded, err := channels["wecom"].GetDecoded()
|
||||
if err != nil {
|
||||
t.Fatalf("pico GetDecoded() error = %v", err)
|
||||
t.Fatalf("wecom GetDecoded() error = %v", err)
|
||||
}
|
||||
picoCfg := picoDecoded.(*PicoSettings)
|
||||
assert.False(t, picoCfg.Streaming.Enabled)
|
||||
assert.Equal(t, 0, picoCfg.Streaming.ThrottleSeconds)
|
||||
assert.Equal(t, 0, picoCfg.Streaming.MinGrowthChars)
|
||||
wecomCfg := wecomDecoded.(*WeComSettings)
|
||||
assert.False(t, wecomCfg.Streaming.Enabled)
|
||||
assert.Equal(t, 0, wecomCfg.Streaming.ThrottleSeconds)
|
||||
assert.Equal(t, 0, wecomCfg.Streaming.MinGrowthChars)
|
||||
}
|
||||
|
||||
func TestInitChannelList_RejectsNegativeStreamingDeliveryValues(t *testing.T) {
|
||||
@@ -255,16 +231,6 @@ func TestInitChannelList_RejectsNegativeStreamingDeliveryValues(t *testing.T) {
|
||||
channelType string
|
||||
settings string
|
||||
}{
|
||||
{
|
||||
name: "pico throttle",
|
||||
channelType: ChannelPico,
|
||||
settings: `{"token":"pico-token","streaming":{"enabled":true,"throttle_seconds":-1}}`,
|
||||
},
|
||||
{
|
||||
name: "pico growth",
|
||||
channelType: ChannelPico,
|
||||
settings: `{"token":"pico-token","streaming":{"enabled":true,"min_growth_chars":-1}}`,
|
||||
},
|
||||
{
|
||||
name: "telegram throttle",
|
||||
channelType: ChannelTelegram,
|
||||
@@ -338,11 +304,11 @@ func TestChannel_JSON_Marshal_SecureMasked(t *testing.T) {
|
||||
func TestChannel_JSON_Marshal_OmitsUnconfiguredStreaming(t *testing.T) {
|
||||
ch := Channel{
|
||||
Enabled: true,
|
||||
Type: ChannelPico,
|
||||
name: "pico",
|
||||
Settings: mustParseRawNode(`{"ping_interval":30}`),
|
||||
Type: ChannelWeCom,
|
||||
name: "wecom",
|
||||
Settings: mustParseRawNode(`{"bot_id":"bot-1"}`),
|
||||
}
|
||||
var cfg PicoSettings
|
||||
var cfg WeComSettings
|
||||
require.NoError(t, ch.Decode(&cfg))
|
||||
|
||||
data, err := json.MarshalIndent(ch, "", " ")
|
||||
|
||||
+43
-105
@@ -1002,21 +1002,6 @@ func TestDefaultConfig_ChannelStreamingDisabled(t *testing.T) {
|
||||
t.Fatal("DefaultConfig().telegram.settings.streaming.enabled should be false")
|
||||
}
|
||||
|
||||
pico := cfg.Channels.Get(ChannelPico)
|
||||
if pico == nil {
|
||||
t.Fatal("DefaultConfig() missing pico channel")
|
||||
}
|
||||
decoded, err = pico.GetDecoded()
|
||||
if err != nil {
|
||||
t.Fatalf("pico GetDecoded() error = %v", err)
|
||||
}
|
||||
picoSettings, ok := decoded.(*PicoSettings)
|
||||
if !ok {
|
||||
t.Fatalf("pico settings type = %T, want *PicoSettings", decoded)
|
||||
}
|
||||
if !picoSettings.Streaming.Enabled {
|
||||
t.Fatal("DefaultConfig().pico.settings.streaming.enabled should be true")
|
||||
}
|
||||
}
|
||||
|
||||
func TestDefaultConfig_DeltaChatExample(t *testing.T) {
|
||||
@@ -1051,52 +1036,6 @@ func TestDefaultConfig_DeltaChatExample(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateSingletonChannels_RejectsMultipleInstances(t *testing.T) {
|
||||
channels := ChannelsConfig{
|
||||
"pico1": &Channel{Enabled: true, Type: ChannelPico},
|
||||
"pico2": &Channel{Enabled: true, Type: ChannelPico},
|
||||
}
|
||||
err := validateSingletonChannels(channels)
|
||||
if err == nil {
|
||||
t.Fatal("expected error for multiple pico channels, got nil")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "singleton") {
|
||||
t.Fatalf("expected singleton error, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateSingletonChannels_AllowsSingleInstance(t *testing.T) {
|
||||
channels := ChannelsConfig{
|
||||
"pico1": &Channel{Enabled: true, Type: ChannelPico},
|
||||
}
|
||||
err := validateSingletonChannels(channels)
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error for single pico channel, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateSingletonChannels_IgnoresDisabledInstances(t *testing.T) {
|
||||
channels := ChannelsConfig{
|
||||
"pico1": &Channel{Enabled: true, Type: ChannelPico},
|
||||
"pico2": &Channel{Enabled: false, Type: ChannelPico},
|
||||
}
|
||||
err := validateSingletonChannels(channels)
|
||||
if err != nil {
|
||||
t.Fatalf("expected no error when only one pico channel is enabled, got: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateSingletonChannels_AllowsMultiInstanceTypes(t *testing.T) {
|
||||
channels := ChannelsConfig{
|
||||
"tg1": &Channel{Enabled: true, Type: ChannelTelegram},
|
||||
"tg2": &Channel{Enabled: true, Type: ChannelTelegram},
|
||||
}
|
||||
err := validateSingletonChannels(channels)
|
||||
if err != nil {
|
||||
t.Fatalf("telegram should allow multiple instances, got error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestDefaultConfig_WebTools verifies web tools config
|
||||
func TestDefaultConfig_WebTools(t *testing.T) {
|
||||
cfg := DefaultConfig()
|
||||
@@ -1190,49 +1129,6 @@ func TestSaveConfig_PreservesDisabledTelegramPlaceholder(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSaveConfig_PreservesExplicitDisabledPicoStreaming(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
path := filepath.Join(tmpDir, "config.json")
|
||||
|
||||
cfg := DefaultConfig()
|
||||
pico := cfg.Channels.Get(ChannelPico)
|
||||
if pico == nil {
|
||||
t.Fatal("DefaultConfig() missing pico channel")
|
||||
}
|
||||
pico.Settings = RawNode(`{"streaming":{"enabled":false}}`)
|
||||
|
||||
if err := SaveConfig(path, cfg); err != nil {
|
||||
t.Fatalf("SaveConfig failed: %v", err)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile failed: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(data), `"streaming"`) || !strings.Contains(string(data), `"enabled": false`) {
|
||||
t.Fatalf("saved config should preserve explicit disabled pico streaming, got:\n%s", string(data))
|
||||
}
|
||||
|
||||
loaded, err := LoadConfig(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadConfig failed: %v", err)
|
||||
}
|
||||
loadedPico := loaded.Channels.Get(ChannelPico)
|
||||
if loadedPico == nil {
|
||||
t.Fatal("loaded config missing pico channel")
|
||||
}
|
||||
decoded, err := loadedPico.GetDecoded()
|
||||
if err != nil {
|
||||
t.Fatalf("pico GetDecoded() error = %v", err)
|
||||
}
|
||||
settings, ok := decoded.(*PicoSettings)
|
||||
if !ok {
|
||||
t.Fatalf("pico settings type = %T, want *PicoSettings", decoded)
|
||||
}
|
||||
if settings.Streaming.Enabled {
|
||||
t.Fatal("explicit disabled pico streaming should remain disabled after SaveConfig/LoadConfig round-trip")
|
||||
}
|
||||
}
|
||||
|
||||
// TestSaveConfig_FiltersVirtualModels verifies that SaveConfig does not write
|
||||
// virtual models (generated by expandMultiKeyModels) to the config file.
|
||||
func TestSaveConfig_FiltersVirtualModels(t *testing.T) {
|
||||
@@ -3251,7 +3147,6 @@ func testChannelsConfigWithTokens() ChannelsConfig {
|
||||
{"dingtalk", DingTalkSettings{ClientSecret: *NewSecureString("dingtalk-client-secret")}},
|
||||
{"onebot", OneBotSettings{AccessToken: *NewSecureString("onebot-access-token")}},
|
||||
{"wecom", WeComSettings{Secret: *NewSecureString("wecom-secret")}},
|
||||
{"pico", PicoSettings{Token: *NewSecureString("pico-token-abc123")}},
|
||||
{
|
||||
"irc",
|
||||
IRCSettings{
|
||||
@@ -3269,3 +3164,46 @@ func testChannelsConfigWithTokens() ChannelsConfig {
|
||||
}
|
||||
return channels
|
||||
}
|
||||
|
||||
func TestSaveConfig_PreservesExplicitDisabledTelegramStreaming(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
path := filepath.Join(tmpDir, "config.json")
|
||||
|
||||
cfg := DefaultConfig()
|
||||
telegram := cfg.Channels.Get(ChannelTelegram)
|
||||
if telegram == nil {
|
||||
t.Fatal("DefaultConfig() missing telegram channel")
|
||||
}
|
||||
telegram.Settings = RawNode(`{"streaming":{"enabled":false}}`)
|
||||
|
||||
if err := SaveConfig(path, cfg); err != nil {
|
||||
t.Fatalf("SaveConfig failed: %v", err)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatalf("ReadFile failed: %v", err)
|
||||
}
|
||||
if !strings.Contains(string(data), `"streaming"`) || !strings.Contains(string(data), `"enabled": false`) {
|
||||
t.Fatalf("saved config should preserve explicit disabled telegram streaming, got:\n%s", string(data))
|
||||
}
|
||||
|
||||
loaded, err := LoadConfig(path)
|
||||
if err != nil {
|
||||
t.Fatalf("LoadConfig failed: %v", err)
|
||||
}
|
||||
loadedTelegram := loaded.Channels.Get(ChannelTelegram)
|
||||
if loadedTelegram == nil {
|
||||
t.Fatal("loaded config missing telegram channel")
|
||||
}
|
||||
decoded, err := loadedTelegram.GetDecoded()
|
||||
if err != nil {
|
||||
t.Fatalf("telegram GetDecoded() error = %v", err)
|
||||
}
|
||||
settings, ok := decoded.(*TelegramSettings)
|
||||
if !ok {
|
||||
t.Fatalf("telegram settings type = %T, want *TelegramSettings", decoded)
|
||||
}
|
||||
if settings.Streaming.Enabled {
|
||||
t.Fatal("explicit disabled telegram streaming should remain disabled after SaveConfig/LoadConfig round-trip")
|
||||
}
|
||||
}
|
||||
@@ -533,9 +533,6 @@ func defaultChannels() ChannelsConfig {
|
||||
},
|
||||
"feishu": map[string]any{},
|
||||
"discord": map[string]any{},
|
||||
"maixcam": map[string]any{
|
||||
"settings": map[string]any{"host": "0.0.0.0", "port": 18790},
|
||||
},
|
||||
"qq": map[string]any{
|
||||
"settings": map[string]any{"max_message_length": 2000},
|
||||
},
|
||||
@@ -582,15 +579,6 @@ func defaultChannels() ChannelsConfig {
|
||||
"cdn_base_url": "https://novac2c.cdn.weixin.qq.com/c2c",
|
||||
},
|
||||
},
|
||||
"pico": map[string]any{
|
||||
"settings": map[string]any{
|
||||
"ping_interval": 30,
|
||||
"read_timeout": 60,
|
||||
"write_timeout": 10,
|
||||
"max_connections": 100,
|
||||
"streaming": map[string]any{"enabled": true},
|
||||
},
|
||||
},
|
||||
"irc": map[string]any{
|
||||
"settings": map[string]any{
|
||||
"server": "",
|
||||
|
||||
@@ -250,9 +250,6 @@ func TestAllSecurityKeysAccessible(t *testing.T) {
|
||||
"enabled": true,
|
||||
"bot_id": "test_wecom_bot_id"
|
||||
},
|
||||
"pico": {
|
||||
"enabled": true
|
||||
},
|
||||
"irc": {
|
||||
"enabled": true,
|
||||
"server": "irc.example.com",
|
||||
@@ -319,8 +316,6 @@ channels:
|
||||
access_token: "onebot_test_access_token"
|
||||
wecom:
|
||||
secret: "wecom_test_secret"
|
||||
pico:
|
||||
token: "pico_test_token"
|
||||
irc:
|
||||
password: "irc_test_password"
|
||||
nickserv_password: "irc_test_nickserv_password"
|
||||
@@ -437,11 +432,6 @@ skills:
|
||||
t.Logf("WeCom BotID: %s", wcSec.(*WeComSettings).BotID)
|
||||
t.Logf("WeCom Secret(): %s", secureStr(wcSec.(*WeComSettings).Secret))
|
||||
|
||||
// Pico
|
||||
picoSec := decodeChannel("pico")
|
||||
assert.Equal(t, "pico_test_token", secureStr(picoSec.(*PicoSettings).Token))
|
||||
t.Logf("Pico Token(): %s", secureStr(picoSec.(*PicoSettings).Token))
|
||||
|
||||
// IRC
|
||||
ircSec := decodeChannel("irc")
|
||||
assert.Equal(t, "irc_test_password", secureStr(ircSec.(*IRCSettings).Password))
|
||||
|
||||
@@ -115,7 +115,6 @@ func TestSaveAndLoadSecurityConfig(t *testing.T) {
|
||||
{"feishu", `{"enabled":true,"settings":{"app_id":"feishu_app_id","app_secret":"feishu_app_secret"}}`},
|
||||
{"discord", `{"enabled":true,"settings":{"token":"discord_token"}}`},
|
||||
{"qq", `{"enabled":true,"settings":{"app_secret":"qq_app_secret"}}`},
|
||||
{"pico_client", `{"enabled":true,"settings":{"token":"pico_client_token"}}`},
|
||||
} {
|
||||
bc := &Channel{}
|
||||
json.Unmarshal([]byte(d.raw), bc)
|
||||
@@ -129,8 +128,6 @@ func TestSaveAndLoadSecurityConfig(t *testing.T) {
|
||||
bc.Decode(&DiscordSettings{})
|
||||
case "feishu":
|
||||
bc.Decode(&FeishuSettings{})
|
||||
case "pico_client":
|
||||
bc.Decode(&PicoClientSettings{})
|
||||
}
|
||||
chs[d.name] = bc
|
||||
}
|
||||
@@ -185,7 +182,6 @@ func TestSaveAndLoadSecurityConfig(t *testing.T) {
|
||||
assert.Contains(t, getSetting("feishu")["app_secret"], "feishu_app_secret")
|
||||
assert.Contains(t, getSetting("discord")["token"], "discord_token")
|
||||
assert.Contains(t, getSetting("qq")["app_secret"], "qq_app_secret")
|
||||
assert.Contains(t, getSetting("pico_client")["token"], "pico_client_token")
|
||||
|
||||
// Rewrite file with deterministic content for load test (use channel_list)
|
||||
yamlOutput := `channel_list:
|
||||
@@ -197,8 +193,6 @@ func TestSaveAndLoadSecurityConfig(t *testing.T) {
|
||||
token: discord_token
|
||||
qq:
|
||||
app_secret: qq_app_secret
|
||||
pico_client:
|
||||
token: pico_client_token
|
||||
model_list:
|
||||
model1:0:
|
||||
api_keys:
|
||||
|
||||
Reference in new issue
Block a user