create call_context method for BotFunction

This commit is contained in:
Akulij 2025-05-19 23:54:39 +05:00
parent c8c67b54e3
commit c2e02efc47

View File

@ -20,6 +20,13 @@ pub type ScriptResult<T> = Result<T, ScriptError>;
#[derive(Serialize, Deserialize, Debug, Clone)] #[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BotFunction(String); // temporal workaround pub struct BotFunction(String); // temporal workaround
impl BotFunction {
pub fn call_context(&self, runner: &Runner) -> ScriptResult<JsValue> {
let func_name = &self.0;
runner.run_script(&format!("{func_name}()"))
}
}
// TODO: remove this function since it is suitable only for early development // TODO: remove this function since it is suitable only for early development
#[allow(clippy::print_stdout)] #[allow(clippy::print_stdout)]
fn print(s: String) { fn print(s: String) {