botserver/src/basic/keywords/last.rs
Rodrigo Rodriguez (Pragmatismo) 73d0ab3a1a refactor: simplify UI panels, use pooled DB, add --noui flag
- Removed unused `id` and `app_state` fields from `ChatPanel`; updated constructor to accept but ignore the state, reducing memory footprint.
- Switched database access in `ChatPanel` from a raw `Mutex` lock to a connection pool (`app_state.conn.get()`), improving concurrency and error handling.
- Reordered and cleaned up imports in `status_panel.rs` and formatted struct fields for readability.
- Updated VS Code launch configuration to pass `--noui` argument, enabling headless mode for debugging.
- Bumped several crate versions in `Cargo.lock` (e.g., `bitflags` to 2.10.0, `syn` to 2.0.108, `cookie` to 0.16.2) and added the new `ashpd` dependency, aligning the project with latest library releases.
2025-11-11 09:42:52 -03:00

18 lines
537 B
Rust

use rhai::Dynamic;
use rhai::Engine;
pub fn last_keyword(engine: &mut Engine) {
engine
.register_custom_syntax(&["LAST", "(", "$expr$", ")"], false, {
move |context, inputs| {
let input_string = context.eval_expression_tree(&inputs[0])?;
let input_str = input_string.to_string();
if input_str.trim().is_empty() {
return Ok(Dynamic::from(""));
}
let words: Vec<&str> = input_str.split_whitespace().collect();
let last_word = words.last().map(|s| *s).unwrap_or("");
Ok(Dynamic::from(last_word.to_string()))
}
})
.unwrap();
}