fix: ADD_SWITCHER keyword syntax - special handling for 'as' keyword format
All checks were successful
Botlib CI / build (push) Successful in 7s
Bottest CI / build (push) Successful in 31s
BotUI CI / build (push) Successful in 18s

The ADD_SWITCHER keyword was generating comma-separated params (ADD_SWITCHER(id, label))
instead of the expected Rhai custom syntax (ADD_SWITCHER id as label).

This fix adds special handling in the multiword processor to output the correct
format when processing ADD_SWITCHER with 2 parameters.

Fixes #495
This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-04-24 18:53:20 +00:00
parent 3048832a2d
commit 9f7da0a291

View file

@ -1388,13 +1388,19 @@ pub fn convert_keywords_to_lowercase(script: &str) -> String {
let keyword = pattern.replace(r"\s+", "_"); let keyword = pattern.replace(r"\s+", "_");
// Build function call // Build function call
// Special handling for ADD_SWITCHER which uses "as" syntax
let output = if keyword == "ADD_SWITCHER" && params.len() == 2 {
format!("ADD_SWITCHER {} as {};", params[0], params[1])
} else {
let params_str = if params.is_empty() { let params_str = if params.is_empty() {
String::new() String::new()
} else { } else {
params.join(", ") params.join(", ")
}; };
format!("{}({});", keyword, params_str)
};
result.push_str(&format!("{}({});", keyword, params_str)); result.push_str(&output);
result.push('\n'); result.push('\n');
converted = true; converted = true;
break; break;