From 591244b5a1c3240a96f3d35e98bc15d0cded4665 Mon Sep 17 00:00:00 2001 From: Akulij Date: Fri, 6 Jun 2025 01:37:35 +0500 Subject: [PATCH] craate getter for varianted commands --- src/botscript.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/botscript.rs b/src/botscript.rs index 97deab2..7bf6f78 100644 --- a/src/botscript.rs +++ b/src/botscript.rs @@ -912,6 +912,28 @@ impl RunnerConfig { bm.map(|bm| bm.fill_literal(command.to_string()).update_defaults()) } + pub fn get_command_message_varianted( + &self, + command: &str, + variant: &str, + ) -> Option { + if !self.dialog.commands.contains_key(command) { + return None; + } + // fallback to regular if not found + let bm = match self.dialog.variants.get(command).cloned() { + Some(bm) => bm, + None => return self.get_command_message(command), + }; + // get variant of message + let bm = match bm.get(variant).cloned() { + Some(bm) => bm, + None => return self.get_command_message(command), + }; + + Some(bm.fill_literal(command.to_string()).update_defaults()) + } + pub fn get_callback_message(&self, callback: &str) -> Option { let bm = self.dialog.buttons.get(callback).cloned();