@@ -390,9 +390,7 @@ func extractFeishuConfig(conf map[string]interface{}) dto.AgentFeishuConfig {
390390 if len (feishu ) == 0 {
391391 return result
392392 }
393- if enabled , ok := feishu ["enabled" ].(bool ); ok {
394- result .Enabled = enabled
395- }
393+ result .Enabled = extractFeishuPluginEnabled (conf , extractBoolValue (feishu ["enabled" ], result .Enabled ))
396394 if threadSession , ok := feishu ["threadSession" ].(bool ); ok {
397395 result .ThreadSession = threadSession
398396 }
@@ -408,16 +406,34 @@ func extractFeishuConfig(conf map[string]interface{}) dto.AgentFeishuConfig {
408406 }
409407 result .GroupAllowFrom = extractStringList (feishu ["groupAllowFrom" ])
410408 defaultBot := defaultFeishuBot ()
409+ defaultBot .Enabled = extractBoolValue (feishu ["enabled" ], defaultBot .Enabled )
410+ defaultBot .Name = extractDisplayName (feishu , "" , "default" )
411411 defaultBot .AppID = extractStringValue (feishu ["appId" ])
412412 defaultBot .AppSecret = extractStringValue (feishu ["appSecret" ])
413+ if dmPolicy := extractStringValue (feishu ["dmPolicy" ]); dmPolicy != "" {
414+ defaultBot .DmPolicy = dmPolicy
415+ }
416+ if _ , ok := feishu ["allowFrom" ]; ok {
417+ defaultBot .AllowFrom = extractStringList (feishu ["allowFrom" ])
418+ }
413419 accounts := childMap (feishu , "accounts" )
414420 defaultAccount := childMap (accounts , "default" )
415- defaultBot .Enabled = extractBoolValue (defaultAccount ["enabled" ], extractBoolValue (feishu ["enabled" ], true ))
416- defaultBot .Name = extractDisplayName (defaultAccount , extractStringValue (defaultAccount ["botName" ]), "Default" )
417- if dmPolicy := extractStringValue (defaultAccount ["dmPolicy" ]); dmPolicy != "" {
418- defaultBot .DmPolicy = dmPolicy
421+ if defaultBot .Name == "Default" {
422+ defaultBot .Name = extractDisplayName (defaultAccount , extractStringValue (defaultAccount ["botName" ]), "Default" )
423+ }
424+ if defaultBot .DmPolicy == "pairing" {
425+ if dmPolicy := extractStringValue (defaultAccount ["dmPolicy" ]); dmPolicy != "" {
426+ defaultBot .DmPolicy = dmPolicy
427+ }
419428 }
420- defaultBot .AllowFrom = extractStringList (defaultAccount ["allowFrom" ])
429+ if len (defaultBot .AllowFrom ) == 0 {
430+ if _ , ok := defaultAccount ["allowFrom" ]; ok {
431+ defaultBot .AllowFrom = extractStringList (defaultAccount ["allowFrom" ])
432+ }
433+ }
434+ baseEnabled := defaultBot .Enabled
435+ baseDmPolicy := defaultBot .DmPolicy
436+ baseAllowFrom := append ([]string (nil ), defaultBot .AllowFrom ... )
421437 bots := []dto.AgentFeishuBot {defaultBot }
422438 for _ , accountID := range sortedChildKeys (accounts ) {
423439 if accountID == "default" {
@@ -428,15 +444,19 @@ func extractFeishuConfig(conf map[string]interface{}) dto.AgentFeishuConfig {
428444 AgentChannelBotBase : dto.AgentChannelBotBase {
429445 AccountID : accountID ,
430446 Name : extractDisplayName (account , extractStringValue (account ["botName" ]), accountID ),
431- Enabled : extractBoolValue (account ["enabled" ], true ),
447+ Enabled : extractBoolValue (account ["enabled" ], baseEnabled ),
432448 },
433449 AppID : extractStringValue (account ["appId" ]),
434450 AppSecret : extractStringValue (account ["appSecret" ]),
435- AllowFrom : extractStringList (account ["allowFrom" ]),
451+ DmPolicy : baseDmPolicy ,
452+ AllowFrom : append ([]string (nil ), baseAllowFrom ... ),
436453 }
437454 if dmPolicy := extractStringValue (account ["dmPolicy" ]); dmPolicy != "" {
438455 bot .DmPolicy = dmPolicy
439456 }
457+ if _ , ok := account ["allowFrom" ]; ok {
458+ bot .AllowFrom = extractStringList (account ["allowFrom" ])
459+ }
440460 bots = append (bots , bot )
441461 }
442462 result .Bots = bots
@@ -447,8 +467,7 @@ func setFeishuConfig(conf map[string]interface{}, config dto.AgentFeishuConfig)
447467 channels := ensureChildMap (conf , "channels" )
448468 feishu := ensureChildMap (channels , "feishu" )
449469 defaultBot := getDefaultFeishuBot (config .Bots )
450- effectiveEnabled := config .Enabled && hasEnabledBots (config .Bots )
451- feishu ["enabled" ] = effectiveEnabled
470+ feishu ["enabled" ] = defaultBot .Enabled
452471 feishu ["threadSession" ] = config .ThreadSession
453472 feishu ["replyMode" ] = config .ReplyMode
454473 feishu ["streaming" ] = config .Streaming
@@ -465,9 +484,20 @@ func setFeishuConfig(conf map[string]interface{}, config dto.AgentFeishuConfig)
465484 }
466485 feishu ["appId" ] = defaultBot .AppID
467486 feishu ["appSecret" ] = defaultBot .AppSecret
487+ feishu ["dmPolicy" ] = defaultBot .DmPolicy
488+ if defaultBot .Name != "" && defaultBot .Name != "Default" {
489+ feishu ["name" ] = defaultBot .Name
490+ } else {
491+ delete (feishu , "name" )
492+ }
493+ if defaultBot .DmPolicy == "open" {
494+ feishu ["allowFrom" ] = []string {"*" }
495+ } else if defaultBot .DmPolicy == "allowlist" {
496+ feishu ["allowFrom" ] = append ([]string (nil ), defaultBot .AllowFrom ... )
497+ } else {
498+ delete (feishu , "allowFrom" )
499+ }
468500 delete (feishu , "botName" )
469- delete (feishu , "dmPolicy" )
470- delete (feishu , "allowFrom" )
471501 delete (feishu , "connectionMode" )
472502 delete (feishu , "domain" )
473503 delete (feishu , "webhookPath" )
@@ -476,29 +506,13 @@ func setFeishuConfig(conf map[string]interface{}, config dto.AgentFeishuConfig)
476506 delete (feishu , "resolveSenderNames" )
477507 delete (feishu , "defaultAccount" )
478508 accounts := make (map [string ]interface {}, len (config .Bots ))
479- defaultAccount := map [string ]interface {}{}
480- if ! defaultBot .Enabled {
481- defaultAccount ["enabled" ] = false
482- }
483- if defaultBot .Name != "" && defaultBot .Name != "Default" {
484- defaultAccount ["botName" ] = defaultBot .Name
485- }
486- if defaultBot .DmPolicy != "" {
487- defaultAccount ["dmPolicy" ] = defaultBot .DmPolicy
488- }
489- if defaultBot .DmPolicy == "open" {
490- defaultAccount ["allowFrom" ] = []string {"*" }
491- } else if defaultBot .DmPolicy == "allowlist" {
492- defaultAccount ["allowFrom" ] = append ([]string (nil ), defaultBot .AllowFrom ... )
493- }
494- accounts ["default" ] = defaultAccount
495509 for _ , bot := range config .Bots {
496510 if bot .AccountID == "default" || bot .IsDefault {
497511 continue
498512 }
499513 account := map [string ]interface {}{
500514 "enabled" : bot .Enabled ,
501- "botName" : bot .Name ,
515+ "name" : bot .Name ,
502516 "appId" : bot .AppID ,
503517 "appSecret" : bot .AppSecret ,
504518 }
@@ -512,7 +526,18 @@ func setFeishuConfig(conf map[string]interface{}, config dto.AgentFeishuConfig)
512526 }
513527 accounts [bot .AccountID ] = account
514528 }
515- feishu ["accounts" ] = accounts
529+ if len (accounts ) > 0 {
530+ feishu ["accounts" ] = accounts
531+ } else {
532+ delete (feishu , "accounts" )
533+ }
534+ }
535+
536+ func extractFeishuPluginEnabled (conf map [string ]interface {}, defaultValue bool ) bool {
537+ plugins := childMap (conf , "plugins" )
538+ entries := childMap (plugins , "entries" )
539+ lark := childMap (entries , "openclaw-lark" )
540+ return extractBoolValue (lark ["enabled" ], defaultValue )
516541}
517542
518543func setFeishuPluginEnabled (conf map [string ]interface {}, enabled bool ) {
0 commit comments