3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 09:35:02 +00:00

dot syntax

This commit is contained in:
almeidx 2021-09-08 14:31:04 +01:00
parent 09f502dc99
commit c975c672bc
No known key found for this signature in database
GPG key ID: 8558FBFF849BD664

View file

@ -66,24 +66,24 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
continue; continue;
} }
rule["name"] = name; rule.name = name;
// If the rule doesn't have an explicitly set "enabled" property, set it to true // If the rule doesn't have an explicitly set "enabled" property, set it to true
if (rule["enabled"] == null) { if (rule.enabled == null) {
rule["enabled"] = true; rule.enabled = true;
} }
if (rule["allow_further_rules"] == null) { if (rule.allow_further_rules == null) {
rule["allow_further_rules"] = false; rule.allow_further_rules = false;
} }
if (rule["affects_bots"] == null) { if (rule.affects_bots == null) {
rule["affects_bots"] = false; rule.affects_bots = false;
} }
// Loop through the rule's triggers // Loop through the rule's triggers
if (rule["triggers"]) { if (rule.triggers) {
for (const triggerObj of rule["triggers"]) { for (const triggerObj of rule.triggers) {
for (const triggerName in triggerObj) { for (const triggerName in triggerObj) {
if (!availableTriggers[triggerName]) { if (!availableTriggers[triggerName]) {
throw new StrictValidationError([`Unknown trigger '${triggerName}' in rule '${rule.name}'`]); throw new StrictValidationError([`Unknown trigger '${triggerName}' in rule '${rule.name}'`]);
@ -152,26 +152,26 @@ const configPreprocessor: ConfigPreprocessorFn<AutomodPluginType> = options => {
} }
const actionBlueprint = availableActions[actionName]; const actionBlueprint = availableActions[actionName];
const actionConfig = rule["actions"][actionName]; const actionConfig = rule.actions[actionName];
if (typeof actionConfig !== "object" || Array.isArray(actionConfig) || actionConfig == null) { if (typeof actionConfig !== "object" || Array.isArray(actionConfig) || actionConfig == null) {
rule["actions"][actionName] = actionConfig; rule.actions[actionName] = actionConfig;
} else { } else {
rule["actions"][actionName] = configUtils.mergeConfig(actionBlueprint.defaultConfig, actionConfig); rule.actions[actionName] = configUtils.mergeConfig(actionBlueprint.defaultConfig, actionConfig);
} }
} }
} }
// Enable logging of automod actions by default // Enable logging of automod actions by default
if (rule["actions"]) { if (rule.actions) {
for (const actionName in rule.actions) { for (const actionName in rule.actions) {
if (!availableActions[actionName]) { if (!availableActions[actionName]) {
throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule.name}'`]); throw new StrictValidationError([`Unknown action '${actionName}' in rule '${rule.name}'`]);
} }
} }
if (rule["actions"]["log"] == null) { if (rule.actions.log == null) {
rule["actions"]["log"] = true; rule.actions.log = true;
} }
} }
} }