Add support for file word-lists

This commit is contained in:
ItsDrike 2024-04-18 22:01:39 +02:00
parent 567da290dd
commit a6581455e7
Signed by: ItsDrike
GPG key ID: FA2745890B7048C0
2 changed files with 42 additions and 1 deletions

View file

@ -1,5 +1,10 @@
use crate::rentry::{build_client, edit_paste, CSRFData, EditError};
use std::{
fs::File,
io::{BufRead, BufReader},
};
mod rentry;
const PASTE_NAME: &str = "Hyprland-controversy";
@ -35,6 +40,15 @@ where
}
}
impl EditCodeGenerator<std::vec::IntoIter<String>> {
pub fn from_file(file_path: &str) -> Result<Self, std::io::Error> {
let file = File::open(file_path)?;
let reader = BufReader::new(file);
let lines = reader.lines().collect::<Result<Vec<_>, _>>()?;
Ok(EditCodeGenerator::new(lines.into_iter()))
}
}
impl<I> Iterator for EditCodeGenerator<I>
where
I: Iterator<Item = String>,
@ -69,7 +83,8 @@ fn main() {
let client = build_client();
let mut csrf_data = CSRFData::get(&client, PASTE_NAME);
let mut edit_codes = EditCodeGenerator::default();
let mut edit_codes = EditCodeGenerator::from_file("test-list.txt").unwrap();
//let mut edit_codes = EditCodeGenerator::default();
while let Some(edit_code) = edit_codes.next() {
match edit_paste(&client, &csrf_data, &edit_code, PASTE_NAME) {

26
test-list.txt Normal file
View file

@ -0,0 +1,26 @@
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z