analyze_logs: fix 0x0 regex

This commit is contained in:
seth 2024-03-27 18:56:22 -04:00
parent a9a63f36ad
commit 4e11bd2bd7
2 changed files with 3 additions and 4 deletions

View file

@ -10,7 +10,7 @@ pub struct _0x0;
impl super::LogProvider for _0x0 { impl super::LogProvider for _0x0 {
async fn find_match(&self, message: &Message) -> Option<String> { async fn find_match(&self, message: &Message) -> Option<String> {
static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"https://0x0\.st/\w*\.\w*").unwrap()); static REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"https://0x0\.st/\w*.\w*").unwrap());
trace!("Checking if message {} is a 0x0 paste", message.id); trace!("Checking if message {} is a 0x0 paste", message.id);
REGEX REGEX

View file

@ -28,8 +28,7 @@ pub trait LogProvider {
fn get_first_capture(regex: &Lazy<Regex>, string: &str) -> Option<String> { fn get_first_capture(regex: &Lazy<Regex>, string: &str) -> Option<String> {
regex regex
.captures_iter(string) .captures_iter(string)
.filter_map(|c| c.get(1).map(|c| c.as_str().to_string())) .find_map(|c| c.get(1).map(|c| c.as_str().to_string()))
.nth(1)
} }
#[enum_dispatch(LogProvider)] #[enum_dispatch(LogProvider)]
@ -66,5 +65,5 @@ pub async fn find_log(message: &Message) -> Result<Option<String>> {
} }
} }
todo!() Ok(None)
} }