commit 2af717560d1c56276a81cc954972cbb1c72ac325
parent fe955f5e10ebdf4f8cb70a29fb1f67a378d82b45
Author: n0tr1v <n0tr1v@protonmail.com>
Date: Mon, 27 Mar 2023 21:40:34 -0700
handle waitroom
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/src/main.rs b/src/main.rs
@@ -860,12 +860,23 @@ impl LeChatPHPClient {
]);
}
- let resp = self.client.post(&login_url).form(¶ms).send()?;
+ let mut resp = self.client.post(&login_url).form(¶ms).send()?;
match resp.status() {
StatusCode::BAD_GATEWAY => return Err(SERVER_DOWN_ERR.into()),
StatusCode::INTERNAL_SERVER_ERROR => return Err(SERVER_DOWN_500_ERR.into()),
_ => {}
}
+
+ let mut refresh_header = resp.headers().get("refresh").map(|v| v.to_str().unwrap()).unwrap_or("");
+ while refresh_header != "" {
+ let rgx = Regex::new(r#"URL=(.+)"#).unwrap();
+ let refresh_url = format!("{}{}", &self.config.url, rgx.captures(&refresh_header).unwrap().get(1).unwrap().as_str());
+ println!("waitroom enabled, wait 10sec");
+ thread::sleep(Duration::from_secs(10));
+ resp = self.client.get(refresh_url.clone()).send()?;
+ refresh_header = resp.headers().get("refresh").map(|v| v.to_str().unwrap()).unwrap_or("");
+ }
+
let mut resp = resp.text()?;
if resp.contains(CAPTCHA_USED_ERR) {
return Err(CAPTCHA_USED_ERR.into());