From 1f4f7698dcb37ffa71256fba981fe4532511d94f Mon Sep 17 00:00:00 2001 From: lemonsh Date: Wed, 27 Jul 2022 00:56:00 +0200 Subject: [PATCH] Title regex gaming --- src/commands/title.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/title.rs b/src/commands/title.rs index 91a529d..6290f8d 100644 --- a/src/commands/title.rs +++ b/src/commands/title.rs @@ -14,7 +14,7 @@ impl Title { pub fn new() -> anyhow::Result { Ok(Title { http: Client::new(), - title_regex: Regex::new(r"(?<=)(.*)(?=)")?, + title_regex: Regex::new(r"]*>(.*?)")?, }) } } @@ -40,7 +40,7 @@ impl Trigger for Title { .unwrap_or("text/html"); if mime.contains("text/html") { let body = response.text().await?; - if let Some(tm) = self.title_regex.find(&body)? { + if let Some(tm) = self.title_regex.captures(&body)?.and_then(|c| c.get(1)) { let title_match = tm.as_str(); let result = decode_html(title_match).unwrap_or_else(|_| title_match.to_string()); Ok(format!("\x039[Title]\x0311 {}", result))