html terminal
update mindus
| -rw-r--r-- | Cargo.toml | 3 | ||||
| -rw-r--r-- | src/bot/maps.rs | 5 | ||||
| -rw-r--r-- | src/bot/mod.rs | 6 | ||||
| -rw-r--r-- | src/bot/schematic.rs | 2 | ||||
| -rw-r--r-- | src/main.rs | 4 | ||||
| -rw-r--r-- | src/process.rs | 5 |
6 files changed, 11 insertions, 14 deletions
@@ -22,7 +22,6 @@ tokio = { version = "1.28.2", features = [ ], default-features = false } tokio-stream = "0.1.14" futures-util = "0.3.28" -strip-ansi-escapes = "0.1.1" serenity = { version = "0.11.5", features = [ "builder", "client", @@ -40,7 +39,7 @@ parse_duration = "2.1.1" serde = "1.0" serde_json = "1.0" btparse = "0.1.1" -mindus = { version = "1", features = ["schem_shadow"], default-features = false } +mindus = { version = "3", features = [], default-features = false } image = { version = "0.24.6", features = ["png"], default-features = false } oxipng = { git = "https://github.com/shssoichiro/oxipng", branch = "master", features = [], default-features = false } diff --git a/src/bot/maps.rs b/src/bot/maps.rs index 8b5976e..015c276 100644 --- a/src/bot/maps.rs +++ b/src/bot/maps.rs @@ -106,10 +106,9 @@ impl MapImage { let deser_took = then.elapsed(); let name = m.tags.get("mapname").unwrap().to_owned(); let render_took = Instant::now(); - let i = m.render(); + let i = unsafe { m.render() }; let render_took = render_took.elapsed(); let compression_took = Instant::now(); - // TODO make render() return RgbImage let i = RawImage::new( i.width(), i.height(), @@ -117,7 +116,7 @@ impl MapImage { transparent_color: None, }, BitDepth::Eight, - image::DynamicImage::ImageRgba8(i).to_rgb8().to_vec(), + i.into_vec(), ) .unwrap(); *lock = i diff --git a/src/bot/mod.rs b/src/bot/mod.rs index 64c0486..3809c4e 100644 --- a/src/bot/mod.rs +++ b/src/bot/mod.rs @@ -186,7 +186,11 @@ async fn get_nextblock() -> String { .unwrap_or("._?".to_string()) } -#[poise::command(slash_command, category = "Control")] +#[poise::command( + slash_command, + category = "Control", + required_permissions = "ADMINISTRATOR" +)] /// say something as the server async fn say(ctx: Context<'_>, #[description = "Message"] message: String) -> Result<()> { ctx.data().stdin.send(format!("say {message}"))?; diff --git a/src/bot/schematic.rs b/src/bot/schematic.rs index 207edca..2d618d8 100644 --- a/src/bot/schematic.rs +++ b/src/bot/schematic.rs @@ -44,7 +44,7 @@ pub async fn draw(ctx: Context<'_>, schematic: String) -> Result<()> { async fn send(ctx: &Context<'_>, s: &Schematic<'_>, send_schematic: bool) -> Result<()> { let mut b = vec![]; - let p = s.render(); + let p = unsafe { s.render() }; PngEncoder::new(&mut b).write_image(&p, p.width(), p.height(), image::ColorType::Rgba8)?; let n = strip_colors(s.tags.get("name").unwrap()); poise::send_reply(*ctx, |m| { diff --git a/src/main.rs b/src/main.rs index 1a1b9ae..95ec46a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,12 +10,10 @@ mod webhook; use server::*; use std::net::SocketAddr; -// loads all the images into memory, ~300mb -use mindus::data::renderer::warmup; #[tokio::main(flavor = "current_thread")] async fn main() { - warmup(); + unsafe { mindus::warmup() }; Server::spawn(SocketAddr::from(( [0, 0, 0, 0], std::env::var("PORT").map_or(4001, |x| u16::from_str(&x).unwrap()), diff --git a/src/process.rs b/src/process.rs index bfa284e..4639531 100644 --- a/src/process.rs +++ b/src/process.rs @@ -67,10 +67,7 @@ impl Process { for line in string.lines() { output!("{line}"); } - let stripped = - String::from_utf8_lossy(&strip_ansi_escapes::strip(&string).unwrap()) - .into_owned(); - output.send(stripped).unwrap(); + output.send(string).unwrap(); sleep(Duration::from_millis(500)).await; } }) |