Fix redundant "" when sending messages (Note: string types should use FormBuilder::add_raw instead of FormBuiolder::add)

This commit is contained in:
Waffle 2019-09-05 19:11:16 +03:00
parent 4094c1ceb8
commit 7e14e8f9e7
2 changed files with 12 additions and 1 deletions

View file

@ -45,6 +45,17 @@ impl FormBuilder {
}
}
/// Add the supplied key-value pair to this `FormBuilder`.
/// With raw str value, so `serde_json` will not add redundant `""`
pub fn add_raw(self, name: &str, value: &str) -> Self {
Self {
form: self.form.text(
name.to_owned(),
value.to_owned(),
),
}
}
pub fn build(self) -> Form {
self.form
}

View file

@ -25,7 +25,7 @@ impl<'a> Request<'a> for SendMessage<'a> {
Box::pin(async move {
let params = FormBuilder::new()
.add("chat_id", &self.chat_id)
.add("text", &self.text)
.add_raw("text", &self.text)
.add_if_some("parse_mode", self.parse_mode.as_ref())
.add_if_some(
"disable_web_page_preview",