Compare commits
1 Commits
ef1fdb5f36
...
main
Author | SHA1 | Date |
---|---|---|
annieversary | 16c1e7da0a |
24
src/main.rs
24
src/main.rs
|
@ -89,32 +89,33 @@ fn run(
|
||||||
let statuses = client.statuses(&acc.id, None)?;
|
let statuses = client.statuses(&acc.id, None)?;
|
||||||
|
|
||||||
let regex = Regex::new(regex).unwrap();
|
let regex = Regex::new(regex).unwrap();
|
||||||
let mut results = Vec::new();
|
let mut count = 0;
|
||||||
|
|
||||||
if verbose {
|
println!("\n\nResults:\n");
|
||||||
println!("Searching...");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Search through statuses
|
// Search through statuses
|
||||||
for status in statuses.items_iter() {
|
for status in statuses.items_iter() {
|
||||||
// Add it to results if it matches and it isn't a retoot
|
// Add it to results if it matches and it isn't a retoot
|
||||||
// or if it matches and isn't a retoot
|
// or if it matches and isn't a retoot
|
||||||
if status_matches(&status, ®ex) && (include_retoots || status.reblog.is_none()) {
|
if status_matches(&status, ®ex) && (include_retoots || status.reblog.is_none()) {
|
||||||
results.push(status);
|
print_status(&status, verbose);
|
||||||
|
count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's a limit of results, check it and exit
|
// If there's a limit of results, check it and exit
|
||||||
if let Some(max) = max_statuses {
|
if let Some(max) = max_statuses {
|
||||||
if results.len() >= max {
|
if count >= max {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("\n\nResults:\n");
|
println!("Found {} results", count);
|
||||||
|
|
||||||
// Print results
|
Ok(())
|
||||||
for status in &results {
|
}
|
||||||
|
|
||||||
|
fn print_status(status: &Status, verbose: bool) {
|
||||||
if !status.spoiler_text.is_empty() {
|
if !status.spoiler_text.is_empty() {
|
||||||
println!("CW: {}", status.spoiler_text);
|
println!("CW: {}", status.spoiler_text);
|
||||||
}
|
}
|
||||||
|
@ -143,11 +144,6 @@ fn run(
|
||||||
println!();
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Found {} results", results.len());
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn status_matches(status: &Status, regex: &Regex) -> bool {
|
fn status_matches(status: &Status, regex: &Regex) -> bool {
|
||||||
regex.is_match(&status.content) || regex.is_match(&status.spoiler_text)
|
regex.is_match(&status.content) || regex.is_match(&status.spoiler_text)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue