MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / extractQQBotConfig

Function extractQQBotConfig

agent/app/service/agents_channels.go:992–1038  ·  view source on GitHub ↗
(conf map[string]interface{})

Source from the content-addressed store, hash-verified

990}
991
992func extractQQBotConfig(conf map[string]interface{}) dto.AgentQQBotConfig {
993 result := dto.AgentQQBotConfig{Enabled: true}
994 qqbot := getChannelConfig(conf, "qqbot")
995 if len(qqbot) == 0 {
996 result.Bots = []dto.AgentQQBotBot{}
997 return result
998 }
999 if enabled, ok := qqbot["enabled"].(bool); ok {
1000 result.Enabled = enabled
1001 }
1002 bots := make([]dto.AgentQQBotBot, 0, len(childMap(qqbot, "accounts"))+1)
1003 defaultBot := dto.AgentQQBotBot{
1004 AgentChannelBotBase: dto.AgentChannelBotBase{
1005 AccountID: "default",
1006 Name: extractStringValue(qqbot["name"]),
1007 Enabled: extractBoolValue(qqbot["enabled"], true),
1008 IsDefault: true,
1009 },
1010 AppID: extractStringValue(qqbot["appId"]),
1011 ClientSecret: extractStringValue(qqbot["clientSecret"]),
1012 AllowFrom: extractStringList(qqbot["allowFrom"]),
1013 SystemPrompt: extractStringValue(qqbot["systemPrompt"]),
1014 }
1015 if defaultBot.Name == "" {
1016 defaultBot.Name = "Default"
1017 }
1018 if defaultBot.AppID != "" || defaultBot.ClientSecret != "" {
1019 bots = append(bots, defaultBot)
1020 }
1021 accounts := childMap(qqbot, "accounts")
1022 for _, accountID := range sortedChildKeys(accounts) {
1023 account := childMap(accounts, accountID)
1024 bots = append(bots, dto.AgentQQBotBot{
1025 AgentChannelBotBase: dto.AgentChannelBotBase{
1026 AccountID: accountID,
1027 Name: extractDisplayName(account, accountID, accountID),
1028 Enabled: extractBoolValue(account["enabled"], true),
1029 },
1030 AppID: extractStringValue(account["appId"]),
1031 ClientSecret: extractStringValue(account["clientSecret"]),
1032 AllowFrom: extractStringList(account["allowFrom"]),
1033 SystemPrompt: extractStringValue(account["systemPrompt"]),
1034 })
1035 }
1036 result.Bots = bots
1037 return result
1038}
1039
1040func extractWecomConfig(conf map[string]interface{}) dto.AgentWecomConfig {
1041 result := dto.AgentWecomConfig{

Callers 2

GetQQBotConfigMethod · 0.85

Calls 7

getChannelConfigFunction · 0.85
childMapFunction · 0.85
extractStringValueFunction · 0.85
extractBoolValueFunction · 0.85
extractStringListFunction · 0.85
sortedChildKeysFunction · 0.85
extractDisplayNameFunction · 0.85

Tested by

no test coverage detected