Compare commits
No commits in common. "main" and "ef1fdb5f369856fd901bf18aae81fa774f37dabe" have entirely different histories.
main
...
ef1fdb5f36
64
src/main.rs
64
src/main.rs
|
@ -89,59 +89,63 @@ 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 count = 0;
|
let mut results = Vec::new();
|
||||||
|
|
||||||
println!("\n\nResults:\n");
|
if verbose {
|
||||||
|
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()) {
|
||||||
print_status(&status, verbose);
|
results.push(status);
|
||||||
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 count >= max {
|
if results.len() >= max {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Found {} results", count);
|
println!("\n\nResults:\n");
|
||||||
|
|
||||||
Ok(())
|
// Print results
|
||||||
}
|
for status in &results {
|
||||||
|
if !status.spoiler_text.is_empty() {
|
||||||
fn print_status(status: &Status, verbose: bool) {
|
println!("CW: {}", status.spoiler_text);
|
||||||
if !status.spoiler_text.is_empty() {
|
}
|
||||||
println!("CW: {}", status.spoiler_text);
|
println!("Content: {}", status.content);
|
||||||
}
|
// Print actual url if it's a retoot
|
||||||
println!("Content: {}", status.content);
|
if let Some(retoot) = &status.reblog {
|
||||||
// Print actual url if it's a retoot
|
if let Some(url) = &retoot.url {
|
||||||
if let Some(retoot) = &status.reblog {
|
println!("Url: {}", url);
|
||||||
if let Some(url) = &retoot.url {
|
}
|
||||||
|
} else if let Some(url) = &status.url {
|
||||||
println!("Url: {}", url);
|
println!("Url: {}", url);
|
||||||
}
|
}
|
||||||
} else if let Some(url) = &status.url {
|
|
||||||
println!("Url: {}", url);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print some extra info
|
// Print some extra info
|
||||||
if verbose {
|
if verbose {
|
||||||
println!("Created at: {}", status.created_at);
|
println!("Created at: {}", status.created_at);
|
||||||
if let Some(retoot) = &status.reblog {
|
if let Some(retoot) = &status.reblog {
|
||||||
println!("Is retoot: yes ({})", retoot.account.acct);
|
println!("Is retoot: yes ({})", retoot.account.acct);
|
||||||
} else {
|
} else {
|
||||||
// We don't want to print these if it's a retoot
|
// We don't want to print these if it's a retoot
|
||||||
println!("Favs: {}", status.favourites_count);
|
println!("Favs: {}", status.favourites_count);
|
||||||
println!("Retoots: {}", status.reblogs_count);
|
println!("Retoots: {}", status.reblogs_count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!();
|
||||||
}
|
}
|
||||||
|
|
||||||
println!();
|
println!("Found {} results", results.len());
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn status_matches(status: &Status, regex: &Regex) -> bool {
|
fn status_matches(status: &Status, regex: &Regex) -> bool {
|
||||||
|
|
Loading…
Reference in New Issue