太潮啦 rust

This commit is contained in:
tasi788 2022-09-17 16:40:55 +08:00
parent bb09f9e3ef
commit f0c1c585f2
3 changed files with 1089 additions and 4 deletions

1059
AutoBuild/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,9 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
fancy-regex = "0.10.0"
reqwest = { version = "0.11.11", features = ["blocking", "json"] }
tokio = { version = "1", features = ["full"] }
[[bin]]
name = "AutoBuild"

View File

@ -1,3 +1,5 @@
use fancy_regex::{Captures, Regex};
use reqwest;
use std::collections::HashMap;
fn main() {
@ -12,15 +14,36 @@ fn main() {
! Expires: 1 hour\n
! Homepage: https://t.me/AdBlock_TW\n
! ----------------------------------------------------------------------\n");
head.insert(String::from("hosts"), "! FutaHosts\n\
head.insert(
String::from("hosts"),
"! FutaHosts\n\
! LowTechFilter {name}\n\
! URL: <https://github.com/FutaGuard/LowTechFilter>\n\
! Version: {version}\n\
! --------------------------------------------------\n");
! --------------------------------------------------\n",
);
let _url: &str = "https://filter.futa.gg/";
for category in filterlist {
println!("{:?}", category);
for text in category.1 {
let mut resp = reqwest::blocking::get(_url.to_owned() + text).unwrap();
if resp.status().is_success() {
} else {
panic!("Something else happened. Status: {:?}", resp.status());
}
let resp = resp.text().unwrap();
let re = Regex::new(r"(?<=Version: )(\d+\.\d+\.)(\d+)").unwrap();
let captures = re.captures(&resp).unwrap();
let mut version: (&str, &str) = match captures {
None => ("2017.0929.", "1"),
_ => (
captures.as_ref().unwrap().get(1).unwrap().as_str(),
captures.as_ref().unwrap().get(2).unwrap().as_str(),
),
};
println!("{:?}", version)
}
}
// println!("{:?}", filterlist::field_names());
}