(conf map[string]interface{}, config dto.AgentDiscordConfig)
| 950 | } |
| 951 | |
| 952 | func setDiscordConfig(conf map[string]interface{}, config dto.AgentDiscordConfig) { |
| 953 | channels := ensureChildMap(conf, "channels") |
| 954 | discord := ensureChildMap(channels, "discord") |
| 955 | defaultAccount := normalizeDefaultAccount(config.DefaultAccount, getDiscordBotAccountIDs(config.Bots)) |
| 956 | effectiveEnabled := config.Enabled && hasEnabledBots(config.Bots) |
| 957 | discord["enabled"] = effectiveEnabled |
| 958 | discord["dmPolicy"] = config.DmPolicy |
| 959 | discord["groupPolicy"] = config.GroupPolicy |
| 960 | discord["defaultAccount"] = defaultAccount |
| 961 | if config.RequireMention { |
| 962 | discord["groupPolicy"] = "allowlist" |
| 963 | } else if config.GroupPolicy == "allowlist" { |
| 964 | discord["groupPolicy"] = "allowlist" |
| 965 | } |
| 966 | if config.DmPolicy == "open" { |
| 967 | discord["allowFrom"] = []string{"*"} |
| 968 | } else if config.DmPolicy == "allowlist" { |
| 969 | discord["allowFrom"] = append([]string(nil), config.AllowFrom...) |
| 970 | } else { |
| 971 | delete(discord, "allowFrom") |
| 972 | } |
| 973 | if config.Proxy != "" { |
| 974 | discord["proxy"] = config.Proxy |
| 975 | } else { |
| 976 | delete(discord, "proxy") |
| 977 | } |
| 978 | accounts := make(map[string]interface{}, len(config.Bots)) |
| 979 | for _, bot := range config.Bots { |
| 980 | accounts[bot.AccountID] = map[string]interface{}{ |
| 981 | "enabled": bot.Enabled, |
| 982 | "name": bot.Name, |
| 983 | "token": bot.Token, |
| 984 | "groupPolicy": config.GroupPolicy, |
| 985 | } |
| 986 | } |
| 987 | discord["accounts"] = accounts |
| 988 | delete(discord, "token") |
| 989 | delete(discord, "dm") |
| 990 | } |
| 991 | |
| 992 | func extractQQBotConfig(conf map[string]interface{}) dto.AgentQQBotConfig { |
| 993 | result := dto.AgentQQBotConfig{Enabled: true} |
no test coverage detected