diff options
| author | Lorenz Leitner <lrnz.ltnr@gmail.com> | 2021-10-12 08:59:29 +0200 |
|---|---|---|
| committer | Lorenz Leitner <lrnz.ltnr@gmail.com> | 2021-10-12 12:06:57 +0200 |
| commit | 75a855cd8d2c9ab3653e82a8ef94139571e3a7cd (patch) | |
| tree | 22f7c6c661504360d17f5b92e02762fa8f61535b /src/hooks/wolfram_alpha.rs | |
| parent | Rename wa, change anyhow version, make reqwest dependency more specific (diff) | |
Move short url to back of result
Diffstat (limited to 'src/hooks/wolfram_alpha.rs')
| -rw-r--r-- | src/hooks/wolfram_alpha.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/hooks/wolfram_alpha.rs b/src/hooks/wolfram_alpha.rs index cb4bc4c..e440eb8 100644 --- a/src/hooks/wolfram_alpha.rs +++ b/src/hooks/wolfram_alpha.rs @@ -1,4 +1,4 @@ -use crate::util::web::shorten_url; +use crate::util::{formatting::truncate, web::shorten_url}; use anyhow::{bail, Context, Error, Result}; use futures::try_join; use irc::client::prelude::*; @@ -97,8 +97,8 @@ async fn wa_query( Ok(format!( "{} - {}", + truncate(&to_single_string(wa_res), 250), // Same length as in gonzobot &user_url_shortened, - to_single_string(wa_res) )) } @@ -134,8 +134,11 @@ mod tests { mockito::start(); let res = wa_query("5/10", None, Some(&mockito::server_url())).await?; - let res_without_link = res.splitn(2, "-").collect::<Vec<&str>>()[1].trim(); - assert_eq!(res_without_link, "Exact result: 1/2 - Decimal form: 0.5"); + let res_without_link = res.rsplitn(2, "-").collect::<Vec<&str>>()[1..].join(" "); + assert_eq!( + res_without_link.trim(), + "Exact result: 1/2 - Decimal form: 0.5" + ); Ok(()) } } |
