From 1a94dc2f8014b2b33a5e17b2e3ccb530b54c7074 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Wed, 29 Jul 2015 22:44:49 +0200 Subject: [PATCH 1/2] Change `long_poll` to take `FnMut` --- src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1c793fc85a..a3e7c53f0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -169,14 +169,19 @@ impl Bot { /// the same update twice. /// The `timeout` parameter influences how long (in seconds) each poll may /// last. Defaults to 30. + /// The handler gets a mutable reference to the bot since borrowing it + /// from the outer scope won't work. When the handler returns an `Err` + /// value the bot will stop listening for updates and `long_poll` will + /// return the Error. If you want to stop listening you can just return + /// `Error::UserInterrupt`. /// /// **Note:** /// If the bot is restarted, but the last received updates are not yet /// confirmed (the last poll was not empty), there will be some duplicate /// updates. - pub fn long_poll(&mut self, timeout: Option, handler: H) + pub fn long_poll(&mut self, timeout: Option, mut handler: H) -> Result<()> - where H: Fn(&mut Bot, Update) -> Result<()> { + where H: FnMut(&mut Bot, Update) -> Result<()> { // Calculate final timeout: Given or default (30s) let timeout = timeout.or(Some(30)); From e9d04741750fdb94214c054337e30a72710e11c9 Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Thu, 30 Jul 2015 01:54:52 +0200 Subject: [PATCH 2/2] Bump version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 11137da477..462916bf11 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "telegram-bot" -version = "0.1.1" +version = "0.1.2" authors = ["Lukas Kalbertodt "] description = "A library for creating Telegram bots."