aboutsummaryrefslogtreecommitdiffstats
path: root/src/commands/math.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/math.rs')
-rw-r--r--src/commands/math.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/commands/math.rs b/src/commands/math.rs
index 43a7de8..25ddaab 100644
--- a/src/commands/math.rs
+++ b/src/commands/math.rs
@@ -57,11 +57,20 @@ pub async fn math(
57 return Ok(()); 57 return Ok(());
58 } 58 }
59 59
60 let output = tokio::process::Command::new("qalc") 60 let output = match tokio::time::timeout(
61 .arg(&equation) 61 std::time::Duration::from_secs(5),
62 .output() 62 tokio::process::Command::new("qalc")
63 .await 63 .arg(&equation)
64 .map_err(|e| Error::Custom(lang::fmt_math_qalc_err(&e)))?; 64 .output(),
65 )
66 .await
67 {
68 Ok(result) => result.map_err(|e| Error::Custom(lang::fmt_math_qalc_err(&e)))?,
69 Err(_) => {
70 ctx.say(lang::L_MATH_NO_RESULT).await?;
71 return Ok(());
72 }
73 };
65 74
66 let result = String::from_utf8_lossy(&output.stdout).trim().to_string(); 75 let result = String::from_utf8_lossy(&output.stdout).trim().to_string();
67 if result.is_empty() { 76 if result.is_empty() {