Hello,
When I try to send a file with a caption it is surrounded by "
and if it contain the character "
it is send as \"
.
Here a minimal example:
use telbot_ureq::types::message::SendDocument;
use telbot_ureq::types::chat::ChatId;
use telbot_ureq::types::file::InputFile;
use telbot_ureq::Api;
fn main() {
let data: Vec<u8> = "exemple".to_string().into_bytes();
let caption = "exemple \" exemple";
let api = Api::new("...".to_string());
let chat_id: ChatId = 123456789i64.into();
let file = InputFile {
name: "test.txt".to_string(),
data: data,
mime: "text/plain".to_string(),
};
api
.send_file(
&SendDocument::new(chat_id, file)
.with_caption(caption)
)
.expect("Error while sending document to Telegram");
}
And here what I get in Telegram:
From what I can see the problem is that the send_file
method use serde_json::to_value but the body is not send as json (but as multipart) so the text is json escaped but Telegram do not decode it.
PS: I'm using the main version from git telbot-ureq = { git = "https://github.com/kiwiyou/telbot" }
bug