Skip to content

Commit

Permalink
Merge pull request #29 from LukasKalbertodt/api-update
Browse files Browse the repository at this point in the history
Api update
  • Loading branch information
knsd committed Feb 17, 2016
2 parents dd2c099 + 56a1d3d commit b6d5849
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 64 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "telegram-bot"
version = "0.3.0"
authors = ["Lukas Kalbertodt <[email protected]>"]
version = "0.4.0"
authors = ["Lukas Kalbertodt <[email protected]>", "Fedor Gogolev <[email protected]>"]

description = "A library for creating Telegram bots."

Expand All @@ -15,7 +15,7 @@ license = "MIT"
exclude = ["deploy.sh"]

[dependencies]
hyper = "*"
rustc-serialize = "*"
url = "*"
multipart = "*"
hyper = "0.7"
rustc-serialize = "0.3"
url = "0.5"
multipart = "0.3"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() {
try!(api.send_message(
m.chat.id(),
format!("Hi, {}! You just wrote '{}'", name, t),
None, None, None));
None, None, None, None));
},
_ => {}
}
Expand All @@ -63,7 +63,7 @@ You can find a bigger example in the `examples` folder.
This library is available via `crates.io`. In order to use it, just add this to your `Cargo.toml`:

```
telegram-bot = "0.3"
telegram-bot = "0.4"
```

## Collaboration
Expand Down
2 changes: 1 addition & 1 deletion examples/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {
try!(api.send_message(
chat_id,
format!("Hi, {}!", name),
None, None, Some(keyboard.into())));
None, None, None, Some(keyboard.into())));

},
MessageType::Location(loc) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
try!(api.send_message(
m.chat.id(),
format!("Hi, {}! You just wrote '{}'", name, t),
None, None, None));
None, None, None, None));
},
_ => {}
}
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! try!(api.send_message(
//! m.chat.id(),
//! format!("Hi, {}!", m.from.first_name),
//! None, None, None)
//! None, None, None, None)
//! );
//! }
//! }
Expand Down Expand Up @@ -161,6 +161,7 @@ impl Api {

/// Corresponds to the "sendMessage" method of the API.
pub fn send_message(&self, chat_id: Integer, text: String,
parse_mode: Option<ParseMode>,
disable_web_page_preview: Option<bool>,
reply_to_message_id: Option<Integer>,
reply_markup: Option<ReplyMarkup>)
Expand All @@ -169,6 +170,7 @@ impl Api {
let mut params = Params::new();
params.add_get("chat_id", chat_id);
params.add_get("text", text);
params.add_get_opt("parse_mode", parse_mode);
params.add_get_opt("disable_web_page_preview", disable_web_page_preview);
params.add_get_opt("reply_to_message_id", reply_to_message_id);
try!(params.add_get_json_opt("reply_markup", reply_markup));
Expand Down Expand Up @@ -531,7 +533,7 @@ impl Api {
// Change connect("&") to join("&") when rust 1.3 becomes stable
let bodyparams = p.get_params().into_iter().map(|&(k, ref v)| {
format!("{}={}", k, &**v)
}).collect::<Vec<_>>().connect("&");
}).collect::<Vec<_>>().join("&");

// Create the request with the body and headers
let req = client
Expand Down
Loading

0 comments on commit b6d5849

Please sign in to comment.