From 1c1825eee55ecb098e8b0ad6dba6bbaced7092cf Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 14 Mar 2016 18:47:49 +0100 Subject: Use appropriate function for update query in `pollUpdates` --- telebot.scm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/telebot.scm b/telebot.scm index c30d095..5e95e1d 100644 --- a/telebot.scm +++ b/telebot.scm @@ -20,6 +20,7 @@ (use medea) (use loops) (use vector-lib) + (use data-structures) (define-constant api-base "https://api.telegram.org/bot") @@ -156,13 +157,13 @@ ;;; framework (define (pollUpdates token handler) - (define offset 0) - (define process (lambda (i u) - (begin (handler u) - (set! offset (+ 1 (cdr (assv 'update_id u))))))) - (do-forever - (vector-for-each process - (cdr (assv 'result (getUpdates token - offset: offset - timeout: 60)))))) + (let ((offset 0)) + (do-forever + (vector-for-each (lambda (i u) + (handler u) + (set! offset (+ 1 (alist-ref 'update_id u)))) + (alist-ref 'result + (getUpdates token + offset: offset + timeout: 60)))))) ) -- cgit v1.2.3