re-add code blocks

This commit is contained in:
2024-10-14 23:21:02 -04:00
parent 6478575c17
commit 3226487a65

View File

@@ -7,6 +7,8 @@ pub async fn eval(ctx: Context<'_>,
#[rest]
expr: String) -> Result<(), Error>
{
let expr = expr.strip_prefix("```").and_then(|s| s.strip_suffix("```")).unwrap_or(&expr);
let values = lamm::evaluate(Cursor::new(expr));
let output = values.fold(Ok(String::new()), |acc, v| {
@@ -15,7 +17,7 @@ pub async fn eval(ctx: Context<'_>,
};
let x = acc.unwrap();
match v {
Ok(v) => Ok(format!("{x}\n{v}")),
Err(e) => Err(e),
@@ -25,4 +27,4 @@ pub async fn eval(ctx: Context<'_>,
ctx.reply(output?).await?;
Ok(())
}
}