icalingua-python-bot/ica-rs/src/py.rs
shenjack 4bda64d8fa
又是一大堆更新
aaa
竟然把某些信息带上了(
2024-02-18 23:02:16 +08:00

22 lines
549 B
Rust

use pyo3::{prelude::*, types::IntoPyDict};
use tracing::{debug, info};
#[pyclass]
#[pyo3(name = "BotStatus")]
pub struct BotStatusPy {}
pub fn run() {
Python::with_gil(|py| {
let bot_status = BotStatusPy {};
let _bot_status = PyCell::new(py, bot_status).unwrap();
let locals = [("state", _bot_status)].into_py_dict(py);
py.run("print(state)", None, Some(locals)).unwrap();
});
}
pub fn init_py() {
debug!("initing python threads");
pyo3::prepare_freethreaded_python();
info!("python inited")
}