Compare commits
No commits in common. "d174ee7bc7f9bd7ed195b58f83888e0a7a744c2e" and "d1b6d153d4ed57b0ff9a3df1f4f5ac76c6119d06" have entirely different histories.
d174ee7bc7
...
d1b6d153d4
@ -479,7 +479,7 @@ impl Runner {
|
|||||||
let val = self.run_script(content)?;
|
let val = self.run_script(content)?;
|
||||||
|
|
||||||
// let rc: RunnerConfig = from_js(unsafe { self.context.context_raw() }, &val)?;
|
// let rc: RunnerConfig = from_js(unsafe { self.context.context_raw() }, &val)?;
|
||||||
let rc: RunnerConfig = DeserializerJS::deserialize_js(&val)?;
|
let rc: RunnerConfig = val.js_into()?;
|
||||||
|
|
||||||
Ok(rc)
|
Ok(rc)
|
||||||
}
|
}
|
||||||
@ -521,6 +521,16 @@ mod tests {
|
|||||||
println!("Val: {:?}", val.to_string());
|
println!("Val: {:?}", val.to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_deserialization_main() {
|
||||||
|
let runner = Runner::init().unwrap();
|
||||||
|
let val = runner.run_script(include_str!("../mainbot.js")).unwrap();
|
||||||
|
let s: RunnerConfig = from_js(unsafe { runner.context.context_raw() }, &val).unwrap();
|
||||||
|
println!("deser: {:#?}", s);
|
||||||
|
let o = val.try_into_object().unwrap();
|
||||||
|
println!("o: {:?}", recursive_format(o));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_func_deserialization_main() {
|
fn test_func_deserialization_main() {
|
||||||
let runner = Runner::init().unwrap();
|
let runner = Runner::init().unwrap();
|
||||||
|
|||||||
11
src/main.rs
11
src/main.rs
@ -105,7 +105,6 @@ pub struct BotController {
|
|||||||
pub bot: Bot,
|
pub bot: Bot,
|
||||||
pub db: DB,
|
pub db: DB,
|
||||||
pub rc: RunnerConfig,
|
pub rc: RunnerConfig,
|
||||||
pub runner: Runner,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BotController {
|
impl BotController {
|
||||||
@ -113,15 +112,9 @@ impl BotController {
|
|||||||
let bot = Bot::new(&config.bot_token);
|
let bot = Bot::new(&config.bot_token);
|
||||||
let db = DB::init(&config.db_url).await?;
|
let db = DB::init(&config.db_url).await?;
|
||||||
|
|
||||||
let runner = Runner::init()?;
|
let rc = Runner::init()?.init_config(include_str!("../mainbot.js"))?;
|
||||||
let rc = runner.init_config(include_str!("../mainbot.js"))?;
|
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self { bot, db, rc })
|
||||||
bot,
|
|
||||||
db,
|
|
||||||
rc,
|
|
||||||
runner,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user