From 75a855cd8d2c9ab3653e82a8ef94139571e3a7cd Mon Sep 17 00:00:00 2001 From: Lorenz Leitner Date: Tue, 12 Oct 2021 08:59:29 +0200 Subject: Move short url to back of result --- src/hooks/wolfram_alpha.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/hooks/wolfram_alpha.rs') 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::>()[1].trim(); - assert_eq!(res_without_link, "Exact result: 1/2 - Decimal form: 0.5"); + let res_without_link = res.rsplitn(2, "-").collect::>()[1..].join(" "); + assert_eq!( + res_without_link.trim(), + "Exact result: 1/2 - Decimal form: 0.5" + ); Ok(()) } } -- cgit v1.2.3