Containers with init (reap zombies), no bot token in Telegram errors
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8b85beb70
commit
c05e2cb6ef
5 files changed
+20
-3
No files matched your search
@@ -130,7 +130,7 @@ impl Bot {
|
||||
}
|
||||
|
||||
async fn call(&self, method: &str, body: Value) -> Result<Value> {
|
||||
let resp = crate::provider::http_client().post(self.url(method)).timeout(Duration::from_secs(60)).json(&body).send().await.context("telegram request failed")?;
|
||||
let resp = crate::provider::http_client().post(self.url(method)).timeout(Duration::from_secs(60)).json(&body).send().await.map_err(|e| e.without_url()).context("telegram request failed")?;
|
||||
let status = resp.status();
|
||||
let v: Value = resp.json().await.unwrap_or_else(|_| json!({}));
|
||||
if v["ok"].as_bool() != Some(true) {
|
||||
@@ -174,7 +174,7 @@ impl Bot {
|
||||
if let Some(c) = caption {
|
||||
form = form.text("caption", c.chars().take(1000).collect::<String>());
|
||||
}
|
||||
let v: Value = crate::provider::http_client().post(self.url("sendPhoto")).timeout(Duration::from_secs(120)).multipart(form).send().await?.json().await?;
|
||||
let v: Value = crate::provider::http_client().post(self.url("sendPhoto")).timeout(Duration::from_secs(120)).multipart(form).send().await.map_err(|e| e.without_url())?.json().await.map_err(|e| e.without_url())?;
|
||||
if v["ok"].as_bool() != Some(true) {
|
||||
bail!("telegram sendPhoto: {}", v["description"].as_str().unwrap_or("error"));
|
||||
}
|
||||
@@ -186,7 +186,7 @@ impl Bot {
|
||||
let f = self.call("getFile", json!({"file_id": file_id})).await?;
|
||||
let path = f["file_path"].as_str().context("telegram file without path")?.to_string();
|
||||
let url = format!("{}/file/bot{}/{path}", api_base(), self.token);
|
||||
let bytes = crate::provider::http_client().get(url).timeout(Duration::from_secs(120)).send().await?.error_for_status()?.bytes().await?;
|
||||
let bytes = crate::provider::http_client().get(url).timeout(Duration::from_secs(120)).send().await.map_err(|e| e.without_url())?.error_for_status().map_err(|e| e.without_url())?.bytes().await.map_err(|e| e.without_url())?;
|
||||
Ok((bytes.to_vec(), path))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user